[PHP] Seeking strategy/algorithm for maintaining order of records
I am building a site for my photography. The photographs are displayed by category. The category table has a field for "order" In my control panel I want to be able to change the order of the categories by changing the values in the category field. I can dynamically build a form of all categories and have a field for new order number, Then loop through the POST and update the values. The field is not unique, so I am not worried about DB errors. But I wonder if there is a better way. Thoughts please? Thank you Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Extending an instantiated class
On Sat, Oct 15, 2011 at 03:01:44PM +0100, Alain Williams wrote: > Well, that is what I think that I need. Please let me explain what I am > trying to do > and tell me how to do it or a better way of doing it. > .. I have solved it. The problem is basically one of ensuring that properties are the same value when accessed via the parent or child class ... be that to get or set a value. So I solved the problem by making the properties in the child class references to the ones in the parent class. Methods are not a problem - inheritance just works fine. To do this, pass the instance of the parent class to the child class constructor and use a reflection class to determine the properties in the parent class. This will not work properly if the child class overrides a property of the parent class ... this does not worry me. class Screen { public $screen; } class Form extends Screen { function __construct(&$s) { $sr = new ReflectionClass($s); foreach($sr->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED) as $p) $this->{$p->name} = &$s->{$p->name}; } } $s = new Screen(); $s->AddJsVar('Date', '15 Oct 2011'); $f1 = new Form($s); $f1->screen = 'something'; // this assigns the property in $s. Comments ? -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Rotation Script
On 15 Oct 2011, at 15:50, d...@nkmo.com wrote: > We have a simple script which rotates and image to a random value, saves > it to a cache directory and displays it. For some reason when I move the > script from a Debian box over to the production CentOS machine, it no > longer caches any of the images. the rest works, but not the cache. If you > could look at it and see if anything jumps out at you, please let me know. > > install the code below to the directory /angles > > > .htaccess: > RewriteEngine on > RewriteRule ^rotate_(\d+)(?:_(?:\d+))?.png$ rotate.php?im=$1 > > rotate.php: > // Setup > if(isset($_GET['im']) && file_exists($_GET['im'].'.png')) { > header('Content-type: image/png'); > $im = $_GET['im'].'.png'; > $degrees = rand(0, 360); > $save = 'cache/'.$_GET['im'].'_'.$degrees.'.png'; > if(!file_exists($save)) { > // Rotate via "command line" and cache it > exec('convert '.$im.' -filter \'Lanczos\' -resize \'150x150\' -rotate > '.$degrees.' -black-threshold 40% '.$save, $out); > } > // Output out (newly?) cached file > echo file_get_contents($save); > } else { > die("Image not found"); > } > ?> > > Use it by url: > http://www.servername.com/angles/rotate_019.png > Each time you reload page the angle should rotate to a new position. My first thought was that the current working directory is probably set differently. However, you say that the script works and presents the rotated images, it's just the cache that isn't right. I still think I'm probably correct, so try these changes... > $im = dirname(__FILE__).'/'.$_GET['im'].'.png'; and... > $save = dirname(__FILE__).'/cache/'.$_GET['im'].'_'.$degrees.'.png'; You also have a pretty major hole here because you're taking a querystring parameter and putting it straight into a command line. What happens if I pass the value of $_GET['im'] as "../../../../../../../../../../../etc/passwd" ? Use escapeshellarg when putting variables into command lines to protect against this type of hack. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Rotation Script
We have a simple script which rotates and image to a random value, saves it to a cache directory and displays it. For some reason when I move the script from a Debian box over to the production CentOS machine, it no longer caches any of the images. the rest works, but not the cache. If you could look at it and see if anything jumps out at you, please let me know. install the code below to the directory /angles .htaccess: RewriteEngine on RewriteRule ^rotate_(\d+)(?:_(?:\d+))?.png$ rotate.php?im=$1 rotate.php: Use it by url: http://www.servername.com/angles/rotate_019.png Each time you reload page the angle should rotate to a new position. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Extending an instantiated class
Well, that is what I think that I need. Please let me explain what I am trying to do and tell me how to do it or a better way of doing it. I have an application where a Screen (web page) may contain several Forms. The Forms will want to access properties, etc, from their Screen. So what I want is to do something like: class Screen { private $JavascriptVars = array(); function AddJsVar($name, $val) { $this->JavascriptVars[$name] = $val; } } class Form extends Screen { public $screen; // Could set to a class Screen function DefineForm($fName) . } $s = new Screen(); $s->AddJsVar('Date', '15 Oct 2011'); $f1 = new Form($s); $f1->DefineForm('search'); $f1->AddJsVar('CompanyName', 'IBM'); $f2 = new Form($s); $f2->DefineForm('login'); $f2->AddJsVar('Error', 'Login failed'); The trouble is that $f1->AddJsVar() will fail, class extention seems not designed to work like that. I could make it work by either: 1) $f1->screen->AddJsVar() --- but I would rather avoid the extra '->screen'. 2) Use of a __call() in class Form -- but that makes things slower. Any help gratefully received. I think that to do what I want PHP would need a syntax like: $f2 = new $s Form(); or $f2 = $s->new Form(); -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dennis Ritchie, Father of Unix and C programming language, dead at 70
I found this, And I liked it. int main() { printf("Goodbye Daddy\n"); return 0; } -- Shiplu Mokadd.im Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
RE: [PHP] Dennis Ritchie, Father of Unix and C programming language, dead at 70
-Original Message- From: Daevid Vincent [mailto:dae...@daevid.com] Sent: 14 October 2011 12:08 AM To: php-general@lists.php.net Subject: [PHP] Dennis Ritchie, Father of Unix and C programming language, dead at 70 #include int main() { printf("R.I.P. Dennis Ritchie: 1941-2011\n"); return 0; } http://www.networkworld.com/news/2011/101311-ritchie-251936.html === He might have put it a bit differently: int main() { printf("Goodbye world\n"); return 0; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dennis Ritchie, Father of Unix and C programming language, dead at 70
int main() { printf("R.I.P. Dennis Ritchie: 1941-2011\n"); return 0 } sad notice... RIP On Fri, Oct 14, 2011 at 10:01 PM, tamouse mailing lists < tamouse.li...@gmail.com> wrote: > On Thu, Oct 13, 2011 at 5:08 PM, Daevid Vincent wrote: > > #include > > > > int main() > > { > > printf("R.I.P. Dennis Ritchie: 1941-2011\n"); > > return 0; > > } > > > > > > http://www.networkworld.com/news/2011/101311-ritchie-251936.html > > > > > > dmr--; /* :-( */ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Ricardo ___ IT Architect website: http://www.pulsarinara.com