php

php: reversing mysql_real_escape_string's effects on binary

I built a webpage where users can submit a PDF which is then inserted into a MySQL database in a mediumblob for retrieval later. This all works fine, except when the PDF contains images or embedded fonts, in which case the images are corrupted and any text using the font disappears (Acrobat display a message about the missing font). I'...

PHP: string indexing

What is the difference between $str[n] and $str{n}, given that $str is a string. I noticed that both seem to work the same, except that {} does not occur in any documentation I found. ...

Capicom Decryption in Linux.

I have a database that encrypted with windows CAPICOM library with RC4. Following PHP script works fine on windows server. ... $oCapiCapi = new COM("CAPICOM.EncryptedData"); $oCapiCapi -> Algorithm = 1; $oCapiCapi -> Algorithm -> KeyLength = 3; $oCapiCapi -> SetSecret('OURveRYSecretKey'); ... $oCapiCapi -> Decrypt($orsd[1]); $...

PHP key value pairs vs. arrays

I'm trying to pass key values pairs within PHP: // "initialize" private $variables; // append $this->variables[] = array ( $key = $value) // parse foreach ( $variables as $key => $value ) { //.. } But it seems that new arrays are added instead of appending the key/value, nor does the iteration work as expect. Please let me know wha...

"Safe" markdown processor for PHP?

Is there a PHP implementation of markdown suitable for using in public comments? Basically it should only allow a subset of the markdown syntax (bold, italic, links, block-quotes, code-blocks and lists), and strip out all inline HTML (or possibly escape it?) I guess one option is to use the normal markdown parser, and run the output th...

Is there a need to pass variable by reference in php5?

With PHP5 using "copy on write" and passing by reference causing more of a performance penalty than a gain, why should I use pass-by-reference? Other than call-back functions that would return more than one value or classes who's attributes you want to be alterable without calling a set function later(bad practice, I know), is there a u...

String to byte array in php

How can I get the byte array from some string witch can contains numbers,letters and so on!? If u are familiar with java I am looking for same functionality of getBytes() method. I tried with snippet like this one: for($i = 0; $i < strlen($msg); $i++){ $data.=ord($msg[$i]); //or $data[]=ord($msg[$1]); } but without succe...

What is a difference of Array and Hash? :php

What is differents from an arrangement in a hash in PHP? An arrangement: array(1,2,3...) A hash: array(key1=value1, key2=value2, ...) Or will it be a thing to treat as the totally same thing? ※ For example, will the function arguments allows array be effective for the hash? Because I distinguish it by the conventional language...

How does MySQL's RENAME TABLE statment work/perform?

MySQL has a RENAME TABLE statemnt that will allow you to change the name of a table. The manual mentions The rename operation is done atomically, which means that no other session can access any of the tables while the rename is running The manual does not (to my knowedge) state how this renaming is accomplished. Is an enti...

How to write script to auto submit to scuttle sites?

I'm looking to see if it's possible for me to code something maybe in php to auto submit a link into a scuttle site. Maybe a bookmarklet, or maybe just a script. Any ideas? Update: I am not trying to write a virus. I just have a bunch of accounts on social bookmarking sites, and I'm tired of clicking through a lot of forms to submit som...

Why does "return fopen" fail?

I have a function: function open($file){ return fopen($file, 'w'); } This is then called by: function write($file,$text){ $h = $this->open($file); fwrite($h,$text); } This doesn't work. It returns that fwrite was given an invalid resource stream. This: function open($file){ $h = fopen($file, 'w'); return $h; }...

Can php5 coexist with php4?

Hello. I use apache. I want to let php4 coexist with php5 in one server, but what kind of method will there be? ...

Run MySQL Query after wget finishes downloading file

I need to run a specific mysql query upon wget, which is running in the background, finishes downloading a file. For example... wget http://domain/file.zip then run: UPDATE table SET status = 'live' WHERE id = '1234' How would I go about doing this? ...

What causes this error in my PHP SQL query?

I'm having a problem with my mysql php code. The code is meant to search the data base with variables inputted by the user and bring up the corresponding results. For example if I searched for only colour photos only colour photos would be listed with the name of the artist, size etc. But I am getting an error message and I don't underst...

Calling member function of other controller in zend framework?

Is it possible to call the member function of another controller in zend framework, if yes then how? <?php class FirstController extends Zend_controller_Action { public function indexAction() { // general action } public function memberFunction() { // a resuable function } } Here's another contro...

Generating objects in PHP using REST

I am trying to make a decision whether I should use a REST service or a SOAP service for some web facing functions that I am producing. This decision is based on whether I can easily use the REST service in implementation. I would prefer to use REST, though I don't want to spend days coding the object model in PHP. The services are bein...

Switching themes in Drupal without the web interface

I'm in the process of learning php and creating themes. Unfortunately, while I was editing a theme that i was currently using in drupal, I made a mistake in the theme such that nothing shows up anymore, even if i were to hit drupal/index.php. I want to change my broken drupal theme to a working one but i'm unable to do so because I can'...

Is this a good way of doing what I want (in PHP)?

I've been working on a simple forum for my site. I'm adding a feature that will mark unread posts + forums since your last visit. Im essentially storing a date of last access to the forum with each user account. When a user comes back to the site, a query is ran to fetch all the post_id and post_parent_forum values, which are then added...

How to delay login attempts after too many tries (PHP)

I'm working on a fairly large web site built in PHP that will potentially have a lot of users. I'm looking into a way to protect the login screen from automated attempts. I have already included a CAPTCHA check on the registration form, yet want to harden the site more. There have been similar questions on StackOverflow that I know of, ...

MacGDBp, but better?

For debugging php code I use MacGDBp but it has its quirks: it shows only the top frame variables of the stack, it sometimes refuses to display any variable at all and last version has decorates the source text with non ascii characters. Is there any alternative that is native OS X? (ie. not Eclipse, I can't stand it). ...