[PHP] Quick question regarding debugging and PHP structure.
Short: Is it possible to see the PHP code that is going to be processed in whole? Long: I love to see things visually, and while programming i create all kinds of debugging variables i keep on the side for each page/request. I know this is possibly not possible since this has to be done from either the Zend Engine or PHP itself, but if i could see a complete output of all the code within my project that is used for a certain execution. Example: I call index.php?page=10 index.php includes functions.php and classes.php classes.php include page_classes.php if there is a $_GET[page] variable set and product_classes.php if there is a $_GET[product] variable set What i would like to see is the linear output of what code is included (so the data of functions.php, classes.php, then page_classes.php, and then index.php (not product_classes.php since its not included within this request) This is most likely possible with some PHP code but I'm thinking of trying to make sense of an old project i didn't create quickly and if this is possible it would help a lot. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Resizing
With the built in functions (GD), you can read up on this function: http://is.php.net/manual/en/function.imagecopyresized.php If you have Imagick installed, you can read up on this: http://is.php.net/manual/en/function.imagick-thumbnailimage.php On Sat, Dec 20, 2008 at 8:38 PM, Stephen Alistoun stephenalist...@gmail.com wrote: Hi all, What is the best way in PHP to Resize an Image to a specific width. For Example I have images in the following sizes: (1) 200px width and 350px height (2) 125px width and 220px height (3) 166px width and 455px height I want all the images to resize to 100px width but the height adjusts automatically. Regards, Stephen -- View this message in context: http://www.nabble.com/Image-Resizing-tp21108753p21108753.html Sent from the PHP - General mailing list archive at Nabble.com. -- 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] still can't get a login with session working ... is there another way to mask the url parameter?
1st. Replace your $sql query with this $sql = sprintf(SELECT * FROM admin WHERE UserName = '%s' AND Password = '%s', mysql_real_escape_string($UserName), mysql_real_escape_string($Password)); $result = mysql_query($sql) or die(mysql_error()); Ólafur Waage olaf...@gmail.com On Thu, Dec 18, 2008 at 3:56 PM, Terion Miller webdev.ter...@gmail.com wrote: Still this won't pass the session to the next page is there a way to pass parameters in the url but mask them? maybe that would be easier, since I do have code that works passing the adminID on the url ... can a parameter be hashed after the fact? I tried echo-ing the fields on the next page and they are not passing... my code that still doesn't work: ?php // start session session_start(); include(inc/dbconn_open.php) ; $errs = error_reporting ('E_ALL'); if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName ='$UserName' and Password ='$Password' or die(mysql_error()); $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = $row['AdminID']; header (Location: Main.php); } else { $msg = Invalid Login; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good PHP book?
Hey, php.net is the best book, but if you want a good book that goes over all the elements of php then pickup the Zend PHP 5 Certification Study Guide: http://www.amazon.com/architects-Zend-Certification-Study-Guide/dp/0973862149/ref=pd_bbs_sr_1?ie=UTF8s=booksqid=1229296547sr=8-1 Olafur Waage On Sun, Dec 14, 2008 at 10:52 PM, German Geek geek...@gmail.com wrote: The best book is php.net, if you already know a programming language ;-). Otherwise Ashley is probably right. I haven't read any books on php, got all the info off the web, but it's still my main language atm. Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Dec 15, 2008 at 11:48 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sun, 2008-12-14 at 16:33 -0600, jeffery harris wrote: Hi guys/gals. I'm a first time user. Does anyone know of a good php book? I tend to trust O'Reilly books a lot for all things programming, although I learnt largely with 'PHP, Apache, MySQL Web Development' from WROX. Ash www.ashleysheridan.co.uk -- 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
[PHP] Quick question regarding $_SESSION and header()
I should be able to set a session var and then do a header redirect right? Small bug regarding that and i just need to be sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-QA] Re: [PHP] Quick question regarding $_SESSION and header()
Whoops, sent the thanks to the wrong list :P On Thu, Dec 11, 2008 at 7:33 PM, Daniel Brown danbr...@php.net wrote: (Forwarding back to PHP General for the archives.) On Thu, Dec 11, 2008 at 14:31, Ólafur Waage olaf...@gmail.com wrote: Its fixed, thanks guys :) On Thu, Dec 11, 2008 at 7:16 PM, Daniel Brown danbr...@php.net wrote: On Thu, Dec 11, 2008 at 14:01, Ólafur Waage olaf...@gmail.com wrote: I should be able to set a session var and then do a header redirect right? Small bug regarding that and i just need to be sure. This isn't a bug in PHP, it's actually in adherance with HTTP standards (and current browser standards). Prior to doing a header() redirect, you have to force the cookie to be written with session_write_close(). -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP Quality Assurance Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagecreatefromgif imagecolortransparent() ??
Here's a code snippet from the php.net documentation on imagecolortransparent by Blaine Ehrhart ?php $im = imagecreatefromgif('trans.gif'); $img = imagecreatetruecolor(16,16); $trans = imagecolorallocate($img,255,99,140); imagecolortransparent($img,$trans); imagecopy($img,$im,0,0,0,0,16,16); imagetruecolortopalette($img, true, 256); imageinterlace($img); imagegif($img,'trans.gif'); imagedestroy($img); ? See if it works. On Thu, Dec 4, 2008 at 10:44 AM, LucaP [EMAIL PROTECTED] wrote: Hi all, the simple code snippet: header('Content-type: image/gif'); $im = imagecreatefromgif(/path/Mypic.gif); $background = imagecolorallocate($im, 255, 255, 255); imagecolortransparent($im,$background); imagegif($im,'/path/TransparentPic.gif'); imagedestroy($im); is creating the new image but is not setting the white background to transparent; I am sure about the presence of the white color in the background (checked it with imagecolorat() etc). a similarly simple test setting transparency on a new image created with 'imagecreatetruecolor()' works correctly... any hints?! Cheers, Luca -- 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] It's Sunday, and I'm bored...
Commit Early Commit Often. :P On Sun, Nov 9, 2008 at 11:03 AM, Richard Heyes [EMAIL PROTECTED] wrote: Hi, I just looked at my commit diff that I need to check - 1500 lines (!). Uhhh... Maybe that policy of committing frequently wouldn't be so terrible after all... -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org (Updated November 1st) -- 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] It's Sunday, and I'm bored...
On Sun, Nov 9, 2008 at 5:33 PM, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Commit Early Commit Often. :P [/snip] Are you from Louisiana? Iceland so no -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]Executing a .jar from a php script
Does the php server have access to run that file? (ie. if its apache, does he or his group have the rights to run that file) Also you can try to use $var = system('java -jar JARNAME', $dump); and try to output from both variables. 2008/10/27 Bastien Helders [EMAIL PROTECTED]: Hi, I would like to execute a jar file using exec('java -jar JARNAME option'), but so far, my web application didn't gave me any hint that it did anything (I tried to echo the result of the function, but nothing), and in fact I don't think anything was done. The jar file is in the same folder as the php scripts, so I don't know what I did wrong. Best Regards, Bastien -- haXe - an open source web programming language http://haxe.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Public in Classes
Here you go. http://talks.php.net/show/php5_ca/4 Ólafur Waage [EMAIL PROTECTED] 2008/9/21 Ben Stones [EMAIL PROTECTED]: Hi, Just started with object oriented programming and glad I have come across it, just need a few things clearing up. When I make a variable or method public, does this mean that it can be used outside of classes, for instance in other classes or as well as instantiating classes? So if I made it private, it wouldn't be able to be instantiated or extended in other classes, am I right? I have never added public when I am creating methods so I presume its already set as default if you don't add it? Hope you can understand my question. Cheers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Printing date out of array
I would suggest the time() value to be saved in your database. Since the date() function can use that as the second parameter and you can use any format date() allows. Or make your own. Ólafur Waage [EMAIL PROTECTED] 2008/8/31 Michael S. Dunsavage [EMAIL PROTECTED]: This is my date array: $months = array (1 = 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); This is my date select in the form: echo 'select name=day'; for ($day = 1; $day = 31; $day++) { echo option value=\$day\$day/option\n; } echo '/select'; echo 'select name=year'; $year = 2008; while ($year = 2020) { echo option value=\$year\$year/option\n; $year++; } echo '/select'; This is how it submits to mysql: Now, when I submit it to mysql, it's all in mm-dd- format. When I submit it to an e-mail, I'd like it to me Month-dd-. How could I do this? Would it be easier to pull the date from mysql and break it down somehow? And if so how would I do that? -- Michael S. Dunsavage -- 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] ASCII Captcha
Thats exactly what i am talking about Richard. Ólafur Waage [EMAIL PROTECTED] 2008/8/29 Richard Heyes [EMAIL PROTECTED]: pre ||| ||| `||| |||`|||`````|||||` ` || ||||| ||` |. |`... | ||` .|| | | .|||||``|.|.```|.|| |. `||||| | |||.. ..`| ||| |||`` |. ```||`||.|` `||.. | ```. . .|`. ```.| |||. S ..... I ... R . I .|||.. K . ||| BUCES BBS|| ||| /pre (I'm not sure it was showed correct) It didn't, but pasting it into notepad made everything OK... Even after that though, it wasn't particularly readable. -- Richard Heyes HTML5 Graphing: http://www.phpguru.org/RGraph -- 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] ASCII Captcha
I just realized that i should have said ASCII Art but not just ASCII, it was so clear in my head but i notice now how it could have been misunderstood. Ólafur Waage [EMAIL PROTECTED] 2008/8/29 Ólafur Waage [EMAIL PROTECTED]: Thats exactly what i am talking about Richard. Ólafur Waage [EMAIL PROTECTED] 2008/8/29 Richard Heyes [EMAIL PROTECTED]: pre ||| ||| `||| |||`|||`````|||||` ` || ||||| ||` |. |`... | ||` .|| | | .|||||``|.|.```|.|| |. `||||| | |||.. ..`| ||| |||`` |. ```||`||.|` `||.. | ```. . .|`. ```.| |||. S ..... I ... R . I .|||.. K . ||| BUCES BBS|| ||| /pre (I'm not sure it was showed correct) It didn't, but pasting it into notepad made everything OK... Even after that though, it wasn't particularly readable. -- Richard Heyes HTML5 Graphing: http://www.phpguru.org/RGraph -- 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] Problems sending $_POST vairable to an ASP page
IIRC ASP cant recive PHP $_POST variables but it can recive HTML post from forms. If you want to send variables to another language. You can try via a get variable. Dont know if the items you want to send are safe to send over though. Ólafur Waage 2008/8/28 shaun thornburgh [EMAIL PROTECTED]: Hi guys, I need to send post variables to an ASP page. I have the following code which isn't producing any errors but isn't working either: foreach($_POST['newsletter-group'] as $key = $value){ $_POST['addressbookid'] = $value; $out = POST /signup.ashx; $fp = fsockopen(dmtrk.net, 80, $errno, $errstr, 30); if (!$fp) { echo $errstr ($errno)br /\n; } else { fputs($fp, $out . \r\n); } fclose($fp); } Can anyone tell me what I am doing wrong please? _ Get Hotmail on your mobile from Vodafone http://clk.atdmt.com/UKM/go/107571435/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ASCII Captcha
Has anyone tried a ASCII Captcha method. To use a similar method like this ASCII generator (http://www.network-science.de/ascii/) Or even gone the next level and have an ASCII based simple math question? I know this isnt strictly a PHP question but spam free sites are very dear to us. Ólafur Waage [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I am pretty certain that this isnt possible under current code. But i just wanted a confirmation on this, since i worked on the code for a while trying to get to the end point. And yes Jochem, i am looking for a magical location :P Well, thanks guys :) Ólafur Waage 2008/8/24 Micah Gersten [EMAIL PROTECTED]: What is the point of figuring that out? If we knew that, we might be able to help you with a solution. As it stands what you want is not possible AFAIK. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results Ólafur Waage 2008/8/23 Robert Cummings [EMAIL PROTECTED]: On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Luke, i am looking for local directory info. Not URL info as i said before. And Ashley, as i said in the original mail. I had tried $_SERVER. Thanks for the reply though. Ólafur Waage 2008/8/23 Luke [EMAIL PROTECTED]: $_REQUEST? Luke Slater Lead Developer NuVoo On 23 Aug 2008, at 12:53, Ólafur Waage [EMAIL PROTECTED] wrote: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results Ólafur Waage 2008/8/23 Robert Cummings [EMAIL PROTECTED]: On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- 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] Serving pages based on user input
You can read about the header function. http://is2.php.net/manual/en/function.header.php Ólafur Waage 2008/8/23 Prasad Chand [EMAIL PROTECTED]: Hi, I am fairly new to PHP. I would like to serve a page to a user based on his input. Say, I have a page 1 where user has 3 options(drop down menu). Based on his selection I would like a php script to direct him to another page (to pages 2,3,4 based on what he selected). I am unable to figure how to do this in php. Can you please give me some pointers. Is there any function which takes path and directs the user to that page? Thanks, Prasad -- 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] Quick question regarding getcwd() and directory location.
Thanks for this David, i was using REQUEST_URI and other $_SERVER info and mixed that together. It worked in some situations but on hosted servers (like GoDaddy and others like that where they use a complicated directory setup) it does not work. Olafur Waage 2008/8/23 David Otton [EMAIL PROTECTED]: 2008/8/23 Ólafur Waage [EMAIL PROTECTED]: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results If checking the output of phpinfo() doesn't help (and it looks like it won't), I'd suggest starting with REQUEST_URI, then, if you know where your webroot is, you should be able to calculate the path to the target directory (/var/www/example/../test/ in your original example) by gluing bits of path together. Hardly an ideal solution as it needs configuration, but it would work. I think this is really a mod_rewrite problem, as by the time PHP takes over you've lost the information you need. You may have better luck in a forum devoted to mod_rewrite, but I'm not optimistic that it has a what file would have handled this request if mod_rewrite hadn't run parameter. I think you're going to have to build your directory path from the information in the original request and some configuration glue. Good luck (BTW, I initially thought there might be something in mod_autoindex to run a custom script, but it doesn't look like there is.) -- http://www.otton.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage 2008/8/22 Ashley Sheridan [EMAIL PROTECTED]: On Fri, 2008-08-22 at 21:56 +, Ólafur Waage wrote: That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage Are you just trying to find the current working directory, or are you navigating to a directory with PHP and want to know where you've ended up? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick question regarding getcwd() and directory location.
I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with script timing out in php 4.4.8
Could you try setting the max_execution_time with ini_set and confirming the status of it with ini_get ? - Waage 2008/6/4 Arno Kuhl [EMAIL PROTECTED]: I recently picked up an issue when I upgraded my IDE, where the browser window timed out while I was debugging the code. I checked with support and was told the problem was with php 4.4.8 which they'd upgraded to, so to confirm I installed 4.4.8 and ran a test - and it seems there is a problem with 4.4.8. The test was: change max_execution_time from 30 to 600 in php.ini - phpinfo confirms max_execution_time=600 ?php $t=70; echo h2Test timeout - sleep for $t seconds/h2; echo sleeping .date('h:i:s').br /; sleep($t); echo stop sleeping .date('h:i:s'); ? $t=59 works fine, but $t=70 times out. (Windows 2000, Apache Release 10324100) I ran the same test successfully with $t=500 seconds on a different machine running php 4.3.4, everything else the same as the original test pc. What bothers me a bit is 4.4.8 has been available since February and checking the archives I see no-one else has reported this problem, which seems highly unlikely, so I'm wondering if this is specific only to my environment somehow. Has anyone else had problems with max_execution_time in 4.4.8? Cheers Arno -- 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] urlencode and urldecode
You can read about apache's mod_include and its echo element. http://httpd.apache.org/docs/2.2/mod/mod_include.html#element.echo 2008/5/17 Chris W [EMAIL PROTECTED]: Whenever you build a query string you need to us the urlencode to encode any characters that may be in there that aren't legal for a URL. On the server I am using now, when you access values using $_GET['xyz'], it does the urldecode for you. I'm not positive, but I am pretty sure, that at one time on a server I used in the past, that I had to manually call urldecode to decode GET vars. Is there a setting to change this or is it something that changed in php in the last few years? -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- 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] encoding to a file
This should work as expected. ?php $f = fopen(file.txt, r); stream_encoding($f, iso-8859-1); ? 2008/5/16 J. Manuel Velasco - UBILIBET [EMAIL PROTECTED]: Hello. When I create a file I need to specify the encoding to ISO-8859-1, how can i do this please ? I have read about stream:default:encoding() but I am not sure how to use it. Thanks in advance. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Loading 2M array crashes program .. but only some of the time
Are you using a persistent connection? 2008/5/18 Mary Anderson [EMAIL PROTECTED]: Hi all, I have a php - postgresql program which bombs with a statement that it has run out of memory. I am running php 5.1.6 and postgres 8.3.something. My program bombs, saying that it fails to allocate memory, when it is loading an SQL query result into a php array using pg_fetch_all. The SQL query works fine when I run it in psql. I am running php with a process limit size of 16M. Some of the time this query works, sometimes it dies. It is my impression that it dies after I have been running the php application for a while -- like there is memory that isn't being cleared up. But that is only an impression! What could be going wrong? -- 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] syntax of sprintf
Try this one $sSQL = sprintf(SELECT username FROM individuals WHERE username='%s', mysql_real_escape_string($username)); $query = mysql_query($sSQL); if($query !== false) { // do something } 2008/5/18 Sudhakar [EMAIL PROTECTED]: until i started using the techniques for avoiding sql injection, i have been using a normal insert and select sql query which worked fine. i have a registration page where a user enters their username and if this already exists i display a message by executing a select query and if the username does not exist then i run an insert query. after adopting the technique to avoid sql injection if(get_magic_quotes_gpc()) { $username = stripslashes($_POST[username]); $email =stripslashes($_POST[email]); } else { $username = $_POST[username]; $email =$_POST[email]; } previously my select and insert query were INSERT INTO individuals(username, email) values('$username', '$email') Select username from individuals where username = '$username' presently the insert query is $insertquery = sprintf(INSERT INTO individuals (username, email) VALUES ('%s', '%s'), mysql_real_escape_string($username), mysql_real_escape_string($email)); This insert query is working however the select query is not doing its task as before of checking if the username already exists or not, even if i register with the same username again it does not alert that the username exists. the select query is $selectqueryusername = sprintf(Select username from individuals where username='%s', mysql_real_escape_string($username)); should i change the syntax of the above select query or is there something else in need to do to fix the select query. please advice. thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: fsockopen on ssl://
Are you doing the command line on the same machine as the server? Have you checked out the apache configuration? Since phpcli runs alone. (iirc) 2008/5/18 bob pilly [EMAIL PROTECTED]: Hi Manuel Thanks for the reply. I have tested it with a timeout of 20 seconds and the same thing occurs. It works as before from the command line and not form within apache.. Any more ideas? Cheers Bob - Original Message From: Manuel Lemos [EMAIL PROTECTED] To: bob pilly [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Wednesday, 14 May, 2008 4:26:41 PM Subject: Re: fsockopen on ssl:// Hello, on 05/13/2008 04:37 PM bob pilly said the following: Hi all I have tried researching this issue but havent come up with any solution so im hoping someone has seen it before and can help. I have the following test script that uses fsockopen to connect to a https site, get the contents and outputs it. ?php $host = www.microsoft.com; $path = /; $fh = fsockopen(ssl://.$host, 443, $errno, $errstr, 5);//opens url for reading with a timeout of 2 seconds if (!$fh){ echo FAIL: $errno $errstr ; } else{ $out = GET $path HTTP/1.1\r\n; $out .= Host: $host\r\n; $out .= Connection: Close\r\n; $out .= \r\n; fwrite($fh, $out); stream_set_timeout($fh,2); $info = stream_get_meta_data($fh); if($info['timed_out']){ echo TIMEOUT\n; } else{ $haystack = ; while (!feof($fh)) { $haystack.= fgets($fh, 4096); } } print $haystack; fclose($fh); } ? if i run this script using php -f test.php it works fine. However if i try and run this on my loca apache server i get the following error: Warning: fsockopen() [function.fsockopen]:unable to connect to ssl://www.microsoft.com:443 (A connection attemptfailed because the connected party did not properly respond after aperiod of time, or established connection failed because connected hosthas failed to respond.) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test.php on line 4 FAIL: 10060 A connection attempt failed because the connected party didnot properly respond after a period of time, or established connectionfailed because connected host has failed to respond. As you can see from that error i am using windows and apache 2.2. My php version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tlsin my config. I suspect that you are giving a very short timeout but then you are not handling the timeout error properly. Anyway, before reinventing the wheel, you may to try this HTTP client class that supports many options including establishing SSL corrections and setting and handling timeouts correctly. http://www.phpclasses.org/httpclient -- Regards, Manuel Lemos PHP professionals looking for PHP jobs http://www.phpclasses.org/professionals/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ __ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] client time zone?
To get the clients time offset you'll need to use javascript and date.getTimezoneOffset() But this idea has a problem. It is that you can never trust that the clients time is actually correct. You can get the closest to it by using the server time and offsetting that with the javascript offset value. But you'll never know if the client has the wrong timezone and you'll have to deal with timezones that don't have daylight savings like for instance Iceland :) - Ólafur Waage 2008/1/6, Per Jessen [EMAIL PROTECTED]: jekillen wrote: Hello; I am running a server that is using UTC and I want to be able to convert to clients local time in some display presentations. Is this indicated by $_SERVER[REQUEST_TIME]? Is there such a value at all? If not, is there a way to get the requesting host's time zone so I can offset the servers clock value correctly? I think you'll need to use javascript. /Per Jessen, Zürich -- 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] image* Functions' Memory Usage
I recently made two commercial sites that used both GD and Imagick and i can share some wisdom i got from those projects. (both projects were card generators where users made their custom cards and but one had a fixed picture and users could add text and the other one allowed users to add their own picture with text) # Some functions of the GD library are VERY memory intensive. For example the image resizing. The resizing process is calling three functions to work and two of them are holding very large amounts of data within them. (the original image and the new image area you are going to put the resized image into, and then the 3rd functions resizes the image) # Basic GD library functions can be quite fast (and most if not all Imagick functions are fast if the image isn't too big) # Speed of both options are always affected by the size of the image being used. (Size in bytes, a 10x15 print quality card generated with a user selected image + text can take up to 30 seconds to generate) And yes thats an annoying generator to debug. # If you are going beyond simple things like adding text onto an image i recommend going with Imagick. # Imagick is a great system to use if you learn all the command lines and combinations, far superior to GD in many ways. # Complex Imagick functions (that works with all possible outcomes) can be VERY slow. # If you have the choice of running Imagick from the command line (installed onto the linux system) or running the Imagick PHPlib, go with the PHP library one (even though it looks like more overhead in code) since error reporting with the command line is close to none. # If you have the choice of the images being generated later (ie. by an admin of the system), go with that path always. (one of my systems does that and the other doesn't) and the problems with the end users on the image generating step are very hard to debug, since they usually describe the problems very badly. Hope this helps some. - Ólafur Waage [EMAIL PROTECTED] 2008/1/4, Casey [EMAIL PROTECTED]: Greetings, list. I have a web application that generates PNG images that are thousands of pixels high by thousands of pixels wide (using imagepng, etc.). The problem is this takes way too much memory, and the rest of the site becomes too slow. I'm working on something to cache the images, but some suggestions in the meantime would be great. Maybe ImageMagick is faster? Flash?Any suggestions? Thank you very much. - Casey -- 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] How to show proper time to users from around the world
Since there are always many ways to do things here's one id like to see how well it worked. It would be getting the IP address of the user and matching it against an IP address locator. Since ive seen these to be accurate to what timezone people are in. Olafur W 2007/8/30, Hemanth [EMAIL PROTECTED]: Its ok if I can display just the time set in their computers wherever they are and even if they are travelling. anyway thats as far as anyone can get short of asking them for the time Is there some simple way I have collected various ideas and snippets searching google trying to piece them all together On 8/30/07, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, August 29, 2007 2:24 am, Hemanth wrote: Is there a solution to showing the proper time and date at user browsers and also recording proper USER times in the database operations in mysql Not really. You can use Javascript to get what the user's clock SAYS is the date/time, but WAY too many users have their clocks set wrong, and you'll never fix that. You can ask them where they live, or ask them to input their own time-zone. Traveling users may prefer to use UTC or something as well, rather than try to figure out what time-zone they are in this minute (cough Indiana cough). -- -- www.ValueAds.bizso easy FREE India Classifieds Jobs, Matrimony, Property and more A Bangalore, India Venture. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match_all to match img tags
Ive already finished the code and pasted it to this mailing list :) Just an fyi. Ólafur Waage 2007/8/11, Tijnema [EMAIL PROTECTED]: On 8/11/07, Stut [EMAIL PROTECTED] wrote: Tijnema wrote: On 8/11/07, Richard Heyes [EMAIL PROTECTED] wrote: Richard Heyes wrote: How can i match an image tag correctly so it does not cause any issues with how the user adds the image. preg_match_all('/img[^]*/Ui'); Off the top of my head. This wouldn't allow for using the right angle bracket in the img tag, but that's almost never going to happen in reailty. Oops that should be: preg_match_all('/img[^]*/Ui', $input, $matches); -- Richard Heyes img src=image.jpg Your script doesn't catch above ;) That's not valid HTML and won't get displayed correctly in most browsers. -Stut hmm.. damn.. you're right :P I always assumed it was just correct... Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- 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] preg_match_all to match img tags
Guys i would like to thank you for the help. Jan i used some of your code to help me get this. There was one issue with yours, preg_match_all while in a foreach will only match the last match and output that as the $m array. Here is the code, i hope someone else can use it. Its a working code in PHP4 and PHP5. I am currenly wrapping the imageManip(); around the $_POST variable that is the blog post when im posting it to the SQL. So the getimagesize(); only has to run once. There is one bug, if the user resizes the image manually to something less than 590, to say maybe 400, this program will still resize it to 590. function imageProportions($image) { $imageLoad = @getimagesize($image); // if the image is larger than 590 pixels, it will resize both height and width // if not it will do nothing to the variables. if($imageLoad[0] 590) { $proportion = $imageLoad[0] / $imageLoad[1]; $imageLoad[0] = 590; $imageLoad[1] = $imageLoad[0] / $proportion; return array($imageLoad[0], ceil($imageLoad[1])); } else { return array($imageLoad[0], $imageLoad[1]); } } function imageManip($data) { // match all image tags (thanks to Jan Reiter) @preg_match_all(/\ *[img][^\]*[.]*\/i, $data, $matches); if( is_array($matches[0]) ) { // put all those image tags in one string, since preg match all needs the data // to be in a string format foreach($matches[0] as $match) { $imageMatch .= $match; } // match all source links within the original preg match all output @preg_match_all(/src=\(.+?)\/i, $imageMatch, $m); // for each match that has the same key as the second match, replace the entire // tag with my img tag that includes width, height and border=0 foreach($matches[0] as $imageTagKey = $imageTag) { foreach($m[1] as $imageSrcKey = $imageSrc) { if($imageTagKey == $imageSrcKey) { $imageStats = imageProportions($imageSrc); $data = str_replace($imageTag, img src=\.$imageSrc.\ width=\.$imageStats[0].\ height=\.$imageStats[1].\ border=\0\ /, $data); } } } } return $data; } 2007/8/10, Jan Reiter [EMAIL PROTECTED]: Maybe this is what you are searching for: $images = array(); $data = blah img src=img.png width=\400\ height='600' src=blah.png img src=gg.tiff; preg_match_all(/\ *[img][^\]*[.]*\/i, $data, $matches); foreach($matches[0] as $match) { preg_match_all(/(src|height|width)*= *[\\']{0,1}([^\\'\ \]*)/i, $match, $m); $images[] = array_combine($m[1],$m[2]); } print_r($image); It will produce: Array ( [0] = Array ( [src] = img.png [width] = 400 [height] = 600 ) [1] = Array ( [src] = gg.tiff ) ) I wrote it just as an example. So you may modify it for your needs! Does anyone know if there is a way to put this into ONE regex?? Jan -Original Message- From: brian [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 3:18 AM To: php-general@lists.php.net Subject: Re: [PHP] preg_match_all to match img tags Ólafur Waage wrote: I know this isn't exactly a php related question but due to the quality of answers ive seen lately ill give this a shot. (yes yes im smoothing up the crowd before the question) I have a weblog system that i am creating, the trouble is that if a user links to an external image larger than 500pixels in width, it messes with the whole layout. I had found some regex code im using atm but its not good at matching the entire image tag. It seems to ignore properties after the src declaration and not match tags that have properties before the src declaration . preg_match_all(/\ *[img][^\]*[src] *= *[\\']{0,1}([^\\'\ ]*)/i, $data, $matches); print_r($matches); This currently makes two arrays for me, the source location from all img tags and a large part of the tag itself. But not the entire tag. What i do is i match the img tag, find the src, get the image properties, and if the width is more than 500, i shrink it down and add width=X and height=Y properties to the image tag. How can i match an image tag correctly so it does not cause any issues with how the user adds the image. style #your_content_div img { max-width: 500px !important; } /style OK, so it won't work with IE6. Screw them. But if the height is set in the img tag it'll keep that, so the image could become distorted. So, you could also do something like: #your_content_div img { visibility: none; } Then run some Javascript routine onload to properly figure the dimensions of each image. Adjust the width down to 500px, if necessary, then the height by whatever percent difference between original width over new width: var new_height = (original_width / 500) * original_height; Then, whether you change the dimensions of the image
[PHP] preg_match_all to match img tags
I know this isn't exactly a php related question but due to the quality of answers ive seen lately ill give this a shot. (yes yes im smoothing up the crowd before the question) I have a weblog system that i am creating, the trouble is that if a user links to an external image larger than 500pixels in width, it messes with the whole layout. I had found some regex code im using atm but its not good at matching the entire image tag. It seems to ignore properties after the src declaration and not match tags that have properties before the src declaration . preg_match_all(/\ *[img][^\]*[src] *= *[\\']{0,1}([^\\'\ ]*)/i, $data, $matches); print_r($matches); This currently makes two arrays for me, the source location from all img tags and a large part of the tag itself. But not the entire tag. What i do is i match the img tag, find the src, get the image properties, and if the width is more than 500, i shrink it down and add width=X and height=Y properties to the image tag. How can i match an image tag correctly so it does not cause any issues with how the user adds the image. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MD5 bot Question
You were talking about an OCR reader for the arrows to see what letters it is pointing to. If the arrow would be at a random location in the actual image, the arrow being not an arrow but ie. a man pointing and the arm being flexible (so even if the man himself would move around randomly, the arm would always face the right direction for the image. I like the idea of a pointing arrow, it could be quick, pretty effective (not 100% since nothing is) and easy for the user to identify. If there was a miniature version of this available, i would use it on my site. Since i hate the text versions. - Olafur W 2007/4/10, tedd [EMAIL PROTECTED]: At 8:10 PM -0400 4/9/07, Robert Cummings wrote: On Mon, 2007-04-09 at 17:14 -0400, tedd wrote: At 4:39 PM -0400 4/9/07, Robert Cummings wrote: On Mon, 2007-04-09 at 22:27 +0200, Tijnema ! wrote: This is exactly what tedd did in his last arrow example. He edited the header of the GIF image, and so that would result in different MD5. Finding this part and skipping it in the MD5 check would do the job. :) Yep, that's an obvious solution since it's the same way virus signatures are matched. The entire image needs some kind of permutation. Passing a couple of curved ripples across the image as a transformation, and in different directions should suffice to obfuscate the image signature without obfuscating the image itself :) Similarly watermarking the image using fractal patterns should also provide good noise. Cheers, Rob. Rob: It doesn't need to be complicated, just random placed pixels on the image from a selection of colors would provide millions of permutations. No, you're wrong. Read the part about I mentioned about virus signatures. A small portion of the whole can be used as an identifier where that portion is unique to the overall entity. For instance, I can throw a tub of tar over you, then a tub of feathers ;) ;) and if one of your fingers doesn't get covered, I can still identify your chicken ass ;) Cheers, Rob. Rob: Your use of metaphor is quite colorful, but if you if change a single pixel in an image, then you change the MD5 signature -- that is what I was talking about -- and that is not wrong. Plus, if you: [A] Passing a couple of curved ripples across the image as a transformation, and in different directions should suffice to obfuscate the image signature without obfuscating the image itself or [B] Similarly watermarking the image using fractal patterns should also provide good noise. You would still leave at least one pixel the same as it was before so your chicken ass would still be exposed, right? Or does your ripple/watermark application alter every pixel by changing its alpha channel or something? And if so, then why is it that you are required to change every pixel? I am sure that there are images that have at least one pixel in common, so I don't see the point you're trying to make -- please explain. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Authentication
Lets say i have a login system. This system authenticates the user via mysql, when the user is authenticated, i set a session variable to let the system know the user is authenticated. ie. $_SESSION[authenticated] = true; Lets also say i know that's how the system works, that a session variable within my browser is set to true. Could i do this if i knew all this info and authenticate myself by setting the variable from the client side? If it is possible, what can i do to prevent this or increase security?
Re: [PHP] Session Authentication
Thanks, yes my knowledge of sessions was a little vague. 2007/4/9, Stut [EMAIL PROTECTED]: Ólafur Waage wrote: Lets say i have a login system. This system authenticates the user via mysql, when the user is authenticated, i set a session variable to let the system know the user is authenticated. ie. $_SESSION[authenticated] = true; Lets also say i know that's how the system works, that a session variable within my browser is set to true. Could i do this if i knew all this info and authenticate myself by setting the variable from the client side? If it is possible, what can i do to prevent this or increase security? No. You're teminology indicates a major lack of understanding regarding how sessions work. Session variables are not within [your] browser. The only thing stored in the browser (usually as a cookie) is the session ID. The contents of the session are stored on the server. So, given that, the answer to your question is... not unless your code is exploitable to allow the user to arbitratily set session variables. -Stut
Re: [PHP] Session Authentication
Thanks for the replies guys, became a pretty big thread. The actual code is just a select statement from the user table using sprintf and mysql_real_escape_string for the username and password. I count how many row's the select statement returns, if its not zero then i authenticate by setting a session variable to true (the one in my 1st post) Thanks again. 2007/4/9, Martin Marques martin@bugs.unl.edu.ar: Stut escribió: As with most things these days it probably breaches the DMCA. But frankly speaking, if doing that works then the developers of the application, and by extension the company, deserve everything they get. DMCA is a real piece of crap. -- select 'mmarques' || '@' || 'unl.edu.ar' AS email; - Martín Marqués | Programador, DBA Centro de Telemática| Administrador Universidad Nacional del Litoral -
Re: [PHP] name of the variable
I found this on the zend forums. Hope it helps. function Dump($var) { if (key_exists($var, $GLOBALS)) { echo pre$$var:\n; var_dump($GLOBALS[$var]); echo \n/pre\n; } else echo span class='error'No variables named em$$var/em!/span\n; } - Ólafur W 2007/3/9, Cefull Lo [EMAIL PROTECTED]: Hi everyone, Is there any function that return the name of the variable?? i.e. $foo='abc'; $bar=somefunc($foo); // $bar='foo' here Thanks -- -BEGIN GEEK CODE BLOCK- Version: 3.1 GSC d- s:++ a- C++ UL/B+++$ !P L+++ E--- W+ N o-- K? w++ O? M- V- PS PE++(-) Y+ PGP++@ t 5 X R$ tv- b+++ DI++ D++ G++@ e h*--- r-- z? -END GEEK CODE BLOCK--
Re: [PHP] Re: [an attempt to inject a bit of humor back into the situation] Re: [PHP] Recomended host
Jochem Maas wrote: Robert Cummings wrote: On Tue, 2006-12-19 at 16:01 -0500, [EMAIL PROTECTED] wrote: Merry Christmas Everyone! and I mean everyone (even Eight-of-Nine ;-) INSENSITIVE CLOD!!! I practice animism! your catching on ... about the insensitivity that is ;-) Rob. I can see the hollyday spirit just flowing through. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] For those who havent seen this
http://dbug.ospinto.com/ Turns arrays into a table for visual debugging. I've been using this for a few things here and there, it itsnt so often here that we link nifty little gadgets so here is one. - Olafur -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] causing HTTP error status
Nic wrote: Richard Lynch [EMAIL PROTECTED] writes: On Fri, May 5, 2006 5:01 am, Nic wrote: Hi Rabin Rabin Vincent [EMAIL PROTECTED] writes: On 5/5/06, Nic [EMAIL PROTECTED] wrote: But /mydir/some.php doing: header(HTTP/1.1 404 Rubbish!!!) _never_ causes the error document to be picked up. That's right. Apache's not going to take action based mod_perl and mod_python can both do this. As can CGIs. So I'll be really surprised if this isn't possible with PHP. It's strange because the docs say this can be done; I can't find an example that is purported to work outside of the docs though. Where do the docs say this? I can't find it in http://php.net/header. The url is: http://www.php.net/manual/en/function.header.php The relevant bit is where it says: There are two special-case header calls. The first is a header that starts with the string HTTP/ (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code. ?php header(HTTP/1.0 404 Not Found); ? I gotta go with Nic on this... Either I'm being really obtuse, or it just plain don't work right. Consider this minimalist example: http://l-i-e.com/404/test.php http://l-i-e.com/404/index.htm The 404 header is being completely ignored, afaict I tried adding exit; right after the header, and my browser just goes way long time and then times out. I tried HTTP/1.1 and that made no difference. I'd suggest checking http://bugs.php.net and filing a bug report if it's not a known issue... Unless somebody can point out something wrong in our logic. I think this got cleared up. Setting the response code (to 404 or 500) is available so that when a PHP _is_ an error page it can set the code correctly; eg: apache config: Directory /someplace ErrorDocument 404 /somplace/error.php /Directory /someplace/error.php ?php header(HTTP/1.1 404 Not Found); echo htmlbodyh1Sorry, the page you wanted wasn't found./h1/body/html; ? But I'm still schocked that PHP can't cause the Apache error page to be served. It seems such a basic thing and all the other web environments I know (even apache + servlets) allow this. Ah well. Nic Wild Guess here but isnt it because apache defines within its config the error pages before it defines .php as a usable proccess? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What editor do you use?
Nicolas Verhaeghe wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 1:54 PM To: Nicolas Verhaeghe Cc: 'Jay Blanchard'; 'PHP-General' Subject: RE: [PHP] What editor do you use? On Thu, 2006-05-04 at 16:39, Nicolas Verhaeghe wrote: [snip] I am currently looking for a good PHP editor for Windows. I know, the question must have been asked so many times, but I thought I could ask it again now that a few editors have evolved, others have appeared. [/snip] Eclipse. You could also STFA Joe! It's better than ever now. It even has syntax highlighting. FWIW, anything that autocompletes is for wimps. --- Well, I like the autocomplete feature, allows me to work faster. How about that? More time to go do what you like to do better. Direct memory access beats secondary helper memory every time. Autocomplete is an incentive to have a lazy mind. When your brain has a larger overall picture of available resources, it can formulate better strategies than when it only has part of the picture. Additionally, when you are typing out a flow of code, anything that interrupts that flow slows you down... ala autocomplete. --- Let's agree to disagree. When you have the experience, autocomplete does save you a lot of time. I realized I was working a lot faster with autocomplete on. Meaning more time to concentrate on improving the apps or looking for new clients. Easy as that. Ive been using PSPad for a while now, quite fond of it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sanity checker?
How would you define ie. a sane case or elseif statment without knowing more about the code, how it is executed or included files that effect the file. File that the checker possibly doesnt have access to. Björn Bartels wrote: Hi, there... agreeing with other posts, i'd say this could easily be done by quality management. don't know if there are any recommended international standards [ www.iso.org ] , but i think this would be a good start. worst case, you will have to define those rules all by yourself. as far as i know there are some university projects trying to build some piece of software to do that... bb Well, Since my original post failed to generate reasonable feedback, not even a successful kick at people's funny bone or a flame, let me restate my question with a story. Php reduces the barrier to web development quite a bit, such that less technical people can jump in really easily. In one side, this is great because it helps the adoption of the language, and more people get to create their dynamic websites. The flip to it is that many non-technical people write low quality php code, which in turn make their code vulnerable and not scalable. I envision a tool that would audit your php code, and tell you if your code is good or not, if it has scaling issues, etc, etc. Basically it tells if your php code is sane or not. I have a few ideas of how a sane php code should look like, but I certainly don't know everything. That's the reasons behind my earlier questions. Basically I am looking for things to check in codes that pose high running time risks. Or even simpler, I am looking for best practices, advices, guidelines that you would give to new php developers. So here are the questions again: Does anyone know of any tools to test the sanity of your php code? If you were to check the sanity of your code, what would you look for? Any pointers for other resources? Thank you Ezra On Wed, 2006-05-03 at 10:22 +0300, Robin Vickery wrote: On 03/05/06, Ezra Nugroho [EMAIL PROTECTED] wrote: PHP experts everywhere, Does anyone know of any tools to test the sanity of your php code? If you were to check the sanity of your code, what would you look for? Hidden messages encoded in the whitespace. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Björn Bartels -Development/IT-Services- -- dbusiness.de gmbh digital business printing gmbh Greifswalder Str. 152 D-10409 Berlin Fon: [0.30] 4.21.19.95 Fax: [0.30] 4.21.19.74 www.dbusiness.de [EMAIL PROTECTED] ftp://dbusiness.dyndns.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing, starting out.
Mattias Thorslund wrote: [EMAIL PROTECTED] wrote: Hello, 1st msg here so im excited what results i will get :) Im a novice with php parsing and have been able to help myself quite well with what ive needed with xml_parse_into_struct and then echoing the fixed variable names but now im dealing with an xml document that is 1st quite large and 2nd changing gradually over time with either added data or changed information. (But not in large numbers) http://www.camelotherald.com/xml/spells-si.xml It is a spell listing for an online mmorpg. It has a spell_list that captures all other tags and a spell_line for each spell line. Within each spell line is a spell which has the detailed info for each spell with in the spell_line I could parse this by echoing the fixed variables but due to its size and the changes done over time its just to much work. This is why i come to a stop. Ive read some guides and tried some example code that should help me through this. What i hoped to get is an example with the xml i provided so i could work with it to complete the project. The example could look something like this: Header with the selected spell_line name ie. Calefaction and below that the spell info in some dummy table format. Then the next spell_line which is Path of Earth then with the spell info in some dummy table setup. Thanks for reading and i hope someone can show me the light of a real xml parse. The comments on the Manual page [http://www.php.net/manual/en/ref.xml.php] contain an example class that parses an XML file into an associative array. I'm using something similar myself, as it seems to be a pretty straightforward way to get an easy-to-use structure in PHP 4 without dom_xml, which isn't always available. Mattias I have been trying as i said above with the php.net examples, the sitepoint examples (which have been great to give me some view of what i need and how it functions basicly) but with no luck. I can make it easy with fixed value but the dynamic part of it is still outside my reach for now. Thanks for the examples Matt and Richard - olafurw -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php