Re: [PHP] HTTP post requests
Greetings, first of all you'll need to have all of your variables in one line: like this for example $vars="var1=".urlencode($var1)."&var2=".urlencode($var2); then you need to post the following $header="POST /your_script.php HTTP/1.0\r\nContent-length: ".strlen($vars)\r\n\r\n$vars\r\n\r\n"; echo $header Of course these are not the complete headers browser sends, HTH, -- Vahan Yerkanian Email: [EMAIL PROTECTED] Leading Web Developer / Designer Phone: (374) 158-2723 Web Development DepartmentFax: (374) 128-5082 ARMINCO Global Telecommunications http://www.arminco.com Matthew Brealey wrote: > > I need to do an HTTP post from a PHP script; I want to set username=. > > What is the correct way to do this in PHP? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] HELP: problem listing directory contents
Greetings All! Recently I've been hit by a strange problem while coding a file indexing system. I have a source directory of the following format: /files/0-9 /files/0-9/0-90 /files/0-9/0-91 /files/a /files/a/a0 /files/a/a1 /files/b ... /file/z ok you got the picture I hope. nothing difficult. now when i try to exec my script, it hangs somewhere at path /files/a/a2 halting right before it should switch to b0... I'm including kinda long script below hoping some kind soul could examine it and throw the errors i've made into my face. I HOPE THIS IS NOT A BUG IN PHP. \n"; #Reset and Start the Timer. $updated=0; $added=0; $removed=0; $total=0; $starttime = doubleval(ereg_replace('^0\.([0-9]*) ([0-9]*)$','\\2.\\1',microtime())); #Get Contents of main directory. $D1=dir_list($FileDir); #Cycle Through each subdir of $FileDir. $S1=sizeof($D1); for ($i1=0; $i1<$S1; $i1++) { #Check whether the current item is not a directory, report and die if it is a file. if (!is_dir($D1[$i1])) die("ERROR 01: $D1[$i1] is a file, should be moved to a subdirectory.\n"); #CD into the current subdir. $SubDir="$D1[$i1]/"; chdir($SubDir); #Get contents of the current subdir. $D2=dir_list($SubDir); #Keep the name of current subdir in $CL $CL=substr($D1[$i1],strrpos($D1[$i1],'/')+1); #Print the header for the current directory. echo ""; if ($CL!="nm") echo strtoupper($CL); else echo "Numbers & Symbols"; echo"\n"; $S2=sizeof($D2); for ($i2=0; $i2<$S2; $i2++) { #CD into the current subsubdir. $SubSubDir="$D2[$i2]/"; echo "Entering $SubSubDir\n"; chdir($SubSubDir); #Generate current HTML filename. $CFL=substr($D2[$i2],strrpos($D2[$i2],'/')+1); if (ereg("nm",$CFL)) $CFL=ereg_replace("nm","0-9",$CFL); if (ereg("0-90",$CFL)) $CFL=ereg_replace("0-90","0-9",$CFL); if ($CFL[1]=='0') $CFL=ereg_replace("0","",$CFL); $CF="$HTMLDir$CFL.html"; #Open current HTML file. echo " Writing to File $CF\n"; $fp=fopen($CF,'w'); #Get contents of the current subdir. $D3=dir_list($SubSubDir); $S3=sizeof($D3); for ($j=0; $j<$S3; $j++) { echo "$D3[$j]\n"; }; #Close current HTML file. echo " Closing File $CF\n"; fclose($fp); #Return one level back,subletter listing. echo "Returning to $SubDir\n"; #chdir($SubDir); }; #Return one level back, letter listing. #chdir($FileDir); }; #Get the finish time and printout the stats. $endtime = doubleval(ereg_replace('^0\.([0-9]*) ([0-9]*)$','\\2.\\1',microtime())); echo "STATISTICS\n"; echo "Time Spent: "; echo $endtime - $starttime; echo " sec\n"; echo ""; ?> Thanks in advance -- Vahan Yerkanian Email: [EMAIL PROTECTED] Leading Web Developer / Designer Phone: (374) 158-2723 Web Development DepartmentFax: (374) 128-5082 ARMINCO Global Telecommunications http://www.arminco.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] url hide
Greetings, the only way which comes to my mind now is to use a stub , e.g. http://www.foo.co.uk/house-search/> this works 100%, though could sound weird at first. HTH, -- Vahan Yerkanian Email: [EMAIL PROTECTED] Leading Web Developer / Designer Phone: (374) 158-2723 Web Development DepartmentFax: (374) 128-5082 ARMINCO Global Telecommunications http://www.arminco.com Eric Dahnke wrote: > > I just asked a similar question two hours ago, and would like to express > my interest in this same question. > > Sorry it for a no answer response. > > AJDIN BRANDIC wrote: > > > Perhaps not related to php but I was wandering, is it possible to hide > > site's real url and replace it with something else (some other URL). ie. > > someone clicks on a link on www.blah.co.uk which takes the user to an > > designated area (ie. /house-search/) on www.foo.co.uk. I want > > the user still to see www.blah.co.uk. This is just for aesthetic reasons > > since ones the user finishes the search for houses (on > > www.foo.co.uk/house-search/) he/she will return to www.blah.co.uk. > > > > I have tried www.javascripts.com but no success?? > > > > Thanks > > > > Ajdin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Shortest route between 2 cities
Greetings All! I'm looking for a code which will find the shortest route between 2 cities, with data being stored in SQL tables listed below. Anyone has coded such a task ever? The most know algorithm for this is called Dijkstra's algoritm. Is there anyone with math skills enough to code this? This will be sure a big asset for our PHP community as any site dealing with some shippment/ticket/route problems will require such code. I'm including the structure of tables used. CREATE TABLE Cities ( cityID int(4) unsigned NOT NULL auto_increment, cityName varchar(20) NOT NULL, PRIMARY KEY (cityID), UNIQUE cityID (cityID, cityName) ); INSERT INTO Cities VALUES ( '1', 'A'); INSERT INTO Cities VALUES ( '2', 'B'); INSERT INTO Cities VALUES ( '3', 'C'); INSERT INTO Cities VALUES ( '4', 'D'); INSERT INTO Cities VALUES ( '5', 'E'); INSERT INTO Cities VALUES ( '6', 'F'); INSERT INTO Cities VALUES ( '7', 'G'); INSERT INTO Cities VALUES ( '8', 'H'); INSERT INTO Cities VALUES ( '9', 'I'); CREATE TABLE CityMatrix ( matrixID int(4) unsigned NOT NULL auto_increment, SourceCityID int(4) unsigned DEFAULT '0' NOT NULL, DestinationCityID int(4) unsigned DEFAULT '0' NOT NULL, Distance int(5) unsigned DEFAULT '0' NOT NULL, Fare int(4) unsigned DEFAULT '0' NOT NULL, PRIMARY KEY (matrixID), UNIQUE matrixID (matrixID) ); # Dumping data for table 'CityMatrix' INSERT INTO CityMatrix VALUES ( '1', '1', '4', '5', '10'); INSERT INTO CityMatrix VALUES ( '2', '3', '4', '50', '5'); INSERT INTO CityMatrix VALUES ( '4', '5', '7', '85', '8'); INSERT INTO CityMatrix VALUES ( '5', '1', '3', '70', '4'); INSERT INTO CityMatrix VALUES ( '6', '9', '6', '39', '6'); INSERT INTO CityMatrix VALUES ( '7', '8', '4', '10', '1'); -- Vahan Yerkanian[EMAIL PROTECTED] Vice President, Design & Development Website @ http://www.abideweb.com/ AbideWeb Technologies, LLC Phone +3741 238650 | Mobile +3749 416358
[PHP] overlaying alpha channel png over jpeg
I hope someone has got solution for this: I'm trying to write a script which will watermark a jpeg file with png logo, and output the resulting jpeg to a file. Unfortunately, whatever I do, I'm unable to get transparent color in png to disappear, by any means. the png file is 8bit, jpeg is true color; Am I doing something wrong? have a look: Best regards, -- Vahan Yerkanian[EMAIL PROTECTED] Vice President, Design & Development Website @ http://www.abideweb.com/ AbideWeb Technologies, LLC Phone +3741 238650 | Mobile +3749 416358 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] LOL, preg_match still not working.
Are you running under FreeBSD 6.2 and/or upgraded recently from 5.2.1 to 5.2.2? I had the same problem on FreeBSD 6.2, with php5 installed from ports collection after I portupgraded to 5.2.1. For me it appeared to be some kind weird misconfiguration problem that happened during the portupgrade... I had to: pkg_delete -rv "php5*" rm -rf /var/db/ports/php5* rm -rf /usr/local/lib/* cd /usr/ports/lang/php5 make install clean cd /usr/ports/lang/php5-extensions make install clean A bit harsh, but all of the preg_* errors disappeared since then. HTH, Vahan Steffen Ebermann wrote: Addendum: I encountered a problem when the string contains linebreaks. Maybe adding \n\r into the brackets fixes your problem. On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote: Hi, I previously had some issues with preg_match and many of you tried to help, but the same problem still exists. Here it is again, if anyone can explain to me how to get this to work it would be great - otherwise I'll just remove it as I just spent way to much time on this. Thanks Here's the code. if(empty($comment)) { $formerror['comment'] = nocomments; } elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', $comment)) { $formerror['comment'] = invalidchars; } This produces an error, which I believe it should not. Testing 12345. This is a test of the emergency broadcast system. WAKE UP!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LOL, preg_match still not working.
Correcting myself before my reply damages someone's box: Vahan Yerkanian wrote: rm -rf /usr/local/lib/* This indeed should be: rm -rf /usr/local/lib/php/* instead ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie, header, output problems
You should not add any output after doing a "Location:" redirect. It's recommended to add an exit() after the header(). Proper browsers should halt their renderer and redirect when they find a Location: header. HTH, Vahan J. Alden Gillespy wrote: I'm creating an e-commerce website, and I just need clarification as to whether a MySQL query is considered as "browser output". I ask because I have the following code, but the cookie isn't being set: if ($op == "login") { if (!isset($username) && !isset($userpass)) { } else { if ($username == "" || $userpass == "") { $errormsg = "Invalid username or password. Please try again."; } else { if (mysql_num_rows(mysql_query("select * from `$cart->user_table` where username=\"$username\" and userpass=\"$userpass\"", $cart->dblink)) == 1) { setcookie("jackloren_user", "$username:$userpass", time() + 2592000); // expires in 30 days header("Location: http://www.jackloren.com/";); //echo "test"; /*if ($rd != "") { redirectURL($rd,""); } else { redirectURL("",""); } */ } else { $errormsg = "Invalid username or password. Please try again."; } } } } However, if I comment out the header and uncomment the echo statement, then the cookie is added, no problem. It seems as if the browser is freaking out when there isn't any output after a cookie is set and a header is sent. I'm also having another similar problem with this function: function auth($redirect_url) { global $HTTP_COOKIE_VARS; if (!isset($HTTP_COOKIE_VARS['jackloren_user'])) { header("Location: http://www.jackloren.com/login.php";); // echo "test"; } else { $userinfo = explode(":", $HTTP_COOKIE_VARS['jackloren_user']); $username = $userinfo[0]; $userpass = $userinfo[1]; echo "$username | $userpass"; if (mysql_num_rows(mysql_query("select * from `$cart->user_table` where username=\"$username\" and userpass=\"$userpass\"", $cart->dblink)) != 1) { redirectURL("login.php", $redirect_url); } else { echo "success"; // nothing } } } If I leave the script the way it is, the browser isn't redirected no matter what I put in the header() statement. However, if I uncomment the echo statement, giving the browser some output, then the redirect works fine. Has anyone experienced this? And if so, how do I fix it? Thanks. J. Alden Gillespy (aka Dogga) Microsoft Beta Tester: - Office 11 - Content Management Server (CMS) 2002 - Systems Management Server (SMS) 2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] looking for PHP, MYSQL & IMAGEMAGIK hosting
I know I'll start another flamewar, but I'm desperate for a quality hosting provider supporting php/mysql/imagemagik anyone has good experience with any company? regards, Vahan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extracting EXIF/IPTC info from jpeg/tiff image files
Hi, Some time ago I needed to read IPTC info from jpeg files, and I ended up with a function to read these fields from JPEG header. Another approach is to use ImageMagick to read the exif/iptc from jpeg/tiff. Here is the function, I hope it'll be useful: function get_IPTC($path) { $size = GetImageSize ($path, &$info); if (isset($info["APP13"])) { $iptc = iptcparse($info["APP13"]); if (is_array($iptc)) { $IPTC_data=array( "Version" => $iptc["2#000"][0], # Max 2 octets, binary number "Title" => $iptc["2#005"][0], # Max 65 octets, non-repeatable, alphanumeric "Urgency" => $iptc["2#010"][0], # Max 1 octet, non-repeatable, numeric, 1 - High, 8 - Low "Category" => $iptc["2#015"][0], # Max 3 octets, non-repeatable, alpha "SubCategories" => $iptc["2#020"], # Max 32 octets, repeatable, alphanumeric "Keywords" => $iptc["2#025"], # Max 64 octets, repeatable, alphanumeric "Instructions" => $iptc["2#040"][0], # Max 256 octets, non-repeatable, alphanumeric "CreationDate" => $iptc["2#055"][0], # Max 8 octets, non-repeatable, numeric, MMDD "CreationTime" => $iptc["2#060"][0], # Max 11 octets, non-repeatable, numeric+-, HHMMSS(+|-)HHMM "ProgramUsed" => $iptc["2#065"][0], # Max 32 octets, non-repeatable, alphanumeric "Author" => $iptc["2#080"][0], #!Max 32 octets, repeatable, alphanumeric "Position" => $iptc["2#085"][0], #!Max 32 octets, repeatable, alphanumeric "City" => $iptc["2#090"][0], # Max 32 octets, non-repeatable, alphanumeric "State" => $iptc["2#095"][0], # Max 32 octets, non-repeatable, alphanumeric "Country" => $iptc["2#101"][0], # Max 64 octets, non-repeatable, alphanumeric "TransmissionReference" => $iptc["2#103"][0], # Max 32 octets, non-repeatable, alphanumeric "Headline" => $iptc["2#105"][0], # Max 256 octets, non-repeatable, alphanumeric "Credit" => $iptc["2#110"][0], # Max 32 octets, non-repeatable, alphanumeric "Source" => $iptc["2#115"][0], # Max 32 octets, non-repeatable, alphanumeric "Copyright" => $iptc["2#116"][0], # Max 128 octets, non-repeatable, alphanumeric "Caption" => $iptc["2#120"][0], # Max 2000 octets, non-repeatable, alphanumeric "CaptionWriter" => $iptc["2#122"][0] # Max 32 octets, non-repeatable, alphanumeric ); } else $IPTC_data=array(); } return $IPTC_data; } Regards, Vahan Binay Agarwal wrote: Hi everybody I need to extract the information (EXIF and IPTC) from jpeg/tiff image files. After that i have to allow my client to modify and put them back in jpeg/tiff files. I want to know whether php has got built-in support in terms of libraries to achieve the goal or i will have to load some external modules/software to do the same. In case external which all modules/software to refer? Please let me know. Thanks Binay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php