[PHP] debugging remote PHP code in eclipse
Hi everybody, I have big trouble to correctly configure Eclipse/Xdebug to remotely debug a PHP website. When web server is local i have no problem, it works like a charm...but in case webserver is not local, that's a real nightmare. till now everything what i found on internet was about settings for a local debugging. few are about remote debugging... and after reading them i still have trouble it's like something is missing...an important step... so i would like to know if someone could help me. If you already successfully setup eclipse/xdebug for a remote debugging, please let me know. i feel like a local copy of website root folder must exist on my client computer but is it true ? how to configure eclipse to be sure it will run code with PHP server ? so please, contact me if you already did it. thx a lot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: debugging remote PHP code in eclipse
I haven't tested yet but I've found yesterday some good tips that maybe could work. 1) Xdebug wizard. Simple paste there the output of phpinfo() and follow the steps. http://xdebug.org/wizard.php If you find problems with phpize, remember to run it inside the inner xdebug folder. 2) Go to your /etc/php5/apache2/php.ini and add the zend_extension for xdebug and its configuration. This is the post I've been following: http://www.cleancode.co.nz/blog/724/remote-php-debugging-eclipse-php-xdebug It's possible (I don't know it for sure) that you may have to activate in Eclipse one specific option about Jit: http://bogdan-albei.blogspot.com.es/2010/06/php-remote-debugging-with-xdebug-and.html Hope this helps! El 12/06/13 18:01, Rafnews escribió: Hi everybody, I have big trouble to correctly configure Eclipse/Xdebug to remotely debug a PHP website. When web server is local i have no problem, it works like a charm...but in case webserver is not local, that's a real nightmare. till now everything what i found on internet was about settings for a local debugging. few are about remote debugging... and after reading them i still have trouble it's like something is missing...an important step... so i would like to know if someone could help me. If you already successfully setup eclipse/xdebug for a remote debugging, please let me know. i feel like a local copy of website root folder must exist on my client computer but is it true ? how to configure eclipse to be sure it will run code with PHP server ? so please, contact me if you already did it. thx a lot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compiler for the PHP code
As suggested look at APC, although I expect the problem is not with php but how you wrote things, it could be database related. If you need to compile php to make things faster, you have a problem outside of php Curt. On Mar 19, 2013, at 4:46 AM, Kevin Peterson qh.res...@gmail.com wrote: My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. Please suggest if we have any compiler option available for the PHP code and more important is this new option. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compiler for the PHP code
My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. Please suggest if we have any compiler option available for the PHP code and more important is this new option.
Re: [PHP] Compiler for the PHP code
Googling compile php code gave me this : http://stackoverflow.com/questions/1408417/can-you-compile-php-code It looks like you have some options but I haven't tried any yet, so I can't help you with the installation 2013/3/19 Kevin Peterson qh.res...@gmail.com My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. Please suggest if we have any compiler option available for the PHP code and more important is this new option. -- Camille Hodoul http://camille-hodoul.com/
Re: [PHP] Compiler for the PHP code
Dear Kevin, please install and use the PECL bcompiler extension. You will need to use the approprate version for your php regards On Tue, Mar 19, 2013 at 11:46 AM, Kevin Peterson qh.res...@gmail.comwrote: My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. Please suggest if we have aany compiler option available for the PHP code and more important is this new option. -- Tumwijukye Vincent Chief Executive Officer Future Link Technologies Plot 78 Kanjokya Street, P. O. BOX 75408, KAMPALA - UGANDA Tel: +256(0)774638790 Off:+256(0)41531274 Website: www.fl-t.com, www.savingsplus.info
Re: [PHP] Compiler for the PHP code
Checkout HipHop by the Facebook guys, it turns PHP into C code and compiles down to binary. ...although I don't think it's for the faint hearted. Have you tried other optimisation techniques first - eg Caching, and Profiling?? If this is a production environment you might wanna think about increasing resources or introducing a load balancer (in the case of PHP based websites) Cheers Ads. Sent from my BlackBerry® wireless device -Original Message- From: Camille Hodoul camille.hod...@gmail.com Date: Tue, 19 Mar 2013 09:52:14 To: Kevin Petersonqh.res...@gmail.com Cc: php-general@lists.php.net Subject: Re: [PHP] Compiler for the PHP code Googling compile php code gave me this : http://stackoverflow.com/questions/1408417/can-you-compile-php-code It looks like you have some options but I haven't tried any yet, so I can't help you with the installation 2013/3/19 Kevin Peterson qh.res...@gmail.com My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. Please suggest if we have any compiler option available for the PHP code and more important is this new option. -- Camille Hodoul http://camille-hodoul.com/
[PHP] Re: Compiler for the PHP code
Il Tue, 19 Mar 2013 08:46:22 +, Kevin Peterson ha scritto: My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. PHP gets compiled to bytecode on the server before being executed. You can cache the precompiled code with (for example) APC. Unless your code is several thousand lines of code (or your server very slow... 486-slow), the compilation phase is not that long. I think your main problem can be one of: 1- wrong algorithm 2- long waits (database, files, network, etc.) 3- heavy calculations Solutions: 1- find and use a different algorithm 2- Try to parallelize code (with gearman or similar, or via pctnl_fork) 3- rewrite the heavy functions in C, C++ or Go and compile them, then call them via PHP extensions or via gearman/fork. Bye. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Compiler for the PHP code (memecached)
-Original Message- From: Alessandro Pellizzari [mailto:a...@amiran.it] Sent: Tuesday, March 19, 2013 2:06 AM To: php-general@lists.php.net Subject: [PHP] Re: Compiler for the PHP code Il Tue, 19 Mar 2013 08:46:22 +, Kevin Peterson ha scritto: My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any. PHP gets compiled to bytecode on the server before being executed. You can cache the precompiled code with (for example) APC. Unless your code is several thousand lines of code (or your server very slow... 486-slow), the compilation phase is not that long. I think your main problem can be one of: 1- wrong algorithm 2- long waits (database, files, network, etc.) 3- heavy calculations Solutions: 1- find and use a different algorithm 2- Try to parallelize code (with gearman or similar, or via pctnl_fork) 3- rewrite the heavy functions in C, C++ or Go and compile them, then call them via PHP extensions or via gearman/fork. Another thing you can do is store both page renders as well as database results in http://memcached.org/ blobs and pull from those in intelligent ways (you can creatively mix and match live stuff with cached stuff and you can make pages expire in defined hours via your cache class or even a crontab). We also add another layer in that if a blob exists in the memecached but not locally, we save it locally for the next hit. Depending on your hardware though the Gigabit/Fiber might be faster access than a local HD/SSD/RAM disk, so YMMV. We use LAMP and our site gets 30,000 hits per SECOND on two servers and 5 pools. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
On Sun, May 6, 2012 at 3:32 PM, rene7705 rene7...@gmail.com wrote: On Sat, May 5, 2012 at 5:13 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Wed, May 2, 2012 at 5:23 AM, rene7705 rene7...@gmail.com wrote: On Wed, May 2, 2012 at 11:47 AM, rene7705 rene7...@gmail.com wrote: I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster. Maybe you git gurus can help me along a bit further. I've managed to install msysgit and get it to work on my windows dev box, so far so good. Now, I'm wondering how to set up my repositories. The last cvs I used was Microsoft's visual source control back in the 90's, so I'm very rusty. At the same time, I'd prefer not to experiment too much.. I've got a tree structure in a folder called simply code, that I have in several locations on my windows box. Each site that I develop for has a folder in .../htdocs/sites/somedomain.com, and many of these sites will need a copy of the common code folder in them. I can restrict myself to developing in one domain's subdir only. The non-common code for each domain is designed to run from any $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing from windowze as http://somedomain.com will from shared hosted linux. I would also like to version control the non-common code for each domain. And I would like to store the entire repository on my windows box at home in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org, and also a truecrypted usb disk, if and when that's plugged in). For distributing the common code to the shared hosted live server (my workflow is to check finalized changes on my win box against all my sites that used the common code base, before deploying to the shared hoster live server), I can simply FTP one finalized copy and use the simplest of rm -rf and cp -r commands in a short script to distribute the changes. I could even do without the PHP filesync code I posted earlier (altho it was fun to build! :) That darn hoster of mine won't support git on shared hosting, only on much more expensive virtual dedicated and dedicated plans :( But I've also found http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan and http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/ that show me how I might get git running on my (kinda lame now) shared hosting account. Maybe a stupid question, but would perhaps copying the common code around with a simple script be faster than multiple pushes by git? Using git, you can set up either publicly hosted repositories on github.com or gitorious.org or perhaps other public repo places. If you don't want you code to be publicly available, you can set up private repositories as well. Not being familiar with Windows implementations much at all, I can't tell you specifically what to do with msysgit, so these will be more generic instructions. I'm going to assume you don't have a host somewhere with ssh access. In this case you'll most likely want/need to set up your repository on your local system. (Note that it isn't *strictly* necessary to have a repository -- you can clone a new tree from the existing code tree, however having a repository can ensure a clean code set in case your working tree gets out of sync somehow.) (These instructions are modified from http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux ) First, create a directory you want to hold all of your local repositories (such as C:\User\rene\MyRepositories). Then create a subdirectory off that to hold your server/application common code (C:\Users\rene\MyRepositories\commoncode). Make that directory (..\commoncode) a *bare* repository. (Not sure how that's done with msysgit, but the basic git command is: git init --bare C:\Users\rene\MyRepositories\commoncode) Then you add the repository as a remote to the working tree: git remote add origin C:\Users\rene\MyRepositories\commoncode Now you can push commits to your repository with the following sequence: git add files you want to commit git commit git push origin master Now, to *deploy*, you can do the following: Somewhere outside your working tree, create a directory called deploy: mkdir C:\Users\rene\deploy Then clone your the repository of your commond code: git clone C:\Users\rene\MyRepositories\commoncode cleancode-20120404 Then you can ftp the contents of cleancode-20120404 to your server as needed. Sorry to be unable to tell you the exact steps with msysgit, but I hope you can interpolate from the commands above. Thanks for that
Re: [PHP] code deployment through php
On Sat, May 5, 2012 at 5:13 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Wed, May 2, 2012 at 5:23 AM, rene7705 rene7...@gmail.com wrote: On Wed, May 2, 2012 at 11:47 AM, rene7705 rene7...@gmail.com wrote: I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster. Maybe you git gurus can help me along a bit further. I've managed to install msysgit and get it to work on my windows dev box, so far so good. Now, I'm wondering how to set up my repositories. The last cvs I used was Microsoft's visual source control back in the 90's, so I'm very rusty. At the same time, I'd prefer not to experiment too much.. I've got a tree structure in a folder called simply code, that I have in several locations on my windows box. Each site that I develop for has a folder in .../htdocs/sites/ somedomain.com, and many of these sites will need a copy of the common code folder in them. I can restrict myself to developing in one domain's subdir only. The non-common code for each domain is designed to run from any $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing from windowze as http://somedomain.com will from shared hosted linux. I would also like to version control the non-common code for each domain. And I would like to store the entire repository on my windows box at home in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org, and also a truecrypted usb disk, if and when that's plugged in). For distributing the common code to the shared hosted live server (my workflow is to check finalized changes on my win box against all my sites that used the common code base, before deploying to the shared hoster live server), I can simply FTP one finalized copy and use the simplest of rm -rf and cp -r commands in a short script to distribute the changes. I could even do without the PHP filesync code I posted earlier (altho it was fun to build! :) That darn hoster of mine won't support git on shared hosting, only on much more expensive virtual dedicated and dedicated plans :( But I've also found http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan and http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/ that show me how I might get git running on my (kinda lame now) shared hosting account. Maybe a stupid question, but would perhaps copying the common code around with a simple script be faster than multiple pushes by git? Using git, you can set up either publicly hosted repositories on github.com or gitorious.org or perhaps other public repo places. If you don't want you code to be publicly available, you can set up private repositories as well. Not being familiar with Windows implementations much at all, I can't tell you specifically what to do with msysgit, so these will be more generic instructions. I'm going to assume you don't have a host somewhere with ssh access. In this case you'll most likely want/need to set up your repository on your local system. (Note that it isn't *strictly* necessary to have a repository -- you can clone a new tree from the existing code tree, however having a repository can ensure a clean code set in case your working tree gets out of sync somehow.) (These instructions are modified from http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux ) First, create a directory you want to hold all of your local repositories (such as C:\User\rene\MyRepositories). Then create a subdirectory off that to hold your server/application common code (C:\Users\rene\MyRepositories\commoncode). Make that directory (..\commoncode) a *bare* repository. (Not sure how that's done with msysgit, but the basic git command is: git init --bare C:\Users\rene\MyRepositories\commoncode) Then you add the repository as a remote to the working tree: git remote add origin C:\Users\rene\MyRepositories\commoncode Now you can push commits to your repository with the following sequence: git add files you want to commit git commit git push origin master Now, to *deploy*, you can do the following: Somewhere outside your working tree, create a directory called deploy: mkdir C:\Users\rene\deploy Then clone your the repository of your commond code: git clone C:\Users\rene\MyRepositories\commoncode cleancode-20120404 Then you can ftp the contents of cleancode-20120404 to your server as needed. Sorry to be unable to tell you the exact steps with msysgit, but I hope you can interpolate from the commands above. Thanks for that useful info, tamouse.. I didn't check this list for a few days thinking the thread had gone dead, but
Re: [PHP] code deployment through php
On Wed, May 2, 2012 at 5:23 AM, rene7705 rene7...@gmail.com wrote: On Wed, May 2, 2012 at 11:47 AM, rene7705 rene7...@gmail.com wrote: I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster. Maybe you git gurus can help me along a bit further. I've managed to install msysgit and get it to work on my windows dev box, so far so good. Now, I'm wondering how to set up my repositories. The last cvs I used was Microsoft's visual source control back in the 90's, so I'm very rusty. At the same time, I'd prefer not to experiment too much.. I've got a tree structure in a folder called simply code, that I have in several locations on my windows box. Each site that I develop for has a folder in .../htdocs/sites/somedomain.com, and many of these sites will need a copy of the common code folder in them. I can restrict myself to developing in one domain's subdir only. The non-common code for each domain is designed to run from any $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing from windowze as http://somedomain.com will from shared hosted linux. I would also like to version control the non-common code for each domain. And I would like to store the entire repository on my windows box at home in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org, and also a truecrypted usb disk, if and when that's plugged in). For distributing the common code to the shared hosted live server (my workflow is to check finalized changes on my win box against all my sites that used the common code base, before deploying to the shared hoster live server), I can simply FTP one finalized copy and use the simplest of rm -rf and cp -r commands in a short script to distribute the changes. I could even do without the PHP filesync code I posted earlier (altho it was fun to build! :) That darn hoster of mine won't support git on shared hosting, only on much more expensive virtual dedicated and dedicated plans :( But I've also found http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan and http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/ that show me how I might get git running on my (kinda lame now) shared hosting account. Maybe a stupid question, but would perhaps copying the common code around with a simple script be faster than multiple pushes by git? Using git, you can set up either publicly hosted repositories on github.com or gitorious.org or perhaps other public repo places. If you don't want you code to be publicly available, you can set up private repositories as well. Not being familiar with Windows implementations much at all, I can't tell you specifically what to do with msysgit, so these will be more generic instructions. I'm going to assume you don't have a host somewhere with ssh access. In this case you'll most likely want/need to set up your repository on your local system. (Note that it isn't *strictly* necessary to have a repository -- you can clone a new tree from the existing code tree, however having a repository can ensure a clean code set in case your working tree gets out of sync somehow.) (These instructions are modified from http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux ) First, create a directory you want to hold all of your local repositories (such as C:\User\rene\MyRepositories). Then create a subdirectory off that to hold your server/application common code (C:\Users\rene\MyRepositories\commoncode). Make that directory (..\commoncode) a *bare* repository. (Not sure how that's done with msysgit, but the basic git command is: git init --bare C:\Users\rene\MyRepositories\commoncode) Then you add the repository as a remote to the working tree: git remote add origin C:\Users\rene\MyRepositories\commoncode Now you can push commits to your repository with the following sequence: git add files you want to commit git commit git push origin master Now, to *deploy*, you can do the following: Somewhere outside your working tree, create a directory called deploy: mkdir C:\Users\rene\deploy Then clone your the repository of your commond code: git clone C:\Users\rene\MyRepositories\commoncode cleancode-20120404 Then you can ftp the contents of cleancode-20120404 to your server as needed. Sorry to be unable to tell you the exact steps with msysgit, but I hope you can interpolate from the commands above. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster.
Re: [PHP] code deployment through php
On Wed, May 2, 2012 at 11:47 AM, rene7705 rene7...@gmail.com wrote: I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster. Maybe you git gurus can help me along a bit further. I've managed to install msysgit and get it to work on my windows dev box, so far so good. Now, I'm wondering how to set up my repositories. The last cvs I used was Microsoft's visual source control back in the 90's, so I'm very rusty. At the same time, I'd prefer not to experiment too much.. I've got a tree structure in a folder called simply code, that I have in several locations on my windows box. Each site that I develop for has a folder in .../htdocs/sites/somedomain.com, and many of these sites will need a copy of the common code folder in them. I can restrict myself to developing in one domain's subdir only. The non-common code for each domain is designed to run from any $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing from windowze as http://somedomain.com will from shared hosted linux. I would also like to version control the non-common code for each domain. And I would like to store the entire repository on my windows box at home in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org, and also a truecrypted usb disk, if and when that's plugged in). For distributing the common code to the shared hosted live server (my workflow is to check finalized changes on my win box against all my sites that used the common code base, before deploying to the shared hoster live server), I can simply FTP one finalized copy and use the simplest of rm -rf and cp -r commands in a short script to distribute the changes. I could even do without the PHP filesync code I posted earlier (altho it was fun to build! :) That darn hoster of mine won't support git on shared hosting, only on much more expensive virtual dedicated and dedicated plans :( But I've also found http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan and http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/ that show me how I might get git running on my (kinda lame now) shared hosting account. Maybe a stupid question, but would perhaps copying the common code around with a simple script be faster than multiple pushes by git?
Re: [PHP] code deployment through php
rene7705 wrote: I can't use anything like git on my shared hoster. But I suppose I could use something like git at home, and use a sync script like I posted in my OP on the shared hoster. I have some legacy hosting packages which are just ftp access and BC just lists them and allows me to manage things quickly when I need to update those sites. One of these days they will get moved to an easier location :) -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
On 1 mei 2012, at 10:59, rene7705 wrote: Hi folks. I was here a while ago, trying to figure out how to keep deployment instances of my common code, running on more than 1 site, in sync with eachother. I've looked at rsync which was recommended here, but didn't like it much, nor could I find a good windows version of it. So yesterday, I decided to try a pure PHP solution. My thinking was: run a PHP sync script once on each physical machine that holds possibly multiple copies of my common code, and FTP the common code only 1 time because I use only 1 shared hosting account besides my windows development machine. I've gotten it so far that it creates an imo good list of what to copy where. The only problem I can foresee is that the copy command will take more than 30 seconds, which makes it hard to run at the shared hoster. And obviously, it's going to need some good input checking to prevent abuse. I've put up a demo at http://skatescene.biz/sites/mediabeez.ws/sync_secret_cndj593n2/ , you can execute the code job to see it in action. I'll also post the working copy of my sync library at the bottom of this post. The only thing missing is the actual copy($source,$dest), I think. But, I'm wondering if this is a good approach to code deployment. It certainly seems easier and more convenient to me than using rsync. Maybe i'm an amateur indeed ;) Anyways, all criticism is welcome here. Thanks for your time! :) ?php function sync_echo_jobs ($path) { $jobs = sync_read_jobs ($path); echo 'div id=rajmvSync_jobs_json!-- '.json_encode($jobs).' --/div'; echo 'ul class=rajmvSync_jobs'; foreach ($jobs['jobs'] as $jobName = $job) { echo 'li'.$jobName.' (a href=javascript:rscg.executeJob(\''.$jobName.'\');execute/a) (a href=javascript:rscg.showEditJobForm(\''.$jobName.'\');edit/a)/li'; } echo '/ul'; ? ?php } function sync_read_jobs ($path) { $filepath = $path.'/rajmvSync_jobs.json'; if (file_exists($filepath)) { $r = json_decode (file_get_contents($filepath), true); } else { $r = array ( 'jobs' = array() ); } return $r; } function sync_write_jobs ($path, $jobs) { $filepath = $path.'/rajmvSync_jobs.json'; file_put_contents ($filepath, json_encode($jobs)); } function sync_addOrEditJob ($path, $name, $paths) { $jobs = sync_read_jobs ($path); $jobs['jobs'][$name] = array ( 'paths' = $paths ); sync_write_jobs ($path, $jobs); } function sync_executeJob ($path, $name) { $jobs = sync_read_jobs ($path); if (array_key_exists($name, $jobs['jobs'])) { $job = $jobs['jobs'][$name]; $paths = explode (\n, $job['paths']); // work only on approved paths; $pathsApproved = array(); foreach ($paths as $idx=$pathToSync) { $drive = strtolower(substr($pathToSync,0,2)); if ($drive=='m:') $pathsApproved[]=$pathToSync; } $paths = $pathsApproved; // get a list of files for each path to sync with the other paths in the same list/var $fileLists = array(); foreach ($paths as $idx = $pathToSync) { $fileLists[$pathToSync] = getFilePathList ($pathToSync, true, /(.*)/, array('file')); } // get all the last modified timestamps for each of the found files $fileList = array(); foreach ($paths as $idx = $pathToSync) { foreach ($fileLists[$pathToSync] as $idx2 = $filepathToSync) { $fileRelativePath = str_replace ($pathToSync, '', $filepathToSync); if (!array_key_exists($fileRelativePath, $fileList)) $fileList[$fileRelativePath] = array(); $fileList[$fileRelativePath][$pathToSync] = filemtime($filepathToSync); } } // $copyList will hold all the copy commands, initialize; $copyList = array(); foreach ($fileList as $fileRelativePath = $locationResults) { foreach ($locationResults as $pathToSync = $filemtime) { if (!array_key_exists($fileRelativePath, $copyList)) $copyList[$fileRelativePath] = array( 'latest' = null, 'source' = null, 'destinations' = array() ); if (is_null($copyList[$fileRelativePath]['latest']) || $filemtime $copyList[$fileRelativePath]['latest']) { $copyList[$fileRelativePath]['source'] = $pathToSync; $copyList[$fileRelativePath]['latest'] = $filemtime; } } } // schedule copy command for all files with older filemtime() than the latest copy foreach ($fileList as $fileRelativePath = $locationResults) { foreach ($locationResults as $pathToSync = $filemtime) { if ($filemtime $copyList[$fileRelativePath]['latest']) { $copyList[$fileRelativePath]['destinations'][] = $pathToSync; } } } // schedule copy command for all new files that must go to all $pathToSync where it is not present yet: foreach ($copyList as $fileRelativePath = $fileRec) { if (count($fileList[$fileRelativePath])!=count($paths)) { foreach ($paths as $idx=$pathToSync) { if (!array_key_exists($pathToSync, $fileList[$fileRelativePath])) $copyList[$fileRelativePath]['destinations'][] = $pathToSync; } } } // debug output of actual copy commands foreach ($copyList as $fileRelativePath = $fileRec) { if
Re: [PHP] code deployment through php
On Tue, May 1, 2012 at 11:11 AM, Camilo Sperberg unrea...@gmail.com wrote: If I understood the problem correctly, you want to keep a single copy of your code on every machine you work, including the final server. Well, I want to work on 1 copy of my common code on my windows machine, then sync those changes to all my sites (hosted on the win dev box) to see if it messes up the other sites, then FTP those changes to my hosting account, and run the sync script there as well. Have you read about SVN ? You can set up a cronjob to execute it automatically if you want, there are clients for Windows, Zend Studio, etc etc. I've read about some source control systems, I've tried them out, but I'd rather go for this simpler approach tbh. I already do regular backups that are timestamped, it's enough for me right now I think.
Re: [PHP] code deployment through php
On 1 May 2012, at 10:19, rene7705 wrote: On Tue, May 1, 2012 at 11:11 AM, Camilo Sperberg unrea...@gmail.com wrote: If I understood the problem correctly, you want to keep a single copy of your code on every machine you work, including the final server. Well, I want to work on 1 copy of my common code on my windows machine, then sync those changes to all my sites (hosted on the win dev box) to see if it messes up the other sites, then FTP those changes to my hosting account, and run the sync script there as well. Have you read about SVN ? You can set up a cronjob to execute it automatically if you want, there are clients for Windows, Zend Studio, etc etc. I've read about some source control systems, I've tried them out, but I'd rather go for this simpler approach tbh. I already do regular backups that are timestamped, it's enough for me right now I think. If you really think rolling your own deployment system is simpler than using source control then I don't think you've understood all of the advantages of source control. I know it can look complicated, but it's really not, and it will make it far easier to keep track of what you're doing and what changes are deployed where than the system you described. I strongly recommend you reconsider. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
RE: [PHP] code deployment through php
-Original Message- From: Stuart Dallas [mailto:stu...@3ft9.com] Sent: Tuesday, May 01, 2012 8:19 AM To: rene7705 Cc: Camilo Sperberg; php-general Subject: Re: [PHP] code deployment through php On 1 May 2012, at 10:19, rene7705 wrote: On Tue, May 1, 2012 at 11:11 AM, Camilo Sperberg unrea...@gmail.com wrote: If I understood the problem correctly, you want to keep a single copy of your code on every machine you work, including the final server. Well, I want to work on 1 copy of my common code on my windows machine, then sync those changes to all my sites (hosted on the win dev box) to see if it messes up the other sites, then FTP those changes to my hosting account, and run the sync script there as well. Have you read about SVN ? You can set up a cronjob to execute it automatically if you want, there are clients for Windows, Zend Studio, etc etc. I've read about some source control systems, I've tried them out, but I'd rather go for this simpler approach tbh. I already do regular backups that are timestamped, it's enough for me right now I think. If you really think rolling your own deployment system is simpler than using source control then I don't think you've understood all of the advantages of source control. I know it can look complicated, but it's really not, and it will make it far easier to keep track of what you're doing and what changes are deployed where than the system you described. I strongly recommend you reconsider. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Stuart, If I may add to your post Version control for different environments (Development and Production) is SO key with SVN. SVN has logging and other key features. Many, and when I say many that is an understatement, Many companies enforce SVN for their protection. Ever had a script not fully transfer, and only partial code remains? With SVN you can roll it back and Whala! You have the original source back. For one of my roles as Project Manager, I love Tortoise SVN. I have changed the scripting a bit to send me emails with descriptions of changes as they happen with attached files. This way I can actually filter my emails to find the exact person who made the bad change, what they had, and what they did instead of searching the logs. Since my developers can only push to the Development Servers I can fix issues before they become a Production Issue. No more, Developers having access to the server directly. They make their changes and commit their changes up, I review and can schedule changes to be committed to Production Servers. To setup a new Developer I simply check out the SVN library for them and they are up to speed day one. The setup is very easy, Yes the controls are a tiny bit confusing at FIRST. But if you want success, then SVN is a SMART decision for any project. Richard Buskirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
On 5/1/12 4:19 AM, rene7705 wrote: On Tue, May 1, 2012 at 11:11 AM, Camilo Sperbergunrea...@gmail.com wrote: If I understood the problem correctly, you want to keep a single copy of your code on every machine you work, including the final server. Well, I want to work on 1 copy of my common code on my windows machine, then sync those changes to all my sites (hosted on the win dev box) to see if it messes up the other sites, then FTP those changes to my hosting account, and run the sync script there as well. Have you read about SVN ? You can set up a cronjob to execute it automatically if you want, there are clients for Windows, Zend Studio, etc etc. I've read about some source control systems, I've tried them out, but I'd rather go for this simpler approach tbh. I already do regular backups that are timestamped, it's enough for me right now I think. No it's not. Really. For what you describe, a proper version control system is the correct tool. Rolling your own with rsync and cron is setting yourself up for failure. A couple people here have mentioned SVN. I used to use SVN, but now have migrated everything I do to Git. Without getting into a religious battle between Git and SVN, I do strongly recommend you look into it. This is an excellent resource for why to use it and how to use it: http://progit.org/book If you're serious about development, get serious about version control. --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
rene7705 wrote: Well, I want to work on 1 copy of my common code on my windows machine, then sync those changes to all my sites (hosted on the win dev box) to see if it messes up the other sites, then FTP those changes to my hosting account, and run the sync script there as well. I have a number of windows based customers who also like to review what we are doing, so I ended up with HG. TortoiseHg provides a nice gui based DVCS system interface on Windows which works identically on Linux and I can push and pull changes around the place without having to worry about anything. The servers 'pull' a copy of the code base from a local server master, which is managed from the development environment. Config information is protected on each site, and the whole thing works identically on both windows and linux so I don't have to worry what the customers are using. THEY can work to their own site and change what we give them access to, while the core code is managed from the central repo. If they come up with something useful it can be merged back into the master copy :) One of the few pieces of software I actually pay for is BeyondCompare which provides the same cross platform facilities for merging files and with it's built in ftp interface allows manually inspecting the file structure on any of the machines. A couple of my Mac based customers are now investigating the same development base. Add Eclipse/PHPEclipse on top and you have the ultimate cross platform IDE :) -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 5:47 AM, rene7705 rene7...@gmail.com wrote: Yea, i'm quite sure I want to develop on Windows 7. Ubuntu still has quircks when it comes to using 3 monitors on a single system, as far as I know. I just like windows 7 a lot better at the moment. And how would it be dangerous to do so? You can certainly develop on windows all you want. Before pushing things to a production environment that's different from your development environment, you should really run tests in (at least) a staging environment that is as close to production as possible. This can easily be done on your own system using a VM. It helps a lot to write portable applications in PHP, which is deftly simple to do in most cases. If you do have different things you want configured on various platforms (development, testing, staging, production, forex) you can do that in a number of ways (setting envars, testing the hostname, keeping a separate configuration file outside of the source control tree, etc) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 7:24 AM, Curtis Maurand cur...@maurand.com wrote: rene7705 wrote: On Tue, Mar 27, 2012 at 1:21 PM, Peter Ford p...@justcroft.com wrote: On 27/03/12 12:13, rene7705 wrote: hey, I just read the rsync man page for the first time, and while it sure looks simple enough for my taste, wouldn't updating multiple remote domains be like a whole series of the same FTP updates to these different domain directories there? In other words, take a long time because of my 200kb/s link to the unix hoster? The first time might be slow, but you can then do incremental updates which would be a lot quicker. ok, that'll do nicely.. Depending upon whether or not you have shell access to the hosts, you could update a host and then use rsync from that host to the rest. If rsync will work to your remote hosts, then can I safely assume you do have ssh access to them (rsync won't work without it unless you can launch an rsync daemon on your remote hosts). If so, then I don't think you really want to do the rsync thing at all, really. Instead, I'd use git or mercurial (or even svn or cvs will do). When you have your changes ready, push them to a remote repository (github.com or gitorious.org, say). Then you can pull the updates from the net by running the corresponding pull from the repository on the remote hosts. Let me also say that you should be keeping *everything* you develop in source control. It goes beyond just being able to backtrack if necessary, although that has been it's primary function. Keeping track of your own development efforts, even solo, can be very important to maintaining your code. Additionally, as you can see above, it aids greatly in deploying your code. Additionally, if you keep your repositories for any open source work on a public repository, it's advertising for your work and a simple off-site backup plan. With shell access, you can also create your own private repositories on one of your host accounts. Anyway, this has drifted far in to the topics of managing and deploying code, not so much PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Mon, Mar 26, 2012 at 9:16 PM, Stuart Dallas stu...@3ft9.com wrote: Rene: please read a book / website / something on PHP security. Some things are important whether you believe they are or not. Yea, I will do that within a week or so.. I can also confirm that I'm not using any source of source control at the moment. I have used visual source control of Microsoft in the past, but that was on a windows-only environment. I now have several domains on a shared unix hoster that I have to update with files from a windows 7 system. Basically, I have on the windows dev server X:\data1\www\htdocs\code (the copy I work on), which have to be updated to X:\data1\www\htdocs\sites\[domainname]\code, preferably as quickly as possible, and then, once release worthy, to the accounts on the shared unix hoster. On the shared unix hoster (godaddy.com 4G hosting), I have 1 FTP account which points to a primary domain (abc.com), which has a filesystem underneath it also with the /sites/[domainname], and the non-primary domains there point to these /sites/[domainname]/ for their $_SERVER['DOCUMENT_ROOT']. I do not have seperate FTP accounts for each domain on the unix hoster. If someone could explain to me which (free) source control system to use and perhaps how, or even point me in the direction of a good tutorial on that subject, you'd make me very happy. I also think it's time I got at least a bit more professional. Yet, I'm looking for the simplest and most efficient solution. I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want.
[PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: On Mon, Mar 26, 2012 at 9:16 PM, Stuart Dallas stu...@3ft9.com wrote: Rene: please read a book / website / something on PHP security. Some things are important whether you believe they are or not. Yea, I will do that within a week or so.. I can also confirm that I'm not using any source of source control at the moment. I have used visual source control of Microsoft in the past, but that was on a windows-only environment. I now have several domains on a shared unix hoster that I have to update with files from a windows 7 system. Basically, I have on the windows dev server X:\data1\www\htdocs\code (the copy I work on), which have to be updated to X:\data1\www\htdocs\sites\[domainname]\code, preferably as quickly as possible, and then, once release worthy, to the accounts on the shared unix hoster. On the shared unix hoster (godaddy.com 4G hosting), I have 1 FTP account which points to a primary domain (abc.com), which has a filesystem underneath it also with the /sites/[domainname], and the non-primary domains there point to these /sites/[domainname]/ for their $_SERVER['DOCUMENT_ROOT']. I do not have seperate FTP accounts for each domain on the unix hoster. If someone could explain to me which (free) source control system to use and perhaps how, or even point me in the direction of a good tutorial on that subject, you'd make me very happy. I also think it's time I got at least a bit more professional. Yet, I'm looking for the simplest and most efficient solution. I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations?
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 12:22 PM, ma...@behnke.biz ma...@behnke.biz wrote: rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Ok, I'll be reading everything I can find on rsync today, but I don't think I wanna use auto-updates from cron, instead I want to hit an icon on my desktop to start the update, either on only the windows system, or from the windows system to all the unix domain directories..
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 12:31 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:22 PM, ma...@behnke.biz ma...@behnke.biz wrote: rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Ok, I'll be reading everything I can find on rsync today, but I don't think I wanna use auto-updates from cron, instead I want to hit an icon on my desktop to start the update, either on only the windows system, or from the windows system to all the unix domain directories.. Are you sure you want to develop on a windows machine, and then push it out on all of your linux systems? That sounds dangerous to me. It's much safer to try it on a machine with same configuration as the production systems first. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 12:45 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:31 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:22 PM, ma...@behnke.biz ma...@behnke.biz wrote: rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Ok, I'll be reading everything I can find on rsync today, but I don't think I wanna use auto-updates from cron, instead I want to hit an icon on my desktop to start the update, either on only the windows system, or from the windows system to all the unix domain directories.. Are you sure you want to develop on a windows machine, and then push it out on all of your linux systems? That sounds dangerous to me. It's much safer to try it on a machine with same configuration as the production systems first. Yea, i'm quite sure I want to develop on Windows 7. Ubuntu still has quircks when it comes to using 3 monitors on a single system, as far as I know. I just like windows 7 a lot better at the moment. And how would it be dangerous to do so?
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 12:47 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:45 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:31 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:22 PM, ma...@behnke.biz ma...@behnke.biz wrote: rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Ok, I'll be reading everything I can find on rsync today, but I don't think I wanna use auto-updates from cron, instead I want to hit an icon on my desktop to start the update, either on only the windows system, or from the windows system to all the unix domain directories.. Are you sure you want to develop on a windows machine, and then push it out on all of your linux systems? That sounds dangerous to me. It's much safer to try it on a machine with same configuration as the production systems first. Yea, i'm quite sure I want to develop on Windows 7. Ubuntu still has quircks when it comes to using 3 monitors on a single system, as far as I know. I just like windows 7 a lot better at the moment. And how would it be dangerous to do so? Code that you write on a windows box might work different/not work at all on a linux machine. Think of different filesystem, different Apache/PHP versions, etc. I have to develop on windows too sometimes, and what I usually do in such cases is first push the code to a subdomain test.mydomain.com. If that works correctly, I push it over to www.mydomain.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 1:02 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:47 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:45 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:31 PM, rene7705 rene7...@gmail.com wrote: On Tue, Mar 27, 2012 at 12:22 PM, ma...@behnke.biz ma...@behnke.biz wrote: rene7705 rene7...@gmail.com hat am 27. März 2012 um 12:16 geschrieben: On Tue, Mar 27, 2012 at 12:08 PM, rene7705 rene7...@gmail.com wrote: I've done a search for rsync windows, and I get some rsync apps allright, but it's not clear to me yet how I would use these windows rsync clones to get done what I want. oh, one more thing; I just found that I won't always be working on the windows dev server's ...\htdocs\code, sometimes i'll find myself working on the /code copy in one of the /sites/[domainname]/code on the windows 7 dev system. how would I use a modern source control system to distribute the code from one of the subdomains to all other locations? Well, I guess google on rsync man page or read the documentation of these tools OR write to a mailing list that focusses on the use of linux tools. Then go and read about cron jobs or git/svn/putyoutoolhere post-receive/post-commit hooks or anything like that. Ok, I'll be reading everything I can find on rsync today, but I don't think I wanna use auto-updates from cron, instead I want to hit an icon on my desktop to start the update, either on only the windows system, or from the windows system to all the unix domain directories.. Are you sure you want to develop on a windows machine, and then push it out on all of your linux systems? That sounds dangerous to me. It's much safer to try it on a machine with same configuration as the production systems first. Yea, i'm quite sure I want to develop on Windows 7. Ubuntu still has quircks when it comes to using 3 monitors on a single system, as far as I know. I just like windows 7 a lot better at the moment. And how would it be dangerous to do so? Code that you write on a windows box might work different/not work at all on a linux machine. Think of different filesystem, different Apache/PHP versions, etc. I have to develop on windows too sometimes, and what I usually do in such cases is first push the code to a subdomain test.mydomain.com. If that works correctly, I push it over to www.mydomain.com. So far the code that I've written and am using works OK on both windows and unix. But I've just booted up my ubuntu installation and am currently upgrading from 11.04 to 11.10, maybe that fixes the issues I was having with it, and if it does I'll seriously consider using ubuntu as my primary dev environment again..
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
hey, I just read the rsync man page for the first time, and while it sure looks simple enough for my taste, wouldn't updating multiple remote domains be like a whole series of the same FTP updates to these different domain directories there? In other words, take a long time because of my 200kb/s link to the unix hoster?
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
On Tue, Mar 27, 2012 at 1:21 PM, Peter Ford p...@justcroft.com wrote: On 27/03/12 12:13, rene7705 wrote: hey, I just read the rsync man page for the first time, and while it sure looks simple enough for my taste, wouldn't updating multiple remote domains be like a whole series of the same FTP updates to these different domain directories there? In other words, take a long time because of my 200kb/s link to the unix hoster? The first time might be slow, but you can then do incremental updates which would be a lot quicker. ok, that'll do nicely..
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
rene7705 wrote: On Tue, Mar 27, 2012 at 1:21 PM, Peter Ford p...@justcroft.com wrote: On 27/03/12 12:13, rene7705 wrote: hey, I just read the rsync man page for the first time, and while it sure looks simple enough for my taste, wouldn't updating multiple remote domains be like a whole series of the same FTP updates to these different domain directories there? In other words, take a long time because of my 200kb/s link to the unix hoster? The first time might be slow, but you can then do incremental updates which would be a lot quicker. ok, that'll do nicely.. Depending upon whether or not you have shell access to the hosts, you could update a host and then use rsync from that host to the rest.
[PHP] including PHP code from another server..
Hi. My last thread got derailed into a javascript and even photoshop discussion, and while I can't blame myself for that really, this time I would like to bring a pure PHP issue to your scrutiny. I run several sites now, on the same shared hoster, but with such a setup that I cannot let PHP require() or include() code from a central place located on another domain name on the same shared hosting account, not the normal way at least. $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the domains on the same hosting account, and obviously you can't access one domain's directory from another domain. Hoster support's reply is A) I dont know code, B) You can't include code from one domain on another and C) use multiple copies, 1 for each domain But that directory (my opensourced /code in the zip on http://mediabeez.wsbtw), takes a while to update to my hoster, many files. Plus, as I add more domains that use the same code base, my overhead and waiting time increases lineary at a steep incline. So.. Since all of this code is my own, and tested and trusted, I can just eval(file_get_contents(' http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) hehe And get_php.php takes care of the nested includes by massaging what it retrieves. Or so is my thinking. The problem I'm facing, and for which I'm asking your most scrutinous feedback, is: How would you transform _nested_ require(_once) and include(_once)? I haven't figured out yet how to transform a relative path include/require. What about for instance a require_once($fileIwantNow)? I do both in my /code tree atm. For my own purposes, I could massage my own PHP in /code/libraries_rv and /code/sitewide_rv manually, but I'd also like to be able to include a single copy of the 3rd party free libs that I use in /code/libraries(/adodb-5.10 for instance). And god knows how they might include and require. Plus, I'd like to turn this into another free how-to blog entry on http://mediabeez.ws, plus accompanying code, so I think I might find some free tips here again. Greetings, from spring sun soaked amsterdam.nl, Rene
Re: [PHP] including PHP code from another server..
REMOVE THAT SCRIPT FROM YOUR SERVER RIGHT NOW! See follow-up email direct to you for the reason! On 26 Mar 2012, at 14:53, rene7705 wrote: Hi. My last thread got derailed into a javascript and even photoshop discussion, and while I can't blame myself for that really, this time I would like to bring a pure PHP issue to your scrutiny. I run several sites now, on the same shared hoster, but with such a setup that I cannot let PHP require() or include() code from a central place located on another domain name on the same shared hosting account, not the normal way at least. $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the domains on the same hosting account, and obviously you can't access one domain's directory from another domain. Hoster support's reply is A) I dont know code, B) You can't include code from one domain on another and C) use multiple copies, 1 for each domain But that directory (my opensourced /code in the zip on http://mediabeez.wsbtw), takes a while to update to my hoster, many files. Plus, as I add more domains that use the same code base, my overhead and waiting time increases lineary at a steep incline. So.. Since all of this code is my own, and tested and trusted, I can just eval(file_get_contents(' http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) hehe And get_php.php takes care of the nested includes by massaging what it retrieves. Or so is my thinking. The problem I'm facing, and for which I'm asking your most scrutinous feedback, is: How would you transform _nested_ require(_once) and include(_once)? I haven't figured out yet how to transform a relative path include/require. What about for instance a require_once($fileIwantNow)? I do both in my /code tree atm. For my own purposes, I could massage my own PHP in /code/libraries_rv and /code/sitewide_rv manually, but I'd also like to be able to include a single copy of the 3rd party free libs that I use in /code/libraries(/adodb-5.10 for instance). And god knows how they might include and require. Plus, I'd like to turn this into another free how-to blog entry on http://mediabeez.ws, plus accompanying code, so I think I might find some free tips here again. Greetings, from spring sun soaked amsterdam.nl, Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] including PHP code from another server..
Hi, Rene I just want to say the same ... whatever you're trying to do here - it will end up in a major security-isse that (I think) you won't fix that soon as someone has hacked your server. That sounds like you don't wanna pay 10$ per month for a good multiple-domain-hosting solution. If you're searching for something cheap for multi-domains, take a look at providers like DreamHost or something similar. Bye Simon 2012/3/26 Stuart Dallas stu...@3ft9.com: REMOVE THAT SCRIPT FROM YOUR SERVER RIGHT NOW! See follow-up email direct to you for the reason! On 26 Mar 2012, at 14:53, rene7705 wrote: Hi. My last thread got derailed into a javascript and even photoshop discussion, and while I can't blame myself for that really, this time I would like to bring a pure PHP issue to your scrutiny. I run several sites now, on the same shared hoster, but with such a setup that I cannot let PHP require() or include() code from a central place located on another domain name on the same shared hosting account, not the normal way at least. $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the domains on the same hosting account, and obviously you can't access one domain's directory from another domain. Hoster support's reply is A) I dont know code, B) You can't include code from one domain on another and C) use multiple copies, 1 for each domain But that directory (my opensourced /code in the zip on http://mediabeez.wsbtw), takes a while to update to my hoster, many files. Plus, as I add more domains that use the same code base, my overhead and waiting time increases lineary at a steep incline. So.. Since all of this code is my own, and tested and trusted, I can just eval(file_get_contents(' http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) hehe And get_php.php takes care of the nested includes by massaging what it retrieves. Or so is my thinking. The problem I'm facing, and for which I'm asking your most scrutinous feedback, is: How would you transform _nested_ require(_once) and include(_once)? I haven't figured out yet how to transform a relative path include/require. What about for instance a require_once($fileIwantNow)? I do both in my /code tree atm. For my own purposes, I could massage my own PHP in /code/libraries_rv and /code/sitewide_rv manually, but I'd also like to be able to include a single copy of the 3rd party free libs that I use in /code/libraries(/adodb-5.10 for instance). And god knows how they might include and require. Plus, I'd like to turn this into another free how-to blog entry on http://mediabeez.ws, plus accompanying code, so I think I might find some free tips here again. Greetings, from spring sun soaked amsterdam.nl, Rene -- 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] including PHP code from another server..
On 26 Mar 2012, at 15:17, Simon Schick wrote: Hi, Rene I just want to say the same ... whatever you're trying to do here - it will end up in a major security-isse that (I think) you won't fix that soon as someone has hacked your server. I couldn't care less about Rene's stuff. It's compromising the security of every customer on that server, and that's not acceptable. Security is arguably more important when using shared servers because your lack of focus on security issues has consequences for everyone else on that server, and potentially on that network. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] including PHP code from another server..
On 26 Mar 2012, at 14:53, rene7705 wrote: My last thread got derailed into a javascript and even photoshop discussion, and while I can't blame myself for that really, this time I would like to bring a pure PHP issue to your scrutiny. I run several sites now, on the same shared hoster, but with such a setup that I cannot let PHP require() or include() code from a central place located on another domain name on the same shared hosting account, not the normal way at least. $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the domains on the same hosting account, and obviously you can't access one domain's directory from another domain. Hoster support's reply is A) I dont know code, B) You can't include code from one domain on another and C) use multiple copies, 1 for each domain But that directory (my opensourced /code in the zip on http://mediabeez.wsbtw), takes a while to update to my hoster, many files. Plus, as I add more domains that use the same code base, my overhead and waiting time increases lineary at a steep incline. So.. Since all of this code is my own, and tested and trusted, I can just eval(file_get_contents(' http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) hehe And get_php.php takes care of the nested includes by massaging what it retrieves. Or so is my thinking. The problem I'm facing, and for which I'm asking your most scrutinous feedback, is: How would you transform _nested_ require(_once) and include(_once)? I haven't figured out yet how to transform a relative path include/require. What about for instance a require_once($fileIwantNow)? I do both in my /code tree atm. For my own purposes, I could massage my own PHP in /code/libraries_rv and /code/sitewide_rv manually, but I'd also like to be able to include a single copy of the 3rd party free libs that I use in /code/libraries(/adodb-5.10 for instance). And god knows how they might include and require. Plus, I'd like to turn this into another free how-to blog entry on http://mediabeez.ws, plus accompanying code, so I think I might find some free tips here again. Don't do this. Use a central source to host your code by all means, but create constantly updated copies on every server that uses it. Since I use git for source control I make use of the submodule feature to make this simplicity itself. It's worth investing time in building the processes that ensure consistency between your various environments. The best ops strategy is the lazy op's strategy! Set up cron scripts on each server to update that code periodically so everything is always up to date. I wouldn't recommend that unless you have good testing procedures in place before your code hits production, but from what I've seen I find the highly doubtful. However, sharing code at runtime over http is a very very very bad idea. Even farms with hundreds or thousands of servers, all running the same application on a fast local network, don't share code in this way. Each server has its own copy of the code, and it's the deployment processes that ensure they're kept up to date. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] including PHP code from another server..
rsync is your friend. --C Stuart Dallas wrote: On 26 Mar 2012, at 14:53, rene7705 wrote: My last thread got derailed into a javascript and even photoshop discussion, and while I can't blame myself for that really, this time I would like to bring a pure PHP issue to your scrutiny. I run several sites now, on the same shared hoster, but with such a setup that I cannot let PHP require() or include() code from a central place located on another domain name on the same shared hosting account, not the normal way at least. $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the domains on the same hosting account, and obviously you can't access one domain's directory from another domain. Hoster support's reply is A) I dont know code, B) You can't include code from one domain on another and C) use multiple copies, 1 for each domain But that directory (my opensourced /code in the zip on http://mediabeez.wsbtw), takes a while to update to my hoster, many files. Plus, as I add more domains that use the same code base, my overhead and waiting time increases lineary at a steep incline. So.. Since all of this code is my own, and tested and trusted, I can just eval(file_get_contents(' http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) hehe And get_php.php takes care of the nested includes by massaging what it retrieves. Or so is my thinking. The problem I'm facing, and for which I'm asking your most scrutinous feedback, is: How would you transform _nested_ require(_once) and include(_once)? I haven't figured out yet how to transform a relative path include/require. What about for instance a require_once($fileIwantNow)? I do both in my /code tree atm. For my own purposes, I could massage my own PHP in /code/libraries_rv and /code/sitewide_rv manually, but I'd also like to be able to include a single copy of the 3rd party free libs that I use in /code/libraries(/adodb-5.10 for instance). And god knows how they might include and require. Plus, I'd like to turn this into another free how-to blog entry on http://mediabeez.ws, plus accompanying code, so I think I might find some free tips here again. Don't do this. Use a central source to host your code by all means, but create constantly updated copies on every server that uses it. Since I use git for source control I make use of the submodule feature to make this simplicity itself. It's worth investing time in building the processes that ensure consistency between your various environments. The best ops strategy is the lazy op's strategy! Set up cron scripts on each server to update that code periodically so everything is always up to date. I wouldn't recommend that unless you have good testing procedures in place before your code hits production, but from what I've seen I find the highly doubtful. However, sharing code at runtime over http is a very very very bad idea. Even farms with hundreds or thousands of servers, all running the same application on a fast local network, don't share code in this way. Each server has its own copy of the code, and it's the deployment processes that ensure they're kept up to date. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] including PHP code from another server..
Curtis Maurand wrote: rsync is your friend. and is even available for windows machines ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] including PHP code from another server..
Now, as the issue adressed and script removed, can you please explain what exactly are the issues of using such approach? I mean security ones, not performance. 2012/3/26 Lester Caine les...@lsces.co.uk: Curtis Maurand wrote: rsync is your friend. and is even available for windows machines ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- 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] including PHP code from another server..
On 26 Mar 2012, at 17:41, Alex Pojarsky wrote: Now, as the issue adressed and script removed, can you please explain what exactly are the issues of using such approach? I mean security ones, not performance. It's the wrong solution to a process and organisation problem. Ultimately it's not really a problem IF you control every part of the infrastructure. Rene clearly doesn't so it has implications for everyone sharing that infrastructure, and anyone using the applications hosted there. * It requires the host to enable allow_url_fopen which means every single script on the server is then able to include/require URLs. It just needs one of them to have a related vulnerability and suddenly people can execute arbitrary PHP code on the server. * Rene mentioned that the code is open source. This implies that the security risk is lessened because the code that is being made publicly accessible is already publicly accessible, so the opportunity for someone to find vulnerabilities already exists. It gets an order of magnitude worse if other people start ignorantly using his code because they're essentially giving him the ability to execute arbitrary PHP code on their server. Not good no matter how much he protests that he won't be evil. * You specifically wished to exclude performance from the discussion, but scalability is potentially a big issue here and should not be completely ignored. I think the real issue for Rene is that of perceived complexity. The idea of having to manually keep many copies of the same code in sync is what leads to finding solutions like this one. This solution leads to unnecessary network traffic and introduces potential security risks that go way beyond your own code, and even if it's not a big issue now it has the potential to become catastrophic! I'd put a fair amount of cash on my guess that Rene is not using any form of source control. To me that is the best solution to this problem. Curtis mentioned rsync which will also do the job, but in my view you're nuts if you're not using some form of source control already, and building a largely automated process around that is trivial and automatically audited. Rene: please read a book / website / something on PHP security. Some things are important whether you believe they are or not. -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
Re: [PHP] including PHP code from another server..
I understand what performance issues this brings, but as for security was just a bit curious. You have just showed me what I was thinking about, but you wrote it much better, clear and structured. Thank you. 2012/3/26 Stuart Dallas stu...@3ft9.com: On 26 Mar 2012, at 17:41, Alex Pojarsky wrote: Now, as the issue adressed and script removed, can you please explain what exactly are the issues of using such approach? I mean security ones, not performance. It's the wrong solution to a process and organisation problem. Ultimately it's not really a problem IF you control every part of the infrastructure. Rene clearly doesn't so it has implications for everyone sharing that infrastructure, and anyone using the applications hosted there. * It requires the host to enable allow_url_fopen which means every single script on the server is then able to include/require URLs. It just needs one of them to have a related vulnerability and suddenly people can execute arbitrary PHP code on the server. * Rene mentioned that the code is open source. This implies that the security risk is lessened because the code that is being made publicly accessible is already publicly accessible, so the opportunity for someone to find vulnerabilities already exists. It gets an order of magnitude worse if other people start ignorantly using his code because they're essentially giving him the ability to execute arbitrary PHP code on their server. Not good no matter how much he protests that he won't be evil. * You specifically wished to exclude performance from the discussion, but scalability is potentially a big issue here and should not be completely ignored. I think the real issue for Rene is that of perceived complexity. The idea of having to manually keep many copies of the same code in sync is what leads to finding solutions like this one. This solution leads to unnecessary network traffic and introduces potential security risks that go way beyond your own code, and even if it's not a big issue now it has the potential to become catastrophic! I'd put a fair amount of cash on my guess that Rene is not using any form of source control. To me that is the best solution to this problem. Curtis mentioned rsync which will also do the job, but in my view you're nuts if you're not using some form of source control already, and building a largely automated process around that is trivial and automatically audited. Rene: please read a book / website / something on PHP security. Some things are important whether you believe they are or not. -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
RE: [PHP] PHP code problem with pages
Maybe my subject line is not descriptive as I wish, but I just did not know how to put on it. I have the following problem, I'm using jQuery to make a slide effect (horizontal), everything seems to be working find, but I have to add a mask with a white color background, I did this by CSS, now I have 6 pages in total, this is managed by wp anyway, it shows the white bakground mask in every page, and I want it to show in every page but not the home page; [] Carlos, this looks like it would better suit your support needs to post this question on the wordpress.org forums. Here is what I can tell you, you need to make use of the functions built into WP and the theme you are using. The function(s) you need to use are as such: is_front_page(); is_home_page(); is_page(); etc and you can find the documentation in the Wordpress Codex here http://codex.wordpress.org/Conditional_Tags You could, alternatively, create your slider as a plugin; create a shortcode hook, and then call the sliders to the page with the shortcode in the dashboard WYSIWYG for that page/post. Marc Hall HallMarc Websites -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP code problem with pages
Hello Mates, Maybe my subject line is not descriptive as I wish, but I just did not know how to put on it. I have the following problem, I'm using jQuery to make a slide effect (horizontal), everything seems to be working find, but I have to add a mask with a white color background, I did this by CSS, now I have 6 pages in total, this is managed by wp anyway, it shows the white bakground mask in every page, and I want it to show in every page but not the home page; since I'm using a slider effect and a container, it became very difficult to me, maybe any of you can explain me a way to a easy fix, I will show you the lines of code: div id=wrapper div id=mask ?php $pages = list_all_pages(); ? ?php //Get first and last page ID $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); $post_key[$cnt] = $post_keys[0]; $cnt++; } ? ?php $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); ? div class=item ?php if(($jxfs_transition == 'horizontal_vertical' $cnt%2 == 0) || ($jxfs_transition == 'horizontal')) { echo 'fl';} ? id=?php echo $post_keys[0]; ? div class=content ?php $page_content = get_page($page-ID); ? ul class=container //This is the container with the white background. li class='grid_820' ?php echo do_shortcode($page_content-post_content); ? /li As you can see, I'm using this for all pages, I was trying to use another template-code to tell wordpress that home page uses another page as home, but it does not work for some reason. Anyway, help will be appreciated. -- Carlos Sura.- www.carlossura.com
Re: [PHP] PHP code problem with pages
On Sat, Jan 21, 2012 at 20:07, Carlos Sura carlos.su...@googlemail.com wrote: Hello Mates, Maybe my subject line is not descriptive as I wish, but I just did not know how to put on it. I have the following problem, I'm using jQuery to make a slide effect (horizontal), everything seems to be working find, but I have to add a mask with a white color background, I did this by CSS, now I have 6 pages in total, this is managed by wp anyway, it shows the white bakground mask in every page, and I want it to show in every page but not the home page; since I'm using a slider effect and a container, it became very difficult to me, maybe any of you can explain me a way to a easy fix, I will show you the lines of code: This is probably better answered via a WordPress support venue, but you can try this: if ($_SERVER['PHP_SELF'] == 'the name of your index file') { // Load alternate styling here } else { // Do your primary styling } div id=wrapper div id=mask ?php $pages = list_all_pages(); ? ?php //Get first and last page ID $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); $post_key[$cnt] = $post_keys[0]; $cnt++; } ? ?php $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); ? div class=item ?php if(($jxfs_transition == 'horizontal_vertical' $cnt%2 == 0) || ($jxfs_transition == 'horizontal')) { echo 'fl';} ? id=?php echo $post_keys[0]; ? div class=content ?php $page_content = get_page($page-ID); ? ul class=container //This is the container with the white background. li class='grid_820' ?php echo do_shortcode($page_content-post_content); ? /li As you can see, I'm using this for all pages, I was trying to use another template-code to tell wordpress that home page uses another page as home, but it does not work for some reason. Anyway, help will be appreciated. -- Carlos Sura.- www.carlossura.com -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What's the problem with this PHP code?
Here is the PHP code: ?php $panka =c:can-it-rock- :the-boat-of- :love- ; $pankb = preg_split(':',$panka); $pankc = $pankb{1}; echo ( . $panka . )\n( . $pankc . )\n; ? I keep getting the following error: Sophia-Shapiras-MacBook-Pro:tmp red_angel$ Sophia-Shapiras-MacBook-Pro:tmp red_angel$ php testo.php Warning: preg_split(): No ending delimiter ':' found in /Users/red_angel/tmp/testo.php on line 8 ( c:can-it-rock- :the-boat-of- :love- ) () Sophia-Shapiras-MacBook-Pro:tmp red_angel$ Sophia-Shapiras-MacBook-Pro:tmp red_angel$ So --- what am I missing? What am I doing wrong? I'm pulling my hair out over this one! Anyone have a clue what's up? I can see that the colon is present *multiple* times in the string that is meant to be split! How come PHP's preg_split() function can't see it? Thanks, Sophia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the problem with this PHP code?
On Fri, Nov 4, 2011 at 1:47 PM, Sophia red_an...@techno-info.com wrote: Here is the PHP code: ?php $panka =c:can-it-rock- :the-boat-of- :love- ; $pankb = preg_split(':',$panka); It should be preg_split('/:/', $panka); $pankc = $pankb{1}; echo ( . $panka . )\n( . $pankc . )\n; ? I keep getting the following error: Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ php testo.php Warning: preg_split(): No ending delimiter ':' found in /Users/red_angel/tmp/testo.php on line 8 ( c:can-it-rock- :the-boat-of- :love- ) () Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ So --- what am I missing? What am I doing wrong? I'm pulling my hair out over this one! Anyone have a clue what's up? I can see that the colon is present *multiple* times in the string that is meant to be split! How come PHP's preg_split() function can't see it? Thanks, Sophia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Shiplu Mokadd.im Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
Re: [PHP] What's the problem with this PHP code?
On Fri, Nov 4, 2011 at 2:52 AM, shiplu shiplu@gmail.com wrote: On Fri, Nov 4, 2011 at 1:47 PM, Sophia red_an...@techno-info.com wrote: Here is the PHP code: ?php $panka = c:can-it-rock- :the-boat-of- :love- ; $pankb = preg_split(':',$panka); It should be preg_split('/:/', $panka); Maybe just to unpack this a bit more, preg_split expects a regex in the first parameter. When you said ':' it thought that you were beginning a regex form with the colon and expected to find another one to end the regex. when you do it this way, regexes have to be quoted as well, as they are strings. $pankc = $pankb{1}; echo ( . $panka . )\n( . $pankc . )\n; ? I keep getting the following error: Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ php testo.php Warning: preg_split(): No ending delimiter ':' found in /Users/red_angel/tmp/testo.php on line 8 ( c:can-it-rock- :the-boat-of- :love- ) () Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ So --- what am I missing? What am I doing wrong? I'm pulling my hair out over this one! Anyone have a clue what's up? I can see that the colon is present *multiple* times in the string that is meant to be split! How come PHP's preg_split() function can't see it? Thanks, Sophia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Shiplu Mokadd.im Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-08-31 08:20 PM, Tedd Sperling wrote: On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: On 11-08-30 11:36 AM, Richard Quadling wrote: On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Cheers, Rob. No, not indenting braces is T LYY. Make things uniform -- a condition followed by indented code located between equally indented braces makes sense to me. How people read other code styles is a mystery to me. Come now Tedd! It's only Thursday and yet you jest so!! :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 2011-08-31, at 11:44 PM, Ross McKay wrote: On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with KR :) --- FWIW, am working my way through an O'Reilly book (HTML5 Canvas) right now and they appear to use The One True Brace Style in their code examples. Not religious about it, but it does help me know which code I wrote and what was touched by someone else! George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-09-01 01:44 AM, Ross McKay wrote: On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with KR :) That's because JavaScript is broken in some ways. As much as I like JavaScript, some parts of the language were thrown together by flinging crap at a fan and seeing what sticks to the wall... this being a prime example. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
Robert Cummings wrote: That's because JavaScript is broken in some ways. As much as I like JavaScript, some parts of the language were thrown together by flinging crap at a fan and seeing what sticks to the wall... this being a prime example. Sounds a lot like PHP :) which I must add I love dearly, though it certainly resembles your remark much more closely than JavaScript. But on-topic, novices using a coding style and feeling their way around a new language would be better served by the 1TB style than anything that easily allows statement insertion (either by them, or by silly language defects like JavaScript's semicolon insertion). -- Ross McKay, Toronto, NSW Australia Hold very tight please! Ting! Ting! - Flanders and Swann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-09-01 02:39 AM, Ross McKay wrote: Robert Cummings wrote: That's because JavaScript is broken in some ways. As much as I like JavaScript, some parts of the language were thrown together by flinging crap at a fan and seeing what sticks to the wall... this being a prime example. Sounds a lot like PHP :) which I must add I love dearly, though it certainly resembles your remark much more closely than JavaScript. But on-topic, novices using a coding style and feeling their way around a new language would be better served by the 1TB style than anything that easily allows statement insertion (either by them, or by silly language defects like JavaScript's semicolon insertion). Oh for sure, it's necessary that novices have something towards which they can evolve. If they start with Allman's then how could they improve their brace style :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 30 August 2011 23:25, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. So I think we've all established that Whitesmith's is the way to go, but what about markup languages? Take our own lovely PHPDocumentation. Here, in the main, we have all subordinate elements starting on their own line, indented. Is there really any other way that would make sense? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Code should be selv-maintaining!
On 01 Sep 2011 at 11:42, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 23:25, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. So I think we've all established that Whitesmith's is the way to go, I've been using the Whitesmith's style since I started coding in BCPL in the mid-70s. Having the braces line up is a big help. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Sep 1, 2011, at 8:16 AM, Tim Streater wrote: On 01 Sep 2011 at 11:42, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 23:25, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. So I think we've all established that Whitesmith's is the way to go, I've been using the Whitesmith's style since I started coding in BCPL in the mid-70s. Having the braces line up is a big help. Good. Not only do I use the Whitesmith style for PHP, but I use it for Javascript, CSS, and everything that has braces (excepting grandchildren). In addition, I also teach college level programming where I present my view on style. While I may not influence established programmers (good habits or no), young minds are open to suggestion. :-) Cheers, tedd _ t...@sperling.com http://sperling.com
RE: [PHP] Code should be selv-maintaining!
Genius! -Original Message- From: Matt Graham [mailto:danceswithcr...@usa.net] Sent: Tuesday, August 30, 2011 5:59 PM To: php-general@lists.php.net Subject: Re: [PHP] Code should be selv-maintaining! From: David Harkness davi...@highgearmedia.com I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends. ...and when you use CCR style, you can sing, I see a bad brace a-risin'? -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- 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] Code should be selv-maintaining!
On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: On 11-08-30 11:36 AM, Richard Quadling wrote: On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Cheers, Rob. No, not indenting braces is T LYY. Make things uniform -- a condition followed by indented code located between equally indented braces makes sense to me. How people read other code styles is a mystery to me. Cheers, tedd _ t...@sperling.com http://sperling.com
Re: [PHP] Code should be selv-maintaining!
On Wed, Aug 31, 2011 at 08:20:14PM -0400, Tedd Sperling wrote: On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: On 11-08-30 11:36 AM, Richard Quadling wrote: On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Cheers, Rob. No, not indenting braces is T LYY. Make things uniform -- a condition followed by indented code located between equally indented braces makes sense to me. How people read other code styles is a mystery to me. Indeed it is a mystery, a religious one. The way we do it is because we finally broke through the clouds of earthly obfuscation to comprehend the blinding truth that is KR. Amen. (Nah, it wasn't Kool-Aid. Tasted more like a cross between RC Cola and Dr Pepper.) ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with KR :) -- Ross McKay, Toronto, NSW Australia Let the laddie play wi the knife - he'll learn - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Aug 29, 2011, at 4:32 PM, George Langley wrote: The One True Brace Style: http://en.wikipedia.org/wiki/Indent_style Didn't know there was a name for the way I learned to indent! Make sense to me - looks so much cleaner and less scrolling/printing. And, I already add a comment to confirm the end brace: } // end if($myVar) to clarify any long nests. George To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd --- t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 30 August 2011 15:04, Tedd Sperling tedd.sperl...@gmail.com wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-08-30 11:36 AM, Richard Quadling wrote: On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends.
RE: [PHP] Code should be selv-maintaining!
LOLercopter! -Original Message- From: David Harkness [mailto:davi...@highgearmedia.com] Sent: Tuesday, August 30, 2011 12:57 PM To: Robert Cummings Cc: rquadl...@gmail.com; Tedd Sperling; php-general@lists.php.net Subject: Re: [PHP] Code should be selv-maintaining! I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code should be selv-maintaining!
David Harkness ...you must be... the most interesting coder in the world ;) -Original Message- From: David Harkness [mailto:davi...@highgearmedia.com] Sent: Tuesday, August 30, 2011 2:57 PM To: Robert Cummings Cc: rquadl...@gmail.com; Tedd Sperling; php-general@lists.php.net Subject: Re: [PHP] Code should be selv-maintaining! I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Aug 30, 2011, at 6:25 PM, Richard Quadling wrote: On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. I always thought that was beer holder? Is it friday yet? ;) Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
From: David Harkness davi...@highgearmedia.com I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends. ...and when you use CCR style, you can sing, I see a bad brace a-risin'? -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code should be selv-maintaining!
Dont get me wrong, I love programming! But what an absolute pain in the ass it is when you re-use old code only to discover something less well made. You all know about this right? You go into your homemade library of code to re-use some piece that you already are using 12 other places in production. Now, last time you worked on the code you thought it was almost perfect. While working on the code this time you find an undiscovered bug or some part of the code that looks like you where on drugs when you made it. Of course we develop experience and more skills all the time, and as a good programmer we never stop doing that, but what a pain it is when the above happens and you have to patch the code being used those 12 other places too, and each place maybe has a slightly different usage, so minor changes affect other stuff. And this goes on while your head is spinning around trying to stay focused on the very task at hand that originated the need for a quick re-usage of old code in the first place. Why the hell can't code be self-maintaining!? :)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-08-29 03:42 PM, Rico Secada wrote: You go into your homemade library of code to re-use some piece that you already are using 12 other places in production. Now, last time you worked on the code you thought it was almost perfect. While working on the code this time you find an undiscovered bug or some part of the code that looks like you where on drugs when you made it. *lol* Yes, I think we've all seen it from time to time. Have you ever gone back and looked at your school assignments in coding? *shudder*. The horror is compounded by the fact I was using KR style indentation back then ;) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code should be selv-maintaining!
-Original Message- From: Rico Secada [mailto:coolz...@it.dk] Sent: Monday, August 29, 2011 3:42 PM To: php-general@lists.php.net Subject: [PHP] Code should be selv-maintaining! Dont get me wrong, I love programming! But what an absolute pain in the ass it is when you re-use old code only to discover something less well made. You all know about this right? You go into your homemade library of code to re-use some piece that you already are using 12 other places in production. Now, last time you worked on the code you thought it was almost perfect. While working on the code this time you find an undiscovered bug or some part of the code that looks like you where on drugs when you made it. Of course we develop experience and more skills all the time, and as a good programmer we never stop doing that, but what a pain it is when the above happens and you have to patch the code being used those 12 other places too, and each place maybe has a slightly different usage, so minor changes affect other stuff. And this goes on while your head is spinning around trying to stay focused on the very task at hand that originated the need for a quick re-usage of old code in the first place. Why the hell can't code be self-maintaining!? :)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In a framework this is not a problem, and easy to update. Development as a whole, is a living document ever growing and expanding it abilities. If taking advantage of the new ability is a long upgrade process then the design is stagnate . This is called the longevity of a design and is why many developers No longer use what is called as flat text programming. Thinking object oriented programming in frameworks is the only way I do business. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Mon, 29 Aug 2011, Rico Secada wrote: You go into your homemade library of code to re-use some piece that you already are using 12 other places in production. Now, last time you worked on the code you thought it was almost perfect. While working on the code this time you find an undiscovered bug or some part of the code that looks like you where on drugs when you made it. This is why it's good to write this kind of thing as functions. Then if you find some great problem with it later, you can drop in the replacement functions and the code that calls it (hopefully) won't need modification. Of course, it's easier to be cleverer after the event. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] execute my php code before every php call
Hi all, I have a simple code that override some env vars but i need it to run before any other php code on every php execution. I would like to avoid any change of all php code (even if its only to include the include command). Any one knows of such way ? I dont mind overriding this vars on php configuration file but i dont have any control of it as its should work on even the most strict web hosting (that still allow env vars manipulation) Any alternatives ? Thanks, TL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] execute my php code before every php call
On Jun 12, 2011, at 1:46 PM, techloop wrote: I have a simple code that override some env vars but i need it to run before any other php code on every php execution. Have you looked at http://us.php.net/manual/en/ini.core.php#ini.auto-prepend-file ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] execute my php code before every php call
On 12 Jun 2011, at 19:46, techloop techloop...@gmail.com wrote: Hi all, I have a simple code that override some env vars but i need it to run before any other php code on every php execution. I would like to avoid any change of all php code (even if its only to include the include command). Any one knows of such way ? I dont mind overriding this vars on php configuration file but i dont have any control of it as its should work on even the most strict web hosting (that still allow env vars manipulation) Any alternatives ? Thanks, TL Look up the auto_prepend_file php.ini configuration option. That should give you the functionality you're after. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Sent from my leaf blower -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Log Rotation, leave it to OS or do it in PHP code?
Dear list, It seems that Python has already a Log Rotation mechanism, which solves the problem of log file growth. I'm wondering whether there is any PHP-based solution around? Now let me ask from a different view: Is it a good approach to implement the Rotation mechanism to PHP? (Code Level) Or leave the job to the operating system and other utilities? Where is the right place to implmenet the Rotation? In Code? In OS? PHP? or a Bash Script? Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Log Rotation, leave it to OS or do it in PHP code?
On Sat, 2011-02-26 at 16:37 +0330, AmirBehzad Eslami wrote: Dear list, It seems that Python has already a Log Rotation mechanism, which solves the problem of log file growth. I'm wondering whether there is any PHP-based solution around? Now let me ask from a different view: Is it a good approach to implement the Rotation mechanism to PHP? (Code Level) Or leave the job to the operating system and other utilities? Where is the right place to implmenet the Rotation? In Code? In OS? PHP? or a Bash Script? Thanks, Personally, I would leave it to the OS and other tools, the reason being that it may not necessarily be the programmer who is managing the server as well. I've worked in a couple of places large enough to have dedicated server guys (and gals) who dealt with deploying managing the servers and their services. They may have a preferred way of rotating and archiving logs that is managed on all the log files, regardless of what scripting language was used to create them. If you're working in a smaller environment that doesn't have different staff supporting the servers, I would still keep the log rotation separate, but you manage this in a number of ways, either leaving it to the OS, write a bash script, PHP script, or some sort of off-the-shelf solution. I would be careful not to clutter an app too much with things it may not need to, and having the rotation dealt with independently means that it can be a utility shared by many of your scripts. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re:[PHP] code quest
Frankly, while that modulo looks like something worthy of learning, for my immediate time critical need I went with a quicker method, which is working. The complete script is below. It simply counts cells and resets the row when a number is exceeded. ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); $counter=0; #40 echo 'table border=1 cellspacing=1 cellpadding=5 bgcolor=F0F0F0tr'; foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { ++$counter ; echo 'td width=150 valign=topcenter'.$d.'bra href='.$d.''; echo 'img src=./'.$d.'/thumb.png width=120 HEIGHT=175 border=5/abr/center'; include($d./desc.txt); echo '/td'; if ($counter 3) { echo '/trtr'; #50 $counter=0; } }; }; echo '/tr/table'; ? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] code quest
Now I have a situation. I need to take the code from my former home page and modify it to lay out a table (let's say 5 cells wide) and as many rows deep to contain all the items. Each item is the name of the directory, under which is an icon image from that directory, under which is a description file read from that directory. Here is my code thus far: ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0tr align=center'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'td'.$d.'bra href='.$d.'img src=/Categories/'.$d.'/thumb.png border=5/abr'; include($d./desc.txt); echo '/td'; }; }; echo '/tr/table'; ? Now I am stymied on changing this to add /trtr at the right points in the structure. I am new to php, and welcome all suggestions and gainful comments. -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
On 15 February 2011 00:53, Kirk Bailey kbai...@howlermonkey.net wrote: Now I have a situation. I need to take the code from my former home page and modify it to lay out a table (let's say 5 cells wide) and as many rows deep to contain all the items. Each item is the name of the directory, under which is an icon image from that directory, under which is a description file read from that directory. Here is my code thus far: ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0tr align=center'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'td'.$d.'bra href='.$d.'img src=/Categories/'.$d.'/thumb.png border=5/abr'; include($d./desc.txt); echo '/td'; }; }; echo '/tr/table'; ? Now I am stymied on changing this to add /trtr at the right points in the structure. I am new to php, and welcome all suggestions and gainful comments. $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'tr align=centertd', $d, 'bra href=', $d, 'img src=/Categories/', $d, '/thumb.png border=5/abr'; include($d./desc.txt); echo '/td/tr'; }; }; echo '/table'; maybe? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
well, this ends the row after every cell. I am trying to get a row of 5 cells across, then end it and start a new row. If the routines stops before the end of the count of 5 due to lack of further directories, closing out the table following the loops will onclude a /tr tag. On 2/14/2011 8:30 PM, Richard Quadling wrote: On 15 February 2011 00:53, Kirk Baileykbai...@howlermonkey.net wrote: Now I have a situation. I need to take the code from my former home page and modify it to lay out a table (let's say 5 cells wide) and as many rows deep to contain all the items. Each item is the name of the directory, under which is an icon image from that directory, under which is a description file read from that directory. Here is my code thus far: ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0tr align=center'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'td'.$d.'bra href='.$d.'img src=/Categories/'.$d.'/thumb.png border=5/abr'; include($d./desc.txt); echo '/td'; }; }; echo '/tr/table'; ? Now I am stymied on changing this to add/trtr at the right points in the structure. I am new to php, and welcome all suggestions and gainful comments. $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d))!in_array(basename($d),$excludes)) { echo 'tr align=centertd', $d,'bra href=', $d, 'img src=/Categories/', $d, '/thumb.png border=5/abr'; include($d./desc.txt); echo '/td/tr'; }; }; echo '/table'; maybe? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
On 2/14/2011 4:53 PM, Kirk Bailey wrote: Now I have a situation. I need to take the code from my former home page and modify it to lay out a table (let's say 5 cells wide) and as many rows deep to contain all the items. Each item is the name of the directory, under which is an icon image from that directory, under which is a description file read from that directory. Here is my code thus far: ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0tr align=center'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'td'.$d.'bra href='.$d.'img src=/Categories/'.$d.'/thumb.png border=5/abr'; include($d./desc.txt); echo '/td'; }; }; echo '/tr/table'; ? Now I am stymied on changing this to add /trtr at the right points in the structure. I am new to php, and welcome all suggestions and gainful comments. You want modulo math... Check out this page http://www.cmsws.com/examples/php/modulo_array_output.php If you like the output, here is the source http://www.cmsws.com/examples/php/modulo_array_output.phps The bottom two examples show how you can use other HTML tags to present data. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
Very nice; I am leaning in the direction of doing it this way. Thank you! :-) On 2/14/2011 9:24 PM, Jim Lucas wrote: On 2/14/2011 4:53 PM, Kirk Bailey wrote: Now I have a situation. I need to take the code from my former home page and modify it to lay out a table (let's say 5 cells wide) and as many rows deep to contain all the items. Each item is the name of the directory, under which is an icon image from that directory, under which is a description file read from that directory. Here is my code thus far: ?php # The next several lines declare an array of directories which are NOT to be listed!# $excludes[] = 'attachments'; #20 $excludes[] = 'data'; $excludes[] = 'include'; $excludes[] = 'resources'; $excludes[] = 'stats'; $excludes[] = '_private'; $excludes[] = '_vti_bin'; $excludes[] = '_vti_cnf'; $excludes[] = '_vti_log'; $excludes[] = '_vti_pvt'; $excludes[] = '_vti_txt'; #30 $excludes[] = '_vxi_txt'; $excludes[] = 'css'; $excludes[] = 'img'; $excludes[] = 'images'; $excludes[] = 'js'; $excludes[] = 'cgi'; $excludes[] = 'cgi-bin'; $excludes[] = 'ssfm'; $ls = scandir(dirname(__FILE__)); echo 'table border=1 cellspacing=5 cellpadding=0 bgcolor=E0E0E0tr align=center'; #40 foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'td'.$d.'bra href='.$d.'img src=/Categories/'.$d.'/thumb.png border=5/abr'; include($d./desc.txt); echo '/td'; }; }; echo '/tr/table'; ? Now I am stymied on changing this to add/trtr at the right points in the structure. I am new to php, and welcome all suggestions and gainful comments. You want modulo math... Check out this page http://www.cmsws.com/examples/php/modulo_array_output.php If you like the output, here is the source http://www.cmsws.com/examples/php/modulo_array_output.phps The bottom two examples show how you can use other HTML tags to present data. Jim Lucas -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code formatter
-Original Message- From: ken.gu...@gmail.com [mailto:ken.gu...@gmail.com] On Behalf Of Ken Guest Sent: Monday, January 31, 2011 3:26 PM To: Hansen, Mike Cc: php-general@lists.php.net Subject: Re: [PHP] Code formatter On Mon, Jan 31, 2011 at 8:27 PM, Hansen, Mike mike.han...@atmel.com wrote: I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Have you found http://pear.php.net/package/PHP_Beautifier yet? ;) http://www.php.net/unsub.php Ken It mostly works ok. Unfortunately, there's a bug in it that removes blank lines. I found this one that seems to work: http://beta.phpformatter.com/ I'd rather have one I can run on the command line, but this will have to do. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code formatter
replies inline... On Wed, Feb 2, 2011 at 3:23 PM, Hansen, Mike mike.han...@atmel.com wrote: -Original Message- From: ken.gu...@gmail.com [mailto:ken.gu...@gmail.com] On Behalf Of Ken Guest Sent: Monday, January 31, 2011 3:26 PM To: Hansen, Mike Cc: php-general@lists.php.net Subject: Re: [PHP] Code formatter On Mon, Jan 31, 2011 at 8:27 PM, Hansen, Mike mike.han...@atmel.com wrote: I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Have you found http://pear.php.net/package/PHP_Beautifier yet? ;) http://www.php.net/unsub.php Ken It mostly works ok. Unfortunately, there's a bug in it that removes blank lines. I found this one that seems to work: http://beta.phpformatter.com/ I'd rather have one I can run on the command line, but this will have to do. Just spotted that bug is reported at http://pear.php.net/package/PHP_Beautifier/bugs - it's a shame it's been logged since 2007 or so with no sign of it getting fixed. :( -- http://blogs.linux.ie/kenguest/
[PHP] Code formatter
I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code formatter
On Mon, Jan 31, 2011 at 8:27 PM, Hansen, Mike mike.han...@atmel.com wrote: I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Have you found http://pear.php.net/package/PHP_Beautifier yet? ;)http://www.php.net/unsub.php Ken -- http://blogs.linux.ie/kenguest/
Re: [PHP] code quest - ECHO?!?
Kirk Bailey wrote: Ok, so what is echo, and how is it different from print. The code in code quest used echo. I have a copy of learning php 5.0 from O'Reilly, and noplace does it mention echo. Why? What's the difference? IS there a difference? Is there an advantage to either? Please clarify for this newbie. The documentation says it all better than I can: http://php.net/manual/en/function.echo.php http://php.net/manual/en/function.print.php Cheers -- David Robley OPERATOR! Trace this call and tell me where I am. Today is Sweetmorn, the 54th day of The Aftermath in the YOLD 3176. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest - ECHO?!?
Groovy; they appear to be identical in all but name. IDENTICAL. Or am I missing a subtle definition difference? David Robley wrote: Kirk Bailey wrote: Ok, so what is echo, and how is it different from print. The code in code quest used echo. I have a copy of learning php 5.0 from O'Reilly, and noplace does it mention echo. Why? What's the difference? IS there a difference? Is there an advantage to either? Please clarify for this newbie. The documentation says it all better than I can: http://php.net/manual/en/function.echo.php http://php.net/manual/en/function.print.php Cheers -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think
Re: [PHP] code quest - ECHO?!?
They are almost identical. Echo supports multiple parameters like echo $a, $b; print is 20% slower than echo (by some tests). echo is shorter than print so it's easy to write. In fact it's all a matter of taste. The same reason we user die instead of exit. Alex On Sun, Dec 12, 2010 at 6:23 PM, Kirk Bailey kbai...@howlermonkey.netwrote: Groovy; they appear to be identical in all but name. IDENTICAL. Or am I missing a subtle definition difference? David Robley wrote: Kirk Bailey wrote: Ok, so what is echo, and how is it different from print. The code in code quest used echo. I have a copy of learning php 5.0 from O'Reilly, and noplace does it mention echo. Why? What's the difference? IS there a difference? Is there an advantage to either? Please clarify for this newbie. The documentation says it all better than I can: http://php.net/manual/en/function.echo.php http://php.net/manual/en/function.print.php Cheers -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht+-+ | BOX | +-+think
Re: [PHP] code quest - ECHO?!?
And the obvious difference, print returns true on success. I'm not sure what would cause an echo it print to ever fail, so it really doesn't make a huge difference. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Alexandru Patranescu dreal...@gmail.com Date: Sun, Dec 12, 2010 18:56 Subject: [PHP] code quest - ECHO?!? To: Kirk Bailey kbai...@howlermonkey.net Cc: php-general@lists.php.net They are almost identical. Echo supports multiple parameters like echo $a, $b; print is 20% slower than echo (by some tests). echo is shorter than print so it's easy to write. In fact it's all a matter of taste. The same reason we user die instead of exit. Alex On Sun, Dec 12, 2010 at 6:23 PM, Kirk Bailey kbai...@howlermonkey.netwrote: Groovy; they appear to be identical in all but name. IDENTICAL. Or am I missing a subtle definition difference? David Robley wrote: Kirk Bailey wrote: Ok, so what is echo, and how is it different from print. The code in code quest used echo. I have a copy of learning php 5.0 from O'Reilly, and noplace does it mention echo. Why? What's the difference? IS there a difference? Is there an advantage to either? Please clarify for this newbie. The documentation says it all better than I can: http://php.net/manual/en/function.echo.php http://php.net/manual/en/function.print.php Cheers -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht+-+ | BOX | +-+think
Re: [PHP] code quest - ECHO?!?
Ok, so what is echo, and how is it different from print. The code in code quest used echo. I have a copy of learning php 5.0 from O'Reilly, and noplace does it mention echo. Why? What's the difference? IS there a difference? Is there an advantage to either? Please clarify for this newbie. -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
OK, now here's a giggle; I like ssi includes. If I put the script in as an ssi include, will it still work? The functionality would also be useful on a page besides the default landing page, such as a 404error.html page, or a thank you page. -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
A good point, but in this application there WILL be AT LEAST 1 legitimate directory at all times, or else the script would not be used, so this ought not be a problem. My problem is that I understand the basic functions to implement, but have not yet aquired sufficient command of php to implement the required multi step algorithm. Jim Lucas wrote: On 11/26/2010 4:03 PM, Kirk Bailey wrote: Hello all, my name is Kirk Bailey, and I am new to php, so please be forbearing. I code in python, and am trying to learn this language as our new client runs a web business based in it. I need a routine that will return a list of every directory immediately under the current directory- but nothing else, just a list of directories, 1 level deep, NO FILES, no listing of current dir or prior dir either. Now in python, I would use os.walk, and use the list of dirs and throw the other 2 lists away, but this ain't Kansas anymore. Does php even DO lists? Um, a list is a 1 dimenional array, if have a list ALIST and you plug in 3, you get back the contents of cell 3 in the list, whaqtever that content is. so if cell 3 in a 6 celled list was Ruby then ALIST[3] would return the string ruby. It's easy to iterate lists. For instance: print 'ul' for dir in ALIST: print 'lia href=\/dir,dir,'/a print '/ul This would let me produce an ordered list of directories, each a link to that directory. This way, when a client installs a new product, the home page area listing products offered automatically updates. Further embellishment would let me replace the dir name with a BRIEF description from a descriptor file read from that dir. Now how to do this in php? This should do. The only problem that I foresee would be an empty ul/ul if you have no directories returned by glob(). print('ul'); foreach ( glob('./*', GLOB_ONLYDIR) AS $dir ) print('lia href=\'.$dir.'\'.$dir.'/a/li'); print('/ul'); Jim Lucas -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think
Re: [PHP] code quest
Now Now, fight nice. We don need no stinkin' @$^*$^(! woids here. :-P Steve Staples wrote: On Thu, 2010-12-02 at 10:07 -0500, Daniel P. Brown wrote: On Wed, Dec 1, 2010 at 23:13, Kirk Bailey kbai...@howlermonkey.net wrote: [snip!] Can this be improved to exclude anything with a '.' or a '-' in it's name? This will exclude the smileys and cgi-bin and such. If it can be persuaded to read a 1 line description from each subdirectory it could then use THAT as the text in the link, instead of the name. This could be useful in many settings. Sure. Change: if (is_dir($d) $d != '.' $d != '..') { To: if (is_dir($d) !preg_match('/[\.\-]/',$d)) { Keep in mind, though, that the change will no longer show anything that matches the below either: example.directory example-directory special-images css.files In other words, you may instead want to explicitly state which directories to omit, and then drop anything that begins with a dot as well (hidden directories on *NIX-like boxes) like so: ?php $excludes[] = 'cgi-bin'; $excludes[] = 'vti_cnf'; $excludes[] = 'private'; $excludes[] = 'thumbnail'; $ls = scandir(dirname(__FILE__)); foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'lia href='.$d.''.$d.'/abr/'.PHP_EOL; } } ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ damn you Daniel... I was just about to reply with almost the EXACT same answer!!! I think the last example would probably be the best one to use, that way you can still have some directories with the . or - or even the _ in the names, and still be able to display them. Steve ps thanks for saving me type it all out Daniel :) -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think
Re: [PHP] code quest
my current code is as follows: *ul ?php # The next several lines declare an array of directories which are NOT to be listed! $excludes[] = 'images'; $excludes[] = 'cgi-bin'; $excludes[] = 'vti_cnf'; $excludes[] = 'private'; $excludes[] = 'thumbnail'; $ls = scandir(dirname(__FILE__)); foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'lia href='.$d.''.$d.'/abr/'.PHP_EOL; } } ? /ul* The page containing this is at this url: http://www.howlermonkey.net/dirlisting.php I believe this will be a starting point for the functionality I am looking for- an automatic menu of areas in a website one may go to. By excluding some folders, people don't go trespassing into the cgi-bin or images folder, or into areas reserved for administrative uses. Daniel P. Brown wrote: On Wed, Dec 1, 2010 at 23:13, Kirk Bailey kbai...@howlermonkey.net wrote: [snip!] Can this be improved to exclude anything with a '.' or a '-' in it's name? This will exclude the smileys and cgi-bin and such. If it can be persuaded to read a 1 line description from each subdirectory it could then use THAT as the text in the link, instead of the name. This could be useful in many settings. Sure. Change: if (is_dir($d) $d != '.' $d != '..') { To: if (is_dir($d) !preg_match('/[\.\-]/',$d)) { Keep in mind, though, that the change will no longer show anything that matches the below either: example.directory example-directory special-images css.files In other words, you may instead want to explicitly state which directories to omit, and then drop anything that begins with a dot as well (hidden directories on *NIX-like boxes) like so: ?php $excludes[] = 'cgi-bin'; $excludes[] = 'vti_cnf'; $excludes[] = 'private'; $excludes[] = 'thumbnail'; $ls = scandir(dirname(__FILE__)); foreach ($ls as $d) { if (is_dir($d) !preg_match('/^\./',basename($d)) !in_array(basename($d),$excludes)) { echo 'lia href='.$d.''.$d.'/abr/'.PHP_EOL; } } ? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think
Re: [PHP] code quest
From: Kirk Bailey kbai...@howlermonkey.net OK, now here's a giggle; I like ssi includes. If I put the script in as an ssi include, will it still work? If you're using Apache, and you do !--#include virtual=something.php -- ...the PHP in something.php will execute and produce output, but something.php will not have any access to $_GET or $_POST or $_SESSION or any of those things. This is generally not what you want. If you do ?php include(something.php); ? ...then something.php will be able to see and work with the superglobals that have been set up further up the page, which is *usually* what you want. You could try both approaches in a test env and see what you get. I'll use SSI for dumb blocks of text and php include for smart blocks of code, because IME that tends to produce fewer instances of gross stupidity. Note that YMMV on all this and ICBW. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php