php

hmac_sha256 in php and c# differ

Hello this is my PHP code: hash_hmac( "sha256", utf8_encode( $filename ), utf8_encode( $password ) ); and this is my C# code: var hmacsha256 = new HMACSHA256( Encoding.UTF8.GetBytes( password ) ); hmacsha256.ComputeHash( Encoding.UTF8.GetBytes( filename ) ); unfortunately both results differ. Can anyone give me a hint? ...

Any support for optimistic locking in CakePHP?

I'm just starting out with CakePHP, and I can't find any support for implementing an optimistic locking scheme. The closest I could find was a comment on this CakePHP blog post saying that it wasn't supported in June 2008. Does anyone know if that has changed, or if someone has published an extension or a tutorial on how to implement it...

Jquery X,Y position send over ajax.

I need an example that uses jquery to send the current x,y position of a <div> (the top left pixel) to a php file using ajax where the position can then be processed. ...

CodeIgniter-Hello World

Hello everyone, i am new to php and CodeIgniter. I am currently studying the tutorials. My controller blog.php is <?php class Blog extends Controller{ function index() { $data['title'] = "My Blog Title"; $data['heading'] = "My Blog Heading"; $data['todo'] = array('clean house','eat lunch','call mom'); $this->load-...

Why use !== FALSE to check stripos in php?

Here is the code I am looking at. foreach ($header as $idx => $field) { if (stripos($field, 'foo') !== false) { $cols['foo'] = $idx; } else if (stripos($field, 'bar') !== false) { $cols['bar'] = $idx; } else if (stripos($field, 'brr') !== false) { $cols['brr'] = $idx; } else if (stripos($field, '...

PHP: Check if XML node exists with attribute

I can't seem to figure this one out. I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <targets> <showcases> <building name="Big Blue" /> <building name="Shiny Red" /> <building name="Mellow Yellow" /> </showcases> </targets> I need to be able to test whether or not a <building> node exists with a ...

PHP _EOL not working when input to $message of mail() function

I'm using PHP _EOL when building the message body of my email but the line feeds are not getting through and the entire message body ends up one long line in the resultant email. This happens regardless of Multi-part or html only messages. Sending as text only it works fine, but of course I want to send Multi-part messages.... Any ideas?...

PHP form auto escaping posted data ???

Hi I have an HTML form POSTing to a PHP page. I can read in the data using the $_POST variable on the PHP. However, all the data seems to be escaped. So, for example a comma (,) = %2C a colon (:) = %3a a slash (/) = %2 so things like a simple URL of such as http://example.com get POSTed as http%3A%2F%2Fexample.com Any ideas as to ...

Does every access to $_SESSION immediatly involves an i/o with the file system?

Every time I access data in $_SESSION, Does it immediately update the session file on the disk, or just once when the process goes down? Or every n bytes of data change (flush)? This question is not necessarily about the specific file session handler, but every handler. (Does every touch in session immediately invoke an I/O of any kin...

Jquery constantly ping for ajax responce.

How can I use jquery to constantly run a php script and get the response every second and also to send small bits of data on mouse down to the same script? Do I really have to add some random extension just to get such a simple timer to work? ...

What's quicker and better to determine if an array key exists in PHP?

Consider these 2 examples $key = 'jim'; // example 1 if (isset($array[$key])) { doWhatIWant(); } // example 2 if (array_key_exists($key, $array)) { doWhatIWant(); } I'm interested in knowing if either of these are better. I've always used the first, but have seen a lot of people use the second examp...

Zend Framework - Static form elements

I have got a form which a user can use to create a new store and to edit an existing one. When this form is being used to edit a store there are certain fields that I want the user to see but not edit eg. store_id. I have explored the different Zend_Form_Elements hoping to find some kind of static element but with no luck. So my questi...

Transactions in wordpress database

Wordpress is using MyISAM storage engine. MyISAM does not support transactions. How wordpress is maintaining transactions? I mean if wordpress is having two database write operations, how does it ensure atomicity? ...

The correct way to fetch a lot of data in PHP5 object oriented

Hello Everyone, Fortunately, I know how to fetch data from the database, That's not a problem. For my object oriented application I would have a table with users / persons. I also have a person class. The case: I would like to show to the end user a list with all the persons. What is the correct way to show do this? using mysql_fe...

how do you detect if your website visitor came from a google search result?

when a user searches from google and lands on our site from the results he/she was shown in the results page, is there a way for my site to detect that he came from google? ...

Automatically update scoreboard without refresh page

when i update score from my admin i want to update score in client autometically without refresh can any one help with script and technices i see such auto refresh http://stackoverflow.com/ ANSWERS , VIEWS autometically updating ...

preg_replace_callback() memory issue

i'm having a memory issue while testing a find/replace function. Say the search subject is: $subject = "I wrote an article in the A+ magazine. It'\s very long and full of words. I want to replace every A+ instance in this text by a link to a page dedicated to A+."; the string to be found : $find='A+'; $find = preg_quote($find...

How do I rename a filename after uploading with php?

How do I rename the file either before or after it gets uploaded? I just want to rename the filename, not the extension. $changeTXT = $_SESSION['username']; $uploaderName = strtolower($changeTXT); $changeTXT = strtolower($changeTXT); $changeTXT = ucfirst($changeTXT); $filelocation = $_POST['userfile']; $filename = $_POST['filename']; $m...

How can I allow my user to insert HTML code, without risks? (not only technical risks)

Hi guys. I developed a web application, that permits my users to manage some aspects of a web site dynamically (yes, some kind of cms) in LAMP environment (debian, apache, php, mysql) Well, for example, they create a news in their private area on my server, then this is published on their website via a cURL request (or by ajax). The n...

How to access/escape PHP object member with a $ character in its name?

I'm decoding some JSON (from the Youtube data API) with json_decode and it gives me an object that looks like this when var_dump()ed: object(stdClass)[29] public 'type' => string 'text' (length=4) public '$t' => string 'Miley and Mandy! KCA VIDEO WINNERS' (length=34) How can I access the $t member? ...