Re: [PHP] Video question
John Messam wrote: How do I display video on my php page and prevent the video from being downloaded. You'll need to be more specific than this. What video format are you using? The only way to stop it from being downloaded is by streaming the video, and even then it is possible if you have the right software. You won't be able to use php to do anything to help you here, it's converting the video file to a streaming format... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ob_start("ob_gzhandler") and error handling functions
Hi, I include a php file at the beginning of every web page in this site. This include file has an error handling function and starts output buffering... // Start of Error Handler error_reporting(E_ALL ^ E_NOTICE); ini_set('log_errors','1'); function ErrHandler($err,$err_string='',$err_file,$err_line) { // Do error logging thang ob_end_clean();// Clear buffer include('/path/incs/errors/errors.inc');// Output friendly error page exit(); } set_error_handler('ErrHandler'); // End of Error Handler It works great and the error handler kicks in if there is an error on the page and outputs a friendly page instead. I really wanted to gzip the pages by using ob_start("ob_gzhandler") but it doesn't work. I think it is because of the error handler function trying to clear the buffer (see the line ob_end_clean() which I assume becomes ob_end_clean("ob_gzhandler") ). It says on the php functions page- *ob_start()* may not be called from a callback function. If you call them from callback function, the behavior is undefined. If you would like to delete the contents of a buffer, return "" (a null string) from callback function. As I am new to this- I don't really understand what it is trying to get at. Is there a way of me using my error handler and evoking the ob_start("ob_gzhandler") ? Thanks. Ianob_ |ob_start("ob_gzhandler");| -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ob_start("ob_gzhandler") and error handling functions
Hi again, Just wandering if someone could help me on this one- I'm quite anxious to get something together. As I said in the last email I just want to use ob_start("ob_gzhandler") but it doesn't seem to work with the error function. I think it might be something to do with not being allowed within a 'callback function'- well that's what it says on the php manual. The thing is I'm not sure what that means, I find that section not particularly clear. Please can someone help! IG wrote: Hi, I include a php file at the beginning of every web page in this site. This include file has an error handling function and starts output buffering... // Start of Error Handler error_reporting(E_ALL ^ E_NOTICE); ini_set('log_errors','1'); function ErrHandler($err,$err_string='',$err_file,$err_line) { // Do error logging thang ob_end_clean();// Clear buffer include('/path/incs/errors/errors.inc');// Output friendly error page exit(); } set_error_handler('ErrHandler'); // End of Error Handler It works great and the error handler kicks in if there is an error on the page and outputs a friendly page instead. I really wanted to gzip the pages by using ob_start("ob_gzhandler") but it doesn't work. I think it is because of the error handler function trying to clear the buffer (see the line ob_end_clean() which I assume becomes ob_end_clean("ob_gzhandler") ). It says on the php functions page- *ob_start()* may not be called from a callback function. If you call them from callback function, the behavior is undefined. If you would like to delete the contents of a buffer, return "" (a null string) from callback function. As I am new to this- I don't really understand what it is trying to get at. Is there a way of me using my error handler and evoking the ob_start("ob_gzhandler") ? Thanks. Ianob_ |ob_start("ob_gzhandler");| -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Altering subject of email in a pop3 mailbox
Hi all. Tried to find this and can't find any info. I am writing a spam filter to run over multiple pop3 mail boxes which will work on keywords and Bayesian. With a very high score the filter will simply delete the email, with a med-high it will back the email in a 'bulk-mail' folder and delete it from the mailbox. with medium score I was wanting it to append the keyword [spam?] to the subject line and keep it in the pop3 mailbox. I can't work out how to do this in php. Can anyone help me on this one? Is it possible to alter a subject line (or body for that matter) of an email in a pop3 mailbox? Thanks. -- [EMAIL PROTECTED] www.selectperformers.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Altering subject of email in a pop3 mailbox
Thanks, Nobody Special. You like filling people with confidence. We all have to start somewhere don't we? I am starting this completely from scratch and it will be quite a while before I put this into service. However thanks for the information on mail boxes. I don't have much knowledge on them because they are all run by our hosting provider. If you could point me to somewhere where I can find more information out on mailboxes I would be most grateful. Many thanks, IG Nobody Special wrote: POP is a protocol used for a client to retrieve emails from a mail box. There are not pop3 mail boxes. The types of mail boxes are mbox and maildir.You cannot modify a message using the pop3 protocol. I think you are the last person I would want writing a spam filter because you don't seem to know how mail is stored to begin with. On 2/22/06, IG <[EMAIL PROTECTED]> wrote: Hi all. Tried to find this and can't find any info. I am writing a spam filter to run over multiple pop3 mail boxes which will work on keywords and Bayesian. With a very high score the filter will simply delete the email, with a med-high it will back the email in a 'bulk-mail' folder and delete it from the mailbox. with medium score I was wanting it to append the keyword [spam?] to the subject line and keep it in the pop3 mailbox. I can't work out how to do this in php. Can anyone help me on this one? Is it possible to alter a subject line (or body for that matter) of an email in a pop3 mailbox? Thanks. -- [EMAIL PROTECTED] www.selectperformers.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Use Linux. W=Wrong Proud member of the reality-based community! In opposing the Federalists, [Jefferson] ushered in a kind of sustained partisan activity that had never existed before. Initially called the Republican party, it became known in the era of Andrew Jackson as simply the Democracy; later on, it was called the Democratic party. But even the modern Republican party, formed in 1854, chose its name in part to honor Jefferson. -- Joyce Appleby on Jefferson -- [EMAIL PROTECTED] www.selectperformers.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Altering subject of email in a pop3 mailbox
Chris wrote: IG wrote: Is it possible to alter a subject line (or body for that matter) of an email in a pop3 mailbox? If it's already in the mailbox, then I highly doubt you can do this. You need to do this on the way in before it gets to the account. Consider the ramifications if you could: Anyone could login to your mail account and change the emails already there. Eek! Thanks- I completely see your point. How do antispam filters work on client's computers? They seem to have no problem with adding to subjects. Also our hosting provider uses a spam filter which adds it to the subject line. However I am finding that not particularly good. Many thanks, IG -- [EMAIL PROTECTED] www.selectperformers.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Backing up emails and then forwarding them
Hi. I want to have a script that when run backs up all emails in a pop3 mailbox that are from email addresses not in a database. The person who has sent the email will receive an email that asks them to verify the email by clicking a link and then the email is sent. I need to know how to resend the email from the database. I have backed up the full body and the full headers. How can I reconstitute the email and send it as an attached eml file? Many thanks, IG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is this password protection script secure?
Hello. I got a password protected login script of t'internet a while back and have implemented it. I just want to make sure it is secure. I am aware that the password is stored directly in the database and I don't think this is a good thing. If the following could be looked at to see if there are any improvements I would be most grateful. The script is then called on each page that requires password protection thus- Here is the code for login.php- $QUERY_STRING;}?>" method="POST" name="customerlogin" id="customerlogin"> Username: Password: value="Login>>>"> session_register("pw"); // register username and password as session variables. $link = mysql_connect("MYSQL_DATABASE_SERVER", "MYSQL_USERNAME", "MYSQL_PW") or die("<--Could not connect-->"); mysql_select_db("MYSQL_DATABASE_NAME") or die("<-- Could not select database-->"); $sql = "SELECT `id`, `Surname`, `Forenames`, `username`, `pw` FROM MYSQL_TABLE_NAME WHERE `username` = '$username'"; $result = mysql_query($sql) or die("Query failed 888"); list($table_id, $Surname, $Forenames, $un, $pw) = mysql_fetch_row($result); $numrows = mysql_num_rows($result); if($numrows != "0" AND $password == $pw) { $valid_user = 1; $name = $Forenames." ".$Surname; } else { $valid_user = 0; } // If the username exists and pass is correct, don't pop up the login code again. // If info can't be found or verified if (!($valid_user)) { session_unset(); // Unset session variables. session_destroy(); // End Session we created earlier. // escape from php mode. ?> $QUERY_STRING;}?>" method="POST"> Incorrect username and/or password. Please enter correct ones to log in: Username: Password: value="Login>>>"> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] display_errors off and custom error pages
I've spent the last couple of hours trying to work this out to no avail. I have recently moved over to a managed dedi server and no can ask my host to change my php.ini. I have found out that the 'display_errors' in the php.ini is set to off and error file logging is off. I would like to be able log to file which is easy to do from the ini file but also to show a custom error page if there is an error on one of the pages. I thought I would be able to use a custom error handler such as - ob_start(); // custom error handler function e($type, $msg, $file, $line) { blah blah ob_end_clean(); // display error page exit(); } set_error_handler("e"); But all I get is a blank page. Does having display_errors off mean that I can't use a custom error handler? I have also tried adding *set_ini*('*display_errors*','1') but this keeps giving me a blank page. Can someone tell me the best (and most secure way) of having custom error pages in php. Ideally I would like it all set from a central place so that i only need to change one file for all the websites on our server. I didn't really want to change display_errors to on as I was told this wasn't very secure- i don't want error messages on any of my pages, I just want a simple error 500 server error page. Many thanks, Ian
Re: [PHP] display_errors off and custom error pages
Richard Lynch wrote: On Fri, April 28, 2006 11:55 am, IG wrote: I have recently moved over to a managed dedi server and no can ask my host to change my php.ini. I have found out that the 'display_errors' in the php.ini is set to off and error file logging is off. Do they have .htaccess turned on? I've checked and it isn't I have asked my host to do this now. However I'd ideally like everything sorted from the Apache config file. Because you can set all this stuff in an .htaccess file... I would like to be able log to file which is easy to do from the ini file but also to show a custom error page if there is an error on one of the pages. I thought I would be able to use a custom error handler such as - ob_start(); You do not need, nor even want probably, ob_start() just to be able to use a custom error handler. I thought I needed ob_start(), why don't I? If part of a page is outputted then it would be impossible to output an error page as html has already been sent out. It doesn't HURT, mind you, but it's not needed at all. // custom error handler function e($type, $msg, $file, $line) { blah blah ob_end_clean(); // display error page exit(); } set_error_handler("e"); But all I get is a blank page. Well, unless your "blah blah" section outputs something, all you COULD get is a blank page. Yes- blah, blah was just a nicely formatted and helpful error page that won't scare off customers. Does having display_errors off mean that I can't use a custom error handler? No, not at all. At the moment I have display_errors off and the above script does not work for some reason. I have tried to put errors into scripts but all I get is a blank page. The other question is do custom error handlers work for parse errors? Again I would ideally like a custom error page to be displayed for all errors including parse errors just in case I make a mistake- I'm always forgetting those ';'s! I have also tried adding *set_ini*('*display_errors*','1') but this keeps giving me a blank page. I don't know where the *s got in in this email- I didn't type them! Anyway it is still giving me a blank page What are all those * characters in there? Get rid of them. Can someone tell me the best (and most secure way) of having custom error pages in php. Ideally I would like it all set from a central place so that i only need to change one file for all the websites on our server. .htaccess, if it is on, will do this, and not require you to remember to 'include' the error_handler on every script. I didn't really want to change display_errors to on as I was told this wasn't very secure- That is correct. It is too likely to expose too much information to Bad Guys. i don't want error messages on any of my pages, I just want a simple error 500 server error page. I thought I might be able to do this by setting an error 500 header with php using the header() command. Whoa. Okay, now we are in a different kettle of fish... I dunno that you CAN force a "500 server error" from within PHP... I guess there ought to be a function for that somewhere, but I've never noticed it... It would probably be documented or linked from or discussed in the User Contributed notes at http://php.net/header though, if it does exist. Would you settle for a nice HTML output like: An error has occurred. Please try again later. Because that's pretty much a no-brainer with the error handler -- But you have to actually output that. I think your basic problem right now is the assumption that PHP exit() with no content output would somehow constitute a 500 server error. It doesn't. [shrug] There's nothing inherently "wrong" with the webserver returning a totally blank document, really. Well, okay, by strict definitions of HTML w3c standards, it's not valid HTML. Good point- web standards are the way forward! But it's also not a 500 error either. As far as Apache is concerned, the document is "fine" and returns a 200. It just happens to be an empty/blank document is all. Blank pages aren't that helpful to a user though. Many thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display_errors off and custom error pages
Thanks, Chris. chris smith wrote: On 4/29/06, IG <[EMAIL PROTECTED]> wrote: I've spent the last couple of hours trying to work this out to no avail. I have recently moved over to a managed dedi server and no can ask my host to change my php.ini. I have found out that the 'display_errors' in the php.ini is set to off and error file logging is off. I would like to be able log to file which is easy to do from the ini file but also to show a custom error page if there is an error on one of the pages. I thought I would be able to use a custom error handler such as - ob_start(); // custom error handler function e($type, $msg, $file, $line) { blah blah ob_end_clean(); // display error page exit(); } set_error_handler("e"); But all I get is a blank page. Does having display_errors off mean that I can't use a custom error handler? I have also tried adding *set_ini*('*display_errors*','1') but this keeps giving me a blank page. The *s got into the email for some weird reason- they aren't in the original code. I would like an error page to be displayed for all errors including parse ones. Blank pages aren't that helpful for the user. Sounds like a parse error (using the code above will give you that). Try it in a htaccess file: php_flag display_errors 1 (I think). You can't use ini_set because a parse error breaks the whole script and it's not executed, so you need to change this value before the script. Do I have to have display_errors set to 1 if I want to display a custom error page? I'd rather have display errors set to 0 but have a custom error page displayed when an error is triggered. Is this possible? Perhaps I have misunderstood how errors work in php. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display_errors off and custom error pages
Thanks, Jochem. Jochem Maas wrote: IG wrote: I've spent the last couple of hours trying to work this out to no avail. I have recently moved over to a managed dedi server and no can ask my host to change my php.ini. I have found out that the 'display_errors' in the php.ini is set to off and error file logging is off. I would like to be able log to file which is easy to do from the ini file but also to show a custom error page if there is an error on one of the pages. I thought I would be able to use a custom error handler such as - ob_start(); // custom error handler function e($type, $msg, $file, $line) { blah blah ob_end_clean(); while (@ob_end_clean()); // and header('Status: 500 Internal Server Error'); are things you should look at. Good idea... also the check the ini setting auto_prepend_file, which can be set in your apache config so that all vhosts share a common include file which defines and sets the errorhandler. Wow- didn't know about auto_prepend_file. That is a great setting- thanks for letting me know about it. also apache has the ability to set a custom handler for 'real' 500 errors. the apache directive is something like: ErrorDocument 500 /path/to/my/500.php where the path is a url (or a local path - I think) // display error page exit(); } set_error_handler("e"); But all I get is a blank page. Does having display_errors off mean that I can't use a custom error handler? I have also tried adding *set_ini*('*display_errors*','1') but this keeps giving me a blank page. Can someone tell me the best (and most secure way) of having custom error pages in php. Ideally I would like it all set from a central place so that i only need to change one file for all the websites on our server. I didn't really want to change display_errors to on as I was told this wasn't very secure- i don't want error messages on any of my pages, I just want a simple error 500 server error page. Many thanks, Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display_errors off and custom error pages
So to use a custom error handler do I HAVE to have display_errors set to 1 in my php.ini file? This would of course mean I would have to use custom error handling across all my scripts. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading an XML outputting PHP file as XML
Hi. I have a PHP file that outputs as XML from a database. i have used the header() function to output the correct header but when I use the simplexml function it is trying to parse the php file itself and not the output of the php file. I can't get my head round this. Can anyone help me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If value is odd or not
Jonas Rosling wrote: Hi all, is there any easy why to check if a value is odd or not? Thanks // Jonas $value = 3; if (strpos(($value/2),".") === FALSE) {echo "even";} else {echo "odd";} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If value is odd or not
Jochem Maas wrote: Jonas Rosling wrote: Hi all, is there any easy why to check if a value is odd or not? ignore every answer that doesn't use the % operator. Thanks // Jonas ie my answer! I think the % operator is the best way, but there was nothing wrong with the answer I gave in that it would let you know whether the value is odd or not. But, I guess being not as clever as the other guys means I better go... sob sob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running conditions while looping through arrays....
I want to run filters on an pop3 inbox. I have the following arrays which I'll get from the database- $subject $email $body $subject_like $email_like $body_like I then go through each email in turn using this loop- $popy = "{".$pop3."/pop3:110}INBOX"; $mailbox = imap_open($popy, $un, $pw); $num_messages = imap_num_msg($mailbox); if ($num_messages <= $no_srch) {$rrt = 0;} else {$rrt = $num_messages-$no_srch;} for($i=$num_messages; $i>($rrt); $i--) { What I want to do is to check if the email address or subject or body of each email is exactly like any of the details stored in the arrays $subject, $email, $body and to check if the email address or subject or body contains a word or phrase from the arrays $subject_like, $email_like, $body_like. For example- $subject[0] = "SPAM"; $email[0]= ""; $body[0] = ""; $subject_like[0] = ""; $email_like[0] = ""; $body_like[0] = ""; // If the subject of the email = "spam" $subject[1] = ""; $email[1]= "[EMAIL PROTECTED]"; $body[1] = ""; $subject_like[1] = ""; $email_like[1] = ""; $body_like[1] = ""; // if the email address of the email = "[EMAIL PROTECTED]" $subject[2] = ""; $email[2]= ""; $body[2] = "spam body text"; $subject_like[2] = ""; $email_like[2] = ""; $body_like[2] = ""; // if the body of the email = "spam body text" $subject[3] = "SPAM"; $email[3]= "[EMAIL PROTECTED]"; $body[3] = ""; $subject_like[3] = ""; $email_like[3] = ""; $body_like[3] = ""; // if the subject of the email = "SPAM" AND the email address = "[EMAIL PROTECTED]" $subject[4] = "SPAM"; $email[4]= ""; $body[4] = ""; $subject_like[4] = ""; $email_like[4] = ""; $body_like[4] = "spam text"; // if the subject of the email = "SPAM" AND the body contains "spam text" If any of the above conditions are met then the email message is then stored in a database and deleted of the POP3 server. Is there a quick way of doing the above? The only way I can think of is by looping through each array for every email. This is really really slow. I'd be grateful for some help here Ian
[PHP] complex control structure- please help
Hi all, This may not be complex at all- maybe my head is just screwed up this afternoon! I am looping through arrays all at one time for the following- $filter_subject $filter_body $filter_email $filter_subject_like $filter_body_like $filter_email_like Examples of the following could be- $filter_subject[0] = "This is the subject"; $filter_body[0] = "This is the body"; $filter_email[0] = "[EMAIL PROTECTED]"; $filter_subject_like[0] = ""; $filter_body_like[0] = ""; $filter_email_like[0] = ""; $filter_subject[1] = ""; $filter_body[1] = ""; $filter_email[1] = ""; $filter_subject_like[1] = "lots of nice things"; $filter_body_like[1] = "horrible body text"; $filter_email_like[1] = "[EMAIL PROTECTED]"; $filter_subject[2] = ""; $filter_body[2] = ""; $filter_email[2] = ""; $filter_subject_like[2] = "Lots of nice things"; $filter_body_like[2] = ""; $filter_email_like[2] = ""; $filter_subject[3] = ""; $filter_body[3] = "This is the complete body"; $filter_email[3] = ""; $filter_subject_like[3] = "Part of the subject"; $filter_body_like[3] = ""; $filter_email_like[3] = ""; I then run something like the following on the variables $subject, $body, $email, $subject_like, $body_like and $email_like for($e=0;$e if($subject == $filter_subject[$e]) {$found_subject = 1;}// Subject has been found if($body == $filter_body[$e]) {$found_body = 1;}// Body has been found if($email == $filter_email[$e]) {$found_email = 1;}// Email has been found if(strpos($subject_like, $filter_subject_like[$e])) {$found_subject_like = 1;}// Subject(like) has been found if(strpos($body_like, $filter_body_like[$e])) {$found_body_like = 1;}// Body(like) has been found if(strpos($email_like, $filter_email_like[$e])) {$found_email_like = 1;}// Email(like) has been found ... } What I want to do is work out if (from the above examples) the following (not written in php by the way, just in kind of english) example 0 - if - ($subject == "This is the subject" AND $body == "This is the body" AND $email == "[EMAIL PROTECTED]") THEN DO THE FOLLOWING example 1 - if - ($subject == "lots of nice things" AND $body_like contains "horrible body text" AND $email contains "[EMAIL PROTECTED]") THEN DO THE FOLLOWING example 2 if - ($subject contains "Lots of nice things") THEN DO THE FOLLOWING example 3 if - ($body == "This is the complete body" AND $subject contains "Part of the subject") THEN DO THE FOLLOWING How can I organise a control structure so that I can do the above? My brain is hurting and I could do with some thoughts from you guys! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] seesion_register() with arrays
Hi All, I´m trying to register into a session an array which has returned from a mysql_fetch_array function. But when I call $array it returns empty or something like this. Do you know how can I do this operation? Regards! Here go my scripts: "> while ($array = mysql_fetch_array($result)) {...} session_register ("array"); ?> "; } ?>