php

Determine ajax request from my server

is it possible to determine the server from which ajax request is send??, and if yes then how could i determine and execute only those requests which are from my server.. ...

PHP equivalent to MySQL's slow query log?

I am working on optimizing my site, and I have had the MySQL slow queries log on for a few days now, but after going through >260M queries, it only logged 6 slow queries, and those were special ones executed by me on phpMyAdmin. I am wondering if there is something to log slow PHP page execution time so that I can find certain pages tha...

Simple Youtube Search PHP Script

Does anybody know any good simple youtube search scripts in php that I could use right off the bat? I don't want to use the Zend Framework (not installed), just the basic REST calls. Thanks ...

Bad idea to have two unique IDs in database table?

Hello all, I wish to allow users to be able to view records from my database by following a URL. I am guessing its not a good idea to have this sort of URL where the identifier of the record to be viewed is the record auto increment ID! http://www.example.com/$db_record_id The above is giving info away unnecessarily. Is this reall...

Tutorial for creating a podcast (in PHP)

I am looking for some tutorials for setting up a podcast in PHP. I have audio files and title/description data, I just want to make sure I get the XML part right so that it handles well in iTunes and other common players. (I don't subscribe to any podcasts, and I don't know what's popular.) The title/description data is stored in a mysq...

CakePHP: Is it possible to associate a model with a database view instead of a table?

I was wondering if it was possible to create a view in a database then be able to link a Model to it? ...

overriding upload_max_filesize

Hello, I am trying to override my upload_max_filesize in php but I still get the value which is in my php.ini file which is 2 mb. ini_set('upload_max_filesize','30M'); ini_set('post_max_size','30M'); echo("<br>".ini_get('upload_max_filesize')."<br>"); ...

How can I save a process resource from proc_open in order to check the status later on?

I'm running a sh script that runs a java process through php on ubuntu server. I'm using proc_open for running the process. usually the Workflow goes like : request a page -> script runs (until it's finished) -> result page. In my case the script runs in parallel so the server won't wait until the script is finished (it takes ho...

How to write such a converter to change PHP file into bash file?

My so far not so bad version to implement this is: function bashFileConvert($file) { return preg_replace('/([^\/\s]+\s+[^\/]+)(\/|$)/','"${1}"${2}',$file); } which mostly processes the problem when there is a space in file name,like $flie = '/usr/local/my test file.txt' while will not be recognizable for bash, so need to conv...

json parse error with double quotes

A double quote even if escaped is throwing parse error. look at the code below //parse the json in javascript var testJson = '{"result": ["lunch", "\"Show\""] }'; var tags = JSON.parse(testJson); alert (tags.result[1]); This is throwing parse error because of the double quotes (which are already escaped). Even eval() won't work ...

how to assign a member function to an array and call it?

I'm currently doing it this way,but seems not the proper way: class Name { protected $jobs2do; public function __construct($string) { $this->jobs2do[] = $this->do; } public function do() { ... } } Because directly assign a function will cause warning,should do something like: function func() ...

Setting a global variable in Magento, the GUI way?

I've recently started using Magento for a client's webshop, and still need to get to grips with its systems. The webshop should have several links to and also grab info from another domain, where the corporate website is located. I would prefer not to hardcode the domain name or URL but instead define it at some place and use that value...

Why when I send XML to PHP are the nodes lowercase, but when I parse them in PHP they are uppercase?

This is a follow up question to this answer: http://stackoverflow.com/questions/948610/how-do-i-parse-xml-from-php-that-was-sent-to-the-server-as-text-xml JavaScript/jQuery: var xmlDoc = jQuery.createXMLDocument( "<items></items>" ); jQuery( "items", xmlDoc ).append( jQuery( "<item>My item!</item>" ) ); jQuery.ajax({ url: "test.ph...

What's the best way to use the Twitter API via PHP?

A client would like me to add their Twitter stream to their website homepage, using a custom solution built in PHP. The Twitter API obviously has a limited number of calls you can make to it per hour, so I can't automatically ping Twitter every time someone refreshes my client's homepage. The client's website is purely HTML at the mome...

Two different login pages according to ID using PHP and MySQL.

$query = "SELECT * FROM users WHERE username = '".mysql_escape_string($username)."' AND password = '".mysql_escape_string($password)."'"; $result = mysql_fetch_array(mysql_query($query)); Now this is my query for general visitors, now if i need a admin and moderator how can i process from t...

Jquery - finding range between two unique id's in mysql

Another question which has me perplexed: I have a table which enables users to enter as many rows as they like based on their userid and unique id (auto incremental). I need to be able to get this information from mysql and place the previously entered information into the fields on the web application (they may need to be edited befor...

redirect in a new window

Hello all, For a banner management system i use a header("Location: http://www.awebsite.com"); to redirect to the proper website. Is it possible to force this header script to open in a new window? ...

php command line

hello, i m trying to use mcrypt_decrypt from commond line but i m getting the folllowing error:- Call to undefined function mcrypt_decrypt() in Command line code on line 1 Any idea ? and any other alternative solution because i m using os:cmd() from erlang to achive this.since erlang do have function to achieve this but i m un...

How can I search the contents of .module files?

I'm working with Drupal at the moment and I'm having a real hard time searching the contents of various .module files. For example I want to search for something like "div style="border: 1px solid red;" and find out which file it's in. All my code editors ignore the .module files in their search because it is a strange extension. Windo...

stdClass object and foreach loops

I am using the following code to get data from a website using Soap. $client = new SoapClient('http://some.url.here'); class SMSParam { public $CellNumber; public $AccountKey; public $MessageCount; public $MessageBody; public $Reference; } $parameters = new SMSParam; $parameters -> AccountKey = "$sms_key"; $parameters -> MessageC...