[PHP] Stupid question of the day (Editing text file in $HOME via web)
I have a text file on a server that I want someone to be able to edit via the web. I need it to have some modicum of security, but it's nothing particularly important and security is not the main concern. I am perfectly willing to simply http-auth it, if need be. But it need to be easily editable using some sort of simple web form. The file is unlikely to be much more than 20-100 lines of simple text, but there are a couple of things that are important. 1) it has to preserve spacing and 'extended' characters 2) it has to be kept readable to the uid of the directory it is in, and not just the webserver, however it can't be world readable without some authentication via the web. 3) the file is in $HOME and not in DocumentRoot, though it _could_ be moved. I don't want to install some fancy word-processing sort of engine just to give a user access to this file, nor does the file need to be html-ized or anything. It is a very simple file: (AAA) XXX-NNN, some descriptive text (AAA) XXX-NNN, some other descriptive text (AAA) XXX-NNN, some different descriptive text (AAA) XXX-NNN, John Smith etc. So, do I whack up something where I just load the file into a HTML Textarea and then write it back (simple enough, though possibly rather dangerous), or is there something straightforward I should go ahead and use that might find use elsewhere on the server? -- "Oh damn", said Maladict. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagecopyresampled creates black pictures
tedd schrieb: At 9:52 AM +0100 10/30/06, Martin Hochreiter wrote: What is wrong here? Martin: Damn, that's a lot of code to do something pretty simple. I had no problems uploading and resampling your image with a lot less. Try using ob_start() and ob_end() to grab your image.: ob_start(); imagejpeg($new,$dir.'view/'.$name,85); ob_end_clean(); hth's tedd "Damn, that's a lot of code to do something pretty simple" ... i am not a php professional - just hacking around to get things run ... Ok, thank you for your code - unfortunately the result is the same (I added the picture as attachement) Maybe php is not responsible for that - should I try another GD library version or image Magik version? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decide witch table within a union
On Tuesday 31 October 2006 02:27, Ed Lazor wrote: > > Someone asked what it was to be used for. > > It's for combining 4 forums into one witch shows the latest > > movement among > > them. More like an introduction sort of... > > Sounds cool. Are you using a pre-made forum package? No Maby it'd been easier, I did that at first... But not much to learn using other ppls tools. > -Ed -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help confirming a PDO_SQLITE bug
Thanks to anyone who entertained my previous email, but I've solved my own problem. It looks like the bug is in PDO_SQLITE 1.0.1. I've just compiled from that extension from CVS, changing nothing else, and the bug is gone. --rick Rick Fletcher wrote: I've just upgraded to Fedora Core 6 and my personal site broke. Along with the upgrade came PHP 5.1.6 and SQLite 3.3.6. After the upgrade any SELECT returns all its values with the last character missing. I've filed a bug at pecl.php.net (http://pecl.php.net/bugs/bug.php?id=9191), but it doesn't look as though that's reviewed very often. I need help confirming that it is a PDO or SQLite bug so that I can begin upgrading or downgrading to avoid it. If you have matching versions of PHP and/or SQLite, can you try out the test script below and see if it's broken in the same way? Thanks, Rick Fletcher Reproduce code: --- query( 'CREATE TABLE "things" ( name VARCHAR NOT NULL )'); $dbh->query( 'INSERT INTO things VALUES ( "thing one" )'); foreach( $dbh->query( 'SELECT * FROM things' ) as $row ) { print_r( $row ); } $dbh = null; ?> Expected result: Array ( [name] => thing one [0] => thing one ) Actual result: -- Array ( [name] => thing on [0] => thing on ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help confirming a PDO_SQLITE bug
I've just upgraded to Fedora Core 6 and my personal site broke. Along with the upgrade came PHP 5.1.6 and SQLite 3.3.6. After the upgrade any SELECT returns all its values with the last character missing. I've filed a bug at pecl.php.net (http://pecl.php.net/bugs/bug.php?id=9191), but it doesn't look as though that's reviewed very often. I need help confirming that it is a PDO or SQLite bug so that I can begin upgrading or downgrading to avoid it. If you have matching versions of PHP and/or SQLite, can you try out the test script below and see if it's broken in the same way? Thanks, Rick Fletcher Reproduce code: --- query( 'CREATE TABLE "things" ( name VARCHAR NOT NULL )'); $dbh->query( 'INSERT INTO things VALUES ( "thing one" )'); foreach( $dbh->query( 'SELECT * FROM things' ) as $row ) { print_r( $row ); } $dbh = null; ?> Expected result: Array ( [name] => thing one [0] => thing one ) Actual result: -- Array ( [name] => thing on [0] => thing on ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I get ini_set('output_handler', '') to work?!
I suppose I could re-compile my command line version with a different php.ini file, but that's kind of lame that I have to have two php.ini files for what ini_set() SHOULD handle. Would modifications via .htaccess work for you? -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
On Oct 30, 2006, at 1:10 PM, Dotan Cohen wrote: On 30/10/06, Stut <[EMAIL PROTECTED]> wrote: Ed Lazor wrote: > It looks like you guys are coming up with some cool solutions, but I > have a question. Wasn't the original purpose of this thread to > prevent sql injection attacks in input from user forms? If so, > wouldn't mysql_real_escape_string be an easier solution? Me thinkie nottie. From the OP... "I need to remove the noise words from a search string." Yes, that is also part of the aim. How come? Not trying to be facetious here. I'm just wondering if you see a benefit that I don't. For example, say the hacker injects some sql and you use mysql_real_escape_string. You end up with something like this... actually, I'll do one step further and just use the quote_smart function described in the mysql_real_escape_string page of the php manual: $query = sprintf("SELECT * FROM users WHERE user=%s AND password=%s", quote_smart($_POST['username']), quote_smart($_POST['password']) ); Say the user tried to inject sql in $_POST['username'] and it looked something like: root';drop all; Having used quote_smart, the value of $query ends up SELECT * FROM users WHERE user='root\'\;drop all\;' AND password='something' The sql injection fails. The data is seen as a literal. The database is going to think there's no user with that name. That means that even if the user did include extra words, they're just part of the value that is checked against user names - rather than being see as potential commands. I'm not sure if I'm describing this well, so let me know what you think and I'll go from there. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
On Oct 30, 2006, at 10:26 AM, Ahmad Al-Twaijiry wrote: is it possible to link the script to my php interface (the one that the users is using it) and if the php interface page will run the script (IN background) if it didn't run for the last 30 seconds ? I see this is very hard and almost impossible , what do you think ? PS: also I need to make sure no more than 1 process of the script is running :) Hi Ahmad. Could you describe what your script is doing? What type of information are you wanting users to see? Is this some sort of status page? Is it some sort of semi-real-time monitoring? -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] only one at atime
On Oct 30, 2006, at 10:14 AM, Ahmad Al-Twaijiry wrote: Hi everyone, I create a php script that will run every minute (by cronjob) and update some database tables (php 5, database mysql 5, tables type innodb) the problem is that I want this script to run only one at atime (only one process from this script can run ) for example, if the cronjob start the script and the script takes more than one minute, then after this one minute the cronjob start another process from this script, it should exit once it find there is an old process of it running) what I do now is that when the script start it will check for a tmp file (/tmp/script.pid) and if it fine it it will exit. if the file (/tmp/script.pid) is not exists, it will create it and start doing the database update and when the script finish it will remove the file any better idea ? It sounds like how I'd approach it, but it depends somewhat on the type of updates your script is performing and how busy your website is. Plus, I'm curious, what kind of updates are needing to occur every 30 seconds? And, if your scripts are at risk of running for more than 30 seconds, does this mean that the volume of data you're working with end up building upon itself? Just wondering, because it sounds like you could end up hammering your database server. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decide witch table within a union
Someone asked what it was to be used for. It's for combining 4 forums into one witch shows the latest movement among them. More like an introduction sort of... Sounds cool. Are you using a pre-made forum package? -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I get ini_set('output_handler', '') to work?!
Thank you for the reply Richard (and Tom). That news sucks however. Seems that the PHP pre-parser should handle this better. It's not like it's a one-pass parser (like Ruby). " . ini_get('output_handler') . "\n"; ?> I suppose I could re-compile my command line version with a different php.ini file, but that's kind of lame that I have to have two php.ini files for what ini_set() SHOULD handle. What other undocumented "gotchas" are there with ini_set() I wonder... DÆVID > -Original Message- > From: Richard Lynch [mailto:[EMAIL PROTECTED] > Sent: Sunday, October 29, 2006 9:25 PM > To: Daevid Vincent > Cc: php-general@lists.php.net > Subject: Re: [PHP] How do I get ini_set('output_handler', '') > to work?! > > On Fri, October 27, 2006 3:46 pm, Daevid Vincent wrote: > > What am I doing wrong... > > > > In my php.ini I have this for my web pages (and I want it): > > > > output_handler = ob_gzhandler > > > > But this causes my command line script to not show output until the > > very > > end. > > > > I thought I could disable it at the top of a script, but it's not > > working!?! > > > > #!/usr/bin/php -q > > > ini_set('output_handler', 'mb_output_handler'); > > TOO LATE! > > The ob_start() has already kicked in by this point. > > ob_flush() until there are no more buffers. > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some starving artist. > http://cdbaby.com/browse/from/lynch > Yeah, I get a buck. So? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
On Monday 30 October 2006 15:10, Dotan Cohen wrote: > Er, so how would it be done? I've been trying for two days now with no > success. From your original message, it sounds like you want to strip selected complete words, not substrings, from a string for indexing or searching or such. Right? Try something like this: $string = "The quick sly fox jumped over a fence and ran away"; $words = array('the', 'a', 'and'); function make_regex($str) { return '/\b' . $str . '\b/i'; } $search = array_map('make_regex', $words); $string = preg_replace($search, '', $string); print $string . "\n"; What you really need to do that is to match word boundaries, NOT string boundaries. So you take your list of words and mutate *each one* (that's what the array_map() is about) into a regex pattern that finds that word, case-insensitively. Then you use preg_replace() to replace all matches of any of those patterns with an empty string. You were close. What you were missing was the array_map(), because you needed to concatenate stuff to each element of the array rather than trying to concatenate a string to an array, which as others have said will absolutely not work. I can't guarantee that the above code is the best performant method, but it works. :-) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A general UL script
Thanks alot Richard. As you mention it I've had some encounters with the _ filenames... I did get it to work after a fasion, but yes I took quite some headache to make it work. For the JS part of the script I could just getElementById witch leave me open for the name to use on my problems as you suggest. On Monday 30 October 2006 22:49, Richard Lynch wrote: > On Mon, October 30, 2006 5:13 am, Børge Holen wrote: > > * First it insert an empty file field (hidden). > > This seems silly, but whatever. Yes, I didn't make the JS and don't know why it is so. > > > * Second, I rename all files to an md5 hash. > > * Third, The md5 hash makes legal filenames witch enables my toolset > > to modify > > modify/validate my jpg. > > And MD5 hash seems kind of excessive, when you could do: > $filename = preg_replace('/[^a-z0-9_\\.]i/', '', $filename); > > But whatever makes you happy. md5 seems clean. Does the work witchever character is used. But probably a great deal slower? > > > The problem I seem to be getting at is this; How do I remove, lets > > say, file > > nr 3 of 6. The input fields can easily (because fields is removed and > > added > > dynamicly) be named everything from 'file_1' to 'file_20'. I only want > > Aha! > > Try using name="file[1]" instead of "file_1" and your life will become > MUCH simpler. You can keep your id="file_1" for JS to use > getElementById and muck with what's visible, but your PHP will be > s much easier with name="file[1]" > > > jpg's > > , so that gif in nr 3 has to be removed before the md5 hash rename. > > > > I could use splice_array to get at it just as I do with the first > > empty one, > > but then again, how do I count down the fields to get to the non valid > > file > > types. > > Once you use name="file[3]" there is no count down. > It's an array. -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A general UL script
On Mon, October 30, 2006 5:13 am, Børge Holen wrote: > * First it insert an empty file field (hidden). This seems silly, but whatever. > * Second, I rename all files to an md5 hash. > * Third, The md5 hash makes legal filenames witch enables my toolset > to modify > modify/validate my jpg. And MD5 hash seems kind of excessive, when you could do: $filename = preg_replace('/[^a-z0-9_\\.]i/', '', $filename); But whatever makes you happy. > The problem I seem to be getting at is this; How do I remove, lets > say, file > nr 3 of 6. The input fields can easily (because fields is removed and > added > dynamicly) be named everything from 'file_1' to 'file_20'. I only want Aha! Try using name="file[1]" instead of "file_1" and your life will become MUCH simpler. You can keep your id="file_1" for JS to use getElementById and muck with what's visible, but your PHP will be s much easier with name="file[1]" > jpg's > , so that gif in nr 3 has to be removed before the md5 hash rename. > > I could use splice_array to get at it just as I do with the first > empty one, > but then again, how do I count down the fields to get to the non valid > file > types. Once you use name="file[3]" there is no count down. It's an array. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
On Oct 30, 2006, at 9:19 AM, Stut wrote: Ed Lazor wrote: It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string be an easier solution? Me thinkie nottie. From the OP... "I need to remove the noise words from a search string." You sure? This is what they said originally: "Nothing else is relevant, but $searchQuery will get passed to the database, so it should be protected from SQL injection. That's why I want to remove characters such as quotes, dashes, and the equals sign." Maybe that doesn't account for all of the extra words they're trying to remove... dunno, thus my question. However, until the OPer accepts that people are right when they say you can't append strings to an array it's never going to work. Every bit of sample code posted retains the following line of code rather than fixing it according to several other previous posts... "^".$noiseArray."$" Happy happy joy joy, oh look, the spring's broken. Doing!! Persistence is a virtue? hehe -Stut (slightly drunk, but feeling generally good about the world) Hy. That's not fair. No bragging unless you plan on sharing :) -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
On Mon, October 30, 2006 11:29 am, Ahmad Al-Twaijiry wrote: > I have a script that I want it to run every 30 seconds, the problem is > that cronjob can run every 1 minute only, do you have any solution ? Run a script that never quits with: http://php.net/usleep while (true){ //your script here usleep(3); //3? rtfm. } It won't really really be every 30 seconds, because the script itself takes time, but it's about as close as you are likely to get without a ton of probably un-needed work... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] only one at atime
On Mon, October 30, 2006 12:14 pm, Ahmad Al-Twaijiry wrote: > I create a php script that will run every minute (by cronjob) and > update some database tables (php 5, database mysql 5, tables type > innodb) > > the problem is that I want this script to run only one at atime (only > one process from this script can run ) > > for example, if the cronjob start the script and the script takes more > than one minute, then after this one minute the cronjob start another > process from this script, it should exit once it find there is an old > process of it running) > > what I do now is that when the script start it will check for a tmp > file (/tmp/script.pid) and if it fine it it will exit. > if the file (/tmp/script.pid) is not exists, it will create it and > start doing the database update > and when the script finish it will remove the file > > any better idea ? On some systems, it's more common to put your lock file in /var/shared/locks or somesuch. You also want to be CERTAIN that you do not have a race condition between 2 scripts creating the lock file at the same time. With a full minute between, you are probably pretty safe on that, but... You may also want to have a function to unlink the file and use http://php.net/register_shutdown_function to delete it, rather than just tacking it on at the end of your script. And, finally, I recommend that you consider doing "something" automated if the lock file is more than X minutes "old" -- You might choose to just ignore it and proceed, on the assmuption that your previous run crashed or was killed before it could delete the file. Even if everything else above seems like overkill, at least this way you'll know the process IS running often enough to keep up. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
Dotan Cohen wrote: > Er, so how would it be done? I've been trying for two days now with no > success. Ok, I guess my original reply didn't get through, or you ignored it. Here it is again for your convenience. Dotan Cohen wrote: > > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); Ok, this is what the compiler will see... $searchQuery=str_replace("^Array$", " ", $searchQuery); Yes, that's a literal Array in the string. You cannot, and you should remember this, you cannot concatenate strings and arrays. What would you expect it to do? Now, the answer is this... $searchQuery = str_replace($noiseArray, ' ', $searchQuery); However, what you seem to be doing is putting regex syntax where it would have no effect even if $noiseArray was not an array. If your intention is to replace the words rather than just the strings then you need to look at preg_replace (http://php.net/preg_replace) and you'll need to decorate the strings in $noiseArray with the appropriate characters to make them the search pattern you need - full details on the preg_replace manual page. -Stut (painfully sober now :( ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
On 30/10/06, Stut <[EMAIL PROTECTED]> wrote: Ed Lazor wrote: > It looks like you guys are coming up with some cool solutions, but I > have a question. Wasn't the original purpose of this thread to > prevent sql injection attacks in input from user forms? If so, > wouldn't mysql_real_escape_string be an easier solution? Me thinkie nottie. From the OP... "I need to remove the noise words from a search string." Yes, that is also part of the aim. However, until the OPer accepts that people are right when they say you can't append strings to an array it's never going to work. Every bit of sample code posted retains the following line of code rather than fixing it according to several other previous posts... "^".$noiseArray."$" Er, so how would it be done? I've been trying for two days now with no success. Happy happy joy joy, oh look, the spring's broken. Doing!! Boing!!! -Stut (slightly drunk, but feeling generally good about the world) Dotan Cohen http://lyricslist.com/ http://what-is-what.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
On Mon, 30 Oct 2006 21:26:29 +0300, Ahmad Al-Twaijiry wrote: The "right" way to do this, as others have mentioned, is with a daemon. Having said that... >is it possible to link the script to my php interface (the one that >the users is using it) and if the php interface page will run the >script (IN background) if it didn't run for the last 30 seconds ? I >see this is very hard and almost impossible , what do you think ? http://www.webcron.org/ However, an admin on a shared host may (quite rightly) kick you for wasting shared resources. A script that has to be run every 30 seconds sounds like it's covering for a bad design decision to me. Can you tell us more about what you're trying to accomplish? We might be able to find a more elegant solution. >PS: also I need to make sure no more than 1 process of the script is running :) Locking. At its simplest, have your script create a dummy file when it first runs, and delete it when it exits. If the file already exists, then you know that a copy of your script is already running, so you exit. (Include a timeout in case the script dies halfway through - if the file is more than 5 minutes old, run anyway). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
Or, you could run two scripts every minute ... one that starts immediately, and one that sleeps for 30s before starting. -- Mitch Dave Hamber wrote: You could run the script as a daemon. man daemon. The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. If you make a loop like this you could get around that: $t=time()+31; while(true){ if(time()>$t+30){ $t=time(); YourMainScriptFunction(); } else usleep(1000); //adjust to how often you want to check } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? Use atd. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: > > On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > > > > > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: > > >> On Friday 27 October 2006 19:34, Richard Lynch wrote: > > >>> And the header("Location: ...") requires a full URL. > > >> > > >> No it doesn't. but he's missing an ' at first glance > > > > > > Yes, it does: > > > http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 > > > > > > Note the use of 'absolute' within that section. > > > > Although I always use a full URL as well, doesn't absolute just mean > > non-relative? As in: > > Location: /Protocols/rfc2616/rfc2616-sec14.html#sec14.30 > > (absolute URI) > > > > Location: ./rfc2616-sec14.html#sec14.30 > > (relative URI) > > If you need contextual information to make sense of the URI (such as > the server name from a previous request) then it's not absolute. > > RFC 2396: Uniform Resource Identifiers > > "An absolute identifier refers to a resource independent of the > context in which the identifier is used. In contrast, a relative > identifier refers to a resource by describing the difference within a > hierarchical namespace between the current context and an absolute > identifier of the resource." Please note you are quoting from an RFC with the following title: Uniform Resource Identifiers (URI): Generic Syntax Pay special attention to "Generic Syntax" in the title. The RFC linked by Richard clearly indicates that for the Location response-header that "the field value consists of a single absolute URI". This currently has the final word for the Location response-header and therefore is the standard. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] only one at atime
Ahmad Al-Twaijiry wrote: Hi everyone, I create a php script that will run every minute (by cronjob) and update some database tables (php 5, database mysql 5, tables type innodb) the problem is that I want this script to run only one at atime (only one process from this script can run ) for example, if the cronjob start the script and the script takes more than one minute, then after this one minute the cronjob start another process from this script, it should exit once it find there is an old process of it running) what I do now is that when the script start it will check for a tmp file (/tmp/script.pid) and if it fine it it will exit. if the file (/tmp/script.pid) is not exists, it will create it and start doing the database update and when the script finish it will remove the file any better idea ? Thanks Nope, typically this is how you solve the problem you mentioned... (just make sure the /tmp directory (or specifically your file are remove when you boot up) I have seen instances where the machines reboot in the middle of the script and then don't execute for a while because of this *lock file*. -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
You could run the script as a daemon. man daemon. The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. If you make a loop like this you could get around that: $t=time()+31; while(true){ if(time()>$t+30){ $t=time(); YourMainScriptFunction(); } else usleep(1000); //adjust to how often you want to check } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
You can still use Cronjob with 1 min setting and in use 2 processes 1. Run script immediately 2. Sleep for 30 sec and then run the script you can use exec/shell_exec functions with output redirected to soem file so that It will run in background. That way you have one process running at 0 sec and one running at 30 sec every minute Suhas On 10/30/06, Ahmad Al-Twaijiry <[EMAIL PROTECTED]> wrote: Thank you all but the problem is that I don't have root access to the server to create daemon :) so if I just run the script in background with 30 seconds sleep and someone reboot the server (or the script dies for any reason ) I will lose my process :) any other ideas ? is it possible to link the script to my php interface (the one that the users is using it) and if the php interface page will run the script (IN background) if it didn't run for the last 30 seconds ? I see this is very hard and almost impossible , what do you think ? PS: also I need to make sure no more than 1 process of the script is running :) On 10/30/06, Dave Hamber <[EMAIL PROTECTED]> wrote: > Sorry, slight adjustment, make that $t=time()-31; in the first line so > that the script runs immediately. > > > > You could run the script as a daemon. man daemon. > > > > The sloppy way of running the script every 30 seconds would be to use > sleep(30), but that would cause the script to run at 30 seconds + > execution time. > > > > If you make a loop like this you could get around that: > > > > $t=time()+31; > > while(true){ > > if(time()>$t+30){ > > $t=time(); > > YourMainScriptFunction(); > > } > > else usleep(1000); //adjust to how often you want to check > > } > > On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: > > Hi everyone, > > > > I have a script that I want it to run every 30 seconds, the problem is > > that cronjob can run every 1 minute only, do you have any solution ? > > > -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
Thank you all but the problem is that I don't have root access to the server to create daemon :) so if I just run the script in background with 30 seconds sleep and someone reboot the server (or the script dies for any reason ) I will lose my process :) any other ideas ? is it possible to link the script to my php interface (the one that the users is using it) and if the php interface page will run the script (IN background) if it didn't run for the last 30 seconds ? I see this is very hard and almost impossible , what do you think ? PS: also I need to make sure no more than 1 process of the script is running :) On 10/30/06, Dave Hamber <[EMAIL PROTECTED]> wrote: Sorry, slight adjustment, make that $t=time()-31; in the first line so that the script runs immediately. > You could run the script as a daemon. man daemon. > > The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. > > If you make a loop like this you could get around that: > > $t=time()+31; > while(true){ > if(time()>$t+30){ > $t=time(); > YourMainScriptFunction(); > } > else usleep(1000); //adjust to how often you want to check > } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: > Hi everyone, > > I have a script that I want it to run every 30 seconds, the problem is > that cronjob can run every 1 minute only, do you have any solution ? > -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] only one at atime
Hi everyone, I create a php script that will run every minute (by cronjob) and update some database tables (php 5, database mysql 5, tables type innodb) the problem is that I want this script to run only one at atime (only one process from this script can run ) for example, if the cronjob start the script and the script takes more than one minute, then after this one minute the cronjob start another process from this script, it should exit once it find there is an old process of it running) what I do now is that when the script start it will check for a tmp file (/tmp/script.pid) and if it fine it it will exit. if the file (/tmp/script.pid) is not exists, it will create it and start doing the database update and when the script finish it will remove the file any better idea ? Thanks -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
Sorry, slight adjustment, make that $t=time()-31; in the first line so that the script runs immediately. > You could run the script as a daemon. man daemon. > > The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time. > > If you make a loop like this you could get around that: > > $t=time()+31; > while(true){ > if(time()>$t+30){ > $t=time(); > YourMainScriptFunction(); > } > else usleep(1000); //adjust to how often you want to check > } On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Search Engine - Synonyms
On Oct 30, 2006, at 6:26 AM, Kevin wrote: Hi, Is it possible to automatically search for synonyms related to a word in a search engine for example if I create a search engine and search for the word 'Horse', it would automatically search for other words such as 'Pony' etc? It is possible: http://www.google.com/help/refinesearch.html Has anyone had any experience on how this would be implemented? I haven't done it, but it seems straight forward. Start with one word, query a database for it's synonyms, and then use the resulting words (including the original word) in the final search query. It just seems like it would take a lot of work to create a database of words and their synonyms. You'll also need to add weight and sort the results so that your initial keyword scores higher. Honestly, if I were you, I'd run this question by the MySQL mailing list. PHP just works with the results of the search, so you still end up having to figure out how to do this in MySQL (or whatever database you're using). Another thing that might help is to Google keywords like "synonym search programming technique". I had to sort through the results, but it did look like there were a few interesting articles. Here's one of them: http://developer.apple.com/documentation/ UserExperience/Conceptual/SearchKitConcepts/searchKit_basics/ chapter_2_section_2.html -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
I've never tried this myself, but how about having the cron job kick off a script which will run script A and script B Script A runs right away, and script B runs after a delay of 30 seconds ( usleep(30* 100) )? -James On Oct 30, 2006, at 12:29 PM, Ahmad Al-Twaijiry wrote: Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Run script every 30 seconds
I'd create a PHP service that stays on the background :), ensuring that such service never goes off from time to time will be the job of the cron job, a little dirty, but works for me. HTH -Original Message- From: Ahmad Al-Twaijiry [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 31, 2006 1:29 AM To: PHP Subject: [PHP] Run script every 30 seconds Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? Set the script up as a 2 iteration loop with sleep( 30 ) at the end of the first iteration. Or something like that... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decide witch table within a union
On Monday 30 October 2006 05:46, Richard Lynch wrote: > On Sun, October 29, 2006 3:34 pm, Børge Holen wrote: > > Hi. > > I got this working (almost) > > How do I decide (inside?) the whileloop the table_nr, 1 to 4 witch the > > link is > > echo'ed from. > > > > I could add another field in each table telling witch table it is. > > Easy > > solution, but feels like polluting the db. > > > > Also I could do another loop to check another of the printed fields up > > agains > > witch table is used, but that adding to the slowness of this union > > stuff, it > > would take forever, if the union in itself is slow or the fact that > > I'm > > cutting the message field after 100 characters I dunno. > > > > This is anyway the main code wherein the problem lies: > > > > $sql=" (select * from table_1 WHERE pid='0' order by id desc limit 10) > > select *, 'table_1' from table_1 ... > > > union > > (select * from table_2 WHERE pid='0' order by id desc limit 10) > > select *, 'table_2' from table_2 ... > > This gives you an extra field with the table name in it. > > You may not be able to use * any more, and have to name all the fields > you actually want. > > Which is a better practice anyway. Yes, I never used *, I just inserted it to get rid of all the convertings of fields from the db. The amount of information wasn't useful to represent my problem. I've learned something very useful through this though... How to both NAME and INSERT information into an virtual field at an instance... THANKS to all of you=D. Someone asked what it was to be used for. It's for combining 4 forums into one witch shows the latest movement among them. More like an introduction sort of... > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some starving artist. > http://cdbaby.com/browse/from/lynch > Yeah, I get a buck. So? -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Run script every 30 seconds
Hi everyone, I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? -- Ahmad http://www.v-tadawul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there such a thing?
On Oct 29, 2006, at 9:22 PM, Richard Lynch wrote: On Fri, October 27, 2006 5:46 pm, Integz wrote: http://www.evilbitz.com/2006/10/27/local-php-standalone-binaries-2/ I responded in that forum. Short Version: No. Check out: http://gtk.php.net/ Do these qualify? http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler http://www.priadoblender.com -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
Ed Lazor wrote: It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string be an easier solution? Me thinkie nottie. From the OP... "I need to remove the noise words from a search string." However, until the OPer accepts that people are right when they say you can't append strings to an array it's never going to work. Every bit of sample code posted retains the following line of code rather than fixing it according to several other previous posts... "^".$noiseArray."$" Happy happy joy joy, oh look, the spring's broken. Doing!! -Stut (slightly drunk, but feeling generally good about the world) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
It looks like you guys are coming up with some cool solutions, but I have a question. Wasn't the original purpose of this thread to prevent sql injection attacks in input from user forms? If so, wouldn't mysql_real_escape_string be an easier solution? On Oct 30, 2006, at 8:17 AM, Jochem Maas wrote: Dotan Cohen wrote: I need to remove the noise words from a search string. I can't seem to get str_replace to go through the array and remove the words, and I'd rather avoid a redundant foreach it I can. According to TFM str_replace should automatically go through the whole array, no? Does anybody see anything wrong with this code: $noiseArray = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\"", "'", ":", ";", "|", "\\", "<", ">", ",", ".", "?", "$", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "[", "]", "{", "}", "about", "after", "all", "also", "an", "and", "another", "any", "are", "as", "at", "be", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "does", "each", "else", "for", "from", "get", "got", "has", "had", "he", "have", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "its", "just", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "now", "of", "on", "only", "or", "other", "our", "out", "over", "re", "said", "same", "see", "should", "since", "so", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", "well", "were", "what", "when", "where", "which", "while", "who", "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); // another idea based on further reading of the thread: function pregify($val) { foreach ((array)$val $k as $v) $val[$k] = '\b'.preg_quote($v).'\b'; return $val; } $searchQuery = preg_replace(pregify($noiseArray), " ", $searchQuery); Thanks in advance. Dotan Cohen http://essentialinux.com http://what-is-what.com/what_is/sitepoint.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove the words, and I'd > rather avoid a redundant foreach it I can. According to TFM > str_replace should automatically go through the whole array, no? Does > anybody see anything wrong with this code: > > $noiseArray = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", > "\"", "'", ":", ";", "|", "\\", "<", ">", ",", ".", "?", "$", "!", > "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "[", > "]", "{", "}", "about", "after", "all", "also", "an", "and", > "another", "any", "are", "as", "at", "be", "because", "been", > "before", "being", "between", "both", "but", "by", "came", "can", > "come", "could", "did", "do", "does", "each", "else", "for", "from", > "get", "got", "has", "had", "he", "have", "her", "here", "him", > "himself", "his", "how", "if", "in", "into", "is", "it", "its", > "just", "like", "make", "many", "me", "might", "more", "most", "much", > "must", "my", "never", "now", "of", "on", "only", "or", "other", > "our", "out", "over", "re", "said", "same", "see", "should", "since", > "so", "some", "still", "such", "take", "than", "that", "the", "their", > "them", "then", "there", "these", "they", "this", "those", "through", > "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", > "well", "were", "what", "when", "where", "which", "while", "who", > "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", > "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", > "u", "v", "w", "x", "y", "z"); > > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); // another idea based on further reading of the thread: function pregify($val) { foreach ((array)$val $k as $v) $val[$k] = '\b'.preg_quote($v).'\b'; return $val; } $searchQuery = preg_replace(pregify($noiseArray), " ", $searchQuery); > > Thanks in advance. > > Dotan Cohen > > http://essentialinux.com > http://what-is-what.com/what_is/sitepoint.html > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace on words with an array
Dotan Cohen wrote: > I need to remove the noise words from a search string. I can't seem to > get str_replace to go through the array and remove the words, and I'd > rather avoid a redundant foreach it I can. According to TFM > str_replace should automatically go through the whole array, no? Does > anybody see anything wrong with this code: > > $noiseArray = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", > "\"", "'", ":", ";", "|", "\\", "<", ">", ",", ".", "?", "$", "!", > "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "[", > "]", "{", "}", "about", "after", "all", "also", "an", "and", > "another", "any", "are", "as", "at", "be", "because", "been", > "before", "being", "between", "both", "but", "by", "came", "can", > "come", "could", "did", "do", "does", "each", "else", "for", "from", > "get", "got", "has", "had", "he", "have", "her", "here", "him", > "himself", "his", "how", "if", "in", "into", "is", "it", "its", > "just", "like", "make", "many", "me", "might", "more", "most", "much", > "must", "my", "never", "now", "of", "on", "only", "or", "other", > "our", "out", "over", "re", "said", "same", "see", "should", "since", > "so", "some", "still", "such", "take", "than", "that", "the", "their", > "them", "then", "there", "these", "they", "this", "those", "through", > "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", > "well", "were", "what", "when", "where", "which", "while", "who", > "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", > "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", > "u", "v", "w", "x", "y", "z"); > > $searchQuery=str_replace( "^".$noiseArray."$", " ", $searchQuery); it's string replacement not regexp replacement, therefore the '^' and '$' are bogus. the first argument to the str_replace() call is the string literal: '^Array$' ... you can't concatenate strings and arrays like that (and get the result you want)! instead, your function call should look like this: $searchQuery = str_replace($noiseArray, ' ', $searchQuery); > > Thanks in advance. > > Dotan Cohen > > http://essentialinux.com > http://what-is-what.com/what_is/sitepoint.html > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange problem with count()
At 1:27 PM +0100 10/29/06, Gunnar Beushausen wrote: Hi! I've a strange problem with count. I wrote a routine to jump to the last position of an array. The code ist this: -snip- Gunnar: I find it wise to check out all the built-in array functions before starting to write something myself -- there are a lot of them including what you just tried to write. Also, in your code you pushed $this->result and then were surprised when count($this->result) gave you a value of 1 -- just how many $this->result's were you thinking you pushed? You're not using count() correctly. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagecopyresampled creates black pictures
At 9:52 AM +0100 10/30/06, Martin Hochreiter wrote: What is wrong here? Martin: Damn, that's a lot of code to do something pretty simple. I had no problems uploading and resampling your image with a lot less. Try using ob_start() and ob_end() to grab your image.: ob_start(); imagejpeg($new,$dir.'view/'.$name,85); ob_end_clean(); hth's tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding PC-850
On 30/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi! I need to be able to encode text to PC-850 but I have big trouble finding out info about this encoding. Does it even exist? I get a few google hits, but nothing useful. Any idea of how I can convert for example an UTF-8 string or an ISO-8859-1 to this PC-850 format? Thanks for any input. Regards Emil It seems to be an IBM encoding compatable with iso-8859-1. Why do you need it? Are you outputing to a webbrowser, or on the command line? Dotan Cohen http://what-is-what.com/what_is/open_source.html http://gmail-com.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding PC-850
Would this help? http://us3.php.net/manual/en/function.mb-convert-encoding.php On Oct 30, 2006, at 7:21 AM, [EMAIL PROTECTED] wrote: Hi! I need to be able to encode text to PC-850 but I have big trouble finding out info about this encoding. Does it even exist? I get a few google hits, but nothing useful. Any idea of how I can convert for example an UTF-8 string or an ISO-8859-1 to this PC-850 format? Thanks for any input. Regards Emil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagecopyresampled creates black pictures
Ed Lazor schrieb: On Oct 30, 2006, at 12:52 AM, Martin Hochreiter wrote: Hi! I'm using imagecopyresampled to create thumbnails of various pictures. That works well except some pictures that imagecopyresampled converts to small black thumbnails (although it converts it correctly to a bigger size) What is wrong here? No idea off-hand, but it would probably help if you you included more information like source code and details about the images that are not working. Hi Ed! I added the upload.php file below and posted the nfs.jpg image file on http://www.rk-lilienfeld.at/nfs.jpg Maybe you can have a look at it . lg - upload.php x:".$x.", y:".$y.""; if(imagesx($ori)>imagesy($ori)) { if(imagesx($ori)<1024) { $smaller=1; $faktor=imagesy($ori)/imagesx($ori); $thumb = imagecreatetruecolor (150,150*$faktor); // echo "image: ".$image; // echo "aktdir: ".$dir."view/".$name; if(!copy ($image,$dir."view/".$name)) { imagedestroy($thumb); imagedestroy($ori); die("kopie 1 fehlgeschlagen"); } # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), $x, $y); } else { $faktor=imagesy($ori)/imagesx($ori); $new= imagecreatetruecolor (1024,1024*$faktor); $thumb = imagecreatetruecolor (150,150*$faktor); # imagecopyresized ( $new, $ori, 0, 0, 0, 0, 1024, round(1024*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $new, $ori, 0, 0, 0, 0, 1024, round(1024*$faktor,0), imagesx($ori), imagesy($ori)); # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); } } else { if(imagesy($ori)<768) { $smaller=1; $faktor=imagesx($ori)/imagesy($ori); $thumb = imagecreatetruecolor (112*$faktor,112); if(!copy ($image,$dir."view/".$name)) { imagedestroy($thumb); imagedestroy($ori); die("kopie 2 fehlgeschlagen"); } # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); } else { $faktor=imagesx($ori)/imagesy($ori); $new= imagecreatetruecolor (768*$faktor,768); $thumb = imagecreatetruecolor (112*$faktor,112); # imagecopyresized ( $new, $ori, 0, 0, 0, 0, round(768*$faktor,0), 768, imagesx($ori), imagesy($ori)); imagecopyresampled ( $new, $ori, 0, 0, 0, 0, round(768*$faktor,0), 768, imagesx($ori), imagesy($ori)); # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); } } imagedestroy($ori); if($smaller==0) { echo 'Ausgabebild: '.$dir.'view/'.$name; imagejpeg($new,$dir.'view/'.$name,85); imagedestroy($new); } echo 'Vorschaubild: '.$dir.'thumb/'.$name; imagejpeg($thumb,$dir.'thumb/'.$name,100); imagedestroy($thumb); } require('connect1.php'); require('inc_query.php'); if(isset($_FILES['userfile']['name'])) { $name=time().'.jpg'; echo "DEBUGINFORMATION:"; echo "name:".$name.""; echo "tmp name:".$_FILES['userfile']['tmp_name'].""; if(move_uploaded_file($_FILES['userfile']['tmp_name'],'/srv/www/phpup/'.$name)) { resize('/srv/www/phpup/'.$name,$name,'/srv/www/htdocs/aktuell/'); unlink('/srv/www/phpup/'.$name); $erg=query($link,"update news set news_pic='".$name."' where news_id=".$_REQUEST['id'].";"); echo ''; if(iss
[PHP] Encoding PC-850
Hi! I need to be able to encode text to PC-850 but I have big trouble finding out info about this encoding. Does it even exist? I get a few google hits, but nothing useful. Any idea of how I can convert for example an UTF-8 string or an ISO-8859-1 to this PC-850 format? Thanks for any input. Regards Emil
RE: [PHP] Is there such a thing?
[snip] http://www.evilbitz.com/2006/10/27/local-php-standalone-binaries-2/ http://gtk.php.net/ [/snip] http://www.priadoblender.com/index.php?layout=main&cslot_1=2 is another 'option' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Search Engine - Synonyms
Another idea from what I just sent: try googling "synonym database". It looks like there are a few leads in there as well. On Oct 30, 2006, at 6:26 AM, Kevin wrote: Hi, Is it possible to automatically search for synonyms related to a word in a search engine for example if I create a search engine and search for the word 'Horse', it would automatically search for other words such as 'Pony' etc? Has anyone had any experience on how this would be implemented? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Search Engine - Synonyms
Hi, Is it possible to automatically search for synonyms related to a word in a search engine for example if I create a search engine and search for the word 'Horse', it would automatically search for other words such as 'Pony' etc? Has anyone had any experience on how this would be implemented? Thanks Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagecopyresampled creates black pictures
On Oct 30, 2006, at 12:52 AM, Martin Hochreiter wrote: Hi! I'm using imagecopyresampled to create thumbnails of various pictures. That works well except some pictures that imagecopyresampled converts to small black thumbnails (although it converts it correctly to a bigger size) What is wrong here? No idea off-hand, but it would probably help if you you included more information like source code and details about the images that are not working. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A general UL script
On Monday 30 October 2006 06:08, Richard Lynch wrote: > On Sat, October 28, 2006 4:06 pm, Børge Holen wrote: > > I'm trying to validate wether or not to run the image check script. > > however empty the file field(s) are This script is started... how do I > > tell it > > there is nothing here, go do other stuff. > > for both multiupload forms and single upload forms since they're > > supposed to > > share this script. My logic tells me there should be something like > > this if > > statements, but then again, I'm more of a copy paster rather than a > > expert. > > Read the documentation about what will and won't happen if the user > does or doesn't fill in one or more FILE inputs: > http://us3.php.net/manual/en/features.file-upload.php > > There is nothing at all tricky in this, really, if you read the docs... Well... I've made one from that page, read all 'bout it. See, the problem lies in the multifile uploader form; * First it insert an empty file field (hidden). * Second, I rename all files to an md5 hash. * Third, The md5 hash makes legal filenames witch enables my toolset to modify modify/validate my jpg. * Forth and last moves them into my webtree. The problem I seem to be getting at is this; How do I remove, lets say, file nr 3 of 6. The input fields can easily (because fields is removed and added dynamicly) be named everything from 'file_1' to 'file_20'. I only want jpg's , so that gif in nr 3 has to be removed before the md5 hash rename. I could use splice_array to get at it just as I do with the first empty one, but then again, how do I count down the fields to get to the non valid file types. I got some functions I found somewhere, that actually does this whole thing... except the md5, witch leads to some filename corruptions 'cus of the characters we have here in norway/sweden/denmark, the famous øæå. It handles both the filename extension(if not containong æøå) and empty fields. But I rather build something from ground up so I can learn it well, instead of using code I've not put together myself. > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some starving artist. > http://cdbaby.com/browse/from/lynch > Yeah, I get a buck. So? -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: >> On Friday 27 October 2006 19:34, Richard Lynch wrote: >>> And the header("Location: ...") requires a full URL. >> >> No it doesn't. but he's missing an ' at first glance > > Yes, it does: > http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 > > Note the use of 'absolute' within that section. Although I always use a full URL as well, doesn't absolute just mean non-relative? As in: Location: /Protocols/rfc2616/rfc2616-sec14.html#sec14.30 (absolute URI) Location: ./rfc2616-sec14.html#sec14.30 (relative URI) If you need contextual information to make sense of the URI (such as the server name from a previous request) then it's not absolute. RFC 2396: Uniform Resource Identifiers "An absolute identifier refers to a resource independent of the context in which the identifier is used. In contrast, a relative identifier refers to a resource by describing the difference within a hierarchical namespace between the current context and an absolute identifier of the resource." -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Imagecopyresampled creates black pictures
Hi! I'm using imagecopyresampled to create thumbnails of various pictures. That works well except some pictures that imagecopyresampled converts to small black thumbnails (although it converts it correctly to a bigger size) What is wrong here? lg Martin (Suse Linux 10.1, Apache 2.2, gd 2.0.32, php 5.1) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Query question
On Sun, 29 Oct 2006 23:04:27 -0600, Richard Lynch wrote: > On Sun, October 29, 2006 2:06 am, Beauford wrote: >> LOL, I don't know either. The format is - 01/01/2006. When I first did >> it I >> used 7, which should be right, but I ended up getting /2002 /2003, >> etc. So I >> went to 8 and all was well. Beats me. > > Dollars to donuts says your 'date' (which is really a string) has some > leading spaces which is messing up your count... > > Of course, after you fix the import process to have an actual DATE in > your DB, this will be a non-issue... > > Short-term, you should probably at least trim() the data so that your > offset of 8 is the number you would expect... Or, you use RIGHT(date, 4) as I believe MySQL always automatically removes trailing spaces in VARCHAR columns. It will save you the use of one additional function and RIGHT() may even be faster than SUBSTRING() because it doesn't need to go through the entire string. But that's just guessing and I think you probably won't even notice this in microseconds :) Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: >> On Friday 27 October 2006 19:34, Richard Lynch wrote: >>> And the header("Location: ...") requires a full URL. >> >> No it doesn't. but he's missing an ' at first glance > > Yes, it does: > http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 > > Note the use of 'absolute' within that section. Although I always use a full URL as well, doesn't absolute just mean non-relative? As in: Location: /Protocols/rfc2616/rfc2616-sec14.html#sec14.30 (absolute URI) Location: ./rfc2616-sec14.html#sec14.30 (relative URI) > You can argue that they shouldn't have designed the spec that way. > > You can argue that it "works" in all popular browsers. > > But there ain't much to argue about what the spec says... Agreed. One should always follow the spec. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php