Re: [PHP] Pass a relative path [with slashes] into a 'clean' url
Assuming you mean URLs as GET variable values, urlencode() and urldecode() might be the ticket: http://ca.php.net/urlencode Aaron On 12/4/06, Graham Anderson [EMAIL PROTECTED] wrote: What is a good/accepted way to pass a relative or absolute path into a clean url ? I could replace the relative url's slashes with another character, but would love to know a cleaner less confusing way...if it exists example url: http://localhost/testscript/../image.png/jpeg/42/0/ example php: list($dummy,$relative_path,$type, $color, $cache) = explode('/', $_SERVER['PATH_INFO']); where: $relative_path=../image.png $type=jpeg $color=42 $cache=0 many thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- +- | Aaron Koning | Information Technologist | Prince George, BC, Canada. +- | Flexible Internet Spatial Template: | http://fist-mapping.org +-
Re: [PHP] Splitting a string
Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only 4 numbers are left $var2 = substr($number,$length-4,2); // get 3rd and 4th last numbers. $var3 = substr($number,$length-2,2); // get last two numbers. Aaron On 11/14/06, Børge Holen [EMAIL PROTECTED] wrote: This numer has dynamic lenght, witch is the root of my problems. $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. I've been using substr with negative numbers to fetch the last two vars. thereafter explode to get the first number. Ok I understand the code and can use it, but it feels wrong. Does anyone have any idea on suitable functions for such a task, both more size (as in code) and speed effective. It is not a mission critical, but moreover a opinion of what things should look like. I've been looking into string/explode functions on php.net without getting past my current code. -- --- 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 -- + | Aaron Koning | Information Technologist | Prince George, BC, Canada. + | http://datashare.gis.unbc.ca/fist/ | http://datashare.gis.unbc.ca/gctp-js/ +
Re: [PHP] Finding out the upload date of the file
http://ca.php.net/stat Might do it for you. Maybe check access time, although if you access the file at after its uploaded, the access time is changed. Maybe mtime? Aaron On 6/23/06, Ko Ko [EMAIL PROTECTED] wrote: Hi, How can I find out the upload date of the file to the server using PHP function? Regards, Ko Ko Reality starts with Dream - How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates. -- + | Aaron Koning | Information Technologist | Prince George, BC, Canada. + | http://datashare.gis.unbc.ca/fist/ | http://datashare.gis.unbc.ca/gctp-js/ +
Re: [PHP] move_uploaded_file and CPU wait state (IO)
Are you sure its the move_uploaded_file() function that is causing the delay? It could be the actual upload of the file itself. If it is the function causing the delay than try the rename() function instead. Also, I have used the copy() and unlink() functions and they work fast. Aaron On 2/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, My first mailing, if I'm in wrong group or such, let me know ;) Here comes my question. I have implemented file uploads to my server. At the end of upload, file is beeing moved from /tmp to permanent directory. However, whenever this happens, CPU goes berzerk and waits for disk to finish moving file. As allowed files may be up to 100 MB per file, having more then 3 users makes complete server freeze. Meantime, server load reaches skyhigh 40+. After file is moved, server resumes normal operation, however while moving file server is completely not responding. Is there a work around? I am not so good with linux (yet ^^), so I do not know if there is place for improvement on OS itself. I asked this question on Debian forum, but am trying here as well. If someone has same problem and prefferably solution, or even sugestions - all is welcome! :) Server P4 2.0 512 MB RAM (will be 2 GB by the end of the week) 2 x 80 GB IDE HDD Thank you! Regards, Aleksandar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- + | Aaron Koning | Information Technologist | Prince George, BC, Canada. + | http://datashare.gis.unbc.ca/fist/ | http://datashare.gis.unbc.ca/gctp-js/ +
Re: [PHP] how 2 open File Browser window in PHP
Please attempt to search www.php.net first for this information. A search for 'file uploads' reveals what you want: http://ca.php.net/features.file-upload Aaron On 1/16/06, suresh kumar [EMAIL PROTECTED] wrote: hi, i dont know exact PHP code for how 2 open file browser window to uplad file or an image plz help me.its very urgent. A.suresh Send instant messages to your online friends http://in.messenger.yahoo.com
Re: [PHP] Cookie problem
Try simplifying the problem to determine the error point. For example don't involve $_POST just try setting a cookie with hard coded variables. If that works then add in the $_POST and test for BOTH $_POST['prefs'] and $_POST['filter']. Example of simplification: ?php // Send cookie setcookie(listpref,selected,time()+7776000); ? Aaron On 1/14/06, Al [EMAIL PROTECTED] wrote: Can't get a cookie to set. Below is the code near the file top BEFORE any html output. $_POST['prefs'] comes from a hidden field in the middle of the html output. $_POST['filter'] comes from a select option. A Submit button closes the page and refreshes it. print_r($_POST) shows $_POST['prefs'] $_POST['prefs'] are just as I expect when the page refreshes. ## code print_r($_POST) session_start(); print_r($_COOKIE); if(isset($_POST['prefs'])) $cookie= setcookie(listpref, $_POST['filter'], time()+7776000); var_dump($cookie) shows bool TRUE I added the session_start() as a test. print_r($_COOKIE) shows the session ID cookie works just fine. IE6 and Firefox don't record the regular cookie. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] private, public, protected in 4.3.11
exception, final, php_user_filter, interface, implements, extends, public, private, protected, abstract, clone, try, catch, throw where not introduced until PHP 5 (http://ca3.php.net/reserved). Therefore, var is the only way to define member variables prior to PHP 5. Aaron On 1/11/06, Peter Lauri [EMAIL PROTECTED] wrote: Hi, Example code that I try to run in version 4.3.11: Class Page { private $myID; function Page() { $this-myID=1; } function getID() { return $this-myID; } } But I get error message: Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in C:\Documents and Settings\Peter Lauri\My Documents\DWS Asia\webserver\ework\classes\page.class.php on line 8 If I change to var $myID; it works. What is wrong? /Peter
Re: [PHP] question about compositing objects
$map is not a member variable of the Loc class in your code... Instead do this: class Loc { // Defines a member variable var $map; // Constructor function Loc() { $this-map = new Map(); // Create map object and save to Loc object $this-map-setKey(); } } $loc = new Loc(); $loc-map-publicMapFunction(); Aaron -- On 1/12/06, jonathan [EMAIL PROTECTED] wrote: I have a class which creates another class within it such as: class Loc{ public function outputInfo() { $map=new Map(); $map-setKey(); } } In my main page can I access the $map object like this: $loc=new Loc(); $loc-map-publicMapFunction(); I thought I would be able to but it doesn't seem like it. thanks in advance. -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning: Missing argument 7 calling a function
Why not send us the Call and the Function for arguments sake (pun intended). Aaron On 1/6/06, enediel gonzalez [EMAIL PROTECTED] wrote: Hello I've a function with 6 arguments that works properly. Trying to add a 7th argument an being sure that calling the function I pass that one I received the following message (several times) on my web page Warning: Missing argument 7 for getcommanddeclaration() in /var/www/cp/apply.php on line 56 It's only one place where this function is called Thanks in advance for any help Enediel Linux user 398956 Debian GNU/Linux -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Set variable outside of scope (redo)
Generally, scope is fairly loose in PHP. If $row is set by mysql_fetch_array(...) it should carry throughout your script as it is, unless modified. Try commenting out non-relavant pieces of the code and var_dump(...)ing the $row variable at the start and throughout the script. Aaron On 1/5/06, Mike Tuller [EMAIL PROTECTED] wrote: Excuse the last post, I didn't have all the code it there. I have a table listing items in a database, and have a delete button next to each item, and I want to be able to click on the delete and delete only that record in the database and then reload the page where it would display the updated information. Here is part of the code I have. // list elements one by one until there are no more in the database while ( $row=mysql_fetch_array($result2) ) { if ($row[range] != ) { echo form action=.$_SERVER['PHP_SELF']. method=\post\ name= \deleteRange\ tr class=\trlist\ td$row[id]/td td$row[range]/td td align=\right\input type=\submit\ name=\deleteRange\ value=\Delete\ //td /tr /form ; } } echo /table; echo br / form action=.$_SERVER['PHP_SELF']. method=\post\ name= \addrange\ table class=\nolist\ tr tdAdd Range: $row[id]/td tdinput type=\text\ name=\name\ size=\53\ tabindex=\9 \ //td td align=\right\input type=\submit\ name=\addRange\ value=\Add Range\ //td /tr /table /form; } elseif (isset($_POST['deleteRange'])) { $query = delete from district.ip_range where id = $row[id]; mysql_query($query, $link) or die (mysql_error()); echo Record .$row[id]. has beed deleted.; } They key I am using to find the record I want to delete is the the $row[id], but that is out of the scope of where the variable is set. Is there a way to set a variable so that it goes outside the scope? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One big file or many includes?
I don't know about whats best for the compiler (rather interpreter), but if it is a really big site with a lot of access, transaction and management functionality I recommend you start breaking the code into classes and separating each class into a file and documenting... A LOT! It will be clearer to understand and maintain. IMHO. There are lots of sites out there that describe how to separate web code into layers such as: display, logic/rules, database interactivity, etc. Aaron On 12/15/05, Martin Leduc [EMAIL PROTECTED] wrote: Hi everyones, I coding PHP since 2002 and this is the first time I have to take this decision. My group and I have to build a VERY, VERY BIG website for a callcenter users. Understand I have to create (or use ;)) several code for access, transactions and management. The customer had buy MSSQL server, so we have to use it and it's working very fine. NO MYSQL (is not my personal choice ;)) Currently it's already hard to program and now we have many file. We have only 20% done and the code are a real mess!!! Creating Class, functions, splitting code in several php files using include, see the files sitemap?? So for the optimisation topic, what is THE BEST for the PHP compiler. One big file or many included files? Regards Martin PS: If some one know somes related links about the subject, please dont hesitate. ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Post-Vars doubled / corrupted
I wasn't aware you could use = instead of echo (? =$_SERVER['PHP_SELF'] ?). Try making an even simpler HTML/PHP example and see if the problem exists there. Then you can incrementally build your HTML/PHP back up to the point where it is breaking. Example: ?php print_r($_POST); ? html head /head body form action= method=post input type=hidden name=testvar value=pleasedontcorrupt / input type=submit name=submit value=Submit / /form /body Aaron On 12/15/05, Sabine [EMAIL PROTECTED] wrote: Hello to all, I distributed my app to a new server and suddenly had values saved twice in the db and so on. I tracked it down and found out, that the problem is the content of $_POST. Vars are doubled, Strings corrupted. Absolutely absurd. I have no idea where to search for the reasons. PHP-Version is 4.3.11 Does anybody else have an idea? Thank you in advance Sabine A simple testcase: ?php echo Post:; var_dump($_POST); ? html body form id=formular action=?=$_SERVER['PHP_SELF'] ? method=post ul id=colors liinput class=buttons name=colors[] id=id1 type=checkbox value=1 title=chose color /label for=id1red/label/li liinput class=buttons name=colors[] id=id2 type=checkbox value=2 title=chose color /label for=id2blue/label/li liinput class=buttons name=colors[] id=id3 type=checkbox value=3 title=chose color /label for=id3green/label/li liinput class=buttons name=colors[] id=id4 type=checkbox value=4 title=chose color /label for=id4yellow/label/li /ul fieldset class=nolegend input type=submit value=change colors name=aendern /nbsp;nbsp;nbsp; input type=submit value=save colors name=speichern / /fieldset /form /body /html Output for $_POST, if you just click on change colors: Post: array(1) { [aendern]= string(34) change colorsaendern=change colors } Output, if you check only red and click change colors: Post: array(2) { [colors]= array(1) { [0]= string(1) 1 } [aendern]= string(13) change colors } output for 2 colors checked: Post: array(2) { [colors]= array(3) { [0]= string(1) 1 [1]= string(1) 2 [2]= string(1) 2 } [aendern]= string(13) change colors } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] encrypt and dcrypt
Ganu, Are you simply looking to use the md5 string for authentication? If so you don't need to retrieve the decrypted version, simply encrypt what the user submits and compare the two md5 strings. Aaron On 12/15/05, Chris Shiflett [EMAIL PROTECTED] wrote: ganu wrote: I want a function like md5() by which I can encrypt a code and again when I need from db i can dcrypt also. but in md5() this func. is not there. I can not go in reverse way. If a simple PHP function could encrypt and decrypt data with no arguments other than the string, anyone could decrypt your data. In other words, it can't be as simple as md5(). You might find the code samples at the bottom of this page helpful: http://phpsecurity.org/code They primarily cover using mcrypt. There's also an article by Robert Peake that's pretty good: http://www.phpmag.net/itr/online_artikel/psecom,id,667,nodeid,114.html Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Post-Vars doubled / corrupted
Hi Sabine, Its been my experience that you need square brackets after the input checkbox name for PHP to see an array. This page discusses that: http://www.evolt.org/article/Storing_form_array_data_to_MySQL_using_PHP/18/60222/ Change your code to the following and give it a try. ul id=colors liinput name=colors[] id=id1 type=checkbox value=1 /label for=id1red/label/li liinput name=colors[] id=id2 type=checkbox value=2 /label for=id2blue/label/li /ul Aaron On 12/15/05, Sabine [EMAIL PROTECTED] wrote: Hi Aaron, thanks for your answer. The HTML elements, which represent arrays are causing problems. I just added ul id=colors liinput name=colors id=id1 type=checkbox value=1 /label for=id1red/label/li liinput name=colors id=id2 type=checkbox value=2 /label for=id2blue/label/li /ul to your minimalistic script. Checked both and got Array ( [colors] = Array ( [0] = 1 [1] = 2 [2] = 2 ) [testvar] = pleasedontcorrupt [submit] = submit ) for post. I don't really think it's a problem of my code. Perhaps a problem of the servers configuration. But I'm not really familiar with installation and configuration duties. So I don't know where to search. But meanwhile I read something about input filters in Apache 2. And thought if there is a filter on this server which corruptes my post vars? Config is (I don't know which parameters are really importend): [IHOST_VERSION]= Linux-1.0 [SERVER_SOFTWARE]= Apache/2.0.55 [SERVER_PROTOCOL]= HTTP/1.1 PHP 4.3.11 Server API Apache 2.0 Filter I searched for information if PHP 4.3.11 is supposed to work fine with Apache 2.0.55, but didn't find a clear answer. Perhaps you know (or someone else knows) if my thoughts are going in the right direction? Bye Sabine Aaron Koning schrieb: I wasn't aware you could use = instead of echo (? =$_SERVER['PHP_SELF'] ?). Try making an even simpler HTML/PHP example and see if the problem exists there. Then you can incrementally build your HTML/PHP back up to the point where it is breaking. Example: ?php print_r($_POST); ? html head /head body form action= method=post input type=hidden name=testvar value=pleasedontcorrupt / input type=submit name=submit value=Submit / /form /body Aaron On 12/15/05, *Sabine* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello to all, I distributed my app to a new server and suddenly had values saved twice in the db and so on. I tracked it down and found out, that the problem is the content of $_POST. Vars are doubled, Strings corrupted. Absolutely absurd. I have no idea where to search for the reasons. PHP-Version is 4.3.11 Does anybody else have an idea? Thank you in advance Sabine A simple testcase: ?php echo Post:; var_dump($_POST); ? html body form id=formular action=?=$_SERVER['PHP_SELF'] ? method=post ul id=colors liinput class=buttons name=colors[] id=id1 type=checkbox value=1 title=chose color /label for=id1red/label/li liinput class=buttons name=colors[] id=id2 type=checkbox value=2 title=chose color /label for=id2blue/label/li liinput class=buttons name=colors[] id=id3 type=checkbox value=3 title=chose color /label for=id3green/label/li liinput class=buttons name=colors[] id=id4 type=checkbox value=4 title=chose color /label for=id4yellow/label/li /ul fieldset class=nolegend input type=submit value=change colors name=aendern /nbsp;nbsp;nbsp; input type=submit value=save colors name=speichern / /fieldset /form /body /html Output for $_POST, if you just click on change colors: Post: array(1) { [aendern]= string(34) change colorsaendern=change colors } Output, if you check only red and click change colors: Post: array(2) { [colors]= array(1) { [0]= string(1) 1 } [aendern]= string(13) change colors } output for 2 colors checked: Post: array(2) { [colors]= array(3) { [0]= string(1) 1 [1]= string(1) 2 [2]= string(1) 2 } [aendern]= string(13) change colors } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random Images with no duplicates?
This should work, although if there are only 9 lines in the file, it will run infintely (or until the page times out)... so put a check in for that. $imagesNeeded = 10; $imageArr = array(); // Create array with $imagesNeeded number of elements. for($i=0;$i$imagesNeeded;$i++) { // choose image $tmpImg = $openFile[array_rand($openFile)]; // Keep getting images until the image you have is not in the existing array of images while(in_array($tmpImg,$imagesArr)) { // choose image $tmpImg = $openFile[array_rand($openFile)]; } // Put unique image into array array_push($imageArr,$tmpImg); } // You now have an array called imageArr with 10 elements/images in it. Aaron On 12/15/05, Mike Rondeau [EMAIL PROTECTED] wrote: Hi, I'm still very green with PHP, but am working to fix that. I've searched high and low for an answer to this question and so far no solution has presented itself. I have a script to populate my web page with random images: ?php #random images example #this is your file $file = images.txt; #open the file $openFile = file($file); #generate a random number srand((double)microtime()*100); #get one of the entries in the file $random_image = $openFile[array_rand($openFile)]; #display the entry echo img src='$random_image' height='170' width='100'/img; ? This works beautifully, but my problem is that sometimes, the same image displays twice or more on the same page-load. My page requires 10 different places where my images need to load, but I can't have any duplicate images show up. Any suggestions on what I need to modify here? Thanks in advance! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple-ish question but something i never knew
My experience was with the Location keyword, it might work better with the Redirect keyword in the header function. I stopped using header and Location after a few problems and meta has never failed for me. MHO. Aaron On 12/9/05, Michael Hulse [EMAIL PROTECTED] wrote: On Dec 9, 2005, at 11:35 PM, Aaron Koning wrote: Its been my experience that meta tags work better. I guess what you are saying is that this: meta http-equiv=refresh content=0;url=https://www.theNewUrl/forward.html; Is better than this: header(Refresh: 0; URL=https://www.theNewUrl/forward.html;); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple-ish question but something i never knew
I have found that using the header function doesn't actually redirect the page, it pulls the content into the page that the function is called from (which works good for somethings, but can get confusing with post variables and such). Its been my experience that meta tags work better. Aaron On 12/9/05, Robert Cummings [EMAIL PROTECTED] wrote: On Sat, 2005-12-10 at 02:07, matt VanDeWalle wrote: I am wanting to forward a user on a signup or similar page (based on a few of their answers) and so far i have it split into basically a two-step process where i have on the first part, an option list with 4 choices, they hit continue or some such labled link, and then having passed all the session variables and making the decision in the next script it would forward them to the right page automatically, do I have to use meta tags to do this or is there some simple way e.g, url=http://rightpage.php?SID; of course without the 's except for in the actual url I could have probably done this switch on the fly like some pages do but I was told that requires java and i don't have or want to use java lol matt if possible i want to keep my webpages java free header( 'Location: http://www.somewhere.com/the/page/to/load.php' ); The parameter to the Location header should be a full URL, although many browsers tolerate relative. 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