Re: [PHP] www. not working
On Sat, 16 Feb 2008 05:45:54 +0300, Jim Lucas <[EMAIL PROTECTED]> wrote: Valedol wrote: just try "if ($POS !== 0) {" well, that said, isn't the first position in a string 0 ? So, in the above example the OP would need // This would mean that www. was found any where in the string if ( $POS ) or // Would mean that www. was found at the beginning of the string if ( $POS === 0 ) sorry, that was bad idea -- - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] www. not working
Jim Lucas wrote: Valedol wrote: On Fri, 15 Feb 2008 23:46:57 +0300, nihilism machine <[EMAIL PROTECTED]> wrote: this still does not work, if a domain has no preceeding www. it redirects to http://www.www.site.com, if it has a www. it goes to www.www.mydomain.com, any ideas? checkWWW(); $this->ServerName = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } // Check if site is preceeded by 'WWW' public function checkWWW() { $myDomain = $_SERVER['SERVER_NAME']; $FindWWW = 'www.'; $POS = strpos($myDomain, $FindWWW); if ($POS === 1) { $this->WWW = true; } else { $this->WWW = false; } } // Redirect to WWW public function WWWRedirect() { if ($this->WWW == false) { $redir = "Location: http://www."; . $this->ServerName; header($redir); } } } $myURL = new URL(); $myURL->WWWRedirect(); ?> just try "if ($POS !== 0) {" well, that said, isn't the first position in a string 0 ? So, in the above example the OP would need // This would mean that www. was found any where in the string if ( $POS ) or // Would mean that www. was found at the beginning of the string if ( $POS === 0 ) Remember that in PHP land $var = 0 evaluates to FALSE. So strpos('foo', 'f') will return 0 (first char), which in an if() expression would turn to false: if(strpos('foo', 'f')) { echo 'f found in foo'; } else { echo 'f not found in foo, or maybe it is the first character; we can not tell'; } That's the reason people use strpos('foo', 'f) !== false since that differentiates the false result (nothing found) from an integer result (for the position it was found on). - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] check if website has www. in front of domain
// Check if site is preceeded by 'WWW' public function checkWWW() { $myDomain = $_SERVER['SERVER_NAME']; $FindWWW = '.'; $POS = strpos($myDomain, $FindWWW); if ($POS === false) { return false; } else { return true; } } any idea why this is not working? just trying to test if the site is www.site.com and not site.com Try this: public function CheckWWW($url = null) { // Default to the current URL if none is given if (is_null($url)) { $url = $_SERVER['HTTP_HOST']; } return preg_match('/^www\./i', $url); } -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gzipped output
Eric Butera wrote: > Let us look at XSS now. http://sla.ckers.org/forum/list.php?2 Looks > like there are quite a few of those too. If Google/Yahoo can't stop > this stuff how are us mere mortals supposed to? In my experience, the bigger the organisation, the more mere mortals. Also, a small team has a much better of chance of getting things right than a big team. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fwrite Function
Hello, Can you please help me, I am writing code where I create a file and write to it from a form on a webpage and then read and display this file on the webpage. I want to change the color of the text that is written to the file. Do you know how I can do this? This is some of my code if you need clarification: * $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,'a') or die("can't open file"); fwrite($boardFileHandle, $name); fwrite($boardFileHandle, $talk); fclose($boardFileHandle); } $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,"r"); $talkR = fread($boardFileHandle, filesize($boardFile)); fclose($boardFileHandle); echo $talkR;* ** ** Thanks
Re: [PHP] check if website has www. in front of domain
// Check if site is preceeded by 'WWW' public function checkWWW() { $myDomain = $_SERVER['SERVER_NAME']; $FindWWW = '.'; $POS = strpos($myDomain, $FindWWW); if ($POS === false) { return false; } else { return true; } } any idea why this is not working? just trying to test if the site is www.site.com and not site.com Try this: Or just change this: $FindWWW = '.'; to this: $FindWWW = 'www.'; Looks like a simple typo. That having been said, however, I think that Richard's solution is more elegant. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Fwrite Function
Its a text file and so doesn't support markup. You could write out html into the file that does mark it up and could be displayed to the user via the browser...or you could use regex or str_replace to mark up certain text on the read of the file to display to the user bastien > Date: Sat, 16 Feb 2008 14:03:26 +0200 > From: [EMAIL PROTECTED] > To: php-general@lists.php.net > Subject: [PHP] Fwrite Function > > Hello, > > Can you please help me, I am writing code where I create a file and write to > it from a form on a webpage and then read and display this file on the > webpage. > I want to change the color of the text that is written to the file. > Do you know how I can do this? > > This is some of my code if you need clarification: > * $boardFile = "MessageBoard.txt"; > $boardFileHandle = fopen($boardFile,'a') or die("can't open file"); > fwrite($boardFileHandle, $name); > fwrite($boardFileHandle, $talk); > fclose($boardFileHandle); > } > $boardFile = "MessageBoard.txt"; > $boardFileHandle = fopen($boardFile,"r"); > $talkR = fread($boardFileHandle, filesize($boardFile)); > fclose($boardFileHandle); > echo $talkR;* > ** > ** > Thanks _ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLTProcessor without validation
Am Freitag, 15. Februar 2008 15:35:02 schrieb Andrew Ballard: > It's there for me as well. (Firefox and IE6, Windows XP). Any chance you've > got a browser plugin or other "feature" that is blocking the image? I thought it was privoxy, but i tried without proxy and had the same result. I copied the url out of the source code and tried to load it directly and got nothing. Firefox 2.0.0.12, Kubuntu Linux. No idea. Regards Siegfried -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: XSLTProcessor without validation
Am Freitag, 15. Februar 2008 10:13:15 schrieb Peter Ford: > What if you don't have a DTD in the XML to validate it with? > I haven't tested it but it was something that worked in the Java XML > processing stuff. No DTD, no validation: simple! > So have you tried stripping the DOCTYPE declaration before XSLTing the XML? Interesting idea. No, i have not tried it. Problem: At least one of the files to be parsed is xhtml. And the result is, besides others, xhtml and html. Ah, BTW: Parsing the rss file is very fast. So indeed this might help. But unfortunately i need the DOCTYPE in the (x)html files, at least in the resulting files. But indeed interesting idea. I'll think about it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLTProcessor without validation
Am Freitag, 15. Februar 2008 15:35:02 schrieb Andrew Ballard: > It's there for me as well. (Firefox and IE6, Windows XP). Any chance you've > got a browser plugin or other "feature" that is blocking the image? I just tried it with Firefox in safe mode, same result: No captcha. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] www. not working
Shawn McKenzie wrote: Shawn McKenzie wrote: Shawn McKenzie wrote: Jim Lucas wrote: nihilism machine wrote: this still does not work, if a domain has no preceeding www. it redirects to http://www.www.site.com, if it has a www. it goes to www.www.mydomain.com, any ideas? If you are running Apache, you do realize that all of this can be done in Apache instead of PHP right? Here is an example of what I have on my domain. ServerName example.com ServerAlias .example.com ServerAlias ww.example.com RedirectMatch (.*) http://www.example.com$1 Jim Lucas Or in DNS zone file (assuming you have an A record for example.com): www.example.com. IN CNAMEexample.com. Many ways to skin a cat, and they are all fun! -Shawn Nevermind. I guess this would already be in place or the conf, .htaccess or PHP wouldn't even be running. :-( I thought about starting a new thread for every different idea that I had in reply to this post. What do y'all think? -Shawn worth noting somewhere on the net, not quite sure if here is the best place for it to be honest. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] www. not working
Nathan Rixham wrote: > Shawn McKenzie wrote: >> Shawn McKenzie wrote: >>> Shawn McKenzie wrote: Jim Lucas wrote: > nihilism machine wrote: >> this still does not work, if a domain has no preceeding www. it >> redirects to http://www.www.site.com, if it has a www. it goes to >> www.www.mydomain.com, any ideas? >> > If you are running Apache, you do realize that all of this can be done > in Apache instead of PHP right? > > Here is an example of what I have on my domain. > > > ServerName example.com > ServerAlias .example.com > ServerAlias ww.example.com > RedirectMatch (.*) http://www.example.com$1 > > > > > Jim Lucas Or in DNS zone file (assuming you have an A record for example.com): www.example.com. IN CNAMEexample.com. Many ways to skin a cat, and they are all fun! -Shawn >>> Nevermind. I guess this would already be in place or the conf, >>> .htaccess or PHP wouldn't even be running. :-( >> >> I thought about starting a new thread for every different idea that I >> had in reply to this post. What do y'all think? >> >> -Shawn > > worth noting somewhere on the net, not quite sure if here is the best > place for it to be honest. Here is where I saw it. Maybe you missed it? -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Uploading PDF
Pastor Steve escribió: Greetings, I am getting an error when I am trying to upload a PDF file through a script. When I do a print_r($_FILES) I get the following: Array ( [userfile] => Array ( [name] => document.pdf [type] => [tmp_name] => [error] => 2 Error 2: http://us3.php.net/manual/en/features.file-upload.errors.php You exceeded the MAX_FILE_SIZE size. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session destruction problem
Hi everybody, I need help with sessions. I have a simple authentification relying only on sessions (i don't use cookies). After the user submits his username and password, the script checks if that corresponds to a record in a mysql table. If this is the case "$_SESSION['sessioname'] = $_POST['login'];". the $_SESSION['sessioname'] is checked in subsequent pages to see if the user is connected or not. The problem is after the user logs out, and after that uses the previous button of the browser he becomes connected. How can i prevent this please. Here is my logout.php: Thank you for advance Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Protected ZIP file with password
Hey folks, Do you know how can I create a protected zip file with password? Is there anyway? I've search on the internet, but without success. Thank's in advance, Petrus Bastos.
Re: [PHP] Gzipped output
Let us look at XSS now. http://sla.ckers.org/forum/list.php?2 Looks like there are quite a few of those too. If Google/Yahoo can't stop this stuff how are us mere mortals supposed to? In my experience, the bigger the organisation, the more mere mortals. Also, a small team has a much better of chance of getting things right than a big team What needs to happen, IMO, is for the browser manufacturers to create a way for users and website programmers to disable scripting in the web page body on a per site or per page basis. Why not be able to supply a meta tag that will only let scripting be attached in the head portion of the page and only from a file. Perfect use for Javascript behaviors to attach code to what's in the page body. That'd stop a lot of XSS issues and it'd force developers to write better code. -- Michael McGlothlin Southwest Plumbing Supply smime.p7s Description: S/MIME Cryptographic Signature
[PHP] PHP/mySQL dropping zeros after inserting number into record
I've got a PHP script that inserts "00012345678" into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is "12345678". I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? (or some way for PHP to tell mySQL not to chop off the zeros?) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/mySQL dropping zeros after inserting number into record
char(14) is a better data type bastien > Date: Sat, 16 Feb 2008 15:22:17 -0800 > From: [EMAIL PROTECTED] > To: php-general@lists.php.net > Subject: [PHP] PHP/mySQL dropping zeros after inserting number into record > > I've got a PHP script that inserts "00012345678" into a record in a mySQL > database (it's a barcode). Things work ok unless the number has preceding > zeros, and then the zeros get cut off and all I get is "12345678". > > I have the mySQL database fieldtype set to bigint(14). If the maximum length > a barcode can be is 14, is there a better fieldtype to use that will keep the > zeros? > > (or some way for PHP to tell mySQL not to chop off the zeros?) > > -- > 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] PHP/mySQL dropping zeros after inserting number into record
Rob Gould <[EMAIL PROTECTED]> writes: > I've got a PHP script that inserts "00012345678" into a record in a > mySQL database (it's a barcode). Things work ok unless the number has > preceding zeros, and then the zeros get cut off and all I get is > "12345678". > > I have the mySQL database fieldtype set to bigint(14). If the maximum > length a barcode can be is 14, is there a better fieldtype to use that > will keep the zeros? Use ZEROFILL, example: CREATE TABLE `db`.`table` ( `barcode` integer(14) ZEROFILL NOT NULL ) -- Emilio Astarita <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check time in between times
On Feb 17, 2008 12:53 AM, Johny Burns <[EMAIL PROTECTED]> wrote: > I am having fields in my table where I put times like 4:30pm in string > format > > Can anybody help with function which helps detect. > Is it the current time between those fields? > > function checkinzone($time1,$time2):boolean > > Has to verify does the current time is in those 2 variables. > > Thank you for your help. My ability with time and date funtions in PHP are > not that great convert $time1 and $time2 to unix timestamps; from there its a matter of basic logic; something like this (vaguely) function isTimeBetween($time1, $time2) { if(!($lowerBound = date('U', $time1)) { return false; } if(!($upperBound = date('U', $time2)) { return false; } $curTime = mktime(); if($curTime > $lowerBound && $curTime < $upperBound) { return true; } else { return false; } } note; $time1 and $time2 will have to unix timestamps; this function will verify that by passing them through the date() function. http://www.php.net/manual/en/function.date.php if you want something a little more flexible; check out; strtotime(); http://www.php.net/manual/en/function.strtotime.php and also, the DateTime class will make for good reading ;) http://www.php.net/manual/en/function.date-create.php -nathan
[PHP] Check time in between times
I am having fields in my table where I put times like 4:30pm in string format Can anybody help with function which helps detect. Is it the current time between those fields? function checkinzone($time1,$time2):boolean Has to verify does the current time is in those 2 variables. Thank you for your help. My ability with time and date funtions in PHP are not that great -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hex Strings Appended to Pathnames
Nathan Rixham wrote: Richard Lynch wrote: I don't know if it's before/after, but PHP can't change the GET request to something it wasn't... So THAT was the URL requested. You might have some kind of funky mod_rewrite rule messing you up... On Tue, January 29, 2008 5:22 am, Mick wrote: Richard Lynch wrote: On Sun, January 27, 2008 7:57 am, Mick wrote: Operating System: CentOS 4.6 PHP Version: 4.3.9-3.22.9 Zend Optimizer (free) version: 3.2.6 Hello. I've got somewhat of a strange problem here involving Squirrelmail. Basically, what is happening is that one of our customers is logged out of his Squirrelmail session at random intervals. This can occur when he goes to read an email or, after composing an email, when he clicks on the Send button. The following log entries correspond with those times that the customer is logged out. [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.php3a5def33 [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.php29e09f87 [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/move_messages.phpf9f96dfb [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.phpdc6cc80a So what would be the cause of appending those hex strings to those pathnames? You'll probably have to ask the squirrelMail guy... Unless you can reproduce it with other applications, it's not in PHP itself, probably. PS I'm a squirrelMail user, and I get logged out a lot too. :-( Hi Richard. Thank you for your reply. You'll probably have to ask the squirrelMail guy... I've already asked him, and he referred me to the PHP/Zend guys i.e. to here. ;) Actually, what the access logs show for these events is this for example: "GET /squirrelmail/src/compose.php9e99b821 HTTP/1.1" 404 "GET /squirrelmail/src/redirect.php3a5def33 HTTP/1.1" 404 Do you know if logging for the access log is performed before or after the URL is passed through to php? Cheers, Mick. Hi Richard. So THAT was the URL requested. As I had suspected. You might have some kind of funky mod_rewrite rule messing you up... There is no rewrite rule. It's an extremely strange problem. Cheers, Mick. I see this is a strange problem, the puzzle for me though is why is the user getting logged out? surely a 404 can't end a session.. Hi Nathan. Apologies for the delay. Been hectic here of late. Anyhow, with regards to: I see this is a strange problem, the puzzle for me though is why is the user getting logged out? surely a 404 can't end a session.. Ok. What happens is that with *every* operation e.g. Looking in the Inbox, or the Trash folder, Options etc, I can see in the logs that the user is logged out and then logged in again. So there must be cookies involved for this to work. Cheers, Mick. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check time in between times
"Johny Burns" <[EMAIL PROTECTED]> writes: > I am having fields in my table where I put times like 4:30pm in string > format Check this: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html Perhaps you could use a data type date for that. > Can anybody help with function which helps detect. > Is it the current time between those fields? > > function checkinzone($time1,$time2):boolean > > Has to verify does the current time is in those 2 variables. This may help you: function strange2min($strange) { $h24h = substr($strange,-2); list($hour,$minute) = preg_split("/(?i:am|pm|:)/",$strange); if ($h24h == 'am' && $hour == 12) { $hour = 0; } elseif ($h24h == 'pm') { $hour = $hour + 12; } return ($hour * 60) + $minute; } function checkinzone($start,$end) { $now = (date('G') * 60) + date('i'); $start = strange2min($start); $end = strange2min($end); return ( ($start <= $now ) &&($now <= $end)); } // test $start = "1:30am"; $end = "9:39am"; echo '', var_dump(checkinzone($start,$end)),''; -- Emilio Astarita <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fwrite Function
Yuval Schwartz wrote: > Hello, > > Can you please help me, I am writing code where I create a file and write to > it from a form on a webpage and then read and display this file on the > webpage. > I want to change the color of the text that is written to the file. > Do you know how I can do this? > > This is some of my code if you need clarification: > * $boardFile = "MessageBoard.txt"; > $boardFileHandle = fopen($boardFile,'a') or die("can't open file"); > fwrite($boardFileHandle, $name); > fwrite($boardFileHandle, $talk); > fclose($boardFileHandle); > } > $boardFile = "MessageBoard.txt"; > $boardFileHandle = fopen($boardFile,"r"); > $talkR = fread($boardFileHandle, filesize($boardFile)); > fclose($boardFileHandle); > echo $talkR;* > ** > ** > Thanks > > First question is -- why aren't you using a database for this information? I would recommend sqlite (http://www.sqlite.org/) Now that that's taken care of, if you're trying to color the text on output, I would do it like this: ___ '; $MESSAGEFORMAT = ''; $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,'a') or die("can't open file"); /* * Here we are going to write to the file, notice I added another line that prints a comma. This will be useful so that you can easily parse out and potentially format the 2 elements at will */ fwrite($boardFileHandle, $name); fwrite($boardFileHandle, ","); // added fwrite($boardFileHandle, $talk); fclose($boardFileHandle); $boardFile = "MessageBoard.txt"; $boardFileHandle = fopen($boardFile,"r"); /* removed $talkR = fread($boardFileHandle, filesize($boardFile)); */ while (($data = fgetcsv($boardFileHandle, 1000, ",")) !== FALSE) { /* * put 1000byte buffer to $data, this also goes 1 line at a time. */ echo $NAMEFORMAT . $data[0] . ""; // print the name echo $MESSAGEFORMAT . $data[1]; // print the text } fclose($boardFileHandle); ?> If you have any questions regarding the implementation I suggest the following reading material: http://us3.php.net/manual/en/function.fgetcsv.php Good luck! == Nick Stinemates ([EMAIL PROTECTED]) http://nick.stinemates.org AIM: Nick Stinemates MSN: [EMAIL PROTECTED] Yahoo: [EMAIL PROTECTED] == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php