php

MCRYPT in .Net

I have a PHP decryption algorithm at one end, and a .Net encryption algorithm at another. I am using mcrypt_decrypt for decrypt purpose in PHP code, and looking for an equivalent of mcrypt_encrypt in .Net. More specifically, the PHP code that I want to convert to .Net is the following: $cipher_alg = MCRYPT_RIJNDAEL_128; $iv = mcrypt_cre...

How to check the charset of string?

How do I check if the charset of a string is UTF8? ...

Extract keywords/tags from string using Preg_match_all

I have the following code $str = "keyword keyword 'keyword 1 and keyword 2' another 'one more'".'"another keyword" yes,one,two'; preg_match_all('/"[^"]+"|[^"\' ,]+|\'[^\']+\'/',$str,$matches); echo "<pre>"; print_r($matches); echo "</pre>"; Where I want it to extract keywords from a string, and keep those wrapped within single or do...

How to redirect a request to a non existant PHP file to a existing DIR in a clean way ?

On of my client asked me to create an Web App in PHP, I ended up using Symfony. At delivery, he told me that he has distributed a software with an embedded Web view pointing to a hardcoded url : www.domain.com/dir/tools.php Now he wants the Web app to appear in it's Web View, but the software isused by about 400 customers, we can't exp...

Does PHP support asynchronous calls?

I am planning to build a web application and am going to host it. Since hosting cost less for php and it being similar to .net i am planning to go for php. I am basically a .net guy. But have no issues in learning php if it is similar to .net. Please give in your opinoins in doing so. Also please tell me if php supports asynchronous ca...

php c++ communication

hi i am new in php,i made the whole code in c++ and want to use this code in php.so i made dll to my code for using it.but i am not able to use this dll in php ,can anybody send me the complete code to use php,c++ extensions. ...

array_push vs $str .= in PHP

which one of the 2 have the best performance? In javascript I was heard douglas crockford say that you shouldn't use str += if you are concatenating a large string but use array.push instead. I've seen lots of code where developers use $str .= to concatenate a large string in PHP as well, but since "everything" in PHP is based on array...

Mutliple sites on same server sharing code.

Hi, I am going to be making a series of about 5 sites. They need to all run on the same system. I am planning on making them all point to the same server, then depending on which domain is used to access it, different content/styles will be served. So its essentially going to be 5 or so different retail sites specializing in a particula...

Error in MySQL update command. (in php)

Good Morning everyone, I am using an update command in php to update data in mysql. This is my code: $sql=mysql_query("UPDATE blpublication SET JournalName = '$_POST[journal]', AcceptanceDate = '$_POST[acceptancedate]', PublishedDate = '$_POST[publisheddate]', Comment = '$_POST[comment]' WHERE JobNo = '$_POST[jobno]'"); if (!mysql_que...

Php parse links/emails

Hello, I am wondering if there is a simple snippet which converts links of any kind: http://www.cnn.com to <a href="http://www.cnn.com"&gt;http://www.cnn.com&lt;/a&gt; cnn.com to <a href="http://www.cnn.com"&gt;cnn.com&lt;/a&gt; www.cnn.com to <a href="http://www.cnn.com"&gt;www.cnn.com&lt;/a&gt; [email protected] to to <a href="mailto:mail...

finding and storing values from string

Hello, i have a string which looks something like this: $fetched = name=myName zip=420424 country=myCountry; // and so on, it is not an array I fetch these values from an api. I want only the zip=873289 (infact only the numbers). So i use: // $fetched above is the output of the fuction below $fetched = file_get_contents("http://e...

Easiest way to persist data on a PHP page

I a web application that I am developing (being developed in PHP) when a user posts any request for service the user has to fill in a very length form. Once user fills in the form and submits it another page (confirmation page) is loaded in which all values filled in by user are show. I must point out that at this stage the data is not ...

Caching image requests through PHP - If-Modified-Since not being sent.

I am serving images through php and having some problems setting it up to respond with 304 headers to save on load time. Most of the code below I found on php.net. It works, however ALWAYS responds with 200. For some reason the If-Modified-Since header is not being received on any requests even though I am sending the Last-Modified head...

Run PHP code from .htaccess?

Say I have a rewrite that needs to pass the url to a PHP function and retrieve a value in order to tell what the new destination should be? is there a way to do that? Thanks. UPDATE: Thanks so far guys..I am still having trouble but i'll show you my code: .htaccess #I got the file path by echoing DOCUMENT_ROOT and added the rest. R...

How to programmaticaly build an APR1-MD5 using PHP

Much like this question I want to generate an htpasswd file entry from PHP. However it needs to be the APR1 (Apache) style, as mentioned in the original answer (The answer did not show how to implement the APR1 style), to work with mod_dav_svn. I can't seem to find a working implementation that will create the password. I found this (I...

PHP Session Confusion

Alright, I'm confused as hell. I have an object that I store in a session. I can add items to this object. Pretty simple so far. I initialize the object like this: $template = new Template($mysqli); $_SESSION['template'] = serialize($template); Now this should create a brand spanking new object and assign it to the session. I then hav...

What good software or scripts are available for managing users and subscriptions on our website?

hi all, Ok so it's not exactly a programing question but does anyone know or have experience with looking for a system for managing users on a website we are building? what is the shortlist of good feature rich secure solutions. we need Php and mysql integration and payment support for main credit cards. We will also want to be able to ...

Reading Image from AJAX response

I have a url that when requested will return an image. I want the url to be requested through an AJAX request. The ajax request returns binary data which is what is being deplayed. but i want the actual image displayed not the binary data. Am using php on the server side and i have set the below headers: header("Cache-Control: no-cache,...

Writing Clean and Efficient PHP Code

I have been looking around online and I cant seem to find an article on this that isn't totally outdated. Does anyone have any good articles that give some good advice? What I have read so far is good, and a bit helpful, but I want to have modern code examples, not ones from 2002. I have coded an extensive PHP/MySQL program and I am tr...

Why are escape characters being added to the value of the hidden input

<body> <div> <?= $_POST['msg'] ?> </div> <form id="frm" method="post"> <input type="hidden" name='msg' value='{"field0": "Im a string", "field1": 84, "field3": "so am I"}' /> <input type="submit" value="test" /> </form> </body> When the form is posted, the following string is displayed between the div tags. {\"field0\...