Re: [PHP] Image Creation and Saving
Are you making sure the $_SESSION['user_sn'] folder exists before saving the image into it? I'm asking because I originally thought it was a permission problem but php will tell you 'permission denied' if that was the case. At 05:05 PM 1/29/2005, NathanielGuy#21 wrote: Hello everyone, I have been troubleshooting a problem with one of my scripts for a while now, its purpose is to allow a user to upload a file, save it to the server, resize it into a thumbnail, and save the thumbnail as well. In my script all goes well until it comes to saving the images, the script throws these errors: Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 91 Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 95 Picture ffq was added to our database! The following is what we have generated and it is what others will see Here is the important part of the script, if more is needed i can post it as well. if ($mime_type == 'jpeg') { $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'png') { $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'gif') { $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']); //Create an image refrence } //Image Sizes list($new_image_width, $new_image_height) = getimagesize($_FILES['new_image']['tmp_name']);//Get img size if ($new_image_width $new_image_height) {//Get thumb size $percent_image_size = (200 / $new_image_width); } elseif ($new_image_width $new_image_height) { $percent_image_size = (200 / $new_image_height); } else { $percent_image_size = (200 / $new_image_height); } $new_thumb_width = ($percent_image_size * $new_image_width); $new_thumb_height = ($percent_image_size * $new_image_height); $new_thumb_file = imagecreatetruecolor($new_image_width, $new_image_height); imagepng($new_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png'); //Copy pic to user dir as pic_id.png $new_thumb_image = imagecreatetruecolor($new_thumb_width, $new_thumb_height); // Create Thumb file imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0, $new_thumb_width, $new_thumb_height, $new_image_width, $new_image_height); //Copy resized to new thumb file imagepng($new_thumb_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png'); //Save image thumb I am very new to file/image manipulation in php so if you see any errors, or unnecessary code please tell me. I'm not quit sure how everything works, although I do have a theoretical picture of how it does. Any comments will be appreciated. --nathan -- http://www.blacknute.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
[PHP] question on getting URL
I have a script called index.php on my main page and it actually is used to launch several webpages like so; http://mysite.com/index.php?id=16 When http://mysite.com runs it still uses index.php. but it doesn't show it in the address bar. All it shows is; http://mysite.com What I would like to do is to get the information from the address bar to know when I am on the main page. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question on getting URL
$file = basename(_FILE_); On Sun, 2005-01-30 at 01:26, David Banning wrote: I have a script called index.php on my main page and it actually is used to launch several webpages like so; http://mysite.com/index.php?id=16 When http://mysite.com runs it still uses index.php. but it doesn't show it in the address bar. All it shows is; http://mysite.com What I would like to do is to get the information from the address bar to know when I am on the main page. -- -- Regards, Matthew Fonda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] General question: packaging in PHP
Hello, i've a general question concerning PHP's architecture. Why isn't there a native packaging concept in PHP? I think php became much more powerfull with the extended OOP features introduced in PHP5 - without a packaging concept you couldn't use these features in big business (in terms of sharing classes/libraries). I know the discussion of OOP features vs. PHPs scripting capabilities, but IMHO doing the half way of OOP isn't right... Are there any thoughts about that in future releases? What do other developers think about this issue? How do organize multiple used classnames? Thanks for your answers.. with best regards, vivian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General question: packaging in PHP
From: Vivian Steller [EMAIL PROTECTED] i've a general question concerning PHP's architecture. Why isn't there a native packaging concept in PHP? This was also suggested on comp.lang.php, recently (the nested class thread), called namespaces, but there wasn't a lot of enthusiasm for it. Apparently, it was even implemented at one point, but then subsequently dropped. I've found it difficult to find the relevant discussion in the archive (possible the internals-list or Zend's engin2-list), could anyone provide a link? I think php became much more powerfull with the extended OOP features introduced in PHP5 - without a packaging concept you couldn't use these features in big business (in terms of sharing classes/libraries). I know the discussion of OOP features vs. PHPs scripting capabilities, but IMHO doing the half way of OOP isn't right... I guess package/namespace doesn't have a lot to do with OO (except that they both allow grouping of functionality, and avoiding name collision, but that's not the only benefit of OO), but as there hasn't been any enthusiasm for overloading, either (not even for user-defined types, where you _can_ use type hints in function signatures), and it's common in OO languages, I guess you have a point. Interestingly, I found that Perl has the possibility of function overloading (also a language that's dynamically typed) (http://www.math.tu-berlin.de/polymake/perl/overload.html) It also has - like Python - operator overloading. But is there any enthusiasm for that in the PHP community, either? Nah... Are there any thoughts about that in future releases? What do other developers think about this issue? How do organize multiple used classnames? The common answer is: Use a prefix... Regards, Terje -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General question: packaging in PHP
verffentlicht per Mail versendet Thanks for your answer! Terje Sletteb wrote: From: Vivian Steller [EMAIL PROTECTED] i've a general question concerning PHP's architecture. Why isn't there a native packaging concept in PHP? This was also suggested on comp.lang.php, recently (the nested class thread), called namespaces, but there wasn't a lot of enthusiasm for it. Apparently, it was even implemented at one point, but then subsequently dropped. I've found it difficult to find the relevant discussion in the archive (possible the internals-list or Zend's engin2-list), could anyone provide a link? I think php became much more powerfull with the extended OOP features introduced in PHP5 - without a packaging concept you couldn't use these features in big business (in terms of sharing classes/libraries). I know the discussion of OOP features vs. PHPs scripting capabilities, but IMHO doing the half way of OOP isn't right... I guess package/namespace doesn't have a lot to do with OO (except that they both allow grouping of functionality, and avoiding name collision, but that's not the only benefit of OO), but as there hasn't been any enthusiasm for overloading, either (not even for user-defined types, where you _can_ use type hints in function signatures), and it's common in OO languages, I guess you have a point. Thanks for metioning this issue! This is another point where I think OO is done the half way in PHP: Why do we need some implicit type check, like public method(Type $type) if we then loose the optional parameter advantage? Either some polymorphism mechanism should be implemented, or something like public method(Type $type = new MyType()) should be able being passed through the interpreter.. also the primitive datatypes should be (exceptionally) used here: public method(string $argument) Otherwise (IMHO) the typecheck mechanism is useless. Interestingly, I found that Perl has the possibility of function overloading (also a language that's dynamically typed) (http://www.math.tu-berlin.de/polymake/perl/overload.html) It also has - like Python - operator overloading. But is there any enthusiasm for that in the PHP community, either? Nah... regrettably... :( Are there any thoughts about that in future releases? What do other developers think about this issue? How do organize multiple used classnames? The common answer is: Use a prefix... but i really dislike using cryptic and long prefixes to ensure uniqueness... dots in the classname (ok, doing it like java) would be so nice, gr** Regards, Terje vivian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a mysql_connect() bug?
Thanks everyone for all the help. I found the problem. It has to do with a bug in my error handler class that my script loaded prior to executing mysql_connect(). Once I removed the error handler class, mysql_connect() started to behave as expected. My bad. Tom On Sun, 30 Jan 2005 01:16:10 -0600, Michael Sims [EMAIL PROTECTED] wrote: tom soyer wrote: Thanks for the error handling code. I think PHP still has a basic problem. If mysql sever connection times out because wrong username or password was used, then mysql_connect() should return FALSE. It does, at least for me on PHP 4.3.10 connecting to a local MySQL 4.0.23 server on Debian. It returns a boolean false, and a warning is triggered: Warning: mysql_connect(): Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in ... If I give it a server name it cannot connect to (due to a firewall blocking the connection, for example) it will hang for about 60 seconds then return false, triggering a warning: Warning: mysql_connect(): Can't connect to MySQL server on ... I was going to suggest that you run a cli test script and trace the system calls to see what's going on but then I saw that you're using Windows. I'm not sure if there is an strace/truss equivalent for it (anyone know)? -- 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] design pattern/code generators
robert mena wrote: Hi All, I am looking for advice regarding design patterns/code generation in PHP5. I have a simple code generation tool (written in PHP) to interface with database. It works fine for simple situations but seems a little strange for more complex ones. Suppose I have a table user (id, name, age) and a table account(idAccount, idUser, name). My generator creates a class for each table and a standard db class. Each class basically has a set/get method for each property and some standard insert, delete, update, search methods ex. class user { var $db function setName(..) function getName() function insert() { $this-db-query(insert into user values...) } ... } I've omited the other methods/constructor but you can get the picture. The problem comes when I have to access information the comes from 2+ tables. Suppose I have to show all users accounts. Now I end up with something like this. $u = new User() ; $a = new Account() ; if($u-search()) { for($i=0;$i...) { $idUser = $u-getId() ; $u-next() ; $a-setIdUser($idUser) ; if($a-search()) { // print } } While this works I feel there must be an easier/cleaner way. If I was just querying the database a join would give me the result in one pass. the join is based on a foreign key constraint - An idea might be to generate a method based on the FK details (in either or both relevant classes), if you are using an older version of mysql, or don't actually define the constraint in the DB, then this maybe impossible - unless you use a config file to generate each class. so that you can do: $user = new User(); $ac = $user-getAccount(); // returns the correct Account object. In my case what should I do ? create a new method showAccounts ? Where should I put it, in User or Account class ? on the User class, Account would probably want a method like showUser(). I am interested in advices regarding how to design it better so I can make the proper adjustments in my generator. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Permissions on uploaded image don't allow for over writing
John, Hugh, I'm not sure what you mean when you say use PHP's FTP. I'm using $HTTP_POST_FILES because the files are retrieved through a web form. As for the user, I would assume that it's whatever default for any viewer coming to a web page. I have people log in using a user name and password retrieved from a MySQL database, but I don't see how the browser or the server would know about that. The thing is I'm really a newbie at this Unix server and file permission thing. I was really hoping that there was some parameter I could set to have the uploaded file set to full access permissions, as it took all the PHP scripting knowledge I had just to get it working as much as it is now. I guess what confuses me most is, if the file was uploaded from a user from the web, how is it not already on the same permission level for other users also accessing the file from the web? It seems like any user can upload and make a file that they can't touch again, and requires an administrator to get rid of. -- Dave Gutteridge [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...
? class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $a = new A(wsx); $arr[1] = $a; //But watch the output!!! // It is (qaz)(qaz), which means that the attribute of a first // object assigned to array is outputted!!! WHY?!?!!! foreach($arr as $a) { echo (.$a-name.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...
No news.php.net wrote: ? class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $arr[0] and $a reference now the same variable $a = new A(wsx); by changing $a you also changed $arr[0] $arr[1] = $a; now $a, $arr[0] and $arr[1] reference the same variable, they just have different names. More: http://sk.php.net/manual/en/language.variables.php http://sk.php.net/manual/en/language.references.php //But watch the output!!! // It is (qaz)(qaz), which means that the attribute of a first // object assigned to array is outputted!!! WHY?!?!!! foreach($arr as $a) { echo (.$a-name.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...
No news.php.net wrote: ? class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $arr[0] and $a reference now the same variable $a = new A(wsx); by changing $a you also changed $arr[0] No. referencs are not pointers! Here in $a = new A(wsx) I assign $a by reference, and now $a references the different location, and $arr[0] references the same. Assigning $a by references doesnt affect $arr[0], though the pointed to the same location before... After all this is the prove: This is my previous assignment code: class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $a = new A(wsx); $arr[1] = $a; //HERE IS THE PROVE print_r($arr); //Watch the OUTPUT... there are DIFFERENT objects laying in the array! This is the point of my question... // But if you do this: foreach($arr as $a) { echo (.$a-name.); } // You see that iterating the objects it somehow references the same object... // or the same 'name' attrribute of the first object in the array... $arr[1] = $a; now $a, $arr[0] and $arr[1] reference the same variable, they just have different names. More: http://sk.php.net/manual/en/language.variables.php http://sk.php.net/manual/en/language.references.php //But watch the output!!! // It is (qaz)(qaz), which means that the attribute of a first // object assigned to array is outputted!!! WHY?!?!!! foreach($arr as $a) { echo (.$a-name.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
Ah, thank you. after checking that the folder was there I found I had made a mistake in the path to the folder. 8_ I can believe I didnt find it before. Aside from that error, did I go about the image resizing and everything in the correct way? What is the use of imagecreatetruecolor(). Thanks for the help. --nathan On Sun, 30 Jan 2005 00:52:06 -0800, hitek [EMAIL PROTECTED] wrote: Are you making sure the $_SESSION['user_sn'] folder exists before saving the image into it? I'm asking because I originally thought it was a permission problem but php will tell you 'permission denied' if that was the case. At 05:05 PM 1/29/2005, NathanielGuy#21 wrote: Hello everyone, I have been troubleshooting a problem with one of my scripts for a while now, its purpose is to allow a user to upload a file, save it to the server, resize it into a thumbnail, and save the thumbnail as well. In my script all goes well until it comes to saving the images, the script throws these errors: Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 91 Warning: imagepng(): Unable to open '/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png' for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on line 95 Picture ffq was added to our database! The following is what we have generated and it is what others will see Here is the important part of the script, if more is needed i can post it as well. if ($mime_type == 'jpeg') { $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'png') { $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']); //Create an image refrence } elseif ($mime_type == 'gif') { $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']); //Create an image refrence } //Image Sizes list($new_image_width, $new_image_height) = getimagesize($_FILES['new_image']['tmp_name']);//Get img size if ($new_image_width $new_image_height) {//Get thumb size $percent_image_size = (200 / $new_image_width); } elseif ($new_image_width $new_image_height) { $percent_image_size = (200 / $new_image_height); } else { $percent_image_size = (200 / $new_image_height); } $new_thumb_width = ($percent_image_size * $new_image_width); $new_thumb_height = ($percent_image_size * $new_image_height); $new_thumb_file = imagecreatetruecolor($new_image_width, $new_image_height); imagepng($new_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png'); //Copy pic to user dir as pic_id.png $new_thumb_image = imagecreatetruecolor($new_thumb_width, $new_thumb_height); // Create Thumb file imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0, $new_thumb_width, $new_thumb_height, $new_image_width, $new_image_height); //Copy resized to new thumb file imagepng($new_thumb_image, '/home/blacknut/public_html/picserv/picserv_mysql/pictures/' . strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png'); //Save image thumb I am very new to file/image manipulation in php so if you see any errors, or unnecessary code please tell me. I'm not quit sure how everything works, although I do have a theoretical picture of how it does. Any comments will be appreciated. --nathan -- http://www.blacknute.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 -- http://www.blacknute.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...
I did a little experimenting, and it looks like foreach is misbehaving, but may I just don't get it, anyway check this out (my php version and output are below): class A { var $name; function A($str) { $this-name = $str; } } // does not work as expected. $arr = array(); $a = new A(qaz); $arr[0] = $a; unset($a); $a = new A(wsx); print_r($a); $arr[1] = $a; print_r($arr[1]); print_r($arr); foreach($arr as $a) { echo (.$a-name.); } echo \n; //^-- I thought this might be the problem, hence: foreach($arr as $b) { echo (.$b-name.); } echo \n--\n; // works as expected $arrB = array(); $arrB[0] = new A(qaz); $arrB[1] = new A(wsx); print_r($arrB); foreach($arrB as $c) { echo (.$c-name.); } echo \n--\n; // works as expected $arrC = array(); $f = new A(qaz); $arrC[0] = $f; $f = new A(wsx); $arrC[1] = $f; print_r($arrC); foreach($arrC as $d) { echo (.$d-name.); } echo \n--\n; // works as expected $arrD = array(); $h = new A(qaz); $arrD[0] = $h; $h = new A(wsx); $arrD[1] = $h; print_r($arrD); foreach($arrD as $g) { echo (.$g-name.); } echo \n--\n; // both items in the array reference the // second object (references $i) - this is correct $arrE = array(); $i = new A(qaz); $arrE[0] = $i; $i = new A(wsx); $arrE[1] = $i; print_r($arrE); foreach($arrE as $j) { echo (.$j-name.); } echo \n--\n; --- which gives the following output on PHP 5.0.2 (cli) (built: Nov 9 2004 19:00:36): A Object ( [name] = wsx ) A Object ( [name] = wsx ) Array ( [0] = A Object ( [name] = qaz ) [1] = A Object ( [name] = wsx ) ) (qaz)(qaz) (qaz)(qaz) -- Array ( [0] = A Object ( [name] = qaz ) [1] = A Object ( [name] = wsx ) ) (qaz)(wsx) -- Array ( [0] = A Object ( [name] = qaz ) [1] = A Object ( [name] = wsx ) ) (qaz)(wsx) -- Array ( [0] = A Object ( [name] = qaz ) [1] = A Object ( [name] = wsx ) ) (qaz)(wsx) -- Array ( [0] = A Object ( [name] = wsx ) [1] = A Object ( [name] = wsx ) ) (wsx)(wsx) -- news.php.net wrote: No -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Creation and Saving
NathanielGuy#21 wrote: Ah, thank you. after checking that the folder was there I found I had made a mistake in the path to the folder. 8_ I can believe I didnt find it before. Aside from that error, did I go about the image resizing and everything in the correct way? What is the use of imagecreatetruecolor(). Thanks for the help. imagecreatetruecolor (PHP 4 = 4.0.6, PHP 5) imagecreatetruecolor -- Create a new true color image Description resource imagecreatetruecolor ( int x_size, int y_size ) imagecreatetruecolor() returns an image identifier representing a black image of size x_size by y_size. Example 1. Creating a new GD image stream and outputting an image. ?php header (Content-type: image/png); $im = @imagecreatetruecolor(50, 100) or die(Cannot Initialize new GD image stream); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, A Simple Text String, $text_color); imagepng($im); imagedestroy($im); ? Note: This function requires GD 2.0.1 or later. Note: This function will not work with GIF file formats. See also imagedestroy() and imagecreate(). --- for a more well laided out copy of this text goto: http://nl2.php.net/imagecreatetruecolor or maybe the manual wasn't clear to you and you are seeking further clarification? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Is this a bug?!!! I cna't believe! Sorry, if im wrong...
Well, unless I'm misstaken, the '= new' should only be used once with every class, so your code doesn't really make sense. The reason is that you are trying to set the A to the new a, not $a to the new a.. Now, A couldn't get changed I suppose, so therefore, $arr[1] will be a reference to $a, which is still a reference to A.. Something like that.. I can only guess it'll work as expected ((wsx)(wsx)) if you change =new to =new.. -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com News.Php.Net [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] ? class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $a = new A(wsx); $arr[1] = $a; //But watch the output!!! // It is (qaz)(qaz), which means that the attribute of a first // object assigned to array is outputted!!! WHY?!?!!! foreach($arr as $a) { echo (.$a-name.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 + SPL - Creating an object as an array.
I would like to create an object like this: ?php class TestClass { private $some_array; public $just; public $some; public $public; public $vars; } ? Is it possible, through SPL, to make the class accessible as $testclass['array_key'], which will return the value for the key 'array_key' from $some_array? Not only that, but I want the class to be accessable as $testclass-just aswell! Is that possible? Examples are welcome. Thanks in advance, Yotam Ofek! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Still cnanot figure out with much easier example...
Just compare the output of print_r($arr) and foreach(...)... !!! Please, explain, or my understanding of the php is gonna ruin. Thanx, Mark. ? $as = array(); $a10 = 10; $a20 = 20; $a = $a10; $arr[] = $a; $a = $a20; $arr[] = $a; print_r($arr); foreach($arr as $a) { echo $a; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp stopped working on my site
The expression that I found won't work anymore is an own pseudo-lang markup that renders into html-lists. Expression for grabbing a list, Example: [lista] some text [/lista] @\[\s*(lista)\s*(sq|o|\*|#|a|i)?\s*\]([^\x00]*?)\[/[EMAIL PROTECTED] $3 is then treated separated into html list-items li. List-items are created by a pseudotag [punkt] or linebreaks. Its one way, you can't mix them both here. // Explode the string into an array $hits = preg_split('#(\[\s*punkt\s*\][^\x00]*?\[/\s*\punkt\s*\])#', $matches[3], -1, PREG_SPLIT_DELIM_CAPTURE); $textarray=array(); foreach($hits as $index=$element){ if( ($index%2)==0){ // strings $element = preg_split('/\s*\r+ \s*/', trim($element), -1, PREG_SPLIT_NO_EMTPY); foreach($element as $val){ // Replace innerstyles if(strlen(trim ($val))0){ // Replace nestled lists //$val=$this- search_and_replace($val, $this-_reg_search['lista'] ); $val=$this- _check_content($val , $matches[1] ); // Add list element array_push ($textarray, 'li '.$list_style.''.$val.'/li'); } } }else{ // [punkt] $element=preg_replace('# \[\s*punkt\s*\]([^\x00]*?)\[/\s*\punkt\s*\]#', '$1',$element); // replace linebreaks $element = preg_replace('/\r/', 'br /', $element); // Replace innerstyles // Replace nestled lists //$val=$this-search_and_replace ($val, $this-_reg_search['lista'] ); $element=$this-_check_content ($element , $matches[1] ); // Add list element array_push($textarray, 'li '.$list_style.''.$element.'/li'); } } Kristian Hellquist wrote: Hi! I had a script for parsing text into html, similar to phpBB. Everything has been working fine until now. Some of my 'pseudotags' like [b] are still recognized (parsed into b) but some more advanced pattern matching is not. I haven't changed the code, but the php-version on the server has changed from default on debian-woody to php-4.3.10. I haven't made the upgrade myself. The users of the site reported the bug to me this week, but the users aren't active so I don't really know when then bug was created. Because I know it has worked before. Does any of you have a clue or experience of this? Or has my code been mysterious altered on the server? An example of the expressions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 Cli bug ?
I have experienced an odd bug where i have been forced to recompile my php. The cli is crappingout , firstly the include paths cant be found now this dyld: php Undefined symbols: _OnUpdateLong _OnUpdateString _compiler_globals _executor_globals _sapi_globals _sapi_module _zend_error_cb _zend_extensions _zend_ini_boolean_displayer_cb Trace/BPT trap Any ideas ? The module is working ok still. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Cli bug ?
You have started a new thread by taking an existing posting and replying to it while you changed the subject. That is bad, because it breaks threading. Whenever you reply to a message, your mail client generates a References: header that tells all recipients which posting(s) your posting refers to. A mail client uses this information to build a threaded view (tree view) of the postings. With your posting style you successfully torpedoed this useful feature; your posting shows up within an existing thread it has nothing to do with. Always do a fresh post when you want to start a new thread. To achieve this, click on New message instead of Reply within your mail client, and enter the list address as the recipient. You can save the list address in your address book for convenience. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Permissions on uploaded image don't allow for over writing
On Sunday 30 January 2005 23:04, Dave wrote: I'm not sure what you mean when you say use PHP's FTP. I'm using $HTTP_POST_FILES because the files are retrieved through a web form. What is meant by that is that after the file is uploaded, during your processing of the upload file, instead of using something like move_uploaded_file() you use php's ftp_*() functions to FTP upload that file back to the server, in the process that file will be owned by whatever ftp user account you used to perform the ftp operations. As for the user, I would assume that it's whatever default for any viewer coming to a web page. I have people log in using a user name and password retrieved from a MySQL database, but I don't see how the browser or the server would know about that. The thing is I'm really a newbie at this Unix server and file permission thing. I was really hoping that there was some parameter I could set to have the uploaded file set to full access permissions, Have a look at umask() and chmod(). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Still cnanot figure out with much easier example...
news.php.net wrote: Just compare the output of print_r($arr) and foreach(...)... !!! Please, explain, or my understanding of the php is gonna ruin. Thanx, Mark. ? $as = array(); $a10 = 10; $a20 = 20; $a = $a10; $arr[] = $a; $a = $a20; $arr[] = $a; print_r($arr); foreach($arr as $a) { echo $a; } ? You can file this as a bug. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Still cnanot figure out with much easier example...
On Monday 31 January 2005 07:09, news.php.net wrote: $as = array(); $a10 = 10; $a20 = 20; $a = $a10; $arr[] = $a; $a = $a20; $arr[] = $a; print_r($arr); foreach($arr as $a) { echo $a; } If you do: foreach($arr as $b) { echo $b; } then it will work as you expect it. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 Cli bug ?
I'll try this again. I have experienced an odd bug where i have been forced to recompile my php. The cli is crappingout , firstly the include paths cant be found now this dyld: php Undefined symbols: _OnUpdateLong _OnUpdateString _compiler_globals _executor_globals _sapi_globals _sapi_module _zend_error_cb _zend_extensions _zend_ini_boolean_displayer_cb Trace/BPT trap Any ideas ? The module is working ok still. I have been heavily using the cli for generating peardataobjects classes. I am running OSX for a dev server, it happened at the same time on my laptopand my G5 any ideas ? Really wierd, just recompiled and its ok. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sending email when sendmail_from sendmail_path = null.
Hello, My client's web host's PHP configuration for both sendmail_from and sendmail_path are both = null. How do I send email with PHP? What options do I need to set within my code, and what to? Tim
[PHP] Re: Sending email when sendmail_from sendmail_path = null.
Hello, on 01/31/2005 12:08 AM Tim Burgan said the following: My client's web host's PHP configuration for both sendmail_from and sendmail_path are both = null. How do I send email with PHP? What options do I need to set within my code, and what to? You need to ask that web host as they probably do not want you send e-mail in anyway. If they let you send messages via an SMTP server, you may want to try this class that comes with a function named smtp_mail() that works like mail() except that it lets you send messages relaying on a SMTP server. http://www.phpclasses.org/mimemessage You also need this: http://www.phpclasses.org/smtpclass and this if the SMTP server requires authentication: http://www.phpclasses.org/sasl -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Cli bug ?
[EMAIL PROTECTED] wrote: I'll try this again. I have experienced an odd bug where i have been forced to recompile my php. The cli is crappingout , firstly the include paths cant be found now this dyld: php Undefined symbols: _OnUpdateLong _OnUpdateString _compiler_globals _executor_globals _sapi_globals _sapi_module _zend_error_cb _zend_extensions _zend_ini_boolean_displayer_cb Trace/BPT trap Any ideas ? The module is working ok still. I have been heavily using the cli for generating peardataobjects classes. I am running OSX for a dev server, it happened at the same time on my laptopand my G5 any ideas ? Really wierd, just recompiled and its ok. Perhaps some kind of auto-update system software is REPLACING your PHP CLI with a new version... Wiping out your good one with a bad one... I guess it's also possible that you are experiencing something triggered by different users/path settings in your environment. Try opening up a shell and doing 'which php' once in a while, and see if it changes out from under you. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Cli bug ?
Perhaps some kind of auto-update system software is REPLACING your PHP CLI with a new version... Wiping out your good one with a bad one... I guess it's also possible that you are experiencing something triggered by different users/path settings in your environment. Try opening up a shell and doing 'which php' once in a while, and see if it changes out from under you. Wierd, no well I just did recompiles on both so I cant check now, could the auto updates on OSXhave something to do with it ? It just happen today on both machines too. Btw how can i setup this list to simply do a reply to reply-to the phplist rather than doing reply all? I know mailman can do it, just wondering why it was never done ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Cli bug ?
Perhaps some kind of auto-update system software is REPLACING your PHP CLI with a new version... Wiping out your good one with a bad one... I guess it's also possible that you are experiencing something triggered by different users/path settings in your environment. Try opening up a shell and doing 'which php' once in a while, and see if it changes out from under you. Wierd, no well I just did recompiles on both so I cant check now, could the auto updates on OSXhave something to do with it ? It just happen today on both machines too. Btw how can i setup this list to simply do a reply to reply-to the phplist rather than doing reply all? I know mailman can do it, just wondering why it was never done ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to handle user authentication, PHP vs. apache
Raymond Still wrote: Hello; I'm trying to figure out the best (most secure and most user friendly, security of primary importance) way to let a user log-in. I am setting up a web application (database application) that will be for private use only and I want to keep it secure. As I understand it, using the Apache htaccess method is secure as there is essentially no communication without a username and password, but it does lack a little in flexibility and presentation. On the other hand, PHP certainly has the edge on flexibility and presentation, but I have questions regarding it's security. If you look at the threads regarding connecting to databases, you often see a warning to the effect of: store your connection password etc, outside of the document path in case PHP fails and your file is displayed unprocessed. So my question is, how can you count on PHP to log somebody in, and prevent access to files when PHP may fail, or the user could just go into the directory structure and bypass security. You've smushed about 5 different security issues into one giant ball of snarled yarn. Your question is roughly allegorical to: How can you call a deadbolt secure when the home-owner could just leave their ADT off and the back window unlocked? Now, for starters: HTTP Authentication is not particularly secure over a non-SSL connection as the password is transmitted in plain-text. In fact, for *ANYTHING* where security matters for logging in and out, use SSL. After that, there's no real win to HTTP authentication except for that cool/annoying popup window. You've got a long way to go before you properly understand all the security issues you've jumbled together -- Took me forever, too. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions memory allocation problem
adrian zaharia wrote: Hi, I am testing the following code that pushes a file to the browser (Apache 1.3 + PHP 4.3.8 but tested also under several other configs) Try it with a BIG test1.zip (e.g. 100M in size) ?php ignore_user_abort(); set_time_limit(0); session_save_path('/tmp'); session_start(); $sFileName = 'test1.zip'; $sFileDir = '/var/www/html/'; header(Content-Type: application/octet-stream); header(Content-Disposition: attachment;filename=\ . $sFileName . \); header(Content-Length: . filesize($sFileDir . $sFileName)); header('Pragma: cache'); header('Cache-Control: public, must-revalidate, max-age=0'); header('Connection: close'); header('Expires: ' . date('r', time()+60*60)); header('Last-Modified: ' . date('r', time())); $oFp = fopen($sFileDir . $sFileName, rb); $iReadBufferSize = 512; while (!feof($oFp)) { echo fread ($oFp, $iReadBufferSize); } fclose ($oFp); exit; ? What i discovered is that if i keep the 2 session initialisation functions the script will work ONLY if the allocated memory is greater than the size of the tested file. If i remove the session functions the script works fine even if the test1.zip file is very big (hundreds of Megs) Is it something i do wrong? Or is a bug and i should report it? I mention that I NEED the 2 functions so removing them is not THE solution. Nor setting in php.ini a huge memory limit :( This naive reader would suggest filing a bug report... At least, *I* don't think it should behave this way. http://bugs.php.net -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Permissions on uploaded image don't allow for over writing
Dave [EMAIL PROTECTED] writes: The Question: How do I allow a user, who is uploading via the web, place an image on the server with permissions that allow the file to be over written? Since you say that the images are uploaded using HTTP, the files will be owned by the user apache (or nobody). The file permission allow read and write to the owner. You do not need to modify them. If the user again uploads the files via HTTP, you do not have to worry about whether he has the permissions to overwrite the files. He *will* be able to overwrite the files. -- Raj Shekhar System Administrator, programmer and slacker home : http://rajshekhar.net blog : http://rajshekhar.net/blog/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems displaying images with PHP-GD
Ian Johnson wrote: I am trying to use GD to create and manipulate images but the statement: header (Content-type: image/jpg); generates the error message: The image http://localhost/gdtst2.php; cannot be displayed, because it contains errors. Wild Guess: You have a blank line in your file before the first ?php or after the last ? -- So even though it looks like a kosher JPEG, it's not. Use View Source in your browser on the JPEG data to see what's there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending email when sendmail_from sendmail_path = null.
Tim Burgan wrote: My client's web host's PHP configuration for both sendmail_from and sendmail_path are both = null. How do I send email with PHP? What options do I need to set within my code, and what to? Not sure you can... You might try using .htaccess to set things like: php_value sendmail_path /usr/bin/sendmail -t -i It may be that your host doesn't WANT you sending PHP email... You then might be able to connect to another server with SMTP to send email. Another possibility is to use PHP's IMAP functions to create emails in your own Outbox, and then your regular mail usage to send them... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to handle user authentication, PHP vs. apache
On Sun, 30 Jan 2005 18:49:41 -0800 (PST), Richard Lynch wrote: Raymond Still wrote: Hello; I'm trying to figure out the best (most secure and most user friendly, security of primary importance) way to let a user log-in. I am setting up a web application (database application) that will be for private use only and I want to keep it secure. As I understand it, using the Apache htaccess method is secure as there is essentially no communication without a username and password, but it does lack a little in flexibility and presentation. On the other hand, PHP certainly has the edge on flexibility and presentation, but I have questions regarding it's security. If you look at the threads regarding connecting to databases, you often see a warning to the effect of: store your connection password etc, outside of the document path in case PHP fails and your file is displayed unprocessed. So my question is, how can you count on PHP to log somebody in, and prevent access to files when PHP may fail, or the user could just go into the directory structure and bypass security. You've smushed about 5 different security issues into one giant ball of snarled yarn. Your question is roughly allegorical to: How can you call a deadbolt secure when the home-owner could just leave their ADT off and the back window unlocked? Now, for starters: HTTP Authentication is not particularly secure over a non-SSL connection as the password is transmitted in plain-text. In fact, for *ANYTHING* where security matters for logging in and out, use SSL. After that, there's no real win to HTTP authentication except for that cool/annoying popup window. You've got a long way to go before you properly understand all the security issues you've jumbled together -- Took me forever, too. :-) -- Like Music? http://l-i-e.com/artists.htm Hello; Your absolutly right and I freely admit it. I know just slightly more than zero about internet security. :) Can any one recomend some good resources so that I can learn? I'm not looking for use this function or that program, but something that will help me to actually understand. TIA Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...
30 2005 16:07 news.php.net (a): ? class A { var $name; function A($str) { $this-name = $str; } } $arr = array(); //Put to array to objects of class A, // where their attribute A::a is assigned a different value //objects are assigned to an array by reference $a = new A(qaz); $arr[0] = $a; $a = new A(wsx); $arr[1] = $a; //But watch the output!!! // It is (qaz)(qaz), which means that the attribute of a first // object assigned to array is outputted!!! WHY?!?!!! foreach($arr as $a) { echo (.$a-name.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Security Consortium
The PHP Security Consortium has officially launched. The following is the press release: -- Leading PHP Experts Join Forces to Establish the PHP Security Consortium NEW YORK, NY - January 31, 2005 - An international group of PHP experts today announced the official launch of the PHP Security Consortium (PHPSC), a group whose mission is to promote secure programming practices within the PHP community through education and exposition while maintaining high ethical standards. As PHP has transitioned from personal projects to enterprise application development, the need to educate the community about secure programming practices has risen, said Chris Shiflett, the group's founder. The PHPSC web site (http://phpsec.org/) provides a variety of security resources for PHP developers, including the group's flagship project, the PHP Security Guide. PHP application security is a topic of growing importance, said Andi Gutmans, one of the group's charter members. The launch of the PHP Security Consortium is a landmark event for the PHP community, and because most web development technologies face similar security concerns, we believe that developers using other solutions can also benefit from our efforts. About the PHP Security Consortium Founded in January 2005, the PHP Security Consortium (PHPSC) is an international group of PHP experts dedicated to promoting secure programming practices within the PHP community. Members of the PHPSC seek to educate PHP developers about security through a variety of resources, including documentation, tools, and standards. In addition to their educational efforts, the PHPSC engages in exploratory and experimental research in order to develop and promote standards of best practice for PHP application development. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Credit card storing, for processing
HI all. this might be slightly OT but I know that the list has quite a knowledgable crowd =) So here is my situation: I have a client who I have developed a site for in PHP it provides various models for shares forecasts, the way it works is that people register for free (with their credit card details-https) now if they are not satisfied after a month they must just unsubscribe. If they have not unsubscribed after the first month they become a customer and each month their credit card is charged the relevant amount depending on what they have subscribed for. Now our the complication is as follows: I know that storing client's credit card details online is a big NONO, so we would have to move the credit card details offline when they register. Im not sure how to go about this. Whether to save the details in text files somewhere else on the server or save to text files not on the server but another location. Can anyone recommend/advise the best way to do this, also what type of encryption should I be using for the credit card info? thanks in advance. Angelo Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Peninsula University of Technology or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php