[PHP] Re: Compare two TXT files
On Sat, Jul 17, 2004 at 07:07:44PM -0600, C.F. Scheidecker Antunes wrote: > > Is there a more efficient way to compare 2 TXT files other than reading > line by line ? > > What I was doing was reading line by line and compare both files, if one > line is different the loops are interrupted and the function returns true. > > Any ideas? If all you're trying to do is determine whether the files are different, and the files are relatively small, then it might be easiest to do something like: function filediff($foo, $bar) { $f_foo = file_get_contents($foo); $f_bar = file_get_contents($bar); return ($f_foo == $f_bar); } Note that this has the opposite return value of your existing function: it returns true if the files are THE SAME, like the unix "diff" command. Alternately, if you want to know what differences exist between files, you could load the files into arrays with the file() function, then use the array_diff() function to spit out a list of lines in one file but not the other. Or, you could tell us more about what you're actually trying to do. :) p -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Webcapture to PDF
On Thu, May 13, 2004 at 09:59:56AM -0600, Ashley M. Kirchner wrote: > >Looking for a (open source) solution here: is there some way that I > can convert an already existing HTML page to a PDF file, by means of a > script (on a unix box)? Well, http://www.babysimon.co.uk/khtml2png/ will build a PNG which you could slurp into a PDF using libpdf in PHP. Or, http://marginalhacks.com/Hacks/html2jpg/ may be your solution. Or find it on FreshMeat at http://freshmeat.net/projects/html2jpg/. Note building PDFs that consist solely of PNG or JPG images is probably a bad idea -- the PDFs will be heavy, and not searchable because the text is not stored as text, it's part of the image. Check out http://www.tdb.uu.se/~jan/html2ps.html for the most "pure" but east pretty solution. I've found that html2ps is way easier to set up than the other two, but the tool is based on standards rather than a browser's idea of what carbon-based lifeforms think is pretty. If your goal is to take browser snapshots, then look at one of first two tools mentioned. If your goal is simply to convert HTML to ps/pdf, then html2ps is the way to go. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: strip comments from HTML?
On Thu, May 06, 2004 at 07:11:55PM +, Curt Zirzow wrote: > > > > $text="one ", "",$text); > > Because your missing a - > $text="one two\n"; /me applies mallet to head % php -r '$text="one two\n"; print ereg_replace("", "",$text);' one two whee, it works! :) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: strip comments from HTML?
On Thu, May 06, 2004 at 11:26:34AM -0400, Rob Ellis wrote: > > > > $text = ereg_replace("","",$text); > > you can make the .* less greedy... > > $text = preg_replace('//', '', $text); Interesting to know. My preg-foo is limited; I came at PHP from a background of awk and sed, so when I regexp, I'm a little more traditional about it. Interestingly, from a shell: $ text='one two\nthree four\n' $ printf "$text" | sed -E 's///g' one two three four which is the same behaviour as PHP. But that still doesn't cover multi-line. PHP's ereg support is supposed to, but doesn't work with this particular substitution: $text="one ", "",$text); returns one
[PHP] Re: strip comments from HTML?
On Thu, May 06, 2004 at 03:02:16PM +1000, Justin French wrote: > > This isn't working: > $text = preg_replace('//','',$text); > > Can someone advise what characters I need to escape, or whatever to get > it going? It's not a matter of escaping. You're matching too much with the ".*". If you're sure you won't have any right-point-brackets inside comments, you can use something like: $text = ereg_replace("","",$text); Accurately matching comments in an extended regular expression is tricky though. The only thing you can really *negate* in an ereg is a range, not an atom. And the close of the comment can't be prepresented as a range, since it's multiple characters. Not to say it can't be done. I just can't think of how at the moment. :) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] paging methodology
On Tue, May 04, 2004 at 02:37:50PM -0700, Chris W. Parker wrote: > > > I don't follow what "$_GET record count from initial query performed > > above;" is for, but that's the basic methodology. > > well that just meant that after the initial count of records is found it > will be retrieved from the querystring instead of through a select > statement (because it had already been performed once before). I never bother with getting the initial record count. Unless you want to display the total number of available pages, of course (in the vein of Google search result set). If all you need is to include "Previous" and "Next" buttons in the right places, you could simply go with: $length=40; // or whatever if ($_GET['offset']) $offset=$_GET['offset']); else $offset=0; // do the query $q="SELECT colums FROM table WHERE yadda LIMIT $offset," . 1+$length; $r=mysql_query($q); // make Prev/Next links as required if ($offset > 0) $prev=""; else $prev=""; if (mysql_num_rows($r) > $length) $next=""; else $next=""; // show the head print " $prev\n"; print " $next\n"; print "\n"; // show the page for ($i=0; $i<$length; $i++) { $row=mysql_fetch_array($r); print $row['blah']; // wrapped in stuff, of course } The idea here is that we always try to SELECT one more entry than we can display on the page. If mysql_num_rows() sees that many rows, then there's a page after the current one. And of course, if $offset is > 0 then there's a page before the current one. I find that this method simplifies my code. I don't need to store the result of a COUNT() in a session variable, so the "count" remains valid even if the number of records changes while someone's browsing. Note that this is not safe code as is. :) At the very least, you should format-check $_GET['offset'] before using it for anything. p -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regular Expression
On Wed, May 05, 2004 at 02:26:25PM +0900, Tumurbaatar S. wrote: > > There's an input string like "{str1,str2,...,strN}". I want to capture > all these strings and due to complexity of them I use a preg_match_all() > instead of simple split. A pattern for the matching strings is ready but > I cannot imagine how to specify that strings are separated by commas > and the last one is not followed by comma. For example, I'm afraid that > this pattern "/^{(?:(pattern),)*|(pattern)?}$/" can match and capture > properly constructed input string, but, in addition, this matches if > the string end is ",}". Any ideas? Why not just strip out the braces and explode on commas? That'll be lighter than regexps any day. If the input is guaranteed to be formatted the way you describe, you could do something like: $out = explode(",", substr($in, 1, strlen($in)-2)); -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Challenge: Sessions & Frames
On Sun, Jan 25, 2004 at 06:26:26PM -0800, Jonathan Hilgeman wrote: > > I'm running into some weird trouble here. I'm a very experienced PHP > programmer, but I rarely ever deal with framed sites. A client wants a > framed PHP site that needs session data passed between the frames. Mu. A session is merely an array tied to a cookie. "Session variables" are elements of that array, and the cookie is maintained by the entire browser, regardless of window or frame. Since PHP is server-side, there's no way for data to be "passed between the frames". You'd need client-side programming for that. The extent of your PHP-based controls over frame content consists of named targets, the same as HTML. But anyway... > The top frame is a nav bar that changes from time to time by means of > Javascript updating it (I know this all should've been done without frames > and Javascript, but the client is REQUIRING frames and JS is the fastest way > to update the frames). I've dealt with more than one company that required an HTTP proxy set up on their corporate firewall set up to strip Javascript from web content in-transit, due to paranoid security policies. Whether those policies make sense is moot; the fact that they exist anywhere means that your client's requirements are born of ignorance ... but you obviously know that already. ;-) > The bottom frame is the main content area. > > All three objects here (parent, top frame, bottom frame) have a common > header that does things like connect to the database, session_start() and > register session variables. Register? As in, session_register()? May I humbly recommend that you switch to $_SESSION[] instead, for the more sensible notation and compatibility with future default php installs? > When I try to log in, the information is passed to the parent, which > authenticates the user, and then changes the top frame to a header page that > is more customized for the user. The bottom frame changes to the user's > control panel. > > Here's where the problem comes in. As I move around in the bottom frame, > going from page to page, the session seems to randomly die, and then it > starts doing things like appending $PHP_SESSID to the links and stuff. Are you calling a session_name() with a custom session name before you call session_start()? If some scripts define a session_name() that isn't included for other scripts, you may be losing your session as its name is inadvertently changed. If you're calling session_name(), are you sure the value is just alphanumeric? Non-alnum characters may or may not work. (Usually not.) > If I try to login again, it seems to authenticate correctly in the parent, > but when the parent tries to change the top frame and bottom frame, those > frames don't always seem to recognize the login attempt. It's almost like > each frame suddenly split into its own session, identified by its own > $PHP_SESSID. Sometimes it works, sometimes it doesn't. If multiple frames are trying to update session variables at the same time, you may be experiencing file locking issues in your session files. Check http://php.net/session_write_close for some discussion on this. > I don't understand what's happening here. Any thoughts? If none of the above suggestions help, then I have no clue. :-) p -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RewriteRule REGEX ?
On Sat, Jan 24, 2004 at 12:18:36PM -0500, Monty wrote: > > From This: articles.php?id=999 > To This:articles/999 ... > What am I doing wrong?? I suspect you may not be looking at the problem the right way. What exactly do you want to do? Normally, you'd go the other direction; that is, you'd have mod_rewrite recognize ^/articles/([0-9]+)$ and translate it to /articles.php?id=$1 ... so that a request to the "pretty" URL gets served as an HTTP GET on the PHP script. I get the impression that you're expecting mod_rewrite to translate copy from inside your HTML files, as well as recognize and reverse the translation when the request comes back in. Is that it? > RewriteEngine on > RewriteRule ^articles\.php\?id=([0-9]+)$ articles/$1 [R] > But I keep getting a 404 error for articles.php, which means that something > must be wrong with my RewriteRule because it's not matching. I've tried > various tweaks and just can't get it to work. I bet if you create an "articles" directory in your documentroot, with with files named things like "999" in it, you'll stop seeing the 404's. Check your apache error_log. If what you're trying to achieve is to have existing HTML files get their embedded URLs translated, you're going to have to do that with an output filter. You can do it with PHP, or use mod_sed ... lots of options. But a rewrite rule won't change page content, it'll only rewrite the *requests* that come in. Of course, if you know all this already, and really are trying to point requests for /articles.php?id=123 to a file named "123" in the directory "articles", then you'll still need to inspect your error_log. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Form woes
Alex, A switch statement probable isn't the way you want to do this. There is no real limit to how many of anything should go in a page, but there are likely better ways to skin this particular cat. Your goal should be to come up with elegant ways to represent problems, such that large tasks can be achieved using minimal code. I'd put your includes in an array. Based on your code, something like: 'create_lsn_name', 2 => 'create_lsn_obj', 3 => 'create_gain', 4 => 'lsn_layout', 5 => 'dev_lsn_page', ); if ($pages[$_GET['dev']]) { printf("\n"; } else { include('create_lsn_name.php'); } if ($_GET['dev'] < 5) { $dev=$_GET['dev']+1; } ?> Now, adding to the include list is just a matter of updating the array. Of course, this doesn't address the issue of navigation *backwards* through the page list. p On Wed, Jan 21, 2004 at 01:07:58PM -0600, Alex Hogan wrote: > > The code below is the submission of my form and the inclusion of different > pages based on what the $dev value is. > > > > My questions are; > > Is there a better, or should I say more elegant, way to do what I'm doing? > > Should I break out the switch statement and put it in another page? > > What is the suggested limit, for clarity of reading and maintaining, for the > number of pages included in a single page? > > > > My goal is to make this extremely easy to edit and maintain. If I can make > a single change in one page that can affect many other pages I should break > up the pages, shouldn't I? > > > > Sorry for the bombardment of questions. > > > > [code] > > method="post" name="frmCreateLesson" class="normal_text" > id="frmCreateLesson"> > > > switch($_GET['dev']){ > > case 1: > > include('create_lsn_name.php'); > > $dev = 2; > > break; > > case 2: > > include('create_lsn_obj.php'); > > $dev = 3; > > break; > > case 3: > > include('create_gain.php'); > > $dev = 4; > > break; > > case 4: > > include('lsn_layout.php'); > > $dev = 5; > > break; > > case 5: > > include('dev_lsn_page.php'); > > break; > > default: > > include('create_lsn_name.php'); > > break; > > } > > > > ?> > > [/code] > > > > alex hogan > > > > > > ** > The contents of this e-mail and any files transmitted with it are > confidential and intended solely for the use of the individual or > entity to whom it is addressed. The views stated herein do not > necessarily represent the view of the company. If you are not the > intended recipient of this e-mail you may not copy, forward, > disclose, or otherwise use it or any part of it in any form > whatsoever. If you have received this e-mail in error please > e-mail the sender. > ** > > -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web page thumbs
You're chasing your tail, but it may be possible to catch it. I note that http://www.alexa.com/ has thumbnails of web pages. For quite a while I've wondered how they do that. So I researched. Visit Alexa, find a site with a thumbnail, and download the image. Check out the JPEG comment -- and see the text, "Thumbnail Framer - Mozilla". A search at Google for these words turns up not much at all (framer.sourceforge.net probably isn't what we're looking for), but it got me thinking ... the tools (Mozilla and ImageMagick) are already installed on my workstation, and all I need is glue. So ... here's how I create a web page thumbnail in FreeBSD. First command line option is a URL, the second is an output file. == 8< == #!/bin/sh if [ -z "$2" ]; then echo "Gimme a filename." ; exit 1 elif ! echo "$1" | egrep -q "https?://"; then echo "Gimme a URL." ; exit 1 fi # First, get the page title, so we can identify the window... title="`lynx -source $2 | sed -Ene 's:.*([^<]+):\1:p'`" if [ -z "$title" ]; then title="Mozilla"; fi # Second, launch mozilla... mozilla -width 1024 -height 768 "$2" & # give it a chance to start... make longer if your link is slow. sleep 5 # Third, capture the window via ImageMagick... import -resize '20%' -trim -silent -window "$title" "$2" # Last, kill off mozilla. killall mozilla-bin == 8< == To be safe, I'd run this as its own user. The Mozilla configuration can be set up prior to running so that all extra button bars and windows are disabled or "folded up". There may be more elegant ways of killing off the window, but this is good enough for me. Building a solution that doesn't require a user to be logged in to an X server is left as an exercise for the reader Of course, none of this has anything to do with PHP. p On Wed, Jan 21, 2004 at 11:29:50AM -0600, Alex Hogan wrote: > > Yes..., if that's possible? > > The page in question is for Instructional Developers to select from a series > of templates to develop lessons from. These templates have different page > layouts that have differing types of text/media areas. The idea is to speed > up the lesson development process while maintaining the standardization that > is currently in place. > > It's those templates that are to be the thumbnails. I would like to not > have to create graphics from the different layouts to put on that page if at > all possible. If a layout changes or additional ones added then the > graphics have to change accordingly. > > > Am I chasing my tail here? > > > alex > > > -Original Message- > > From: Brian V Bonini [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, January 21, 2004 10:59 AM > > To: Alex Hogan > > Cc: PHP General list > > Subject: Re: [PHP] web page thumbs > > > > On Wed, 2004-01-21 at 10:19, Alex Hogan wrote: > > > Is there a way to create thumbnails of web pages? > > > > > > > > > > > > I have a page where the user will select a template from a list and I > > would > > > like to be able to give them thumbs to associate with the template > > types. > > > > > > Are you saying you want to create this on the fly each time it's needed? > > > > -- > > BrianGnuPG -> KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys > > Key Server: pgp.mit.edu > > == > > gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC > > GnuPG: http://gnupg.org > > http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC > > Linux Registered User #339825 at http://counter.li.org > > > ** > The contents of this e-mail and any files transmitted with it are > confidential and intended solely for the use of the individual or > entity to whom it is addressed. The views stated herein do not > necessarily represent the view of the company. If you are not the > intended recipient of this e-mail you may not copy, forward, > disclose, or otherwise use it or any part of it in any form > whatsoever. If you have received this e-mail in error please > e-mail the sender. > ** > > -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: alternative to protecting files through http auth.
On Wed, Jan 14, 2004 at 04:17:06PM -0500, Scott Taylor wrote: > > Is there no other way to protect your (non PHP) files than through > authentication? I've been trying to set up a system that will protect > files. Those trying to access the files would only be able to do so > after entering their email address. So I set up a form that submits the > email to my database. But then the problem is: how to access the files? Put the files in a directory somewhere outside the DocumentRoot of the web site in which the PHP code lives. Have the PHP code do whatever "authentication" you want (even if it's just collecting an email address), and upon success, use file() or readfile() or include() or file_get_contents() or equivalent to pull the file contents from their location on the server. Alternately, if you aren't able to create directories or access files outside the DocumentRoot for your site, you can create an unbrowsable storage directory protected with a .htaccess file. If the filesystem permissions are correct, your PHP script will be able to read content from that directory, because PHP code isn't subject to .htaccess rules. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: detecting flash in php
On Fri, Jan 09, 2004 at 01:11:38PM +0800, Louie Miranda wrote: > > is there anyway of detecting flash? in php Not really. But you're not completely out in the cold. Note that PHP runs on the server, so any test you do has to be offloaded to the client side. Use Javascript for this. Use MING to build your Flash content. :) <!-- FlashMode = 0; if (navigator.plugins && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash"]) { var plugin_version = 0; var words = navigator.plugins["Shockwave Flash"].description.split(" "); for (var i = 0; i < words.length; ++i) { if (isNaN(parseInt(words[i]))) continue; plugin_version = words[i]; } if (plugin_version >= 5) { var plugin = navigator.plugins["Shockwave Flash"]; var numTypes = plugin.length; for (j = 0; j < numTypes; j++) { mimetype = plugin[j]; if (mimetype) { if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1)) FlashMode = 1; // Mac wierdness if (navigator.mimeTypes["application/x-shockwave-flash"] == null) FlashMode = 0; } } } } } if (FlashMode == 1) { // do your flash stuff... For example: document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-44455354" codebase="<a href="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0"">http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0"</a>;>\n'); document.write('<param name=movie value="<a href="http://yourdomain.ca/foo.swf"">http://yourdomain.ca/foo.swf"</a>;><param name=quality value=high><param name="BGCOLOR" value="#EE"><param name="salign" value="tl"><param name="menu" value="0">\n'); document.write('<embed src="<a href="http://yourdomain.ca/foo.swf"">http://yourdomain.ca/foo.swf"</a>; quality=high pluginspage="<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"">http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"</a>; type="application/x-shockwave-flash"></embed>\n'); document.write('</object>\n'); } else { document.write("<p>Sorry, this page requires Flash."); } // --> Sorry, this page requires JavaScript -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counting back 90 days...
On Mon, Jan 05, 2004 at 09:51:33AM -0500, Eric Wood wrote: > > In Business Basic I use Julian Dates: > http://www.basis-documentation.com/commands/jul_function.htm. > > This lets me easily calculate days between dates just by substracting > integers. Why has PHP made dates more difficult? Unix timestamps have been around since unix began, and strtotime supports arbitrary human-readable formats. PHP supports both of these. How does PHP make dates more difficult? -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counting back 90 days...
Richard Davey <[EMAIL PROTECTED]> 05/01/2004 11:45: > > Based on the current time: > $previous_90_days_timestamp = strtotime ("-90 day"); > All in one: > $previous_90_days_date = date("Y-m-d", strtotime("-90 day")); On Mon, Jan 05, 2004 at 11:55:36AM +, [EMAIL PROTECTED] wrote: > > My word... > 6 odd lines, to one... Beware timestamps, though. They usually won't work for dates before 1970 or after 2038. If you suspect you'll need to use dates outside that period (for example, show the 90 days of as of some date in 1969), your results may be unpredictable. For example, strftime("%+",0) returns "Wed Dec 31 19:00:00 EST 1969" in my timezone, and strftime("%+",-1) returns a blank. Yet, doing a strtotime("1969-12-31 23:59:59 GMT") will get you a -1, and the date() function appears to support negative timestamps ... which means you can't skimp on your testing if you decide to go this route. ;-) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What would the best way to veladate a URL string?
On Sun, Dec 14, 2003 at 11:23:25AM +1300, Philip J. Newman wrote: > > What would the best way to veladate a URL string? Validate? How about something like: eregi('^(f|ht)tp://([a-z0-9._:-]+@)?([a-z0-9][a-z0-9-]+\.)+[a-z][a-z]+(/([a-z0-9.%&=-]+)?)?',$string); You can adjust the "get" part to suit... -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] wrong headers from server
This may be a curl question, but it may not I have a script through which I'm trying to push all images. The push happens using mod_rewrite: RewriteRule ^/(.+\.(gif|jpg|jpeg|png))(\?.*)?\$ /inc/script.php?f=$1 [NC,L,PT] Oddly, when hitting the script from a command line, I get different results depending on how it's called: > curl -D- http://hostname/test.jpg | grep Content- Content-Type: text/html > curl -I http://hostname/test.jpg | grep Content- Content-Type: image/jpeg What's going on here? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: easier than switch
On Mon, Aug 04, 2003 at 11:19:42PM +0100, skate wrote: > > i have several forms on one page, they all submit a different variable, i then want > to set one variable depending on that... okay, now i'm confusing myself, lets try > explain it with some code... > > if(isset($_POST)) > { > $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] || $_POST['words'] > || $_POST['chat']; > } You have a single page, containing multiple forms, all of which share the same action? What about putting a hidden variable into each form to provide an authoritative reference to which form was posted? Then, if processing unique to each form can be done with: if ($_POST['func']=="thisone") { // fooblah } else if ($_POST['func']=="thatone") { // barblah } else if ($_POST['func']=="another") { // otherblah } else { die("Form hacking detected"); } And you can do things with the content of $_POST['func'], like this: $typelist=array( 'thisone' => "This is one", 'thatone' => "That is one too", 'another' => "Another one here", ); $type=$typelist[$_POST['func']]; Is that long the lines of what you're looking for? -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: subtracting dates...
On Sat, Aug 02, 2003 at 08:30:34PM +0100, John Ryan wrote: > > In mySQL, I store dates as -MM-DD, a standard DATE type. It stores users > date of births. I need to calculate in a PHP script, the users age from this > DOB. I get a PHP date in the same format as the mySQL and subtract, which > returns the year rounded off. ie, it doesnt matter if your birthdays in june > of 1983 and the date is januray 2003, your age is still returned as 20, when > it should be 19. The function you're probably looking for is floor(). > Does anyone know how can i get the right age? One quick way would be simple subtraction: $old = "1973-06-02"; $new = "2003-08-02"; $year = 60*60*24*365.25; // seconds in a year $age = strtotime($new) - strtotime($old); print "Age in years: " . floor($age / $year) . "\n"; But you'll run into infrequent problems surrounding leap years. I'm sure there's a more accurate way to do this, perhaps even using MySQL's somewhat more advanced (and less timestamp-centric) date calculation functions, but this is what I can come up with on short notice. Note that strtotime will give NEGATIVE TIMESTAMPS for dates earlier than Jan 1st 1970 at midnight GMT, so this still works for folks over 33. ;) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Hi
On Tue, Jul 22, 2003 at 11:42:04AM +0300, Rausch Alexandru wrote: > From: "Rausch Alexandru" <[EMAIL PROTECTED]> > Subject: Hi > > MYSQL problems problems. > I want to install an user login aplicationa on my site, but it is intarely in FLASH. > ( www.poker.club66.ro ). > What do u think? I think this doesn't sound like a problem with "Hi", as your subject line indicated. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to..
On Tue, Jul 22, 2003 at 04:08:35AM +0500, Haseeb wrote: > >i like keeping all the functions in one file and the >include the file whenever i need any function. ... >some programmer that prefer to use only one file as front end and place >switch or if conditions and include other files depending on the condition. ... >divide the functions into files. and then include only that file >that has the function. I do a little of all three, myself. But, it depends on the project. If the project is small enough, a single function file will do. I start to segregate functions by category when I see logical divisions between the functions. (I.e. billing things, statistical things, etc.) Then I choose which function libaries to call based on whatever criteria I have on hand -- usually user input. Often it's simpler than that -- a project could have a "billing.php" script that calls "functions-billing.php", and "stats.php" that calls "functions-stats.php". And if a particular billing function wants to use something out of stats, it can simply include that library. Another thing I've done from time to time (though I wouldn't recommend it) is name your function library after a variable that's used to denote the part of the program you're running in. For example: if (ereg('^[a-z]+$',$sect)) @include("functions-" . $sect . ".php"); That way, you're basing your include on something that you're already managing, perhaps as a form or session variable. YMMV. Don't forget to do your sanity checking. This method may be prone to security problems. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: running SSH through a PHP script
On Fri, Jul 18, 2003 at 11:29:50AM -0400, [EMAIL PROTECTED] wrote: > There is no delay in the SSH commands when run from a shell, only > through the web page. Any ideas? What user is running the ssh commands? Does that user have a home directory to which it has write permissions in order to create a ~/.ssh/ directory in which to store host keys? The ssh key negotiation will always take a certain amount of time. If all three ssh commands are to the same remote host, you should consider stringing them together on a single command line, so that you only have to run ssh once. $result = `/usr/bin/ssh [EMAIL PROTECTED] "cd /some/path/ && ./do_something && ./do_something_else"` Note: this is one of those cases where you should be ULTRA careful about user input. If your ssh command includes any variables that have been posted in a form, do extensive format checks on them. Usernames should always match ^[a-z0-9]+$ . Nothing being used in the ssh command should be allowed to have [;&|] in it. Be so anal and paranoid that you risk compromising functionality, and you're less likely to screw yourself. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mail From option in PHP.ini
On Fri, Jul 18, 2003 at 11:00:18AM -0400, Brian S. Drexler wrote: > > Ok, I want to specify who the mail is coming from by using the sendmail_path > option in the PHP.ini. I've added the [EMAIL PROTECTED] to it, but I want > to be able to dynmaically change [EMAIL PROTECTED] to [EMAIL PROTECTED] or > whatever else. Anyone have any ideas how I can do this? I'm pulling the > e-mail I'd like to change it to from a MySQL database but can I rewrite the > php.ini file on the fly or am I stuck. Any help is greatly appreciated. You can't change the Return-Path header, because it's not set by the sender. It's added by the *receiving* mail server, and reflects the from address in the SMTP envelope, rather than anything in the headers of the message itself. It sounds heinous, but one solution might be to make your sendmail_path a *wrapper* that will look at certain environment variables and come up with a -f option with which to launch sendmail. I don't recommend this solution. Another possibility might be to run PHP inside FastCGI and use suexec. If the PHP script is being executed this way, I would think that any sendmail processe launched would have the username in the envelope-from. You also might get a performance gain by doing things through FastCGI, though you'd lose some of the module-specific features like persistent database connections. Worth testing, anyway. Let us know how it goes. :) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How unsafe is register_globals?
But those are APACHE directives. What I'm looking for is finer-grained control over what php_flag lines will be accepted. A quick test wrapped in a APPEARS not to be at risk, but I'd rather get confirmation of this before I rely on it. Can someone confirm that mod_php4 will not allow safe_mode and open_basedir to be altered by php_flag lines in .htaccess files? Thanks. On Thu, Jul 17, 2003 at 07:19:19AM -0700, Mark wrote: > > http://httpd.apache.org/docs-2.1/mod/core.html#allowoverride > > You can indicate which directives can be overrriden, and which > cannot. > > --- Paul Chvostek <[EMAIL PROTECTED]> wrote: > > On Thu, Jul 17, 2003 at 01:56:57PM +0800, Jason Wong wrote: > > > > > > > > gets the error "php_flag not allowed here". I see from the > > comments at > > > > http://www.php.net/register_globals that I need AllowOverride > > Options to > > > > make that function ... but is it possible to have fine-grained > > enough an > > > > AllowOverride statement that only register_globals can be > > changed? > > > > > > > > I wouldn't want a user to use his .htaccess file to turn off > > safe_mode > > > > or open_basedir. > > > > > > Take control of the setting yourself by setting it httpd.conf, > > inside the > > > container of the virtual host in question. > > > > Not so easy with mod_vhost_alias, given that I want it to apply > > only to > > certain users, and possibly only for directories for those users. > > > > The .htaccess solution is the right one unless "AllowOverride > > Options" > > allowed the user to turn off safe_mode and open_basedir. I don't > > have a > > non-production machine to test it on at the moment. > > > > Any idea how I give the user local register_globals control without > > also > > letting them alter the other php.ini options? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How unsafe is register_globals?
On Thu, Jul 17, 2003 at 01:56:57PM +0800, Jason Wong wrote: > > > > gets the error "php_flag not allowed here". I see from the comments at > > http://www.php.net/register_globals that I need AllowOverride Options to > > make that function ... but is it possible to have fine-grained enough an > > AllowOverride statement that only register_globals can be changed? > > > > I wouldn't want a user to use his .htaccess file to turn off safe_mode > > or open_basedir. > > Take control of the setting yourself by setting it httpd.conf, inside the > container of the virtual host in question. Not so easy with mod_vhost_alias, given that I want it to apply only to certain users, and possibly only for directories for those users. The .htaccess solution is the right one unless "AllowOverride Options" allowed the user to turn off safe_mode and open_basedir. I don't have a non-production machine to test it on at the moment. Any idea how I give the user local register_globals control without also letting them alter the other php.ini options? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How unsafe is register_globals?
On Wed, Jul 16, 2003 at 11:42:29PM -0500, Jonathan Villa wrote: > > This is only my stubborn opinion... > > I would turn it on for now with a warning that it will be turned off > soon... At least in my case, it's never been on in the past, and the queries are coming from folks who want me to change it from its current OFF state. > From: Chris Shiflett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 16, 2003 11:22 PM > > So, I would turn it on if I were in your situation, or rather, I would allow > them to override the default settings via a .htaccess file (assuming Apache). Perhaps that's where I need advice. Currently, a .htaccess file with: php_flag register_globals on gets the error "php_flag not allowed here". I see from the comments at http://www.php.net/register_globals that I need AllowOverride Options to make that function ... but is it possible to have fine-grained enough an AllowOverride statement that only register_globals can be changed? I wouldn't want a user to use his .htaccess file to turn off safe_mode or open_basedir. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How unsafe is register_globals?
I've got this new server running with folks from all over uploading PHP code. I don't know all the folks, so I've turned on safe_mode, set an open_basedir to each user's documentroot, and left register_globals at its default. And now I'm getting scads of requests to turn on register_globals from folks who want to run php-nuke and some other established packages that rely on it. I realize that register_globals isn't itself unsafe ... but do the potential insecurities put my server at risk, or only customer data? By turning register_globals on with an otherwise safe open_basedir, are there things that could be revealed about the server that would otherwise be hidden? My instinct says to leave register_globals OFF, and if folks want to run software that requires it, they should lobby the software maintainers to upgrade the software. (But how likely is php-nuke to get fixed?) Thoughts? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: elegant way of doing something else the last time through a loop?
On Mon, Jul 14, 2003 at 01:11:11PM +0200, Petre Agenbag wrote: > > HI list Hi Petre. > I want to search through a table by "exploding" the search string and > then compounding my own sql string by working through the array. I do alot of this. I have a solution which offloads the slight extra CPU onto the database server, while simplifying the PHP code a little. > the if statement inside the loop is > meant to "strip" out "the" and "and", meaning that it won't much help to > use that approach anyway. I've got a more flexible way of doing that too. How about this: $sql = "SELECT * FROM $table_name WHERE "; if ($_POST['any_all'] == 'ANY') { $logic = 'OR'; $sql .= '1=0'; } elseif ($_POST['any_all'] == 'ALL') { $logic = 'AND'; $sql .= '1=1'; } else die ('form hacking detected'); // protect from nasty user input $string = ereg_replace( '[^a-z0-9]+', ' ', strtolower($_POST['text']) ); $skip = array( 'the' => 1, 'and' => 1, 'a' => 1, ); foreach (explode(' ', $string) as $val) { if (!$skip[$val]) { $sql .= $logic . " name like '%$val%'"; } } $sql .= ' ORDER BY name'; -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mailing list server with PHP frontend
On Sat, Jul 12, 2003 at 08:17:03PM -0300, Manuel Lemos wrote: > > You may want to try this class for creating lists with the ezmlm mailing > list manager. It has support for creating and editing the lists > properties and even has a SOAP interface for accessing the subscriptions > from remote machines. The ezmlm package has a number of problems that make it really annoying to deal with; it has its own way of interpreting message headers which isn't much related to any RFC. The primary problem is the fact that it considers the "Return-Path" header (i.e. the envelope sender) to be the authoritative address of the sender, superceding the From and Reply-To headers. The only way around it is to "spoof" the envelope sender, thereby falsifying your headers. Gahgh. Now ... if you were to write a class to manage Mailman configs ... that would be useful. ;-) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mind exploded on this one!
On Fri, Jul 11, 2003 at 02:21:42PM -0400, Phil Powell wrote: > > $booleanNonFormVars = array('hasSelectedLetter', 'hasEnteredProfile', > 'hasSelectedProfile', ... > $booleanVars = array('profileID', 'showemail', 'showbirthday', 'season', > 'profilememberid'); > $profileVarArray = array('firstname', 'lastname', 'city', 'state', 'country', > 'favebands', ... > $profileNonFormVarArray = array('profileName', 'letter', 'name'); > $arrayListArray = array('booleanNonFormVars', 'booleanVars', 'profileVarArray', > 'profileNonFormVarArray'); > > Bluntly put, I need to get: > $hasSelectedLetter > $letter What exactly are you hoping to get out of this? What's suposed to be the eventual content of the $hasSelectedLetter variable? Are these really how the arrays get set up, or is it really more like: $booleanNonFormVars = array( 'hasSelectedLetter' => 'somevalue', 'hasEnteredProfile' => 'anothervalue', ... ); ? If so, you could take advantage of the fact that this is an interpreted language, and do something like this: foreach ($booleanNonFormVars as $key => $value) ${$key} = $value; foreach ($booleanVarsas $key => $value) ${$key} = $value; foreach ($profileVarArrayas $key => $value) ${$key} = $value; etc. Alternately, if $booleanNonFormVars are things for which you're just trying to test existence, you could: foreach ($booleanNonFormVars as $value) ${$value} = true; foreach ($booleanVarsas $value) ${$value} = true; Is either of these approaches what you're after? -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression
On Tue, Jul 08, 2003 at 06:47:26AM -0500, Wendell Brown wrote: > > I think this would do better... > > if( preg_match( "/P[\. ]*O\.* +BOX/i", $address ) ) Unless preg_match does something non-standard, you don't need to escape a period that's inside square brackets. In fact, the regexp you've built will also match an $address of "p\o box". -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: what's wrong with this?????
On Tue, Jul 08, 2003 at 11:26:52AM -0400, Artoo wrote: > > I keep getting Parse error: parse error, unexpected T_LNUMBER in > /usr/local/psa/home/create.php on line 9 > > This is line 9, which should just create a table. > > $result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL > AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50) NOT > NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL, > password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL, > date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table > Error: ".mysql_error()); > > What's that error mean and is that CREATE TABLE query correct? The CREATE TABLE is correct, but look at your ENUM values and DEFAULT. What kind of quotes are you using? How do you think they should be interpreted? For easier reading, let's split up the query $q = 'CREATE TABLE members (userid INT() NOT NULL AUTO_INCREMENT, ' . 'first_name VARCHAR(30) NOT NULL, ' . 'last_name VARCHAR(50) NOT NULL, ' . 'email_address VARCHAR(255) NOT NULL, ' . 'username VARCHAR(30) NOT NULL, ' . 'password VARCHAR(30) NOT NULL, ' . 'activated ENUM("0","1") DEFAULT "0" NOT NULL, ' . 'date_joined DATETIME NULL, ' . 'last_login DATETIME NULL)'; $result = mysql_query($q) or die("Create table Error: ".mysql_error()); It's a heck of alot easier to see errors when you space things out a bit. The investment of the extra CPU time for PHP to glue the pieces together probably makes sense in the long run. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: script not stopping
> "Paul Chvostek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Mon, Jul 07, 2003 at 03:28:27PM -0600, Micah Montoy wrote: > > > > > > if ($_POST["imgList"] = ""){ > > > > You're *assigning* a variable in this condition. On Mon, Jul 07, 2003 at 04:02:21PM -0600, Micah Montoy wrote: > > How do I specify it that I just want to check to see if the form field was > blank and if so, inform the user? if ( !isset($_POST["imgList"]) ) { } or if imgList is a text string, you could safely punt with: if ( $_POST["imgList"] == "" ) { } >I know I could do this with JavaScript > but I need to be able to do correct conditions. What do you mean by "correct"? Why can't you do this in JS? (Note that even if you do it in JavaScript, you should *still* do it in PHP, to support all browsers. These days, quite a few corporate networks force web traffic through proxies that block JavaScript, cookies and sometimes even Flash.) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: script not stopping
On Mon, Jul 07, 2003 at 03:28:27PM -0600, Micah Montoy wrote: > > if ($_POST["imgList"] = ""){ You're *assigning* a variable in this condition. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] security question
Can anyone think of any security caveats with regard to turning output_buffering on? I can't, but it's too hot to think straight these days Tnx. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Database question
On Thu, Jul 03, 2003 at 07:00:17AM -0700, Hardik Doshi wrote: > > Currently i am connecting the underlying database > server from every php page. To reduce the connection > overhead i am thinking to store the PEAR DB object > into the registry (session) at the time of user login. > Here i am connecting the Database only one time and > rest of the time i am using the object stored in the > memory. Nice as it sounds, this won't work. I don't recall where it's documented, but at least with MySQL (and I'm assuming with the others as well), a database link identifier cannot be stored in a session variable and then re-used by another session. Check out http://www.php.net/features.persistent-connections for details. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] online file management
On Wed, Jul 02, 2003 at 05:26:26PM -0500, Dean E. Weimer wrote: > > > > The ideal candidate would authenticate based on a MySQL table and would > > be able to handle multiple users with unique base directories. I'd > > rather not use an PHP-based FTP client, but I'm open to that if nothing > > else is available. > > Try http://www.wonko.com/notftp/ if you want a ready to use PHP Based FTP > client, If you are running on Unix or Open Source there should be FTP > servers available that can authenticate through MySQL. Thanks very much for the link. It's unfortunate that NotFTP *is* in fact an FTP client, rather than not one. :-/ I really don't want to have to maintain a set of FTP accounts if I can avoid it, but I may look to NotFTP for "inspiration" on a user interface for my own tool. > > Before I write one myself, is there a package that has already been > > built that any one can recommend (or recommend against)? > > I tried this recently, But I discovered that this leaves users directories > rather insecure. At least when being used on a web server where users > could upload PHP scripts, since there is nothing to stop them from > uploading scripts that modify other users files. This can be solved neatly by use of open_basedir. Users' scripts can only read files according to limitations that I set on the server. And another option of course is to store all files in blobs in db table. I wouldn't do it for anything high traffic, but for cases where a file will be uploaded once and downloaded once or twice then deleted, I won't have to deal with ongoing performance issues. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safe_mode and file/directory ownership
Jason, safe_mode_gid may indeed be the solution, though it seems to go way too far in relaxing things. It's the functionality of safe_mode that I want ... with the proviso that the web server should be able to read files that it writes. I will not consider turning off safe_mode entirely, any more than I will consider giving customers shell access to my servers. That would seem to be foolhardy. But that may just be the paranoia talking. p On Tue, Jul 01, 2003 at 10:19:01PM -0700, Jason Sheets wrote: > > Take a look at safe_mode_gid, it tells PHP to do safe mode owner > checking using the group id rather than user id. > > safe_mode_gid boolean > > By default, Safe Mode does a UID compare check when opening files. If > you want to relax this to a GID compare, then turn on safe_mode_gid. > Whether to use UID (FALSE) or GID (TRUE) checking upon file access. > > http://www.php.net/manual/en/features.safe-mode.php > > Other than that consider turning off safe mode if you have access to it, > or turn it off for your virtual host. > > Paul Chvostek wrote: > >I've got a script whose configuration creates a storage directory owned > >by the web server in which files get stored, also owned by the web > >server. With safe_mode in effect, I'm getting errors like: > > > > Warning: file_exists() [function.file-exists]: SAFE MODE Restriction in > > effect. The script whose uid is 10054 is not allowed to access > > /path/to/some/data owned by uid 80 in /path/to/some/file.php on line 111 > > > >Wouldn't it make sense for safe_mode also to allow read access to files > >owned by the web server's process as well as the directory owner's? > > > >Obviously, a process running as uid 80 won't be able to suid to another > >user. If I make the directory owned by the user, the files will be > >inaccessible, but if I make the directory uid 80, then *it* will be > >inaccessible. > > > >Is there some other solution to storing (and then retrieving) files with > >safe_mode on? -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] online file management
> - Original Message - > From: "Paul Chvostek" <[EMAIL PROTECTED]> > > > > I'm looking for a tool that will allow online file management, with a UI > > something like that of a traditional FTP client. > > > > The ideal candidate would authenticate based on a MySQL table and would > > be able to handle multiple users with unique base directories. I'd > > rather not use an PHP-based FTP client, but I'm open to that if nothing > > else is available. On Tue, Jul 01, 2003 at 09:44:01PM -0600, Suhas Pharkute wrote: > > I have developed a package which is exactly same what you explained here. It > is PHP-MySQL (Windows/Linux)combination. I have another older version which > was PHP-MSAccess (Windows). If you want I can give you logins for test > purposes. > > This system is currently in use. I have to creat identical system for you on > another server. Please let me know if you are interested in this. I'm interested in an established package with support by the user community, not a package with source distribution restrictions and prohibitive licensing fees. If you release your software for public review, I'll happily consider it. Otherwise, I guess I'll write my own -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] safe_mode and file/directory ownership
I've got a script whose configuration creates a storage directory owned by the web server in which files get stored, also owned by the web server. With safe_mode in effect, I'm getting errors like: Warning: file_exists() [function.file-exists]: SAFE MODE Restriction in effect. The script whose uid is 10054 is not allowed to access /path/to/some/data owned by uid 80 in /path/to/some/file.php on line 111 Wouldn't it make sense for safe_mode also to allow read access to files owned by the web server's process as well as the directory owner's? Obviously, a process running as uid 80 won't be able to suid to another user. If I make the directory owned by the user, the files will be inaccessible, but if I make the directory uid 80, then *it* will be inaccessible. Is there some other solution to storing (and then retrieving) files with safe_mode on? Thanks. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] online file management
Hiya. I'm looking for a tool that will allow online file management, with a UI something like that of a traditional FTP client. The ideal candidate would authenticate based on a MySQL table and would be able to handle multiple users with unique base directories. I'd rather not use an PHP-based FTP client, but I'm open to that if nothing else is available. Before I write one myself, is there a package that has already been built that any one can recommend (or recommend against)? Thanks. :-) -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: WEB HOST
On Tue, Jun 24, 2003 at 01:43:02PM +0200, Denis 'Alpheus' Cahuk wrote: > > THe host is good, but buggy. > I cant install pre-made scripts (like the phorum or phpBB) and I can't > access to phpMyAdmin and cant change my password anymore, and cant even > cancel I *did* say it was under construction. I haven't yet written the scripts to cancel or do automatic software installation yet. They're on the menus so folks can see what's coming. You should be able to get into phpMyAdmin, but it can take a minute for your password to be updated after you confirm the account. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: WEB HOST
On Tue, Jun 24, 2003 at 10:22:06AM +0200, Denis 'Alpheus' Cahuk wrote: > > I need a php4 web host with MySQL. > It has to be free and there should be no ads or pop-ups. > I should be allowed to show my own ads on my page. What incentive does a company have to provide service like this? We have a free hosting package, and we don't do pop-ups, but every page is watermarked, so it acts as advertising for us. If you don't consider that an "ad", then feel free to visit http://www.it.ca/web/ and sign up. The management software is still a little under development, so this package will work better if you have enough technical ability to install your own software. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Performance question
On Mon, Jun 23, 2003 at 08:09:57AM -0700, Hardik Doshi wrote: > > Hi Group, Hi Hardik. > I have a question regarding retrieving the > information. I have the functionlity in which on every > user click, system needs to retrieve information for > particular user and display the page according to the > retrieved information. Now question is which is the > scalable solution? (1) Retrieve information from the > database on each user click. (2) Retrieve information > from the session (here information is retrieved once > and stored in the session file on the server, when > user logs into the system) I'd go for (2). Try to avoid constant database lookups if you don't really need them. The database server takes alot more resources to find a piece of data than mod_php4 takes to pull it out of a session file. Even data stored in cookies can be moved to session variables for use by the session. If page views then do not require database cycles *or* repeated cookie-based network traffic, you save both CPU and bandwidth. And the session data goes away when the session is destroyed. Anything you can do to save CPU and bandwidth is good. Unless you own shares in Intel and Cisco, of course. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sending headers
On Mon, Jun 23, 2003 at 04:26:40PM +0200, Petre Agenbag wrote: > > I am having trouble using headers. > > I try to include a redirect header in my script, but is fails with the > familiar ( headers already sent) error. > > I KNOW you should put the headers call where it will cause the first > output, and I do that, the only thing happening infront of the headers > call is an include statement to my main db class; this class has > absolutely NO output unless a function is called (which it is not)... > > What am I missing? I assume your database inclusion script is spitting out something you didn't intend it to. It could be as simple as an extra blank line after your closing '?>'. To find out what's going on, use a command line like: curl -D- http://hostname/path/to/script.php | more Assuming you have curl installed of course. If not, try looking at your script output through http://samspade.org/t/safe . -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Another hosting question....
On Wed, Jun 18, 2003 at 07:52:21PM -0400, Mike Morton wrote: > > What I am looking for specifically is a company that someone can recommend > from direct experience, one that is customer friendly, offers dedicated > servers at a REASONABLE price, offers admin support and server support, etc, > etc, etc, and most importantly has expertise in compiling PHP. > > If anyone out there know of a company like this and can recommend them - I > would appreciate it :) It will save literally hours and hours of sorting > through the google listings that a php dedicated hosting search brings > back! (2 days of sorting to this point anyhow!) I would tout my own company, but we focus more on co-location of customer-provided equipment rather than server rental. So I'll tout the competition and throw http://prioritycolo.com/ into the fray. The guy who owns and runs it is friendly, honest and highly knowledgeable, the upstream connectivity is fast and reliable (though not multihomed AFAIK). The servers are FreeBSD with CPanel (unless you specifically require something else), and the prices are excellent. Plus, he's local. :-) His cage is at 151 Front, just down the hall from mine. -- Paul Chvostek <[EMAIL PROTECTED]> it.canadahttp://www.it.ca/ Free PHP web hosting!http://www.it.ca/web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Automatic Headers and Footers
On Mon, Jun 09, 2003 at 12:26:24PM -0500, Wendell Brown wrote: > > > >OK, another waythe HTML could be read into a page (fopen()) > >containing the header/footer stuff. You'd have to deal with > >identification of which page you want loaded, but shouldn't be too hard. > > Here is what I ended up doing > > http://marc.theaimsgroup.com/?l=php-general&m=105484835424858&w=2 That works. I did something similar, not to add headers and footers, but to implement a simple templating system -- the HTML pages had text like __FIRSTNAME__ and __LASTNAME__ which had to be replaced with session variables. The site owner had some very strange ideas about how they wanted to design their site, and wanted to do the whole thing in FrontPage, yet customize pages using data from a PHP-based login. The basic idea is that the customer uploads pages (a few hundred of 'em) all under their DocumentRoot. I've got stuff like: $base="http://www.example.com";; // URL *without* trailing backslash $qu="'" . '"'; $href="( and , as you did with output buffering. I'm not sure if either solution has a performance edge over the other. In both cases, each of the HTML and PHP file get loaded once per page view, and whether the translation happens in PHP's output buffering or via mod_rewrite is probably insignificant. As always, multiple solutions to every problem. :) -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cannot execute... Cron jobs
Scott Holmes wrote: > I'd just like to interject here that I execute php code from cron and > I do not have php compiled as a cgi. I use lynx. Here is a sample of > what I'm doing to e-mail a weekly newsletter to a membership database: > > #!/bin/sh > LYNX_TEMP_SPACE=/tmp > TMPDIR=/tmp > TERM=vt100 > lynx -dump http://localhost/WFCC/mail_ltrs.php On Thu, Mar 13, 2003 at 12:20:38AM -0500, Leif K-Brooks wrote: > > You can do that, but it's much less secure. I'd love to know where you see the security problem. If Scott is paranoid, he can run a separate instance of his web server that binds only to 127.0.0.1, but even if the script is publically runable, it can check HTTP_HOST and REMOTE_ADDR before doing anything critical. Scott never mentioned the rest of his setup; judging its security is premature. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking for a Valid Email String.
The original question was regarding email addresses, not usernames. If an ISP has a policy of requiring each left-hand-side of an email address to be a username, that ISP has a serious problem. On Wed, Mar 12, 2003 at 02:42:04PM +1300, Philip J. Newman wrote: > > how ever i don't think most ISPs let users pick names with the + sign in it > > > Don't forget plus signs. When providing email addresses to lists and > > web sites, I regularly tag my address (as the From address on this > > message demonstrates). Using procmail for local delivery allows these > > addresses to be delivered to my account, and I can more easily track > > down the origin of "tagged" spam. When I come across a web site or list > > that doesn't allow my address with a plus sign, I find another site or > > list. So I use: > > > > function isvalidemail($what) { > > if > (!eregi('[a-z0-9][a-z0-9._=+-]*@([a-z0-9][a-z0-9-]*\.)+[a-z][a-z]+$',$what)) > return(false); > > list($user,$domain) = explode("@",$what); > > if (!getmxrr($domain,$mxhosts)) return(false); > > if (!count($mxhosts) > 0) return(false); > > return(true); > > } -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking for a Valid Email String.
> On Wed, 12 Mar 2003, Philip J. Newman wrote: > > > Required: Help for checking for a valid email string. On Tue, Mar 11, 2003 at 08:19:36PM -0500, David E.S.V. wrote: > > you mean something like this? > > //checking if the email is valid > > if (eregi("^[0-9a-z]([-_.]?[0-9a-z])[EMAIL > PROTECTED]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email, $check)) > { > if ( !getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) > $mensaje="server not valid"; > > // checking DNS > if(!checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY")) > $mensaje="server not valid"; > > } Don't forget plus signs. When providing email addresses to lists and web sites, I regularly tag my address (as the From address on this message demonstrates). Using procmail for local delivery allows these addresses to be delivered to my account, and I can more easily track down the origin of "tagged" spam. When I come across a web site or list that doesn't allow my address with a plus sign, I find another site or list. So I use: function isvalidemail($what) { if (!eregi('[a-z0-9][a-z0-9._=+-]*@([a-z0-9][a-z0-9-]*\.)+[a-z][a-z]+$',$what)) return(false); list($user,$domain) = explode("@",$what); if (!getmxrr($domain,$mxhosts)) return(false); if (!count($mxhosts) > 0) return(false); return(true); } -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Enabling HTTP_REFERER
Check out http://www.it.ca/software/noleech-light It can still be circumvented by a sophisticated leech, since the REFERER field is supplied by the client, but I've got another one I wrote which gets used in conjunction with another script to dynamically build references to files that expire after a period of time, so that if someone tries to load a file more than a few minutes after loading the page that points to it, the download will fail. I'm not distributing that one publically, but it can be available privately for a fee. p On Tue, Mar 11, 2003 at 03:29:39PM -0500, Stephen wrote: > > I think that solves all my problems then. I was doing a redirect. > Could that be causing the problem? How else could I overcome this problem? > I'm trying to make a good anti leech system. > > Thanks, > Stephen Craton > http://www.melchior.us > > > ----- Original Message - > From: "Paul Chvostek" <[EMAIL PROTECTED]> > To: "Stephen" <[EMAIL PROTECTED]> > Cc: "Niels Andersen" <[EMAIL PROTECTED]>; "PHP List" <[EMAIL PROTECTED]> > Sent: Tuesday, March 11, 2003 1:02 PM > Subject: Re: [PHP] Re: Enabling HTTP_REFERER > > > > Niels was right on the money. > > If you just typed the URL in the address bar, then HTTP_REFERER will not > be set. For that variable to be set, you must visit the URL as a result > of clicking a link on another page. > > p > > On Tue, Mar 11, 2003 at 12:27:15PM -0500, Stephen wrote: > > > > Yes, and I tried going by just typing the URL in the address bar. > > > > Either way, the HTTP_REFERER variable should have atleast appeared in the > > print_r() function I ran. > > > > Thanks, > > Stephen Craton > > http://www.melchior.us > > > > > > - Original Message - > > From: "Niels Andersen" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Tuesday, March 11, 2003 7:57 AM > > Subject: [PHP] Re: Enabling HTTP_REFERER > > > > > > I don't mean any disrespect, but I just want to check that the basics are > > OK, sometimes I forget stuff like that myself: Did you click a link to go > to > > your test page? > > > > "Stephen" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > For some reason my webhost doesn't allow the HTTP_REFERER variable. I call > > it up and it's empty, so I did a print_r($HTTP_SERVER_VARS); and there > > wasn't a variable called HTTP_REFERER. I've heard that some servers > disable > > it. Since I have a dedicated server, how can I enable this variable again? > > -- > Paul Chvostek <[EMAIL PROTECTED]> > Operations / Abuse / Whatever > it.canada, hosting and development http://www.it.ca/ > > > -- > 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 -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Enabling HTTP_REFERER
Niels was right on the money. If you just typed the URL in the address bar, then HTTP_REFERER will not be set. For that variable to be set, you must visit the URL as a result of clicking a link on another page. p On Tue, Mar 11, 2003 at 12:27:15PM -0500, Stephen wrote: > > Yes, and I tried going by just typing the URL in the address bar. > > Either way, the HTTP_REFERER variable should have atleast appeared in the > print_r() function I ran. > > Thanks, > Stephen Craton > http://www.melchior.us > > > - Original Message - > From: "Niels Andersen" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, March 11, 2003 7:57 AM > Subject: [PHP] Re: Enabling HTTP_REFERER > > > I don't mean any disrespect, but I just want to check that the basics are > OK, sometimes I forget stuff like that myself: Did you click a link to go to > your test page? > > "Stephen" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > For some reason my webhost doesn't allow the HTTP_REFERER variable. I call > it up and it's empty, so I did a print_r($HTTP_SERVER_VARS); and there > wasn't a variable called HTTP_REFERER. I've heard that some servers disable > it. Since I have a dedicated server, how can I enable this variable again? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: seperate streetname from number
On Tue, Mar 11, 2003 at 05:17:52PM +0100, André Sannerholt wrote: > Hi everyone! Hi André. > I wondered how to sepearate string variables that contain streetnames and > numbers: > > If for example > $variable="Hauptstraße 15"; > > $variable_string[0] should be "Hauptstraße" > $variable_string[1] should be "15" > > So I need a function that recognizes a number and explodes the variable at > that very position. > It's important that the thing also works when $variable="Hauptstraße15"; > without any space. Else it would have been easy to do with the explode > function... You probably also want the function to recognize addresses in which the number precedes the street name (Canada, US, Britain, etc). You also want to support multiple-word streetnames, which would not work if you explode using a space as seperator. This is untested: function splitstreetaddress($what) { if (ereg('[^0-9][0-9]+$', $what)) { $temp = ereg_replace('(.*[^0-9])([0-9]+)$','\\1__\\2', $what); list($name, $number)=explode('__', $temp); } else if (ereg('^[0-9]+', $what)) { $temp = ereg_replace('^([0-9]+)(.*)','\\1__\\2', $what); list($number, $name)=explode('__', $temp); } else { $name=$what; $number="" } $retval[0]=trim($name); $retval[1]=trim($number); return $retval; } -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how do I strptime?
I currently do this: $raw="Nov 28 18:26:35 2002"; $when=`date -jf '%a %b %e %T %Y' "$raw" '+%s'`; when I'd much rather do this: $raw="Nov 28 18:26:35 2002"; $when=strptime($raw, '%a %b %e %T %Y'); which is of course a non-existent function in PHP. I'd like to stop calling a subshell every time I process a date, but I'd also like to avoid jumping through hoops with mktime. Is there a better way? Tnx. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: search script
On Mon, Feb 24, 2003 at 12:40:45PM -0500, Bryan Brannigan wrote: > > Ok, my problem of the day. I need to take a field from a form that has either a > first name, last name or both and then search the database for all records that > match one of those items. The problem, the database only has one field for the > name.. where both the first and last name are stored. > > Is there anyway I can do this? Sure, depending on your database. In MySQL, you could use something like the INSTR() function, making your query something like: SELECT * FROM table WHERE INSTR(fullname,'$fname') > 0 OR INSTR(fullname,'$lname') > 0; or in PostgreSQL, which I believe doesn't have an INSTR function: SELECT * FROM table WHERE POSITION('$fname' in fullname) > 0 OR POSITION('$lname' in fullname) > 0; And to make it case insensitive, wrap the options in LCASE or UCASE. This sort of thing might be more likely to get a quick response on the php-db list, and a more concise response if you include the type of database you're using. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Cron Job help Needed
On Wed, Feb 19, 2003 at 03:36:33PM -0500, Pushpinder Singh Garcha wrote: > > I need to ask you about some resources for "cron" jobs. Please suggest > some online help This isn't really a PHP thing. But you can always read man pages, the documentation that comes with every unix-style operating system. For starters, check: http://www.freebsd.org/cgi/man.cgi?query=cron http://www.freebsd.org/cgi/man.cgi?query=crontab http://www.freebsd.org/cgi/man.cgi?query=crontab&sektion=5 Man pages for operating systems other than FreeBSD are also available via that web interface, in case you need details which are operating system specific. (And if you don't know, you probably don't need 'em.) Most likely you will need unix shell access to set up and maintain your cron jobs. Your local unix system administrator (or consultant) can help with that. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file not opening in internet explorer
On Wed, Feb 19, 2003 at 07:27:02AM -, DIKSHA NEEL wrote: > > hi all, Hi Diksha, > $fp = fopen("\bdoi_change\sundar.html", "w"); Mind your slashes. Is this PHP script running on a unix/Linux box, or in MS Windows? If it's unix, remember that a backslash is *not* the characters used to identify directories. > i am able to write to this file through my php page > filecheck.php and even am able to read the written contents. > > but when i enter http://192.168.0.1/bdoi_change/sundar.html > in my internet explorer address bar, it says the page cannot > be displayed. Remember that from fopen()'s perspective, the root directory is whatever is root to the web server's process. And a URL's root directory is the DocumentRoot directive in your Apache configuration. If you have pointed your DocumentRoot at your operating system's root directory, then the above setup should work, but otherwise, you need to fopen() the file relative to your DocumentRoot. And check your web server's log files. Apache will keep a log of every HTTP request that's made. That log will always tell you exactly what's happening, and where the system is looking for files. > the file permissions are "rw-r-r" No they're not. They might be "rw-r--r--", but not what you put. When you talk about file modes, it's safer to refer to them in octal. So "rw-r--r--" would be 644, and "rw-rw-rw-" would be 666. Less confusion. p -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pro-rated date
Anybody have a quick way of determining the number of days remaining in the current month? I'm currently using: $nextmonth = strftime("%Y-%m-01",strtotime("+1 month")) $monthdays = strftime("%d",strtotime($nextmonth)-86400); $daysleft = $monthdays - strftime("%d",time()); I can obviously compact things into a single line, but it's enormous and offends my sense of esthetics. I was hoping I might be able to feed something funky like "first day of next month" to strtotime, but the gnu date input format isn't quite that flexible. Any advice? Is there an *elegant* way of doing this? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP-based SMS solution
On Wed, Feb 12, 2003 at 09:50:38PM +0800, YC Nyon wrote: > > I am developing a web-based GPS vehicle tracking solution using php. > I'm looking on how php can communicate with a SMSC using Smpp to issue AT > commands. Neat idea. If you've got free SMS and a computer built in to the car already, then why the heck not? I was going to do this once I got my "Empeg Car" unit (ARM CPU and Linux), but never got around to it. If the SMSC is available via IP, then the way to do this in PHP is probably to use an existing SMPP daemon with which PHP communicates using fsockopen(). It should be trivially easy to implement SNPP things and issue AT commands. If you're actually going to have to initiate telephone calls, then you probably want to use PHP only to wrap an existing SNPP client, like Qpage (1), or Hylafax's "sendpage" (2). > Development platform is windows 2000. Of course, I'd do it in some flavour of unix, probably FreeBSD. I wouldn't dream of implementing something like this on a gaming OS. Next, we'll be running SQL servers on our Playstations ;) (1) http://www.freebsd.org/cgi/man.cgi?manpath=ports&query=qpage (2) http://www.freebsd.org/cgi/man.cgi?manpath=ports&query=sendpage -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: issues with ksort()
On Fri, Feb 07, 2003 at 11:09:10AM -0600, Shawn McKenzie wrote: > > What else does ksort() do to the array??? Does it matter that my keys look > like this: '[some-text]'??? > > This works great: > > foreach($myarray as $key => $val) { > echo "$key = $val"; > } > > This gives me a Warning: Invalid argument supplied for foreach(): > > $sortedarray = ksort($myarray); > foreach($sortedarray as $key => $val) { > echo "$key = $val"; > } > > Any ideas??? Inserting a print_r into your test script tells you the problem, as does a closer look at http://www.php.net/ksort . You're assuming ksort()'s return value is the sorted array. It is not. Try something more along the lines of: $testarray=array( "[three]" => 3, "[two]" => 2, "[one]" => 1, ); ksort($testarray); print_r($testarray); -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: regex
On Fri, Feb 07, 2003 at 05:29:49PM +0100, Marian Feiler wrote: > > i have to check if there's a dot in a string, and i need nothing but the > regex pattern for this... tryed a lot, but the dot itself means to matches > all. You can escape the dot either by putting a backslash in front of it or putting it inside square brackets. So: ereg("a.b","aaabbb"); is true, but ereg("a[.]b","aaabbb"); is false. Other "sensitive" characters can also be escaped in this way; the bracket expression [][.^$()|*+?-] matches any of those characters. And to match any *except* those characters, use [^][.^$()|*+?-]. Check the re_format(7) man page for details. If you don't have a unix box handy, check http://www.freebsd.org/cgi/man.cgi?query=re_format . -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Powerpoint presentations?!?
I've been asked to write code that will dynamically generate Microsoft Powerpoint presentations. It has to assemble collections of pages, and possibly substitute a word or phrase here and there (mailmerge style). There doesn't seem to be a published document describing Powerpoint file format or capabilities. The only generation tool I can find is a sourceforge.net project that has no files. The only conversion tools I can find convert FROM powerpoint, not TO it. Heck, I run FreeBSD at home so I can't actually VIEW ppt files. Any advice? Do I tell the customer that it's Flash or PDF or find another developer? I'd *much* rather do this in pdflib or ming, but that may just not be possible -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] listbox problems
On Sun, Feb 02, 2003 at 04:55:08PM -0500, Matt wrote: > > > i have a listbox: > > > > > //connect to db and get query > > mysql_connect("."); > > mysql_select_db("..."); > > $query=mysql_query("select username from users); > > /*finish the listbox*/ > > while($account=mysql_fetch_array($query)){ > > echo "$account[username]"; > > Try: > echo " $selected = ($account['username'] == $_POST['user']) ? 'selected' : ''; > echo $selected; > echo ">{$account['username']}"; > > > } > > ?> > > > > This is good. I've always liked things like this: $query="SELECT ..."; if ($result=mysql_query($q)) { $sel[$user]=" selected"; print "\n"; while ($row=mysql_fetch_array($result)) { printf(" %s\n", $row['id'], $sel[$row['id']], $row['text']); } print "\n"; } -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: printing
On Tue, Jan 28, 2003 at 09:38:09AM +0200, Shaun van den Berg wrote: > > Is there a way in php to print to a printer? say i have a order from , when > someone clicks the submit button - then print the form plus the entered > details to a page ? Are you talking about having a submit button that launches a browser's print dialog, as if the user pressed the print button in their browser, or do you want a user's form submission to cause a printer on (or near) your web server to spit out something based on the form contents? I've build scripts that print to a server-side printer by creating output using pdflib, then submitting the PDF to the local (unix-based) lpr system. Then the only complexity is getting lpr to deal with PDF files (along with solutions to the security issues that surround giving your web server process the ability to submit print jobs). I do this for requests for paper invoices which fit inside window envelopes, so any invoices that turn up on the printer just get stuffed and mailed. I also do something similar for requests for FAXed quotes. The software builds a PDF, then submits it to Hylefax's sendfax program, which dumps it to a fax server elsewhere on the network. If you're doing this in a Microsoft environment, I have no clue how you'd even approach the problem, let alone solve it. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP vs Perl for system scripts (non-web)
I have to write a swath of code to manage system-related stuff based on database content. Scripts will be run as root by cron, and determine what they have to do via user interaction and SQL lookups. Functions will include manipulation of system configuration files, legacy text file configs, and some signalling with posix_kill. On some of the machines in question, there won't even be an httpd installed, so I'd be building a php as a standalone binary, and running it with shell magic and a -q option. I've done this kind of stuff in the past in smaller environments, and it seems to work nicely. I'm more comfortable writing stuff in PHP. I use PHP alot more, and I find the resultant code more readable and easier to maintain. Aside from Perl's ubiquity and the dubious advantage of future flexibility by using Perl's DBI interface to talk to different SQL servers (I'm using MySQL at the moment), are there any compelling reasons I should write system stuff in Perl rather than PHP? Thanks. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Populating a list box from a database - The code
I assume you want the array populated with something other than the display name in the , so I've made up "OrgId" as a field name in your database. How 'bout something a little easier to read, using a more consistent style? ... if ($err) print "Database error: " . $err . ""; else { print "\n" foreach ($options as $id => $name) printf("\t%s\n",$id,$name); print "\n"; } ?> Note that none of this code has been tested. :) p On Sun, Dec 29, 2002 at 01:18:22AM +0800, Denis L. Menezes wrote: > > > //connecting to the database > $link = mysql_connect("localhost","lodestone","trypass"); > if ($link){ >Print ""; >} else { >Print "No connection to the database"; >} >if (!mysql_select_db("catapult_com")){ > Print "Couldn't connect database"; > } else { > Print ""."\n"; > } > > $sql="SELECT OrgName From TableResults ORDER BY OrgName"; > $result=mysql_query($sql); > > While($Organisation=mysql_fetch_array($result)) > { > Print("$Organisation[1]\n"); > } > > ?> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] creating random strings?
I need to create batches of randomly generated usernames and passwords. To start off, I have: $validuchars='abcdefghijkmnopqrstuvwxyz'; $validpchars='abcdefghijkmnopqrstuvwxyz23456789'; $lenu=strlen($validuchars)-1; $lenp=strlen($validpchars)-1; The first method I came up with was: $uid=''; for($i=8;$i;$i--) $uid.=substr($validchars,mt_rand(0,$lenu),1); $pwd=''; for($i=8;$i;$i--) $pwd.=substr($validchars,mt_rand(0,$lenp),1); But I'm wondering if there's any significant benefit to this instead: for( $uid=''; strlen($uid)<8; $uid.=substr($validuchars,mt_rand(0,$lenu),1) ); for( $pwd=''; strlen($pwd)<8; $pwd.=substr($validpchars,mt_rand(0,$lenp),1) ); I can't see any difference in speed. Does the savings of the $i variable have any signficance at all? Another thing I was thinking of doing was making more pronouncable usernames with something like: $cons="bcdfghjklmnpqrstvwxyz"; $vowels="aeiouy"; $lenv=strlen($vowels)-1; $lenc=strlen($cons)-1; $uid=""; for($i=4;$i;$i--) $uid.=substr($cons,mt_rand(0,$lenc),1) . substr($vowels,mt_rand(0,$lenv),1); Any thoughts? Incidentally, I'm guaranteeing uniqueness of usernames with a unique index in the MySQL table that stores this stuff. Including the INSERT, I can create about 10 of these in 60 seconds. So this is more a question of style than of practical limitations. ;) -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ping...
On Fri, Dec 13, 2002 at 10:02:54AM -, Brian McGarvie wrote: > > I can exec ping OK... but I need a way to ping and basically give me a OK or > Not OK... any ideas? This isn't really a PHP question, since ping is a command in the OS and not in PHP itself. And of course, you didn't mention what OS you run. I run FreeBSD. In FreeBSD, ping has options that could be used thusly: $target="209.238.46.67"; exec("/sbin/ping -c 1 -t 3 $target", $junk, $ret); if ($ret==0)// In shell, 0 means success print "Wahoo! I can see $ipaddr!\n"; else print "Bummer... $ipaddr seems to be down.\n"; The option -c specifies a "count" (the number of pings to send), and -t specifies a timeout in seconds. If your operating system is UNIX or Linux, you can "man ping" from a shell to see what you need to do to duplicate this functionality, or check out various OS man pages at http://www.freebsd.org/docs.html#man . If you're running a Microsoft operating system, you're most likely out of luck. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Beginner question : Removing spaces in forms
On Fri, Dec 13, 2002 at 02:19:07PM +1100, Andrew Wilson wrote: > > Hay guys i was wondering if there was a form parameter of something > equivalent for input text boxes that when a user enters a number or series > of numbers that it removes the spaces. Are you saying that your users will hit their space bar a number of times after entering a numeric value into a text box? If so, then http://www.php.net/trim may be what you want. If not, you'll need to explain it more concisely. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: fwrite and line breaks
On Fri, Dec 13, 2002 at 12:44:14AM -0600, Jami wrote: > > I know that fwrite needs to be written as such: > > $Open=fopen($MyFile, "w"); > fwrite($Open, "Text to add to file.\n"); > > The file is being saved on a Unix server, but Windows/Mac users will be downloading >the file. How can I create line breaks that notepad/textpad will use to create new >lines, instead of boxes where the break should be? I have tried changing "w" to "wb" >as suggested on php.net, but that does not work either and I am out of ideas. For Windows, use: fwrite($Open, "Text to add to file.\r\n"); And for Mac, I think it's: fwrite($Open, "Text to add to file.\r"); Aren't standards wonderful? ;-) If you want a more general solution, you might play with something like: $text="This is the first line.\nAnother line makes two.\n"; if ($target=="win") $text=str_replace( "\n", "\r\n", $text); else if ($target=="mac") $text=str_replace( "\n", "\r", $text); fwrite($Open, $text); Set your $target somewhere (maybe by parsing HTTP_USER_AGENT), and you can stick with consistent use of UNIX-style text in your PHP. There's probably a more elegant way to do this, but I don't know it. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regex question
On Thu, Dec 12, 2002 at 11:01:47PM -0800, Troy May wrote: > > How would take a regular non-formatted text link (http://www.link.com) and > turn it into ready to post HTML? (href=http://www.link.com>http://www.link.com) > > Darn, Outlook formats it, but you get the idea. It would just be typed out > normally. How about: $href="(https?://([a-z0-9]+\.)+[a-z][a-z]+/[a-z0-9_./~%-]*)"; $repl="\\1"; $line=eregi_replace($href, $repl, $line); You can of course make $href less restrictive if you're liberal minded about your URL formats. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Finding Mode
On Sat, Dec 07, 2002 at 07:12:09PM -0500, Stephen wrote: > > Another math question... How would I find the mode (number that repeats most > often) of an array? Then, if there isn't a number that repeats most often, > tell the user that. A while back, I wrote functions for mean, median and mode. I've put them up at http://www.it.ca/software/statsmmm.php . I don't much like the mode function -- it seems awkward, but I couldn't figure out how to write it any smaller. Also included is a function that calculates the 95th percentile of values in an array, roughly the same way the median() function works ... but I don't recommend using this for bandwidth calculations for co-lo customers because of the hassle of pulling all that data into an array. 95th percentile is more easily calculated in the SQL server than in php. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multidimensional arrays (more and more...)
On Thu, Nov 28, 2002 at 10:19:38AM -0800, Mako Shark wrote: ... > My problem is I need to loop through these. So I can't > just assume that the count is count($issue[]) divided > by 8, because that won't work in a for loop. I suppose > I could just iterate through my for loop in jumps of > 8, but that seems really hacky and unintuitive to > whomever has to figure out my code when I'm gone. By your description, count($issue)/count($issue[]) is the number of real elements. And a foreach loop will correctly step through whatever array you pass to it, even if the values of that array are themselves arrays. Or could you try something like count(array_keys($issue)) ... or the loop could be as simple as: $count=0; foreach($issue as $junk) $count++; which is clear, though to my eye is the same as count(); I'm surprised that count($issue) would report something other than the number of elements in $issue. I never count my multidimensional arrays so it's never come up for me. :-/ -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multidimensional arrays (more and more...)
Well, counting is easy... count($issue) will be correct. If you want to count things that match only specific elements, use things like: $c=0; foreach($issue as $what) if ( $year==2003 && $month>=5 ) $c++; As I said in the previous email, to sort by array elements, you'd need to use array_multisort. Something like... $sortkey=array(); foreach($issue as $what) $sortkey[]=$what['number']; array_multisort($issue,$sortkey); And for looping, foreach is still your best bet: foreach($issue as $key => $what) { if ($what['senttosubscribers']==0) $issue[$key]['description'].=" (EMPTY)"; else $issue[$key]['description'].=str_replace(" (EMPTY)","",$what['description']); } With regard to PHP being "screwey", I haven't found this -- I use multidimensional arrays quite a bit and find that they behave exactly as I would predict. Maybe I'm just lucky. ;-) p On Thu, Nov 28, 2002 at 09:55:25AM -0800, Mako Shark wrote: > > Wow. This goes way beyond simply printing > multidimensional arrays. Here's some sample data: > > $issue[]["number"] = "number"; > $issue[]["headline"] = "headling"; > $issue[]["writers"] = "writers"; > $issue[]["list"] = "list"; > $issue[]["senttosubscribers"] = "0"; > $issue[]["month"] = "05"; > $issue[]["year"] = "2003"; > $issue[]["description"] = "description"; > > What I need to do now is count(), sort() by number, > and loop through this array. > > I read that PHP is screwy when counting and sorting > multidimensional arrays, but they *have* to have come > up with a method, right? -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multidimensional array
A multidimensional array is just an array whose values are themselves arrays. So ... $thing="2002-11"; // or whatever $issue=array(); $issue[$thing]=array(); $issue[$thing]['number']="this"; $issue[$thing]['headline']="that"; And if you ksort($issue), the key/value associations will be maintained; you're just changing the order of the elements. If you want to sort by other "fields", array_multisort() may be for you. p On Thu, Nov 28, 2002 at 09:11:03AM -0800, Mako Shark wrote: > > Here is a problem I'm having similar to somethnig > someone just posted, but not quite the same. I'm not > too experienced with the intricacies and > complications of arrays, but I have a bunch of fields > like this for a magazine organizer (best way to put > it, I guess): > > $issuenumber[] > $issueheadline[] > $issuewriters[] > $issuemonth[] > $issueyear[] > $issuedescription[] > among other fields. > > I would like to store this all in one multidimensional > array, like > $issue->number[] > $issue->headline[] > etc. > > What is the syntax? I'm bumbling around right now. > Also, if I sort() the array by number, would the rest > of the fields be properly sorted? I assume so, but > don't want to find out the hard way that it doesn't. > > __ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Hello ! How to write a programme in PHP which executes a routine at a given time ?
PHP itself does not have any facility for running things according to a schedule in the way you describe. It looks like you need to run some additional software using cron (or your operating system's equivalent). Unix systems have a command called "at" which can be used to execute things at specific times, but what it actually executes is still a problem. If you want to be able to launch programs on external machines, there are security issues which must be addressed as well. And what does "centian" mean? On Fri, Nov 29, 2002 at 01:18:16AM +0800, Jonathan wrote: > > Dear all , > Hello ! I am a student and going to write a suit of programme . The > producers as follow > > producer 1. > User A add an new appointment A ( "open Winamp at 2:30 on computer B") > through IE in his local computer A . > > producer 2. > Computer A send the message to server A through http . The Servlet / > ASP.net which locates on server A receives the message and send message to > computer B (IP or domain name of computer B is given , named > "www.computerB.com") . > > producer 3. > Computer B receives the message from server A through http at 1:01 . It is > expected to implement the new added appointment A ( "open Winamp at 2:30 on > computer B" ) at given time . > > I know what to implement the producer 1 and 2. However , I don't know how > to implement producer 3. Do you mind to tell me how to make a PHP programme > to execute a centian routine at a given time ? Thank you ! -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: test for ascii or binary string
On Fri, Nov 29, 2002 at 10:27:05PM -0600, Jonathan Sharp wrote: > > Is there a way to determine if a string has ascii or binary data in it? You could always see if it matches a regular expression that represents the ascii range you're considering. I.e., ereg('[^a-zA-Z0-9]',$string) will return true if non-alphanumerics are in the string. Remember that a string is just a string. Whether the data contained in it is represented as ASCII or something else is completely a matter of implementation. ALL 7-bit data can be represented as ASCII. All 8-bit data can be represented as "IBM Extended ASCII" or whatever you want to call it. But the string is just a string of bits. -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever +1 416 598- it.canada - hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php