Re: [PHP] Serving an image
What is the diference between using imagecreatefrompng() and readfile()? Any performance improvement? If you don't do any image minipulation, I would recommend readfile indeed. The differences being that imagecreatefrompng load the image into memory, ready to change it (overlay, rotate, crop, colours, .. anything), and readfile just sends whatever file you point it to back to the browser (or other output). Then again, if you all you're doing is sending an image to the browser; then why not do a redirect - or simply refer to the image directly? Wouter
Re: [PHP] Class not functioning
Allen, Before you go with my static-approach, please do consider Shawn's registry pattern suggestion. That's pretty sweet too ;-). A little response to your long text, before I help you fix the bug. A static property is basically the same as a regular property on an object. Only difference is that they are not reset when the class is instantiated into an object. They are just there. Now, about your bug. The syntax for referencing a static property is a bit weird - which has to do with the existence of class constants, which might have set you off. Notifier::notifyQueue would reference a class constant. The [] syntax is not valid here, since a constant is - you got it: constant. And thus cannot be changed. Notifier::$notifyQ[] = 'div ... /div'; references the static property. But... since notifyQ is a proptected static property, it is very unlikealy that you'll ever actually write Notifier::$notifyQ. You add to this queue from within the class itself, so therefore self::$notifyQ is a lot better. Does that answer your question? Btw; Shawn; Assuming that your Registry class holds objects, there is no need have the ampersand in front of the get method or $object argument. Objects are *always* references. And you might want to look at the __get, __set and __isset magic. Wouter 2009/12/16 Allen McCabe allenmcc...@gmail.com Wouter, Implementing your static idea was pretty easy, I was already referencing Notifier with the :: operator in my other methods, however I am running into trouble assigning new values to the static array. I am getting a syntax error, unexpected '[' on this line of my Notifier class: Notifier::notifyQ[] = 'div class='.$message; . . . Any ideas why this is causing an error? (note: I did try using $this-Notifier, and it said I cannot do what-not to a non-object, can't remember the exact message at the moment) On Tue, Dec 15, 2009 at 2:30 PM, Wouter van Vliet / Interpotential pub...@interpotential.com wrote: Allen, The short answer (but don't follow this): ?php class Meetgreet { public function deleteSingle($id, $number) { // do something global $Notify; $Notify-addToQ( .. ); } } ? The long(er) answer: I assume your Notifier object functions as singleton? Ie; accross your entire application, there is only one instance of that class? Why not go-static? That is, to my experience, the sweetest way to make something globally accessible - without making something global. Like so ?php class Notifier { protected static $queue = Array(); // make sure it can't be instantiated private constructer __construct() { } public static function addToQ( $arg, $anotherArg) { self::$queue[] = $arg.' - '.$anotherArg; } } // and then from within any method anywhere, call Notifier::addToQ('foo', 'bar'); ? Does that work for you? Regards, Wouter (ps. call me a purist, but a function defined in a class is no longer called a function, but a *method*) 2009/12/15 Allen McCabe allenmcc...@gmail.com Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... ?php $Notify-printQ() ? On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri nirmalyalah...@yahoo.comwrote: --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-general@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other
[PHP] Debian Lenny: Which 5.3 package should I use?
Hi Guys Gals, I've been playing around with PHP 5.3 for a while now on development servers and servers solely used for start-ups and lower-profile apps. But now I'm about to upgrade the servers for a high profile/high traffic website and with this upgrade I'd also like to make the switch from 5.2 to 5.3. But - which package should I choose? I want to rely on community tested builds, so compiling myself is out of the question. The server will run on Debian Lenny. The Two and a Half options I've been able to find are: DotDeb: http://www.dotdeb.org/2009/12/06/the-php-5-3-1-packages-have-been-updated/ Debian Experimental: http://packages.debian.org/source/experimental/php5 ~raaa Launchpad: https://launchpad.net/~raaa/+archive/ppa Are there any others? Which is the best when it comes to: - Security? - Stability? - Ease of upgrade to Debian Squeeze later next year? Thanks in advance for any help you're able to offer! Regards, Wouter -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] strip tags but preserve title attributes
I've had quite some luck using the html2text class by Jon Abernathy http://www.chuggnutt.com/html2text.php It's targetted to php 4, and rather old code - but it does the job for me. Where the 'job for me' is converting html to text for when I'm sending out emails in HTML format and want to offer the proper plain text alternative. To be honest, I haven't checked how it handles title/alt attributes on images - but I'm confident that it does it nicely, and if it doesn't that you can add it yourself. And if that doesn't suit your needs - you might want to take a look at this: http://sourceforge.net/projects/simplehtmldom/ Regards, Wouter 2009/12/15 Andrew Ballard aball...@gmail.com On Mon, Dec 14, 2009 at 6:43 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I'm looking for a way to strip HTML tags out of some text content (sourced from a web page) to leave just the text which I'll be running some basic analysis on. The thing is, I want to preserve text that is in alt and title attributes. I can't use any DOM functions, as I can't guarantee that the content will be valid XHTML, although it should be valid HTML. I'm happy doing this with string functions and regular expressions, but I was wondering if something for this already existed? The server I plan on putting this on does not have access to the shell (although it is a Linux server) so I won't be able to have Lynx or Elinks parse the content for me either :( Thanks, Ash http://www.ashleysheridan.co.uk Are you sure you can't use DOM? It has a function specifically for parsing HTML that does not have to be well-formed to load. http://www.php.net/manual/en/domdocument.loadhtml.php If that doesn't work, you might look at Zend_Filter_StripTags in ZF. I don't know if it will do exactly what you're after, but it seems to be more flexible than the strip_tags function built into PHP. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Parsing JSON; back-slash problem
If you don't have access to do this, look at stripslashes() And if you absolutely want to be on the safe side - check* if the magic_quotes option is enabled - if so; do stripslashes. If not - then obviously don't. * http://www.php.net/manual/en/function.get-magic-quotes-gpc.php -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Class not functioning
Allen, The short answer (but don't follow this): ?php class Meetgreet { public function deleteSingle($id, $number) { // do something global $Notify; $Notify-addToQ( .. ); } } ? The long(er) answer: I assume your Notifier object functions as singleton? Ie; accross your entire application, there is only one instance of that class? Why not go-static? That is, to my experience, the sweetest way to make something globally accessible - without making something global. Like so ?php class Notifier { protected static $queue = Array(); // make sure it can't be instantiated private constructer __construct() { } public static function addToQ( $arg, $anotherArg) { self::$queue[] = $arg.' - '.$anotherArg; } } // and then from within any method anywhere, call Notifier::addToQ('foo', 'bar'); ? Does that work for you? Regards, Wouter (ps. call me a purist, but a function defined in a class is no longer called a function, but a *method*) 2009/12/15 Allen McCabe allenmcc...@gmail.com Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... ?php $Notify-printQ() ? On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri nirmalyalah...@yahoo.comwrote: --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-general@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other classes that should be adding to the $q array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The Database!', 'error');) However, when I try to get my webpage to display them using: $Notify-printQ(); it does not seem to want to loop through this array (and print the messages). I am getting NO error message, in fact everything 'looks' fine, I'm just not seeing the appropriate message. Any help would be appreicated! Allen, You have made a small typing mistake in function printQ() where you would like to checked the array for its existence. By mistake you have wrote if (isset($q)). But your array variable is not an freely accessible array,the array is embedded into an object. So, you have to write the like if (isset($this-q)). Another point, you can't add a message into the array by calling the member function addtoQ() using scope resolution operator ::. If you really want to add message into the array, you have to call the member function from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error Updating The Database!', 'error');). --- নির্মাল্য লাহিড়ী [Nirmalya Lahiri] +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536] -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Security Issue
Karl, Some simple checks on $contpath could solve your problem. Make sure that: - it doesn't start with a / - doesn't contain /../ - it doesn't contain a double slash //, or make sure the URL Fopen wrapper is disabled: http://nl3.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen Usually $contpath = str_replace('/', '', $contpath); takes care of everything. On 04/09/07, Karl-Heinz Schulz [EMAIL PROTECTED] wrote: It was able to call up external includes using the below code which resulted that the server was used to send out spam. How can I protect the code? TIA ?php session_start(); //--- // index.php //--- include(../inc/const.php); include(../inc/mysql.php); $menu=2; include(../inc/static.php); //include(../inc/prolog.php); $base = getenv(SERVER_NAME).getenv(SCRIPT_NAME); //$menu = $HTTP_GET_VARS['menu']; $submenu_list = $HTTP_GET_VARS['submenu_list']; $contfile = $HTTP_GET_VARS['contfile']; $id = $HTTP_GET_VARS['id']; $stk = $HTTP_GET_VARS['stk']; $contpath = $HTTP_GET_VARS['contpath']; if ($contpath==) { $contpath=./; } ? html head titleNeuer Wissenschaftlicher Verlag - ?php print $typ_subnav[$menu]?/title script language=javascript SRC=../js/rollover.js/script link rel=stylesheet href=../css/bor.css /head body bgcolor=#ff topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 link=#00 vlink=#00 alink=#00 table height=100% width=100% topmargin=0 cellspacing=0 cellpadding=0 border=0 tr valign=top height=105 td colspan=3 valign=top ? include(../inc/prolog.php);? /td /tr tr valign=top height=30 td valign=top height=30 background=../../img_pool/bg_left_right.gif? include(../inc/leftmenu.php);?/td td width=100%nbsp;/td !-- hier ist die rechte spalte mit dem background -- !-- td height=30 background=../../img_pool/bg_left_right.gifimg src=../img/trans.gif width=180 height=1/td -- /tr tr valign=top td valign=top background=../../img_pool/bg_left_right.gif?php nav_menupic($menu);? ?php // // Subnavigation // include(../inc/subnav.php); ? /td !-- END LEFT-NAV -- td valign=top ?php include($contpath . /content.php);? !-- END CONTENT -- /td ?//php include(../inc/epilog.php); ? /tr /table /body /html -- Interpotential.com Phone: +31615397471
Re: [PHP] Reload page after form submit
On 30/08/2007, Per Jessen [EMAIL PROTECTED] wrote: Wagner Garcia Campagner wrote: Hello, I'm building a web page just like a blog... Where the user input some information... (name, website and comment) This information is stored in a file... And then the page displays it... When the user access the page the first time, the information is displayed correct... After the user submit the information, the page become outdated... without this last information the user submitted... Is there a way to tell PHP to reload the page after the user submit the information, so the page is always updated?? After you've processed the POST request, you finish with something like this: header(HTTP/1.0 303 See other); header(Location: #); exit; It needs a little bit more than that. The script to which the form has been submitted knows about the $_POST data, once you Location: to another page that gets forgotten. Just add a line like $_SESSION['lastFormSubmit'] = $_POST just before the first header() call and you're fine. -- Interpotential.com Phone: +31615397471
Re: [PHP] Database includes
On 27/08/07, Stut [EMAIL PROTECTED] wrote: I use a slightly different approach to prevent the need to mess about with files when moving to production. At the end on config.php I have this... if (file_exists('config_dev.php')) require 'config_dev.php'; I've got my own variation on this, came to use it to prevent overwriting config files for stage/dev/live or other versions of a site. I've got a general purpose constants file, which defines a lot of constants which are generally used a lot in my applications (file rootdir, DAY, HOUR, database passwords, some regexes, these things). Instead of just defining them there, I define them using a simple conditional define function (if (!defined($constantName) define($constantName, $value)). On top of my constants.inc.php (as I chose to call it) I use the following: if (isset($_SERVER['SERVER_NAME'])) { $_config_file = dirname(__FILE__).'/../eg/'.$_SERVER['SERVER_NAME'].'.inc.php'; @include($_config_file); } The included hostname specific config file would then define some constants, and because they are already defined the default values from constants.inc.php don't get set anymore. Hope this is of help to anybody, it has certainly relaxed my deployment process.. Wouter In config_dev.php I override anything defined in config.php that needs to be different on the current server. The config_dev.php file is *not* in source control so it doesn't exist in production but each development and test environment has a version that modifies the production environment. There is a hit involved in the call to file_exists, but PHP caches it so the effect is minimal. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] help with session
I would go for: if (isset($_REQUEST['gender'])) $_SESSION['registrationGender'] = $_REQUEST['gender']; print isset($_SESSION['registrationGender']) ? You are registered as gender: .$_SESSION['registrationGender'] : Your gender is unknown; And make no assumptions about a gender when you don't know any ;-) On 26/08/07, Jason Cartledge [EMAIL PROTECTED] wrote: Hi, this is my first post to this newsgroup. Does this code look ok or is there a more clean way of doing this? I am learning. Thank you for reading. Jason if ( !empty($_REQUEST['gender']) ) { $registrationGender=$_REQUEST['gender']; } else { if (session_is_registered('registrationGender')) { $registrationGender=$_SESSION['registrationGender']; print you are preregistered as a $registrationGender; } else { print your gender is unknown, youare assumed to be a male; $registrationGender=male; } } $_SESSION['registrationGender']=$registrationGender; _ 100's of Music vouchers to be won with MSN Music https://www.musicmashup.co.uk/index.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Creating a table with merged cells
You may want to look into the rowspan and colspan attributes of td G'luck! On 23/08/07, Phpmanni [EMAIL PROTECTED] wrote: Hi I need to represent a sort of map. The map is a rectangular table of size X in widht and Y in height, so that I have X*Y square cells. I need to record in a database some infos for each cell. This is easy, I thought to use a record that is something like (X,Y,MyData), so with two nested loops I can create the HTML table with data in it. The problem is that I need to join adjacent cells, so that I can obtain bigger cells made of base little square cells. So, starting from a table like this (see with fixed size font) +-+-+-+-+-+-+-+-+-+ | | | | | | | | | | +-+-+-+-+-+-+-+-+-+ | | | | | | | | | | +-+-+-+-+-+-+-+-+-+ | | | | | | | | | | +-+-+-+-+-+-+-+-+-+ I must find a way to store in the database a table like this +-+-+-+-+-+-+-+-+-+ | 2 | | | |4 cells| +-+-+-+-+-+-+-+-+-+ | |BIGBIGB| | | | | +-+BIGBIGB+-+-+-+-+ | |BIGBIGB| | | | | +-+-+-+-+-+-+-+-+-+ I thougt to use a record like (X,Y,XWIDTH,YHEIGHT,DATA), but I cannot imagine the way to create the resulting HTML table. Using graphics will be a lot easyer, but I must insert combos and checkboxes into the cells, so I must use html... Any ideas? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Out of Memory error
I've got a followup question to this. Whenever you're doing something that takes too much memory, having a file uploaded that's bigger than max upload size (actually, not sure if that applies but I think it does) or when your script is taking too long to execute it just dies with a very unfriendly error. Is there any way to catch these errors, stop the script in some other way just before it ends so we can provide some reasonable feedback to the user? On 23/08/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-08-24 at 01:21 +1000, Naz Gassiep wrote: I'm getting out of memory errors in my image handling script, I *think* its because I'm handling images that are too large to fit in memory, but I thought I'd check before just upping the setting to 32mb. It is currently set to 16mb and I am working with a 2048x1536 image. Is it possible that the image is what is causing the scrip to OOM? Very likely. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Override parent class constants
I hate to disappoint you, but there's no real alternative. Same annoyance with get_class() and __CLASS__ always giving you the class in which the call is defined instead of the class which is actually being called when dealing with static methods. What you could do is define a protected static method in every subclass, something like getConstant(), which always gives you the constant from the correct class. I can't come up with a better solution than that. And I've been trying to find one since the first version of php5 ;-) On 22/08/07, James Ausmus [EMAIL PROTECTED] wrote: Hello - I'm trying to find a (sane) way to, in an extended class, override the parent class's constants, something like the following (which doesn't actually work): class baseClass { const myBaseVar = base value!; protected $myVar; function __construct() { $this-myVar = self::myBaseVar; echo $this-myVar; } } class extClass { const myBaseVar = overriden value!; } And, when instanciated, should do the following: $bc = new baseClass(); Output: base value! $ec = new extClass(); Output: overridden value! Any way to do that? There's a hacky way to do it, which would be to change the __contruct() function to the following: function __construct() { $this-myVar = eval(echo . get_class($this) . ::myBaseVar;); echo $this-myVar; } but that is really, really ugly - I don't want to have to change all instances of myVar re-initialization in my baseClass methods into eval statements... Any thoughts? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Re: Table shows even when if () is false
On 22/08/07, M. Sokolewicz [EMAIL PROTECTED] wrote: I'm pretty sure if(!empty($result_deferred_comments)) { does something else than you think it does. $result_deferred_comments = mssql_query($deferred_comments) or die(mssql_error()); if it fetches any rows it will return a RESOURCE (yes, a resource which is NEVER empty()), if it has 0 rows, it will return TRUE(yes! Again non-empty), if it errors, it will return false (yes, empty). Instead, use if(false !== $result_deferred_comments true !== $result_deferred_comments){ Minor addition; you actually want to know if the result value is a resource or a boolean. So, why not use 'is_resource' ? Apart from having shorter lines of code I usually prefer checking for something that's true, but maybe that's a personal thing ;-) Dan Shirah wrote: From my understanding, if $result_deferred_comments is empty, than none of the code below the if should be executed, correct? The actualy rows/columns that would contain the data do not appear, but I am still seeing the DEFERRED PAYMENT REQUEST COMMENTS table. Is the only way to block out EVERYTHING from being displayed if $result_deferred_comments is empty to use around all of the HTML and not exit out of the PHP tags? Or am I doing something else wrong? Or, is it a problem with (!empty())? Since the value is an array, will it never be parsed as empty even if there is no data retrieved? Below is my code: ?php $credit_card_id = $_GET['credit_card_id']; $deferred_comments= SELECT * FROM comments WHERE credit_card_id = '$credit_card_id' AND request_type = 'D'; $result_deferred_comments = mssql_query($deferred_comments) or die(mssql_error()); if(!empty($result_deferred_comments)) { ? table width=700 border=1 align=center tr td bgcolor=#FF9900 div align=centerstrongDEFERRED PAYMENT REQUEST COMMENTS/strong/div/td /tr /table table width=700 border=0 align=center ?php while ($row_deferred_comments = mssql_fetch_array($result_deferred_comments)) { $id_deferred_comment = $row_deferred_comments['request_id']; $dateTime_deferred = $row_deferred_comments['comment_date']; $deferred_comments = $row_deferred_comments['comments']; $deferred_wrap_comments = wordwrap($deferred_comments, 60, br /\n); ? tr td width='108' height='13' align='center' bgcolor=#FFD9C6 class='tblcell' div align='center'?php echo $id_deferred_comment ?/div/td td width='148' height='13' align='center' bgcolor=#FFD9C6 class='tblcell' div align='center'?php echo $dateTime_deferred ?/div/td td width='444' height='13' align='center' bgcolor=#FFD9C6 class='tblcell' div align='left'?php echo $deferred_wrap_comments; ?/div/td /tr ?php } ? /table ?php } ? Thanks, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
On 20/08/07, tedd [EMAIL PROTECTED] wrote: At 10:40 PM +0200 8/19/07, Wouter van Vliet / Interpotential wrote: What you're proposing, is to actually display some content on another page then were the content is originally intended? I'm sorry, but I would consider that 'bad practice'. To me, it makes perfect sense that you don't want to leave the user on the page where login was originally handled. For various reasons. One very obvious would be the 'refresh thing', where your browser asks the user if they want to send the form again. Quite annoying. Then, what about bookmarks? ... No, what I had proposed was an alternate method to accomplish what you said you wanted. But, it appears that my efforts and the demo did not receive sufficient attention for you to understand what wass being presented. Instead, you tell me that what I've shown you is bad practice -- interesting. First of all - I didn't ask the initial question ;-). Other than that, I think our philosophies our basically the same. But when you say that you are redirecting the user to another page, while you are actually including a php script - that's not my understanding of redirecting. You said that you wanted to remove login from the browser history, which is screwing around with the user's browser and is clearly bad practice. Generally yes, removing a page from the browser's history would be considered bad practice. However, we are not really talking about a page here. What I understood from the initial question is as follows: - http://www.site.com/ contains some login form, action of that form is (for example) /login.php - The user is sent to /login.php where the login is checked - From there, the user either gets to a content page where it would typically show welcome {user} or something, or back to the index page when login failed - As you see, login.php is not really a page but more of a 'pseudo page' and therefore I cannot see any reason not to send a proper 303 header. see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html My method simply stops the user from visiting the same page more than once during a session and leaves their browser data alone -- nothing bad practice about that! AFTER my demo runs, if you repeatedly refresh the page you are directed to, then certainly that would become annoying. But that wasn't the intent, nor part of the demo, which you clearly didn't read and obviously didn't understand. As far as bookmarking the page, but of course you can bookmark the page! Did you even try? Oh well, so much for trying to help someone understand sessions. As my mother often said No good deed ever goes unpunished. I've got another one, There is no selfless good deed. If you had simply said, I don't understand, please explain; or asked a question or two; or said thanks, but no thanks, I'm going to do it another way, then that would have been fine. But to say that the demo I prepared for you exhibited bad practice, especially when you are absolutely friggen clueless as to what it is doing, is a bit too much -- I'll be sure to pass over your post in the future. I don't think there wasn't anybody who didn't appriciate your suggestion. Only thing I was trying to do was chip in my two cents. Again, I wasn't the one who originally asked the question and I certainly am not friggen clueless. I just came to think about what the teacher at my Flex course from a couple of months ago said about good and bad practice. He said there is none. If your solution works good for you, that's your good practice. And if mine doesn't work for you, it's your bad practice - while it is still my good practice. Something however I am trying to fight against, if you let me put it like that - is people approaching scripts as if they are pages. When you are including a script that is usually called as a page into another script you should be very aware for any clashes between variables. Another reason why it may be easier to just put in a Location: header and call your script as it was originally intended. Wouter tedd --- I would definately go for the Location: header solution! On 19/08/07, tedd [EMAIL PROTECTED] wrote: At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
What you're proposing, is to actually display some content on another page then were the content is originally intended? I'm sorry, but I would consider that 'bad practice'. To me, it makes perfect sense that you don't want to leave the user on the page where login was originally handled. For various reasons. One very obvious would be the 'refresh thing', where your browser asks the user if they want to send the form again. Quite annoying. Then, what about bookmarks? ... I would definately go for the Location: header solution! On 19/08/07, tedd [EMAIL PROTECTED] wrote: At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon returning, the session variable is checked and if it is not null, then the user is redirected to another page like so: if($visit != null) { ob_clean(); include('a.php'); exit(0); } Very simple. 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 -- Interpotential.com Phone: +31615397471
Re: [PHP] Cookies and sent headers
You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your ?php opening. To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is: php_flag output_buffering On Good luck! On 18/08/07, Kelvin Park [EMAIL PROTECTED] wrote: Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Capturing shell command output.
You may want to look into shell_exec, which executes a command and returns the output. If you're accepting arguments from user input, don't forget proper use of escapeshellcmd and escapeshellarg ;-). Something else that might cause your commands from failing, is that the utilities are not inside apache's PATH - trying to call them by there absolute filename can help out. Have you inspected your error_log? There often tends to be a lot of useful stuff in there. Good luck! Wouter On 18/08/07, shiplu [EMAIL PROTECTED] wrote: HI, I am working on a PHP project that interacts with command line utilities. My php is running by apache. Means I am not running any php CLI. here is the function that I am using for capturing command output. function run_command($comamnd){ $ret=`$command 1 COMMAND.OUT 21`; $contents=get_file_contents(COMMAND.OUT); return $contents; } The function does not work. If I use any shell command like ls, cat, echo, set. it works. But If I use any utility like, mpg321, cd-info. It does not work. It outputs a blank string. I used system(), passthru() with both 21 and 21. But no out put. All the time, its blank. Even I used a shell script run.sh run.sh contents: = #!/bin/sh sh COMMAND 1 COMMAND.OUT 21 cat COMMAND.OUT echo 0 COMMAND = I called this script by this function function run_command($command){ $h=fopen(COMMAND,w); fwrite($h,$command); fclose($h); ob_start(); passthru(./run.sh); $ret = ob_get_contents(); ob_end_clean(); return $ret; } and by this. function run_command($command){ $h=fopen(COMMAND,w); fwrite($h,$command); fclose($h); return system(./run.sh); } Please help me. or show me some way. -- shout at http://shiplu.awardspace.com/ Available for Hire/Contract/Full Time -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Photo upload framework/library for PHP
I often use MCImageManager, by moxiecode: http://tinymce.moxiecode.com/paypal/item_imagemanager.php. Integrates well into tinyMCE, but can be used without that as well. I'm not entirely sure it's what you are looking for, but I think it very well may be. And if it doesn't help you now, it may do so at some other point ;-) On 18/08/07, Steve Finkelstein [EMAIL PROTECTED] wrote: Hi all, Can anyone suggest a photo upload/framework type library I can incorporate seamlessly into a PHP project I'm working on? I'd like for users to have an elegant UI to upload photos of their vehicles into my application. Mutli-file and progress bars would be a plus. I'm looking to integrate this code using the Code Igniter framework. Thanks all for any suggestions. - sf -- Interpotential.com Phone: +31615397471
Re: [PHP] cant get if logic correct..
is_integer probably wouldn't work, since you're dealing with strings here. Your best friend here would probably be 'is_numeric' which would return true on both the string '1' as the integer 1 true. As well as 1.1 and '1.1'. The only one solution I could think if would be: preg_match('/^\d+$/', $stnr); -- Ain't it always the small things like this that consume too much time? On 17/08/07, Sanjeev N [EMAIL PROTECTED] wrote: Why don't you try to check for if it is integer. You will get the function to check the variable (is_integer not sure) in manual. Warm Regards, Sanjeev http://www.sanchanworld.com http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Gregory Machin [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 15, 2007 7:01 PM To: php-general@lists.php.net Subject: [PHP] cant get if logic correct.. Hi i have a piece of code that gets info from a comma delimited file, then gets each value that is to be insterted into the database The variabls must only contain numbers and must not be null .. but the logic i have is iether not working or there are some hidden characters creeping in because it is processing the data ... how can i do this better ? for($i=2;$i$arrsize;$i++){ $parts=explode(,,$lines[$i]); $stnr=$parts[0]; $subj=$parts[1]; $mark=$parts[4]; if (($stnr) and ($subj) and ($mark)){ //do alot of something lol } } -- Gregory Machin -- 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 -- Interpotential.com Phone: +31615397471