php

How can I create an algorithm for generating random strings?

I want to generate random strings like: sssder tvmwww 66rfdd 123123 oo007oo 1234 2020 1111 rrrr r8r8r uiuiu wewewe fefefe abced xyz.. Specifically, I want a string with a length of 5 to 8 characters that is easy to remember. Is this possible? ...

FFmpeg video problem

Hello. I am using FFmpeg for the video conversion and thumbnail generations on my php site, but the main problem is that if I upload any file it is directly converted to flv. And thumbnail genration: how how can I do this? Please help me. ...

How to run multiple PHP scripts from CLI

I have three different crawler scripts that I want to run in parallel and I'm wondering what command do I use to execute all three at the same time. I'm on a nix platform ...

replace rand() with openssl_random_pseudo_bytes()

I need a replacement for PHP's rand() function that uses a cryptographically strong random number generator. The openssl_random_pseudo_bytes() function gets you access to the strong random number generator, but it outputs its data as a byte string. Instead, I need an integer between 0 and X. I imagine the key is to get the output of o...

PHP MVC & SQL minus Model

I've been reading several articles on MVC and had a few questions I was hoping someone could possibly assist me in answering. Firstly if MODEL is a representation of the data and a means in which to manipulate that data, then a Data Access Object (DAO) with a certain level of abstraction using a common interface should be sufficient for...

Should I combine multiple php arrays or not?

I have the following arrays below in PHP that I store a user_id number in to keep track of moderator/admins on my site, then in a page I can just use in_array() to determine if a user should have moderator privileges, I figure this saves some mysql queries by using an array instead. I am wondering, would there be any performance gain ...

Multiple matches within a regex group?

Hey all! I need to match all 'tags' (e.g. %thisIsATag%) that occur within XML attributes. (Note: I'm guaranteed to receive valid XML, so there is no need to use full DOM traversal). My regex is working, except when there are two tags in a single attribute, only the last one is returned. In other words, this regex should find tag1, ta...

upload and proces user selected file in html, javascript and php

I want to have a user select a file and then have php put the contents in db. Now the last part (processing the file in php) is easy. But is there a way I can process a user selected file whithout a new page load? If I use the following: <FORM ACTION="upload.php" METHOD="post" ENCTYPE="multipart/form-data"> <INPUT TYPE="file" NAME="som...

Why does my jqGrid script work fine with PHP but fail with Perl?

Here is client Side code: jQuery(document).ready(function(){ jQuery("#list").jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'], colModel :[ {name:'invid', index:'invid', width:55}, {name:'invdate', index:'invdate', width:90}, {...

To build a `Delete` -button efficiently with JavaScript / PHP

Which of the following code is better in building a delete -action for removing a question? 1 My code <a href='index.php?delete_post=777>delete</a> 2 Stack Overflow's code <a id="delete_post_777>">delete</a> I do not understand completely how Stack Overflow's delete -button works, since it points to no URL. The id apparently can ...

Can I prevent long queries in PDO?

Is there any way to make a PDO object throw an error if a query takes too long? I have tried PDO::ATTR_TIMEOUT to no effect. I'd like a way to have a query throw an error if it is running for longer than a certain amount of time. This is not something that I can do in the database, ie, no maintenance jobs running on the db or anything...

Easier to Follow PHP open source projects to Learn from

hi there, i've read a book on PHP coding and I've also created my own project from scratch (it was a personal blog) but I would like to gain more practical experience on topics such as security, architecture, and design. I believe analyzing the code of professionals will help me gain such knowledge. I have looked at wordpress as well ...

Sort tinytext time from mysql db query with sql or sort the array it produces using PHP

Hey guys - The problem stems from a poorly designed database used to store real estate information. I set up a template for my client to select a weekend and to display the open houses for that weekend. Open house times (ohtime1, ohtime2, ohtime3) are stored as tinytext, with no way of knowing AM or PM. "12:00 - 2:00" and "01:00 - 03:00"...

How to use the Google SpreadSheets API to feed data to an application?

I've read through the Google Spreadsheets API PHP documentation. All examples are using Zend, which I cannot use. See this page: http://code.google.com/apis/spreadsheets/docs/1.0/developers%5Fguide%5Fphp.html Does anybody know a simple example of the following: How can I use PHP w/ curl (or whatever) and the Google Spreadsheets API to ...

Query works ok in phpmyadmin but not with mysql_query php function

I have this sql query: SELECT DISTINCT r.uri uri FROM resource r INNER JOIN object o ON o.idResource = r.idResource WHERE r.type = 2 AND r.idResource IN ( SELECT DISTINCT r1.idResource FROM object o1 INNER JOIN resource r1 ON r1.idResource = o1.idResource INNER JOIN class c1 ON c1.idClass = o1.idClass INNER JOIN property p2 ON...

How do I use cURL/PHP to dump the current twitter trending topics into mySQL

Trying to run a cron job every few hours that reads the current Twitter Trending topics listed here: http://search.twitter.com/trends.json And then dump the top 10 trends into a mySQL table on my server how to do this? thanks ...

Return from include file

Hello, in PHP, how would one return from an included script back to the script where it had been included from? IE: 1 - main script 2 - application 3 - included Basically, I want to get back from 3 to 2, return() doesn't work. Code in 2 - application $page = "User Manager"; if($permission["13"] !=='1'){ include("/home/radonsys/p...

What is a safe way to read the PHP $_REQUEST superglobal?

I am trying to read get parameters in such a way that will not open up potential security issues. What I was thinking was matching the request parameter explicitly to what I expect and then setting a default for anything that doesn't match. For example: if ($_REQUEST['media'] == "video") $sort = "video"; elseif ($_REQUEST['media']...

[JAVA] Upload and POST file to PHP page

Hello I need a way to upload a file and POST it into php page... My php page is: <?php $maxsize = 10485760; $array_estensioni_ammesse=array('.tmp'); $uploaddir = 'uploads/'; if (is_uploaded_file($_FILES['file']['tmp_name'])) { if($_FILES['file']['size'] <= $maxsize) { $estensione = strtolower(substr($_FILES['file']['name...

PHP Image gallery array

Hi, Somebody asked me to created a PHP image gallery that will read the images out of a directory and then create thumbnails for the gallery. There is one directory with thumnails, and one directory with fullsize images. I read the file names out of the /thumb/ directory and insert each file name as a value into the thumbArray. From t...