php

get values of elements from another site (rapidshare)

Hello, I am developing a script in php to manage my rapidshare accounts (for learning purposes), i wanted to know how can we login remotely and get accounts details on my site, something that api does, the details like traffic left, expiry date, etc. ...

How to use rapidshare api?

Hello, I am trying to use rapidshare apis but dont know exactly how to use it? http://api.rapidshare.com/cgi-bin/rsapi.cgi?subroutine=getaccountdetails_v1&type=prem&login=MY_USERNAME&password=MY_PASSWORD after using this i am getting error "ERROR: Subroutine invalid." Can anybody tell me what is wrong with my link? ...

Advantage to parsing Excel Spreadsheet data vs. CSV?

I have tabulated data in an Excel spreadsheet (file size will likely never be larger than 1 mb). I want to use PHP to parse the data and insert in to a MySQL database. Is there any advantage to keeping the file as an .xls/.xlsx and parsing it using a PHP Excel Parsing Library? If so, what are some good libraries to use? Obviuously,...

$_GET and Wordpress

I want to add a custom php file to a wordpress to do a simple action. So far I have in my theme index.php file: <a href="myfile.php?size=md">link</a> and the php is <?php echo "hello world"; ?> <?php echo $_GET["size"]; ?> <?php echo "hello world"; ?> The link, once clicked, displays: hello world Is wordpress taking over the ...

PHP + PDO/MySQL: how to automatically clip strings to the proper length on insert

I have a table with various VARCHAR fields in MySQL. I would like to insert some user data from a form via PHP. Obviously if I know the field lengths in PHP, I can limit the data length there with substr(). But that sort of violates DRY (field length stored in MySQL and as a constant in my PHP script). Is there a way for me to configure ...

PHP - Read-Only spreadsheet filetype?

I'm using a simple web-based PHP application that outputs a table as a spreadsheet header("Content-Disposition: attachment; filename=" . $filename . ".xls"); header("Content-Type: application/vnd.ms-excel"); //inserts tab delimited text But I'm finding the downloaded spreadsheet opens as a read-only file and must be saved locally and...

How to search by key=>value in a multidimensional array in PHP

Is there any fast way to get all subarrays where a key value pair was found in a multidimensional array? I can't say how deep the array will be. Simple example array: $arr = array(0 => array(id=>1,name=>"cat 1"), 1 => array(id=>2,name=>"cat 2"), 2 => array(id=>3,name=>"cat 1") ); When I search for key=name a...

Dealing with an anemic domain model

I was trying to separate my DAL from my Business Layer, and in doing so, I decided to eschew any ActiveRecord approach and go for a DataMapper approach. In other words, my domain objects would not take care of persisting themselves. In doing so, I seem to be encroaching on the "anemic domain model" anti-pattern. For instance, one of the...

PHP + PDO/MySQL: how to automatically query to find out VARCHAR field lengths?

is there a way to use PHP+PDO to query a MySQL database and find out the column widths of some VARCHAR fields? I don't want to hardcode them into my PHP file if possible. (purpose: determine maximum lengths of strings to be either inserted into these columns, or compared against existing data in the columns.) ...

How can I check if a word is contained in another string using PHP?

Pseudo Code text = "I go to school"; word = "to" if ( word.exist(text) ) { return true ; else { return false ; } I am looking for a PHP function which returns true if the word exists in the text. ...

Trimming a white space

In a string that includes quotes, I always get an extra whitespace before the end quote. For instance "this is a test " (string includes quotes) Note the whitespace after test but before the end quote. How could I get rid of this space? I tried rtrim but it just applies for chars at the end of the string, obviously this case is n...

ImageMagick: convert png fail via PHP and works via bash shell

I've got a very weird bug which I've yet to find a solution. UPDATE see solution below What I am trying to do is convert a full size picture into a 160x120 thumbnail. It works great with jpg and jpeg files of any size, but not with png. ImageMagick command: /opt/local/bin/convert '/WEBSERVER/images/img_0003-192-10.png' -thumbnail x32...

MySQL Can't create a new thread (errno 12)

I'm runnning MySQL 5.0.45/ PHP Version 5.2.6 / CentOS with Plesk. I get occasionaly a burst of "Can't create a new thread (errno 12); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug" Global memory is not the issue since I have about 620M free. Anyone know what could be the cause for t...

PHP shell execute - Without waiting for a return

Hi, I have this process intensive task that i would like to run in the background. The user clicks on a page the PHP script runs and finally based on some conditions if required then it has to run a shell script EG: shell_exec('php measurePerformance.php 47 844 [email protected]'); Currently I use shell_exec BUT this requires the scrip...

Validating rfc2616 date string with PHP

For security, requests to a PHP webservice will require a Date: header. I need to calculate if the Date: header is within 15 minutes of the computer clock. I can easily do this by comparing $dt = new DateTime($_SERVER['HTTP_DATE']); to the actual date. However, strotime also supports formats such as "now", which will always be 'valid...

PHP: reading config.ini to array with file()

My config file looks like this: title = myTitle; otherTitle = myOtherTitle; when I read the file with file(), it creates this array [0] => title = myTitle; [1] => otherTitle = myOtherTitle; and what I want the array to look like is [title] => myTitle; [otherTitle] => myOtherTitle; Am I using the wrong approach her? Should i just...

How do I run Django and PHP together on one Apache server?

I can currently run either Django through mod_wsgi or PHP on my Apache server. My Django projects run at: http://localhost and source is at C:/django_proj My PHP projects run at: http://php.localhost and source is at C:/web If I turn both on, php.localhost and localhost go to the Django project. I've already set them up through Apache...

How do I replace bad words with php?

Hi I have some text i need to filter out a list of bad words in like: $bad_words = array( 'word1' => 'gosh', 'word2' => 'darn', ); I can loop through these and replace one at a time but that is slow right? Is there a better way? thanks ...

Is this php code written correctly according to OO principles?

Iv been trying to get my head around object orientation and I think iv started to get some of the concepts, but im not sure. Making a google search that answers if my train of thought is correct proved to be quite hard so I decided to ask here really quick, please tell me if the question is against any rules. Im I thinking correctly in ...

Function name conflict in php from 2 different libraries

I have 2 'libraries' which I need to include on the same page. Simple Machine Forums and Wordpress. However both have the function is_admin() which conflicts with each other. Fatal error: Cannot redeclare is_admin() (previously declared in /home/site.com/wordpress/wp-includes/query.php:100)in /home/site.com/smf/Sources/Security.php on ...