php

How do I write a simple PHP transparent proxy?

I need to make a proxy script that can access a page hidden behind a login screen. I do not need the proxy to "simulate" logging in, instead the login page HTML should be displayed to the user normally, and all the cookies and HTTP GET/POST data to flow through the proxy to the server, so the login should be authentic. I don't want the ...

What does stdout in display_errors in phpinfo() mean?

I have 'stdout' under display_errors in my phpinfo. What does it mean? Where can I find the documentation about it? I could not find one in http://php.net/ I read here telling that it should be off for the security reasons. Thanks in advance. ...

How to join filesystem path strings in php?

Is there a builtin function in php to intelligently join path strings? Like path_join("abc/de/","/fg/x.php") which should return "abc/de/fg/x.php", but path_join("abc/de","fg/x.php") should have the same result If not, is there a class availabel. Could also be valuable for splitting paths or removing parts of them. If you have written ...

How can I use and access an SQLite DB using PHP and Wamp Server?

I know PHP 5 already supports SQLite but for some reason I can't get it to work. I followed the instructions from http://www.scriptol.com/sql/sqlite-getting-started.php. I also made sure that the following are not commented out from php.ini: extension=php_pdo_sqlite.dll and extension=php_sqlite.dll. But when I open the PHP file from loc...

example of interactive manual for web app

I have requirement to write help(for example show description of what some button does) for my web app. Are there any good examples for doing this? ...

How to use the php command line interactively?

Are there any howtos for using the php command line interactively? I found a lot about running sripts that are in text-files, but not really about the shell with the prompt where I type in commands: $ php -a Interactive shell php > echo "hello world"; hello world php > $a = 1; php > echo $a; 1 php > exit; $ When I go to the linux she...

How do I prevent an included PHP script from changing the Location URL?

I'm including a PHP script that changes the URL. // index.php ob_start(); include "script.php"; // This script redirects using header("Location:"); $out = ob_get_clean(); // I use the $out data for calculations echo $out; Is there a simple way to counter or undo this unwanted redirect? How about: header("Location: index.php"); ...

Which PHP scripts for creating a portfolio do you know?

I know indexhibit, indexr and the core CMS are there any more? ...

How to get screen resolution of visitor in javascript and/or php?

I would like to know the screen resolution of a visitor visiting my page so I can properly make a jquery thickbox cover about 75% of their screen. Solutions to the question or helping me solve my problem are greatly appreciated! ...

Sending POST data with curl and php

Greets. So, I'm running Fedora Core 8 on an Amazon EC2. I installed httpd, php5 and libcurl, and a bunch of other stuff. Seemed to be working great, but then I realized that POST data isn't being sent by curl in my php scripts. Same request in the command line works tho. I also ran the same php scripts on my local machine (Win XP) and a...

Limit execution of a php-page to requests made from a certain ip-range

I have a PHP page I need to limit execution access of to only clients inside our firewall. How would I write a php-script that can look up the clients ip-address and match it to a ip-range (for instance 10...* or 200.10.10.*). ...

PHP's USORT Callback Function Parameters

This is a really esoteric question, but I'm genuinely curious. I'm using usort for the first time today in years, and I'm particularly interested in what exactly is going on. Suppose I've got the following array: $myArray = array(1, 9, 18, 12, 56); I could sort this with usort: usort($myArray, function($a, $b){ if ($a == $b) return...

PHP, why sometimes "\n or \r" works but sometimes doesnt??

Well, I am abit confuse using these \r,\n,\t etc things. Because I read online (php.net), it seems like works, but i try it, here is my simple code: <?php $str = "My name is jingle \n\r"; $str2 = "I am a boy"; echo $str . $str2; ?> But the outcome is "My name is jingle I am a boy" Either I put the \r\n in the var or i...

wordpress wp_get_archives output change with preg_replace

good morning boys and girls...can someone point me to the right direction, please. i want to replace my php-echo-output »JUNE 29, 2009–JULY 5, 2009« with just plain text: »last week« <?php ob_start(); wp_get_archives('type=weekly&limit=1'); $wklyarchives = ob_get_contents(); ob_end_clean(); $wklyarchives = preg_replace('%\&\#8211\;[a-...

webDAV / PHP / MS Word question

Can someone explain this strange (or normal) behaviour: I've got an Webdav directory. In this folder, I have a word document, called document.doc. When I open Word, en then choose to open file, and fill in the whole URL (http://server/webdav/document.doc), Word will open the document just fine. Changes I make are being saved on save cli...

Capturing console output from proc_open

I'm using proc_open to launch a telnet session connecting to a server program. Connection is ok but when I get the reply, I can't store the whole string on a file as it is cut after some chars. Here is my snippet: $descriptorSpec = array( 0 => array( "pipe", "r" ), 1.=> array( "file", $logPath, "w" ) ); $...

How to include variable in SPARQL query using PHP

I am creating a query form and let the user to enter the keyword from the form. Then the query form will bring to the next page where I carry the variable created in the query form to the next page. The excerpt code for the new page is as folows: //received variable $abc1=$_POST['querykeyword']; $querystring = ' Prefix try <http://www....

I need to have a field which value would be the id of the item, how can I achieve this?

I'm making an insert statement, the id field has auto_increment, another field must get the exact same value of the id field. All I can think of is to create an hash, save it in the insert, then search for it with a select, retrieve the id and then insert it in the proper field. I am also aware of the LAST_INSERT_ID() command, but I ha...

Is there a specific smarty function to order alphabetically an array?

Hi, I'm using a smarty template for a multi-language website. I got an array of country that is order by country code, which is ok for the english version as country name are in the right order but no ok for other languages (for example United Kingdom stay in the "U" whereas in French it prints "Royaume Uni". Is there a smarty function...

Keyword search, multiple tables, PHP and Mysql, Which Join to use?

Hi I have 3 tables event, location, event_location. Event can have multiple locations. Location table has lattitude, longitude, hasGeocode fields. so for keywords "hello world" a simple query to Event table becomes Select * from event where keywords like '%hello%' OR keywords like '%world%' but if if the user has entered their loc...