[PHP] hide multiple recipients
Hi I'm new (to the list and php) - be gentle on me! I'm working on a script that will allow a client to send an email message to an email list that is pulled out of a database(mysql). I've got the script working sort of..., though it needs more work. Essentially, I pull the e-mails out of a database, put them all into one string, and then stick that string into the "to" field using php's mail() function. In the e-mail the recipient gets, all of the e-mail addresses are viewable in the "to:" field. Is there some way to hide those e-mail addresses? Many thanks in advance Jimbo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] variables from perl cgi into a php
Hi I wonder if any one can help with this problem. I have a script working really well (not my scripting but my script) written in perl /cgi. I would like to write some simple scripts using the variables and data from the cgi script. Is there a way that I can extract the variables in the cgi script to run in a php script. Sorry if this sounds very confussing I am! Many thanks in advance for your help. James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables from perl cgi into a php
Thanks for your reply John... To embelish a bit... I have a multiuser web based image managment application (the Perl script) and I want to add some accounting scripts (to be written in php). The guy that wrote the perl script is unavailable to work it in the perl script due to time constraints - so I was wondering if I can pass the variables - such as invoice amounts, the username (from the cookie) the image numbers that the invoice numbers relate to from the cgi into the perl script then into a mysql database. Any more help.Will virtual() do this sort of thing? TIA James >From: "mailing" <[EMAIL PROTECTED]> >> I wonder if any one can help with this problem. >> I have a script working really well (not my scripting but my script) >written in perl /cgi. >> I would like to write some simple scripts using the variables and data >from the cgi script. >> Is there a way that I can extract the variables in the cgi script to run >in a php script. > >Not sure if I follow what you're wanting to do, but you can use virtual() >inside of a PHP script to run a Perl script... > >---John Holmes... > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] looking for php programmers in mumbai / bombay
we are looking for experienced php programemers in mumbai or bombay. full time or freelance... please contact at [EMAIL PROTECTED] sumeet shroff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looking for php programmers in mumbai / bombay
Derek Williams wrote: not quite PC, but why do you need to be in mumbai or bombay, is the client located there? mailing wrote: we are looking for experienced php programemers in mumbai or bombay. full time or freelance... please contact at [EMAIL PROTECTED] sumeet shroff yes..i am the clienti would prefer a local person. sumeet shroff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_id database
I am new to PHP so please excuse my ignorance. I want to manage and create session id's for my shopping cart with a MySQL database. I have a database with a session_id column that is auto-increminting. Is there any example of anyone using a mysql database to manage session_id's? Regards, Adrian Mcmanus IT Director The B&F System, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowlegde Base
> greetings > i'm looking for good/free Knowledge Base/ FAQ system > any recommendation ? > For a simple easy to use and free Knowledge Base/FAQ system I've used ODFaq and have been quite happy with it. http://www.oodie.com/project/odfaq/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IRC from PHP - help
hello i'm a newcomer to this list, fairly experienced PHP programmer but coding mostly for personal web sites or hobbies. I also run an irc chat network and am curious as to if I can integrate php into it somehow. for example: I want to have a webpage that can present a list of all connected users to my irc network, or maybe a webpage to facilitate nickname registration/activation. my idea is to somehow connect a randomly-nicknamed client to the server like "PHP-19942333" or something, which would execute the commands. I fully understand the irc protocol and have written a working irc client in VB. i don't have experience enough to know if PHP has some sort of "event" mechanism, for example, to be like on ircNamesList($names) { echo $names['1']; } or something. (pseudo-code) does anyone have an idea as to how this stuff could be done? Here's a sort of pseudo-code of what I'd want, PHP-style but obviously most of the functions are fake. // Begin pseudo-code. echo "Activating nickname..."; $php_nickname = "PHPInterface" // or have it generate a random number irc_connect(192.168.1.1,6667,$php_nickname) $nick_command = "REGISTER $_GET['nick'] $_GET['email'] $_GET['pass']"; irc_send_privmsg("NickServ",$nick_command); // some way to hold processing until the response is received... wait_for_response(); // or maybe a while loop, like while $success = "false"... // after response, die exit("Finished"); // parse response on event irc_privmsg($nick,$msg) { if ($nick == "NickServ") { if ($msg == "Your nickname has been successfully registered.") { echo "Registration succeeded!"; } elseif ($msg == "Invalid syntax") { echo "Error."; } irc_quit("PHP Script finished."); } ?> obviously I'd also have to dress that page up a lot more, adding HTML code and such. This would also need a lot of error-trapping. Like if IRC couldn't connect for whatever reason, or if NickServ wasn't available, or who knows what. Well that's basically what I'm after. IDEAS??.. Flint -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Create Your Own Script Directory
For any of you interested, I've created a set of scripts that let you run your own PHP Scripts Directory, like the /PHP/Scripts_and_Programs/ directory of HotScripts for example. I originally made this for my own site, but I decided to release it to the public instead =) It has all the usual features a site like this should have, which can be found on the page below, and also has a precompiled database of 3,375 scripts which can optionally be inserted. http://www.nukedweb.com/phpscripts/phpscriptindex.php If you do decide to set this script up, and plan to keep it running, let me know! I'd like to keep tabs on who's actively using the script. I'll be creating another script that lets people submit the scripts they've written to all the sites from one page. But don't email me here, I can't find replies to my messages here ;) Just use the Contact link on my site. ~ Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Free MySQL Hosting...again
I had a little trouble with my cable modem before, but the Free MySQL Hosting is back up if any of you are interested. =) http://mysql.nukedweb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can you guys do me a favor?
I just started a service on my website, for free TopSite Hosting. It's had great exposure from Hotscripts.com, in fact, my "Remote-Hosted Search EWngine" service has taken off quite well. The only problem here is that people just don't seem to take to it too well. I haven't had one person sign up, and I don't know why! Not many people contact a website with bug issues, and I think that's what I need here! Anyways, the favor I'm asking, if you're even slightly interested in this idea, to create your own TopSite, set it up on your site, and email me with any bugs, comments and suggestions. If running your own TopSite isn't your cup o' tea, then you can join the TopSite I've already created, for PHP sites (the URLs for all of these are below). I could also use the help so I can create an administration panel for TopSite owners, to edit/remove TopSites, and check if their code is on their page. I haven't been able to create this feature since no one's signed up yet ;) Also email me with bugs/comments/suggestions if you help me this way too! I'll greatly appreciate all of it. :) Create a TopSite: http://www.nukedweb.com/topsites/ Top 10 PHP Sites: http://www.nukedweb.com/topsites/topsites.php?ts=php Please don't reply to this email! I'll never be able to find it ;) Use the Contact link on the menu on the website. :) Also, if you're interested (here comes the shameless plug), if you'd be interested in selling my PHP scripts on your website and making a little extra money, check out: http://www.nukedweb.com/phpscripts/affiliates.php Many thanks in advance! ~ Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multple Form Values with Same Name
I'm working on converting a pre-existing website for a company, from something called Lasso, into PHP. This domain name registration site uses the same form value, "$Suffix" as the checkbox values for all the TLDs they offer. I was originally under the impression PHP would put them all into an array, $Suffix[0] $Suffix[1] etc... I assumed it, but never tried it cuz I didnt need to till now. Is this the way it's suppose to be, or is it returned another way? Right now, $Suffix returns the value of only one of the checkboxes (the last one in the queries list I assume). ~Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Free MySQL Hosting :)
As a project I'm working on that will later manifest into something more, I'm offering free MySQL hosting on one of my servers. Just enter the desired username and password, and 3 databases will be created for you to use from your PHP scripts. The info you'll need to connect to the MySQL server will be provided. Don't expect some grand website when you click the URL, it's just a simple page I put up that does nothing but create the databases. :) http://64.53.137.236:82/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New Site to submit your scripts to..
I've recently finished creating a Script Index (almost identical to HotScripts) for people to submit their PHP (and Perl) scripts. The database right now is over 7,000 (both PHP and Perl), but only because I've collected the data from other sites. If you have a script, I ask of you to submit it here. :) Think of it as one more place to have your script noticed, and rank one notch higher in the search engines, as well as helping out another script index site. :) PHP Scripts: http://www.nukedweb.com/php/ Perl Scripts: http://www.nukedweb.com/perl/ You can submit scripts by browsing to the correct category and clicking the Add a Script link at the top. Indexes are recompiled a few times a day. :) Also, if you have a website directed at other webmasters, feel free to submit it to the Website Resources Index at http://www.nukedweb.com/webresources/ :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php query for mysql table
select * from yourtable where question like '%life%' -- Original Message -- From: "Wolfgang Schneider" <[EMAIL PROTECTED]> Reply-To: "Wolfgang Schneider" <[EMAIL PROTECTED]> Date: Mon, 20 Aug 2001 12:22:15 +0200 >Hi > >I am a newbie to php + mysql and wanted to ask for some help on a >particular item which I can't seem to find "the right key" in the >documentation. I am trying to set up a simple Q&A system with an entry >page where one can select to either have all questions & answers from a >mysql database displayed or else search with a text field for only >those questions which contain a certain word(s). > >Can someone tell me how to set in a query when trying to find records >in a mysql table that have a certain word or perhaps 2 or 3 words >(among others) ...? > > I know about using SELECT and WHERE in order to find records which >match *exactly*, but am looking for something a bit different ... > >Example: >The values of 3 records for the "question" field of the database might >be the following: > >[1] How do you deal with anger? >[2] Ever been full of anger in your life? >[3] Is life always easy? > >How can I set a PHP query with SELECT and WHERE to express the >following: > >Which questions contain the word "life"? That is, have someone search >the database in the "question" field for records where the word "life" >is used as part of the question ... The result then should return the >records 2 & 3 above > >Any help is greatly appreciated. Thanks mucho. >God bless you with His grace and peace >Wolfgang > >Looking for Biblical information? COME AND SEE! >-- ONLINE Courses: http://classes.bibelcenter.de ... NEW! >-- BibelCenter: http://www.bibelcenter.de >-- Bookstore: http://www.worthy.net/BibelCenter/ > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] confusing problem w/sessions
start your session before sending any html output to browser check that register_globals is on if not use $HTTP_SESSION_VARS("a") instead to reference your session var assign a value after having initialiazed your var not before -- Original Message -- From: "Gabriele Biondo" <[EMAIL PROTECTED]> Date: Mon, 20 Aug 2001 14:34:35 +0200 >Dear sirs; >i have a simple snippet of code : >session_start(); >$a = 10; >session_register("a"); >?> > >i am trying to understand how do session work. > >Accessing at this document directly from the server (it is a SuSE 7.2 PE - >running PHP 4.0.4 >and apache 1.3.9) i find out the following problem: > >Warning: cannot send session cookie - headers already sent (output started >at ) > >and > >Warning: cannot send session cache limiter - headers already sent (output >started at ) > >The matter is that if i access this variables from another page, they seem >to be empty... > >How can i solve this little confusing problem? > >Thanks in advance > >Gabriele > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] tempnam() not working as expected...
Can someone explain the following to me: /Users/tamara/Sites/gallery/lib/common/t/dirGuWOLW is a directory /private/var/folders/pI/pIx-p0mhH5eEQ64yAiDQmE+++TI/-Tmp-/fileC7Rnzg is a directory Why isn't the second tempnam using the directory path I pass to it? The strange thing I notice is that if I pass in a directory path to tempnam that was NOT created initially by tempnam, it works: miishka:t tamara$ mkdir a miishka:t tamara$ php -r 'echo tempnam("/Users/tamara/Sites/gallery/lib/common/t/a","file").PHP_EOL;' /Users/tamara/Sites/gallery/lib/common/t/a/filepSwRzF miishka:t tamara$ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] case-insensitive $_REQUEST,$_GET,$_POST keys?
On Fri, Apr 13, 2012 at 12:22 PM, David OBrien wrote: > On Fri, Apr 13, 2012 at 1:13 PM, tamouse mailing lists > wrote: >> >> Anyone have a quick-and-dirty way to check $_REQUEST keys that is >> case-insensitive? >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > this what you asking? > > foreach ( $_REQUEST as $key => $value ) { > if ( strtolower($key) in array('name','username','password')) $data[ > strtolower($key) ] = $value; > } That would do it! Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tempnam() not working as expected...
On Mon, Apr 16, 2012 at 3:09 AM, ma...@behnke.biz wrote: >> mkdir($d,777,true); /* make the directory */ > Try using "mkdir($d, 0777, true);" Herein, my friends, lies the problem. Silly me, using a DECIMAL number (777) instead of an OCTAL number (0777). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sms class
On Tue, Apr 17, 2012 at 2:08 PM, DZvonko Nikolov wrote: > I need a class that sends sms messages to list of numbers. > I'm quite new to that issue, so I need to know what I need > more. Thanks in advance. If this is very low volume, would using email->sms work? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Email Antispam
On Wed, Apr 18, 2012 at 8:47 PM, Ross McKay wrote: > On Wed, 18 Apr 2012 11:08:00 -0400, Jim Giner wrote: > >>He literally wants the "addresses" visible on the sight? [...] > > Yes, they want the addresses visible and clickable on the website. They > have contact forms, but they also want the email addresses (of their > scientists and other consultants) available to their clients. And they > want the addresses to be shielded against harvesting for spam. Ob/Deobfuscation schemes that use javascript are a partial solution. Many spam harvesters are smart enough these days to know enough about decoding email addresses even obfuscated with javascript, with or without the mailto: scheme. Any that do obfuscation by substituting html entities for the characters are quite easily cracked. (Just appearance of a string of html entities is often enough to indicate there is something there to decode.) There is no 100% solution here. Coming up with clever ways to obfuscate the address on download, and deobfuscate it afterwards to display to the user will work for a while, however, the people writing spam harvesters are just as clever as we are. If the application is going to end up with email addresses displayed on the screen, some spam harvester is going to be able to get them. Even if you come up with a method that will stop them now, it won't stop them forever. > As I said, I don't like doing it this way, but the client gets what they > want after the options have been explained to them. They need to understand the options, but even more important, the risks of any solution, and of the concept as a whole. After you've presented the risks, and the lack of a 100% solution, if they still want to do something against their own policies, you have to decide if your liability in giving it to them is going to be a problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] sms class
> -- Forwarded message -- > From: DZvonko Nikolov > Date: Thu, Apr 19, 2012 at 5:10 AM > Subject: Re: [PHP] sms class > To: tamouse mailing lists > > > if this is simple, yes. > > > --- > Regards > > DZvonko Nikolov > > > dzvo...@gmail.com > dzvo...@yahoo.com > --- > The best things are simple, > but finding these simple things is not simple. > > > Simplicity carried to the extreme becomes elegance. > ------- > > > From: tamouse mailing lists > To: DZvonko Nikolov > Cc: "php-general@lists.php.net" > Sent: Thursday, April 19, 2012 7:19 AM > Subject: Re: [PHP] sms class > > On Tue, Apr 17, 2012 at 2:08 PM, DZvonko Nikolov wrote: > > I need a class that sends sms messages to list of numbers. > > I'm quite new to that issue, so I need to know what I need > > more. Thanks in advance. > > If this is very low volume, would using email->sms work? > > (Remember to 1: post back to the list, 2: reply at the bottom) Look here: https://en.wikipedia.org/wiki/List_of_SMS_gateways Mailing stuff from php is also dead easy: http://us2.php.net/manual/en/book.mail.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Maybe this will make the syntax errors stand out more: http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On Thu, Apr 19, 2012 at 2:17 PM, Steven Staples wrote: >> -Original Message- >> From: Silvio Siefke [mailto:siefke_lis...@web.de] >> Sent: April 19, 2012 3:11 PM >> To: php-general@lists.php.net >> Subject: Re: [PHP] SqLite INSERT want not write >> >> On Thu, 19 Apr 2012 14:57:04 -0400 >> "Steven Staples" wrote: >> >> > I think all you had to do was change this line: (line 27 in the >> > original >> > paste) >> > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) >> > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, >> > :teaser, :content);'; >> > >> > To this: >> > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, >> > :teaser, :content);"; >> >> Thats end with: >> PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error >> >> I has changed what say Stuart, no Sytax errors but in the database nothing >> will write. >> >> Regards >> Silvio >> > > Ok, so I was wrong... ;) it does happen > > Try this: > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, > :teaser, :content);"; > > Or > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES (NOW(), :autor, :title, :teaser, :content);"; > > > The first example, you don't need the time(), and you had the date format > wrong... > The second example, uses the NOW() time, which is the timestamp for sql > > Maybe this time I will get it right ;) -- its been a long day, and it is > only 1/2 done > > Steve > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > For sqlite, you can specify the current datetime with just "now". So perhaps the insert statement could be simplified to: $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES(now, :autor, :title, :teaser, :content);"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] School timetable in php
On Sun, Apr 22, 2012 at 1:41 AM, Vinay Kannan wrote: > Weekly subject wise lecture schedule, subject wise / faculty wise. > > > On Sun, Apr 22, 2012 at 12:02 PM, tamouse mailing lists > wrote: >> >> On Fri, Apr 20, 2012 at 7:00 AM, Vinay Kannan wrote: >> > I am trying to develop a school time table system in php mysql, anybody >> > has >> > any headsup on the same, i was thinking about some existing scripts to >> > take >> > a look at. >> >> Not entirely clear what is meant by "time table" -- do you mean >> schedule of classes? Important dates in the school year? or...? >> >> Also, what is it you want to be able to do with this? Who will be >> using this? There are many different approaches one can take, >> depending on what needs to happen. Hard to know what to suggest >> without a little more info? > > I modified an application that was originally set up for scheduling conference rooms, my version was to schedule appointments at a convention. You can grab it at https://github.com/tamouse/cdmacal . It is probably *way* more complex than you need, but it might give some ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running through an enormous SQL file
On Fri, May 4, 2012 at 6:36 PM, Brian Dunning wrote: > I have a script that downloads a 267MB SQL file (it creates and loads a MySQL > database). Any idea how to do this? Obviously I'm not going to get a file > that size into memory to loop through. Is there any need to use PHP with this at all? If it's already in SQL, can't you just feed it to mysql? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculating driving distance between UK postcodes
On Fri, May 4, 2012 at 9:18 AM, Terry Ally (Gmail) wrote: > Google works in Javascript extensively - not a language with which I > have in-depth experience hence my reason for asking for PHP solution. > > For example the following will get me a JSON output with the distance in > Kms and time. I don't know how to get PHP to read this information and > extract just the distance. I need the distance so that I can calculate cost > of a trip. > > http://maps.googleapis.com/maps/api/distancematrix/json"; method="get"> > > > > > onClick="document.getElementById('google').submit()">Get > Distance > Using Google Maps API is pretty straight-forward. You don't need to set up a form or a use a POST to get the info. This page should describes how to use a standard GET query to get the info you want: < https://developers.google.com/maps/documentation/distancematrix/ > Setting up the proper URL to call, you can activate it using file_get_contents provided you have allow_url_fopen set to true in php.ini. (Do make sure to check for possible errors returned.) You can get the response back as either JSON or XML, both of which PHP can parse into useful data structures: < http://us.php.net/manual/en/function.json-decode.php > < http://us.php.net/manual/en/book.simplexml.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott wrote: > I need to access a FUNCTION I programmed within a different FUNCTION. Are > these able to be passed like a variable? Or are they able to become like a > $_SESSION variable in nature? How am I able to do this? > > I am essentially programming: > > === > function name( $flag1, $flag2 ) { > > # some PHP > > echo name_of_a_different_function( $flag1 , $flag2 ); > > } > === > > The error I am receiving is “Call to undefined function > name_of_a_different_function” Where is name_of_a_different_function defined? If it is somewhere in the same file as name, that shouldn't be a problem, provided it is defined in the same namespace/scope as name. If it is defined in a different file, you need to include that file before you make the echo statement. For example: function func1 ($flag1, $flag2) { # blah blah echo func2($flag1, $flag2); } function func2 ($flag1, $flag2) { #blah blah return "some string value"; } in the same file should be just fine. It doesn't really matter what order func1 and func2 are declared in. However, if func2 is defined in some_other_file.php, you need to include it in this_file.php (where func1 is defined) first: this_file.php: include('some_other_file.php'); function func1 ($flag1, $flag2) { #blah blah echo func2 ($flag1, $flag2); } some_other_file.php: function func2 ($flag1, $flag2) { #blah blah return "some string value"; } If func2 is a method for an object/class, you'll have to access it that way in func1: this_file.php: include('MyClass.php'); function func1 ($flag1, $flag2) { # blah blah, instantiate object? $myobj = new MyClass(); echo $myobj->func2 ($flag1, $flag2); } MyClass.php: class MyClass { function func2 ($flag1, $flag2) { #blah blah return "some string value"; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Emacs
On Fri, May 4, 2012 at 7:43 AM, Gerardo Benitez wrote: > Hi Mihamina, > > I think that a few number of people use Emacs to write Php, in fact for > proffesionals porpuse the people use a IDE for Php, like Netbeams, Eclipse > PDT or Zend Studio. > > Regards, > Gerardo > > On Wed, May 2, 2012 at 8:21 AM, Mihamina Rakotomandimby > wrote: > >> Hi all, >> >> For curiosity, are there people here using Emacs to code in PHP? >> What modes do you add? cedet, ecb,... >> >> I see (just for the example) that Drupal has a short documentation page >> for Emacs http://drupal.org/node/59868 >> >> Have you got some in your bookmarks for general PHP coding? >> >> -- >> RMA. >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > -- > Gerardo Benitez > - > Programador Web Freelance I use Emacs for editing practically everything. I use a [php-mode.el](http://php-mode.sourceforge.net/) that is derived from cc-mode, and works pretty well (except for one annoyance in that it doesn't recognize octothorpes (#) for comment beginners :P). [Multiple Major Modes](http://emacswiki.org/emacs/MultipleModes) is also pretty helpful so you can edit files that mix PHP, HTML, JS, and CSS (which is NOT a best practice, but sometimes necessary). The [Emacs Wiki](http://emacswiki.org) seems to be the best place for finding things in general, but is still not really as good as just doing a google/bing/ddg search on what you're looking for. *Lots* of people write about emacs, and there are generous tidbits all over. Another thing I use heavily are snippets. The best package I've found for this is the (Yet Another Snippets mode)[https://github.com/capitaomorte/yasnippet] which speeds up development quite a bit. I have a (very limited) info page on Emacs on my wiki: http://wiki.tamaratemple.com/Technology/Emacs (this is not advertising; my server is small and won't handle a huge number of hits; please don't /. it!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieve pages from an ASP driven site
On Wed, May 2, 2012 at 11:37 PM, EPA WC wrote: > Hi List, > > I am trying to write a crawler to go through web pages at > http://www.freebookspot.es/CompactDefault.aspx?Keyword=. But I am not > quite familiar with how asp uses _doPostBack function with the "next" > button below the book list to advance to the next page. I hope someone > who knows ASP well can help out here. I need to know how to retrieve > next page with PHP code. > > Kind regards, > Tom Looking at that page source, I think this might be a bit problematic. Notice that practically the whole page is inside a form. When you get down to the "Next> " button, that is going to sumbmit the form with it's appropriate fields set. If you look at the beginning of the form, you'll see some interesting fields, one in particular, __VIEWSTATE is pretty clearly an encoded value of some sort. When your crawler parses the page, it will have to stash the field values that the form sets in order to process the form correctly to get the next page of entries by simulating a POST-data submit. This is (probably?) most easily handled via libcurl. Unsolicited advice: Many sites do not appreciate scraping activity; make sure your crawler obeys robots.txt rules, and do not overtax the site with crawler activity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get content rss feed
On Wed, May 2, 2012 at 7:00 AM, Doeke Wartena wrote: > I try to get the content from the following rss feed > http://www.adafruit.com/blog/feed/ > > I want to store it in a database in order to use it for a school assignment. > If i look in my browser to the feed then i see content and description, > however if i try to get them with php then description is this: > > [description] => SimpleXMLElement Object > ( > ) > > > and content is gone. > > > -- > $db = dbConnect(); > > $xml = getFileContents("http://www.adafruit.com/blog/feed/";); > $xmlTree = new SimpleXMLElement($xml); > > for($i = count($xmlTree->channel->item)-1; $i >= 0; $i--) { > $item = $xmlTree->channel->item[$i]; > echo ""; > print_r($item); > echo ""; > } > > dbClose($db); > > ?> > -- > > this is 1 part of the print_r: > > SimpleXMLElement Object > ( > [title] => Birth of the ARM: Acorn Archimedes Promo from 1987 > [link] => > http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/ > [comments] => > http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/#comments > [pubDate] => Sat, 28 Apr 2012 04:01:35 + > [category] => Array > ( > [0] => SimpleXMLElement Object > ( > ) > > [1] => SimpleXMLElement Object > ( > ) > > ) > > [guid] => http://www.adafruit.com/blog/?p=30498 > [description] => SimpleXMLElement Object > ( > ) > > ) > > I guess content is gone cause it's like this: > > > > And description is gone cause it's like this: > >
Re: [PHP] Running through an enormous SQL file
Please put replies at BOTTOM On Fri, May 4, 2012 at 9:24 PM, Brian Dunning wrote: > How would you launch that from PHP? > > On May 4, 2012, at 6:11 PM, tamouse mailing lists wrote: > >> Is there any need to use PHP with this at all? If it's already in SQL, >> can't you just feed it to mysql? It's a standard command you would launch via [exec or shell_exec](http://us.php.net/manual/en/book.exec.php) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function
On Fri, May 4, 2012 at 9:18 PM, Jim Giner wrote: > But the OP says "function is defined inside a different function". Your > theories to a solution don't fit that problem. [snip] > But the OP says "function is defined inside a different function". Your > theories to a solution don't fit that problem. > > (Sorry you all had to read thru so much stuff just to get to my one-line > response.) There's no need to include something if it turns out to be irrelevant. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott wrote: > I need to access a FUNCTION I programmed within a different FUNCTION. Are > these able to be passed like a variable? Or are they able to become like a > $_SESSION variable in nature? How am I able to do this? > > I am essentially programming: > > === > function name( $flag1, $flag2 ) { > > # some PHP > > echo name_of_a_different_function( $flag1 , $flag2 ); > > } > === > > The error I am receiving is “Call to undefined function > name_of_a_different_function” Thanks to Jim, I understand a bit more, however, I still do not see where name_of_a_different_function is being defined. Rather than suppose something, please post the function where name_of_a_different_function is defined. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code deployment through php
On Wed, May 2, 2012 at 5:23 AM, rene7705 wrote: > On Wed, May 2, 2012 at 11:47 AM, 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. >> >> >> > 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 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] Best practice question regarding set_include_path()
On Thu, May 10, 2012 at 1:50 PM, admin wrote: > > > -Original Message- > From: Al [mailto:n...@ridersite.org] > Sent: Thursday, May 10, 2012 11:44 AM > To: php-general@lists.php.net > Subject: [PHP] Best practice question regarding set_include_path() > > For my applications, I've been using includes and other file addressing by > using the doc root as the base dir. e.g. > require_once $_SERVER['DOCUMENT_ROOT'] . > '/miniRegDB/includes/miniRegDBconfig.php'; > > Recently, I ran into a problem with a new installation on a shared host > where the doc root was assigned in an unusual manner. I rather not require > setting a custom base dir [instead of $_SERVER['DOCUMENT_ROOT']'] for my > applications. > > So, I was wondering if it would be good practice to use the > set_include_path() and add the base dir for my applications. I've used this > for dealing with Pear function files on shared servers and had no problems. > > Need some guidance regarding this subject. > > Thanks > > -- > > I use define to set the application path > define('BASE_PATH','C:\\inetpub\\vhosts\\yourwebsite.com\\httpdocs\\'); > > Example: > require_once (BASE_PATH. '/miniRegDB/includes/miniRegDBconfig.php'); > > > works great for JQuery paths > > > $(document).ready(function() { > $('#dareport').html('<img src="<?php echo BASE_URL;?>images/loading.gif" > />'); > }); > > > To me it is much better than set_include_path() but works in the same > premise > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I tend to use a slightly more portable version: define('APP_ROOT',dirname(__FILE__)); in a configuration file. (If the configuration file happens to be at a different depth than the main application file(s), I stack on more dirname's to get back to the application root.) Similarly, I usually need an application URL path. This can be trickier, depending on how you structure your application. This generally works for the applications I develop: define('APP_URL_BASE','http://'.$_SERVER['HOST_NAME'].dirname($_SERVER['SCRIPT_NAME'])); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting date string to unix timestamp
On Fri, May 11, 2012 at 8:46 PM, Karl DeSaulniers wrote: > On another note, just curious why I keep getting your responses, but don't > get the emails that I post. > Anyone else having trouble with the list like that? That is how the mailing list works. You don't see the messages you send. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
On Thu, May 17, 2012 at 3:37 PM, Jim Giner wrote: > ok - finally had to come up with my own regexp - and am failing. > > Trying to validate an input of a time value in the format hh:mm, wherein > I'll accept anything like the following: > hmm > hhmm > h:mm > hh:mm > > in a 12 hour format. My problem is my test is ok'ing an input of 1300. > > Here is my test: > > if (0 == preg_match("/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/",$t)) > return true; > else > return false; > > Can someone help me correct my regexp? If the ":" separator is inserted before the regex check, the following should suffice: '/^(0?[1-9]|1[12]):([0-5][0-9])$/' Test script: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] errors not showing
On Sat, May 19, 2012 at 11:16 PM, Tim Dunphy wrote: > Hello Simon, > > Thanks for your response. > > However I still can't seem to get errors to show up. > > [dunphy@localhost:~/jf-current] #cat /private/etc/php.ini | grep -e > error_reporting -e display_errors > ; display_errors > ; error_reporting > error_reporting = E_ALL & E_NOTICE > ;error_reporting = E_ALL & ~E_DEPRECATED > display_errors = On > ; separately from display_errors. PHP's default behavior is to suppress those > ; Eval the expression with current error_reporting(). Set to true if you want > ; error_reporting(0) around the eval(). > > [dunphy@localhost:~/jf-current] #sudo apachectl -t > Syntax OK > > [dunphy@localhost:~/jf-current] #sudo apachectl restart > > > [dunphy@localhost:~/jf-current] #uname -a > Darwin localhost 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 > 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386 > > I was wondering if there might be something else I might've missed? > > Thanks > Tim > > On Sat, May 19, 2012 at 11:57 PM, Simon J Welsh wrote: >> On 20/05/2012, at 3:55 PM, Tim Dunphy wrote: >> >>> hello, list! >>> >>> I have 'error_reporting = E_ALL' set in my php.ini file. However when >>> I run a php script that has errors in it all that happens is that the >>> page WSODs. I am running Mac OS X 10.6. Any thoughts on why errors >>> don't show up in the browser and how to correct this? >>> >>> >>> Thanks >>> Tim >> >> You also need to set display_errors to On. >> --- >> Simon Welsh >> Admin of http://simon.geek.nz/ >> > > > > -- > GPG me!! > > gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Are these syntax errors or run-time errors? The former won't display to the page at all, as they abort PHP before that point. Those written to wherever PHP is set to log errors, which might be the same as the apache error log unless you've set something specifically for it in php.ini. The best way I've found to suss out syntax errors is to "lint" the source file with php -l from the command line. On the other hand, if they are not syntax errors, then make sure you set error_reporting and display_errors (I also always set display_startup_errors as well) soon enough to catch them (and that nothing you include turns them off). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] errors not showing
On Sun, May 20, 2012 at 3:30 PM, Maciek Sokolewicz wrote: > On 20-05-2012 07:17, tamouse mailing lists wrote: >> >> Are these syntax errors or run-time errors? The former won't display >> to the page at all, as they abort PHP before that point. Those written >> to wherever PHP is set to log errors, which might be the same as the >> apache error log unless you've set something specifically for it in >> php.ini. >> >> The best way I've found to suss out syntax errors is to "lint" the >> source file with php -l from the command line. >> >> On the other hand, if they are not syntax errors, then make sure you >> set error_reporting and display_errors (I also always set >> display_startup_errors as well) soon enough to catch them (and that >> nothing you include turns them off). > > > I always find it useful to check these values not by grep'ing the php.ini > file, but by checking phpinfo() output. Just make a new file with > phpinfo(); > > in it, and run it in the browser. That will show you the values of > display_errors and error_reporting that are actually used. I have seen cases > where the php.ini file a person thought was being used was actually NOT > used, and as such changing values inside that file had no effect. > > - Tul Good point! Seems best to see what the application believes is happening. The phpinfo() will also tell you just which php.ini file(s) is(are) being read. Usual caveats about leaving such a file unprotected on a publicly accessible server and what not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] requesting comments on rajmvServiceLog (access + error logging through PHP and JS to MySQL)
On Mon, May 21, 2012 at 7:31 AM, rene7705 wrote: > On Mon, May 21, 2012 at 1:17 PM, Simon Schick > wrote: >> Specially the function rajmvServiceLog_graphs_raphael_calculateData() with a >> code of ca. 280 lines is quite long ... > > 280 lines is long?! :) In general, yes. 280 lines is long. Too long, likely. Usually it indicates you aren't designing your code in a top-down fashion, and it is a high candidate for refactoring in order to break out into reusable functions. A rule of thumb is no more than 50 lines per function, most much less. Back in the day when we didn't have nifty gui screens and an 24 line terminals (yay green on black!), if a function exceeded one printed page, it was deemed too long and marked for refactoring. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function size
On May 23, 2012 9:14 AM, "Tedd Sperling" wrote: > > Hi gang: > > On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: > > A rule of thumb is no more than 50 lines per > > function, most much less. Back in the day when we didn't have nifty > > gui screens and an 24 line terminals (yay green on black!), if a > > function exceeded one printed page, it was deemed too long and marked > > for refactoring. > > You hit upon a theory of mine -- and that is our functions grow in size up to our ability to view them in their totality. When our functions get beyond that limit, we tend to refactor and reduce. > > I know from the last several decades of programming, my functions have increased in number of lines. But, they have reached a limit that limit is generally about the number of lines I can read in half of my monitor's height. This of course, is dependent on monitor resolution, font-size, and how far I am sitting from the monitor. But I think this is a natural and physical limit that we don't normally recognize. I can cite studies that support my theory. > > It would be an interesting survey to ask programmers to review their code and provide the average number of lines in their functions AND how many lines of code their monitor's can display. In other words, look at your editor; count the number of lines your monitor can display; estimate the number of lines in your average function; and report the findings. For example, mine is about half -- my monitor can display 55 lines of code and my average function is around 25 lines. YMMV. > > Interesting, yes? > > Cheers, > > tedd > > > _ > tedd.sperl...@gmail.com > http://sperling.com > > > > > Yes, I think that is *exactly* the criterion-- not a mystery or an emergent thing, really, was a pretty expicit reasoning--being able to see/scan the entire function on one page (or now in one screenful) makes it much easier to see what happens in the function, where blocks open/close, and it forces one to break up code into logical units.
Re: [PHP] Re: Function size
On Tue, May 29, 2012 at 2:52 AM, Tony Marston wrote: > On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: >> A rule of thumb is no more than 50 lines per >> function, most much less. Back in the day when we didn't have nifty >> gui screens and an 24 line terminals (yay green on black!), if a >> function exceeded one printed page, it was deemed too long and marked >> for refactoring. > > I think the idea of setting an arbitrary limit on the number of lines that a > function should contain is quite ludicrous and something which I will > completely ignore. If a function requires a hundred or more lines then so be > it. The only reason to take a block of code and put it into its own function > is when that code is likely to be called more than once so that it conforms > to the DRY principle. If it is only ever used in one place then there is no > point. You obviously haven't spent much time maintaining other people's code. There is a point: if you are unfamiliar with code, wading through screens and screens of a function to find things like block beginning/ends makes for difficult time finding places where changes need to be made. If you will never have your code maintained by anyone else, or collaborate with anyone else, feel free to do what you want. > > The problems I have with creating lots of small used-only-once functions is > as follows: > - you have to create a meaningful name for each function. Yes, you do, which is also considered a hallmark of good design. > - all those functions should be arranged in alphabetical order within their > containing file - having them in a random sequence makes it difficult to > find the one you want. Also correct; this is a key point in making sure your scripts are maintainable. > - when browsing through the code you have to keep jumping to another > function, and then returning to where you came from. > > I don't know about you, but I would rather use the scroll wheel on my mouse > than keep jumping from one position in the file to another. May I suggest an editor/IDE that lets you navigate to functions directly, then? > Another problem I have encountered in the past with such an idea is that it > encourages a stupid programmer to decrease the number of lines of code by > compressing as many statements as possible into a single line, which then > makes the code less easy to read and understand. This is much worse than > having more than 20 lines in a function. There are counterbalancing things as well. If the only aspect of one's coding standards are "make it fit on one screen" then yes, you might see someone idiotic enough to do that. However, a good set of coding standards includes things which will prevent this, such as not stacking code like that. > Whether a file contains 10 functions of 100 lines each, or 100 functions of > 10 lines each, you still end up with 1000 lines of code. If you do not have > the mental capacity to deal with a 100-line function then you are in the > wrong job. The rules of thumb for coding standards are for maintainability, primarily, so throwing up strawmen to try to weasel out of an idea is pretty specious. If you do not care about how much time it takes to fix defects in other people's code, then I hope you remain a solitary programmer and don't expect anyone else to use your code, otherwise, you are in the wrong job. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cyberweaponry
On Thu, May 31, 2012 at 12:21 PM, Tedd Sperling wrote: > I watched a interview today where an security expert claimed that the Flame > Virus was written in a scripted language named lua (http://www.lua.org/). Is the interview online someplace? (Youtube?) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Uploading large files with HTTP_Request class
On Thu, May 31, 2012 at 5:28 AM, Voß, Marko wrote: > Hello, > > I need to perform uploading of large files using the HTTP_Request class: > > http://pear.php.net/manual/package.http.http-request.php > > I am *not* using this one: > > http://php.net/manual/en/class.httprequest.php > > > The HTTP_Request class support the following functions: > > setBody() and addFile() > > The addFile()-function however simulates a form field and the server > application does not read the incoming file from such a field. I have to put > the file content as a stream through the body. > > Adding the file content using the setBody()-function will of course cause an > out of memory error: > > $fp = fopen($filename, 'r'); > $request->setBody(fread($fp, $filesize($filename))); > $fclose($fp); > $response = $request->sendRequest(); > > > How am I supposed to do that with this class? Are there any alternatives, > which do not force me to add new PHP dependancies/libraries to the project? I > am writing a library and do not want to force the users to add dependancies > to their projects in order to use this library. > > I am currently using PHP 5.3.0. > > > Thank you and best regards, > Marko > > > --- > > Fachinformationszentrum Karlsruhe, Gesellschaft für > wissenschaftlich-technische Information mbH. > Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB > 101892. > Geschäftsführerin: Sabine Brünger-Weilandt. > Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Does the receiving server only accept uploads via HTTP? Or is there another protocol you could use? I'm not aware of anyway via HTTP you can send "chunks" up; as far as I know, that only works for server->client transfers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Uploading large files with HTTP_Request class
On Thu, May 31, 2012 at 5:28 AM, Voß, Marko wrote: > I need to perform uploading of large files using the HTTP_Request class: > http://pear.php.net/manual/package.http.http-request.php > The HTTP_Request class support the following functions: > setBody() and addFile() Reading the above, and checking on the documentation, I notice an inconsistency. I only find the setBody() method in HTTP_Request2, while addFile() is in HTTP_Request. The correct method for adding files in HTTP_Request2 is addUpload() (which still may not work given the limitations of the upstream server). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Your Amazon.com order confirmation.
On Fri, Jun 8, 2012 at 9:23 AM, Dan McCullough wrote: > I was hoping for a TV I'm still waiting on my delivery of a case of tuscan whole milk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: define()
On Sat, Jun 16, 2012 at 7:17 AM, Ashley Sheridan wrote: > On Sat, 2012-06-16 at 07:09 -0500, Karl DeSaulniers wrote: > >> On Jun 16, 2012, at 6:39 AM, Maciek Sokolewicz wrote: >> >> > On 16-06-2012 08:36, Karl DeSaulniers wrote: >> >> Quick question phprz. Is it ok to put a token inside a define() >> >> statement? >> >> >> >> IE: >> >> define('TOKEN', $sometoken); >> >> >> >> I guess what I am really after is if this can be read by a hacker? >> >> I may be misguided as to what define()'s parameters are. >> >> Once you define something it becomes a server variable? >> >> And server variables are easy to read/get ? >> >> >> >> If it is unsafe, what is the best method of storing/using a token so >> >> that it can be called at will? >> >> Kind of like a global, just more secure. Can you secure a define >> >> statement? >> >> >> >> TIA, >> >> >> >> Best, >> >> Karl DeSaulniers >> >> Design Drumm >> >> http://designdrumm.com >> >> >> >> >> > >> > I don't think you understand what define does, or what a constant is. >> > >> > The define function literally "defines" a constant. That is, it >> > creates a constant in your script. >> > A constant isn't a server variable, it's not some kind of special >> > global whatever. >> > >> > A constant is a kind of variable, but which is constant; that is, it >> > can not change value once set. Constants in PHP look like variables, >> > only without the preceding $-mark. They are not inherently safer or >> > better than normal variables. >> > >> > Now, the question we would all like to pose is: "what are you trying >> > to do?". You say you're looking for the best method of storing/using >> > a token to be called at will. Then of course a good question would >> > be "what do you mean by 'token'?" and what do you want to do with >> > that 'token'? Why is that 'token' so important to you? >> >> Thanks for the reply. I had a feeling I was off-track. >> I am using the token for a paypal verification. Paypals PDT. >> Would like to know how to store safely in my config file to use in my >> scripts. >> >> Karl DeSaulniers >> Design Drumm >> http://designdrumm.com >> >> > > > Store it in a PHP script outside of document root if you can, this > prevents it ever being seen if the server is misconfigured to not parse > php scripts properly. > > Try to secure all the scripts on the site, as any of them could be a way > in, allowing someone to execute their own code on the server. This is > standard practice generally though. > > -- > Thanks, > Ash > http://www.ashleysheridan.co.uk > > For credentials, such as tokens, passphrases, etc, I don't tend to store these in any particular language so that I can read and use them no matter what implementation language I'm using. These are stored outside of any server path, and strict permissions/ACL controlled. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's happened to our newsgroup?
On Jun 26, 2012 5:31 PM, "Stefan Wixfort" wrote: > > On 26.06.2012 23:48, Simon J Welsh wrote: >> >> >> On 27/06/2012, at 9:45 AM, Daniel Brown wrote: >> >>> On Tue, Jun 26, 2012 at 5:42 PM, Matijn Woudt wrote: >>>> >>>> >>>> Isn't everyday friday in summer? ;) >>> >>> >>>If it is, then it could be argued that every day is a Monday in >>> winter --- and right now, those poor folks in the southern hemisphere >>> (I'm looking at you, Thiago Pojda) are in a season of endless Mondays. >>> >>> -- >>> >> >> >> >> So glad I take Mondays off then. > > > Clever gi... er guy... > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Oh you know randall is all over this: http://xkcd.com/1073/
Re: [PHP] Re: php form action breaks script
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy wrote: > Hey guys, > > It's been a little while since I've toyed with this, and I hope you > don't mind my coming back to you for some more advice. But I've > enjoyed some limited success with David R's advice regarding adding > some strong quoting to the mix. Here is what I last tried - > > Just a wee typo here: You've quoted '[PHP_SELF' -- the extra bracket at the beginning what's wrong there. Should just be 'PHP_SELF'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy wrote: One more little thing: These notices: > Notice: Undefined index: subject in > /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php > on line 23 Notice: Undefined index: elvismail in > /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php show up because you are processing form fields in $_POST when there might not be any yet. These lines: > $from = 'bluethu...@jokefire.com'; > $subject = $_POST['subject']; > $text = $_POST['elvismail']; > $output_form = "false"; Should appear *after* this line: > if (isset($_POST['Submit'])) { You should also check the $_POST entries for 'subject' and 'elvismail' to make sure they are set to avoid the notices, even if you do move them after the submit check. You never know! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] slicing and dicing strings
On Wed, Jun 27, 2012 at 5:15 PM, Kirk Bailey wrote: > ok, it slices and dices, but how? > in python, to print all but the last char in string FOO, we say > print FOO[:-1] > But this seems to bark like a basset hound in php. Whyfore? As said, PHP is not Python. Pretty much *nothing* else is Python. That said, the trope still has legs in PHP: >From <http://us2.php.net/manual/en/function.substr.php> : "If start is negative, the returned string will start at the start'th character from the end of string." > Now tihs tyro is seeking sage words to help me understand this. > RTFM is not sage words; if you don't want to help me please don't waste the > bandwidth. RTFM with no hint of where to look is a problem. But the dictum of "Read here in the manual" will surely be the best thing. You will then know where to look for future questions. > Would anyone care to help me understand this without dedicating 4 precious > and in over demand/under supply hours to RTFM? You may not have 4 precious and overdemanded/undersupplied hours, but at some point everyone who can answer this has had to slog through the manual; we haven't just been lounging in our opulence pouring over the documentation out of some need to aleviate our boredom. Nor is anyone on this list to spend their time providing answers which *are* readily available with just a bit of google-fu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Depreciation message I can't make out....
On Thu, Jun 28, 2012 at 1:00 PM, Daniel Brown wrote: >> PHP Deprecated: Comments starting with '#' are deprecated in >> /web/conf/php5.ini on line 1256 in Unknown on line 0 > > Comment-out, using semicolons (;), any comments in your > /web/conf/php5.ini file that begin with the hashmark (#), and then > also comment-out (;) the magic_quotes_gpc line. Just a quick followup -- # comments are deprecated for .ini files, only, correct? They are still full citizens in php source, aren't they? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's happened to our newsgroup?
On Wed, Jun 27, 2012 at 9:42 AM, Tedd Sperling wrote: > On Jun 26, 2012, at 3:21 PM, Al wrote: > >> No postings for days. >> > > Maybe everyone learned it -- no new questions. > > Cheers, > > tedd We now all have php.net open all the time so no more questions need to be asked! :> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] log tailing
On Fri, Jun 29, 2012 at 3:49 AM, Mihamina Rakotomandimby wrote: > I have a /var/log/messages and /var/log/syslog file to parse to extract > information from. > > I have the to extract the date, and some information in the line. [snip] > I just need help on the right regexp function to use. > Would you know some PHP/regexp tutorials for that? The best documentation I've ever found on Regexes is O'Reilly's "Mastering Regular Expressions" (3rd ed is 2006, but REs haven't changed since then). <http://shop.oreilly.com/product/9780596528126.do> Only problem is it is hella expensive. (Well another problem is it is hella big: >500 pages.) Apart from that, there are *tons* of tutorials on the net. Just google up "regular expression tutorials" and you should see pages and pages of them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Depreciation message I can't make out....
On Sat, Jun 30, 2012 at 12:57 PM, Gary Lebowitz wrote: > By the way, I told GoDaddy about the # deprecation issue and they told me > that I could simply change my root directory php5.ini file. But the error > message is related to the PHP.ini file in /web/config, as I said. I could > almost hear them shrugging their shoulders, what-me-worry style. If anyone > with more might than i could explain this error might affect others when > multiplied hundreds of times it could be useful. > > Am 30.06.2012 19:23 schrieb "Daniel Brown" : >> >> On Thu, Jun 28, 2012 at 8:37 PM, tamouse mailing lists >> wrote: >> > >> > Just a quick followup -- # comments are deprecated for .ini files, >> > only, correct? They are still full citizens in php source, aren't >> > they? >> >> Correct, Tam. >> >> -- >> >> Network Infrastructure Manager >> http://www.php.net/ >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > By the way, I told GoDaddy about the # deprecation issue and they told me > that I could simply change my root directory php5.ini file. But the error > message is related to the PHP.ini file in /web/config, as I said. I could > almost hear them shrugging their shoulders, what-me-worry style. If anyone > with more might than i could explain this error might affect others when > multiplied hundreds of times it could be useful. > Sadly, my only advice is to get away from GoDaddy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP] log tailing
-- Forwarded message -- From: "tamouse mailing lists" Date: Jun 30, 2012 4:35 PM Subject: Re: [PHP] log tailing To: "Daniel Brown" On Jun 30, 2012 1:34 PM, "Daniel Brown" wrote: > > On Sat, Jun 30, 2012 at 2:30 PM, Daniel Brown wrote: > > > > > > > $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk > > {'print $1,$2,$3 "|" $5 "|" $11'}`)); > >Actually, the above was intended to grab just sshd entries, so > instead of 'tail' you should use 'grep sshd' in the line above. > > > > foreach ($ssh_entries as $s) { > >$l = explode('|',$s); > > > >// Remember to do whatever sanity necessary! > >$sql = "INSERT INTO ssh_activity > > VALUES('".$l[0]."','".$l[1]."','".$l[2]."')"; > > } > > ?> > > > > -- > > > > Network Infrastructure Manager > > http://www.php.net/ > > > > -- > > Network Infrastructure Manager > http://www.php.net/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Crud-- sent to Dan instead of list: Or just let awk do it: tail /var/log/syslog | awk '/sshd/{print($1,$2,$3 "|" $5 "|" $11)}'
Re: [PHP] Hello again
On Sun, Jul 1, 2012 at 6:21 PM, RGraph.net support wrote: > Just thought I'd say hello again. Back to brush up on my PHP a little > after a bit of a break - more reading than replying I'd imagine. I > have some pretty bad jokes too that I might surreptitiously insert > here and there... Welcome back. Friday is mainly the free-for-all day (philosophical questions, puns, jokes) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Prevent duplicate field names?
On Mon, Jul 2, 2012 at 5:38 PM, Scott Baker wrote: > It was my mistake, and the SQL was easily fixed. But it woulda been nice > to have PHP realize there was a dupe when it was building that array to > return to me. This is just not a province of PHP. What sort of behaviour would one expect PHP to do given this scenario? It is surely not an error in every case; I can see some code relying on this exact behaviour. Making it some sort of option in PHP increases the complexity a great deal, not only in trying to determine how to design and then *change* the API to accommodate it, but in figuring out what exactly one might *do*. Since SQL is a completely separate language from PHP, it makes much more sense to learn to deal with these thing separately, and understand what your SQL is doing. Indeed, SQL will happily return multiple columns with the same column name; you must be aware of this when writing it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does this code work?
On Tue, Jul 3, 2012 at 2:31 AM, Robert Williams wrote: > On Jul 2, 2012, at 22:15, "Jim Lucas" wrote: > Hmm, I wonder if those thirty years are having a different sort of impact on > me, in the form of decaying eyesight I've had to tweak up the default fonts on things... *sigh* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make a secure download ?
On Thu, Jul 5, 2012 at 10:17 AM, Gibbs wrote: > On 05/07/12 14:32, donkfat...@donkfather.eu wrote: >> >> Hi, >> >> I am trying to put a file to download. I want it secure so only the people >> having the password can access it. >> I made a page that requires a password.. if the password is correct it >> changes the password send it on my mail and redirects >> the user to another script. This script searches in the database for the >> id given with GET and finds the name of the file >> which is md5(something). it changes the name of the file in md5(smth >> else). After that it searches in the download folder >> for a file named md5(smth else). if it finds the file it gives you the >> link to the file. >> So i need to find a way to change the filename after the user downloads >> the file. to keep it secure so the user >> wont be able to share the link to oters. >> >> if you need more info ask :D >> thanks >> and sorry for my bad english . >> > > Sounds like you are overcomplicating it. Following what you've already done > though... > > Have the original files stored somewhere outside of the web root. That way > they aren't accessible whatsoever + you shouldn't have to change any of the > files at any stage. > > Then you can simply update/change the ID that associates with it in your > database when that URL is hit... > > Gibbs It does sound a bit complicated. If I surmise correctly, what you are attempting to do is give an authorized person the ability download a file from your server by sending them a link to it in an email. Right so far? If so, here's what I suggest doing: 1) Store your downloadable content in a directory *outside of the web server file space* (as Daniel mentioned above). 2) Keep a table of authorized people -> file download tokens, and file download tokens -> download file spec. (You might want to also include a back-reference for the latter so you can keep stats on files downloaded.) 3) Write a special script that only handles downloads, not part of your regular application. 4) When the authorized person requests the download, create a token and store it in the data base, linking it to the person's info and the download file spec, and send the person an email with a link to the URL invoking the special script with token. 5) When the person clicks the link, have your script mark the token as "used" (so it can't be used again -- or optionally keep it around and possibly do something like record the number of downloads, ip addresses, date/time, and so on -- can be useful also for given someone, say, 5 legal downloads and then shutting it off). 6) Then matching the token to the file spec, deliver the contents, appropriately setting headers as per the file contents. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using named Pipes between PHP and ZIP
≈On Sun, Jul 8, 2012 at 11:30 AM, Dennis Heck wrote: > Hello everyone, > > I'm looking for a solution for the following: > 1) collecting data from a simple html form and send them to a php script > 2) take the data and place them in a php-generated excel sheet > 3) zip the excel sheet and password protect the zip file (standard > encription will be sufficent, no AES needed) > 4) send the zip file as an email attachment > This kind of output is fixed, changing the output is not an option. > > I'm ok with building the excel sheet and sending the mail, but I'm still > trying and error with the zip. Since I need password protection in the zip, > I cannot use the php build in zip extension. I guess I will need to call ZIP > on the shell. I'm aware I could first save the generated excel sheet to the > filesystem and afterwards call the zip process on the file, putting the zip > file also to the file system. But I wonder if there's an option to stream > the data till they finally can be put to the multipart mail - without saving > anything to the filesystem. > > Here is my first try, just a little modification of the example on proc_open > in the php docu. To keep the test simple, I load a sample xls from the > filesystem instead of generating from the php class and output it directly > to the browser. The script works well except one point: the file contained > in the zip will have no name an no file extension. > >header ('Content-type: application/zip'); >header ('Content-Disposition: attachment; filename="download.zip"'); > >$descriptorspec = array( >0 => array("pipe", "r"), > 1 => array("pipe", "w"), > 2 => array("file", "error-output.txt", "a") >); > >$dateiname = 'xyz.xls'; >$file = fread(fopen($dateiname, "r"), filesize($dateiname)); > >$process = proc_open('zip -P 1234', $descriptorspec, $pipes); > >if (is_resource($process)) { > >fwrite($pipes[0], $file); >fclose($pipes[0]); > >$zip = stream_get_contents($pipes[1]); >fclose($pipes[1]); > >$return_value = proc_close($process); >} > >echo $zip; >?> > > So I look for an option to get the name and extension in the zipfile. Here I > found named pipes as an option. Calling via shell, tested with a textfile in > order to use less > >mkfifo xyz.txt >less readme.txt > xyz.txt & zip output.zip -FI xyz.txt -P 1234 >rm xyz.txt > > Now I get a pw protected zip file containing xyz.txt. Now how can I combine > both? How can I tell php to use the named pipe instead of stdin in > proc_open? Or any other idea to get the file in the zip the correct name and > extension. > > Thanks in advance, > Regards, > Dennis > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I *think* all you need in the first paramter to proc_open is : zip -P password - - The first - is the zip file -- which will be send to stdout. The second - is the input -- which you should pipe your spreadsheet into. Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Find match of string if only at end of string
On Wed, Jul 11, 2012 at 11:45 AM, Marc Guay wrote: > Answered it myself (funny how writing out a problem as descriptively > as possible makes the brain work better). > > $end_of_url = substr("http://domain.com/about/page/subpage/";, > strlen("/about/page/") * -1); > $same_post = ($end_of_url == "/about/page/"); or regex: ':/about/page/:$' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO: extend or encapsulate?
It's Friday, so... Yes, it's true, I have just started looking at using PDO instead of mysqli -- a bit behind the times... My question at this stage, is do people tend to extend the PDO class for their own use, or encapsulate it in a class (or do most people use it mostly in procedural code?) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: extend or encapsulate?
On Sat, Jul 14, 2012 at 12:04 AM, Paul M Foster wrote: > On Fri, Jul 13, 2012 at 12:06:22AM -0500, tamouse mailing lists wrote: > >> It's Friday, so... >> >> Yes, it's true, I have just started looking at using PDO instead of >> mysqli -- a bit behind the times... >> >> My question at this stage, is do people tend to extend the PDO class >> for their own use, or encapsulate it in a class (or do most people use >> it mostly in procedural code?) > > I encapsulated it in my own database class. One reason for that is that > the PDO "class" is really two classes, which is fine for low level > drivers but not production code that I have to use daily. A second > reason is that many of the methods are not really necessary in a > production environment. I want to limit the methods my code uses to > interact with the database. Third, I wanted to handle errors and > exceptions with my own methods, more suitable to the code I write. For > example, a fatal error should only, but always, be issued if the > database code is given something illegal to chew on. Anything else, like > a failure to return the expected result, should simply yield some sort > of sentinal value or something. If *my code* ever gives the database > library something illegal to chew on, then it should only be because of > my bad code, not because a user managed to somehow get bad data through. > That is, my code should always catch illegal data before it ever gets to > the database library. Fourth, encapsulation means that I can have the > class itself carry around some of the data that I would normally have to > explicitly pass around among functions. This way, I make that useful > data (like the number of records returned from the last fetch), part of > the "payload" of the class itself. > > Extension is tricky and requires a more subtle and refined knowledge of > the classes involved. Besides, it exposes methods which I would prefer > not be used by my code. Encapsulation limits the methods of the classes > to just what I deem necessary and no more. I can always write new > methods if I need them. > > Paul > > -- > Paul M. Foster > http://noferblatz.com > http://quillandmouse.com I am rather agreeing with both of you. Back in the days I used to poke at Java, one of the caveats was to only inherit from abstract classes, and encapsulate final classes. It does make more sense to me that way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Seeking a scheduling algorithm
On Jul 14, 2012 5:34 PM, "Bill Guion" wrote: > > On Jul 14, 2012, at 4:53 PM, php-general-digest-h...@lists.php.net wrote: > > > From: Tedd Sperling > > Subject: Seeking a scheduling algorithm > > Date: July 14, 2012 4:53:15 PM EDT > > To: php-general@lists.php.net > > > > > > Hi gang: > > > > Does anyone have a resource, or better yet code, to solve the scheduling problem described below? > > > > Let's say you have a week calendar that has openings between 8:00am to 5:00pm for Monday through Friday (40 hours). > > > > Then you have an assortment of appointments that must be scheduled into the week calendar. Some of the appointments are simply a one hour per week, while others may be two, three, four, or five times per week and each appointment for an hour or more (up to eight hours). > > > > The problem is, knowing what appointments (i.e., twice a week for 2 hours, three times a week for one hour, etc.) must be scheduled for the week, what is the most efficient way to schedule these appointments into that week? > > > > The most efficient way is defined as scheduling appointments with little, or no, gaps in between appointments. For example, four one-hour appointments on Monday between 8:00am to 12:00pm is better than four one-hour appointments spread out between 8:00am to 5:00pm. > > > > Anyone have any solutions, ideas, resources, code? > > > > Thanks, > > > > tedd > > > > _ > > t...@sperling.com > > http://sperling.com > > > > > Tedd, > > There is an old general rule that the most time efficient way to schedule is to put the "big" time requests on the schedule first. In this case, that would mean schedule all five times a week requests first, then the four times a week, then the three times a week. The two hour requests should be scheduled next: three times a week and twice a week can be scheduled at the same time. Then fill in the rest with the one hour requests. > > Hope that makes sense. > > -= Bill =- > -- > > A closed mouth gathers no feet. > What this sounds like, to me, is quite similar to either a memory allocation scheme or a disc defragmenting scheme. I haven't worked either of those since I went to Jurassic United, though...
Re: [PHP] PDO: extend or encapsulate?
On Sun, Jul 15, 2012 at 5:50 AM, shiplu wrote: > From OOP point of view. > > Use encapsulation: > When a class has a "has-a" relation-ship with other class you should use > encapsulation. For example, If MyDB is a class that "has-a" pdo driver in > it, then PDO will be encapsulated inside MyDB class. This is also called > containment. MyDB should contain PDO. > > Use inheritance: > When a class has a "is-a" relation ship with other class use inheritance. > For example, Dog is an Animal. so Dog should extend Animal class. MyPHPDb > is-a PHP Database Object (aka PDO). So it'll be inheritance. MyPHPDb should > extend PDO. > > Think about the relation have. Then implement it. > > > -- > Shiplu.Mokadd.im > ImgSign.com | A dynamic signature machine > Innovation distinguishes between follower and leader > Yes, good: "has-a" and "is-a". In some cases, the distinction seems clear. The think in this case, the class I'm implementing "has-a" PDO driver, rather than "is-a" PDO driver. In this case, I'm encapsulting the PDO classes within my class to provide removal of details from the main program for dealing with data, which isn't particularly interested in how that data is manipulated or stored. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What do you call the end-user?
On Thu, Jul 19, 2012 at 12:26 PM, Tedd Sperling wrote: > Hi gang: > > I can't wait for tomorrow -- so here's my off-topic post today. > > First question: > > What do you call the people who ultimately use your code? It all depends on where and how my code is ultimately used. If it is code that someone sitting at a browser making requests that end up running code I wrote, they are a user, or where there needs to be clarification, and end user. > I call them the "end-user", but others have stated other terms, such as > "customer" or "user". Again, it sort of depends on the disposition of the code I wrote. In any case, "customer" to me implies some sort of delivery possibly for remuneration. Customers tend to be singular for any given package (not meaning exclusive) and some kind of contract is held between us. I don't run any commercial sites for my own benefit, otherwise the term customer might expand to people buying or trading things with me via that site, in which case those customers become a subset of end users as well. Isn't this fun? In the case where I'm developing a portion of a product that another developer may pick up an use in application, they are "using" my code, but are definitely quite distinct from an end-user or a customer. Sometimes they might be called a "partner", but not always. > Second question: > > Are you concerned with their ("whomever") experience in using your code? All those various constituents have needs whom I may wish to address. The end-user, obviously has need to be able to transact their business in as easy a fashion as possible, and being able to trust the chain of software and hardware that will carry out those wishes. The customer needs to be able to trust in the product or service they are buying, but equally, to be able to understand and navigate whatever process is in place for our transaction. And the development partner, as well, needs to be able to trust that the package I'm producing is documented well enough, and it is clear and as easy as possible to integrate with their own software. > This question transcends your code working correctly, accurately, and > securely -- no need to comment on those aspects. But rather more specifically > do you consider how easily your "whomever" can use your work efforts? > > As you may have guessed - I just attended a UX conference and they provide an > interesting perspective on UX. I was wondering how php developers typically > address the subject. This sort of thing is not only applicable to UX needs, but to many other areas as well. It's also not limited to any particular interface, but how that interface changes and evolves over time, and it's responsiveness to the various constituents' needs. > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On Jul 19, 2012 8:31 PM, "Tedd Sperling" wrote: > > On Jul 19, 2012, at 1:50 PM, Daniel Brown wrote: > > > >As an aside on the subject of jQuery, our very own Jay Blanchard > > has written a comprehensive book on the topic entitled "Applied > > jQuery: Develop and Design": > > > >http://links.parasane.net/92xb > > > > Just bought it -- thanks. I'll add it to my other three jQuery books > > Always support the people on this list. > > 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 > I have to ask, is it available in a non-DRMed shook format?
Re: [PHP] Creating drop-down menus
On Jul 20, 2012 9:20 AM, "tamouse mailing lists" wrote: > > > On Jul 19, 2012 8:31 PM, "Tedd Sperling" wrote: > > > > On Jul 19, 2012, at 1:50 PM, Daniel Brown wrote: > > > > > >As an aside on the subject of jQuery, our very own Jay Blanchard > > > has written a comprehensive book on the topic entitled "Applied > > > jQuery: Develop and Design": > > > > > >http://links.parasane.net/92xb > > > > > > > Just bought it -- thanks. I'll add it to my other three jQuery books > > > > Always support the people on this list. > > > > 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 > > > > I have to ask, is it available in a non-DRMed shook format? Ok, so shook is what ebook autocorrects to
Re: [PHP] Mac 10.7 Install/Copy fresh PHP over Pre-Installed PHP
Ugh. This is why I no longer want an apple computer. On Jul 31, 2012 8:26 AM, "JeffPGMT" wrote: > > AGAIN - THANKS TO ALL... > > IT installed XCode, here's another? command line tools sans XCode available > from Kenneth's github, > https://github.com/kennethreitz/osx-gcc-installer > > However another irony, now that XCode is installed, in the new XCode 4.4 > command line tools are not installed by default, so I found my way to > Preferences, Downloads, Command Line tools Install checkbox... it's > downloading (similar to watching paint dry) > > JeffP... > > "Simon J Welsh" wrote in message > news:2a4921bf-db43-464b-8bbe-5ea1e3665...@simon.geek.nz... > On 31/07/2012, at 10:54 PM, Jason Pruim wrote: > > On Jul 30, 2012, at 12:01 PM, "JeffPGMT" wrote: > > > >> Thanks All, now I have to tell the business owner to let the IT guy > >> update > >> to 10.8 if he likes, which will buy me time to sort out all of what you > >> folks contributed. > >> > >> I wasn't aware that Mamp free installed anything more than basic and Yes, > >> setup so that Apache, MySql and PHP work well together was what I had > >> wanted > >> to learn using the stock install and was able to do w/exception of imap > >> being available. > >> > >> Perhaps I will install XCode as it's the law of worst case probably will > >> occur if I don't, that is I'll need it in a pinch later on. > >> > >> JeffPGMT... > >> > > > > Hey Jeff, > > > > Unless its changed in mt lion, you will need to install Xcode to use make > > or any other program assembler... > > O > > You can download just the command line tools from > https://developer.apple.com/downloads, which is ~100 MB instead of a couple > of gigs. Has been like this for some time now. You just have to be careful > with some older code not compiling properly with LLVM. > --- > Simon Welsh > Admin of http://simon.geek.nz/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
Re: [PHP] File moving hell on Windows
On Jul 31, 2012 12:12 PM, "Brian Dunning" wrote: > > Regular Windows networking. > > On Jul 30, 2012, at 2:29 PM, Mike Mackintosh < mike.mackint...@angrystatic.com> wrote: > >> > > What protocol are you targeting? FTP, SFTP, SSH, SMB, etc? > > > > -- > > Mike Mackintosh > > PHP 5.3 ZCE > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Is this a php problem?
Re: [PHP] PHP Stats
On Jul 31, 2012 12:19 PM, "Lester Caine" wrote: > > Sebastian Krebs wrote: >> >> http://w3techs.com/technologies/details/pl-php/all/all For example. Click >> around, nice stats there. > > http://w3techs.com/technologies/history_overview/programming_language/ms/yis > the more interesting one ... PHP usage IS still growing. > > -- > 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 > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Interesting to see coldfusion on there still... but not Ruby...
Re: [PHP] php safe mode no more?
What I've noticed running apache suexec + fastcgi is that the memory requirements increased over running nonsuexec and mod_php under apache. when i went to a nginx + fastcgi, things worked much better overall with limited memory (i'm on 1GB limited slice, non-burstable). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Web search engine in PHP
On Aug 6, 2012 7:33 AM, "shiplu" wrote: > Solr with Nutch will do it. Where *do* come up with those names :)
Re: [PHP] PHP session variables
On Aug 13, 2012 8:01 AM, "Robert Cummings" wrote: > > On 12-08-10 04:42 PM, Tedd Sperling wrote: >> >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: >> >>> Hi. My question will maybe out of topic, I'm sorry. >>> How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? >> >> >> Ege: >> >> No your question is on topic. >> >> This question should be asked on the list, so I'll present Q:A instead of answering privately >> >> http://www.webbytedd.com/b/timed1/ >> >> The code is there -- if you have questions, please post them to the list. > > > Ted, > > Please see the current signature for microtime(): > > mixed microtime ([ bool $get_as_float = false ] ) > > The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) > > 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 > What are the timing values if you do something besides session start with no close?
Re: [PHP] PHP session variables
On Aug 14, 2012 1:36 AM, "tamouse mailing lists" wrote: > > > On Aug 13, 2012 8:01 AM, "Robert Cummings" wrote: > > > > On 12-08-10 04:42 PM, Tedd Sperling wrote: > >> > >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: > >> > >>> Hi. My question will maybe out of topic, I'm sorry. > >>> How can you know that one way will be much slower than other one? I mean, how can I learn which function is faster before I test it? > >> > >> > >> Ege: > >> > >> No your question is on topic. > >> > >> This question should be asked on the list, so I'll present Q:A instead of answering privately > >> > >> http://www.webbytedd.com/b/timed1/ > >> > >> The code is there -- if you have questions, please post them to the list. > > > > > > Ted, > > > > Please see the current signature for microtime(): > > > > mixed microtime ([ bool $get_as_float = false ] ) > > > > The optional paramter was added in PHP 5.0.0. I think it's safe to update your habits :) > > > > 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 > > > > What are the timing values if you do something besides session start with no close? Just to clarify, since at least 4.3.x subsequent calls session_start raise an E_NOTICE and are ignored, so you're first call is generating almost all the time.
Re: [PHP] Need to have form protection techniques
On Thu, Aug 16, 2012 at 11:05 PM, Ansry User 01 wrote: > I need to know the forms validity techniques for Php. Is that all? Seriously, that is a very lengthy discussion, and may depend on which framework you may be using. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I do count the occurrence of each word?
On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston wrote: > I want to parse this text and count the occurrence of each word: > > $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html; > #Can I do this? > $stripping = strip_tags($text); #get rid of html > $stripping = strtolower($stripping); #put in lowercase > > > First of all I want to start AFTER the expression "News Releases" and stop > BEFORE the next occurrence of "-30-" > > #This may occur an undetermined number of times on > http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html > > > > Second, do I put $stripping into an array to separate each word by each > space " "? > > $stripping = implode(" ", $stripping); > > > Third how do I count the number of occurrences of each word? > > Sample Output: > > determined = 4 > fire = 7 > patrol = 3 > theft = 6 > witness = 1 > witnessed = 1 > > > $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html > #echo strip_tags($text); > #echo "\n"; > $stripping = strip_tags($text); > > #Get text between "News Releases" and stop before the next occurrence of > "-30-" > > #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r > #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n > #$stripping = str_replace(" ", " ", $stripping);# getting rid of the > occurrences of double spaces > > #$stripping = strtolower($stripping); > > #Where do I go now? > ?> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This is usually a first-year CS programming problem (word frequency counts) complicated a little bit by needing to extract the text. You've started off fine, stripping tags, converting to lower case, you'll want to either convert or strip HTML entities as well, deciding what you want to do with plurals and words like "you're", "Charlie's", "it's", etc, also whether something like RFC822 is a word or not (mixed letters and numbers). When you've arranged all that, splitting on white space is trivial: $words = preg_split('/[[:space:]]+/',$text); and then you just run through the words building an associative array by incrementing the count of each word as the key to the array: foreach ($words as $word) { $freq[$word]++; } For output, you may want to sort the array: ksort($freq); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I do count the occurrence of each word?
On Sun, Aug 19, 2012 at 12:38 AM, Marco Behnke wrote: > Am 19.08.12 06:59, schrieb tamouse mailing lists: >> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston >> wrote: >>> I want to parse this text and count the occurrence of each word: >>> >>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html; >>> #Can I do this? >>> $stripping = strip_tags($text); #get rid of html >>> $stripping = strtolower($stripping); #put in lowercase >>> >>> >>> First of all I want to start AFTER the expression "News Releases" and stop >>> BEFORE the next occurrence of "-30-" >>> >>> #This may occur an undetermined number of times on >>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html >>> >>> >>> >>> Second, do I put $stripping into an array to separate each word by each >>> space " "? >>> >>> $stripping = implode(" ", $stripping); >>> >>> >>> Third how do I count the number of occurrences of each word? >>> >>> Sample Output: >>> >>> determined = 4 >>> fire = 7 >>> patrol = 3 >>> theft = 6 >>> witness = 1 >>> witnessed = 1 >>> >>> >>> >> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html >>> #echo strip_tags($text); >>> #echo "\n"; >>> $stripping = strip_tags($text); >>> >>> #Get text between "News Releases" and stop before the next occurrence of >>> "-30-" >>> >>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r >>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n >>> #$stripping = str_replace(" ", " ", $stripping);# getting rid of the >>> occurrences of double spaces >>> >>> #$stripping = strtolower($stripping); >>> >>> #Where do I go now? >>> ?> >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> This is usually a first-year CS programming problem (word frequency >> counts) complicated a little bit by needing to extract the text. >> You've started off fine, stripping tags, converting to lower case, >> you'll want to either convert or strip HTML entities as well, deciding >> what you want to do with plurals and words like "you're", "Charlie's", >> "it's", etc, also whether something like RFC822 is a word or not >> (mixed letters and numbers). >> >> When you've arranged all that, splitting on white space is trivial: >> >> $words = preg_split('/[[:space:]]+/',$text); >> >> and then you just run through the words building an associative array >> by incrementing the count of each word as the key to the array: >> >> foreach ($words as $word) { >> $freq[$word]++; >> } > > Please an existence check to avoid incrementing not set array keys > > foreach ($words as $word) { > if (array_key_exists($word, $freq)) { > $freq[$word] = 1; > } else { > $freq[$word]++; > } > } Ah, yes, good point -- as written, my code will raise two notices. In addition, "declare" the $freq array: $freq=array(); as well before the foreach loop to ensure notice-free operation. > > >> >> For output, you may want to sort the array: >> >> ksort($freq); >> > > > -- > 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] OT (maybe not): Drupal vs WordPress
On Sun, Aug 19, 2012 at 8:28 PM, wrote: > http://www.computerworld.com/s/article/9219685/Site_builder_shootout_Drupal_vs._Joomla_vs._WordPress > Very good article IHMO. > > >> Hi to everyone, >> I was trying to figure this out for the last week or two. I have read tons >> of articles that compare Drupal and WordPress, but I still wasn't swayed >> to either side. >> I know that they are both good, both do the job well, and both have >> advantages and disadvantages. For example, Drupal has a steeper learning >> curve, but you get more control over the website. >> Most of Drupal vs WordPress articles are "emotionally" driven and it >> reminds me of the PC vs Apple flame war. I was trying to exclude these as >> much as I could but it's hard. >> >> Is there any website/article/benchmark/test/experiment/whatever I can >> trust to be unbiased? I need a website that measures the CMS' through >> facts, not heated, emotional arguments. In which cases is it better to use >> Drupal over WordPress (and vice-versa)? I know the first two words are >> going to be "it depends", but let's talk about it in general (for small >> basic websites, more complex websites, easy customization, etc). >> >> I found this on one page: "... Drupal was built as a fine-grained >> multi-role system where you can assign different permissions to different >> roles to do different things (e.g. content editor, content reviewer, >> member, etc.) and assign users to these roles..." Does that mean that >> WordPress can't do that? Maybe it can, and the quotation is true, but it >> is kind of misleading to say that one of the programs does something, and >> then not mention the other product at all. >> >> Special points for me are (not a must, though) >> - multiple websites with single core (both CMSs have the capability but I >> got impression Drupal does it better?) because of maintenance >> - compatibility with CiviCRM >> >> Once I decide what to use, I have to stick with it for a while. >> >> Thanks for any help. >> >> LAMP >> >> >> -- >> 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 > Since both Drupal and Wordpress blather about not needed to know any programming to use, I'm not much interested. I like wordpress for my blogs, drupal has never felt compelling when I've delved into it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
OT Reply -- just frustrated with the way email screws up program listings. It's a royal pain to have to strip out code and then put it in an editor and tidy it up just to be able to make heads or tails out of something. There are lots of code pasting sites around, but that breaks up the continuity of the list archive. No solution, just frustrated -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Thu, Aug 23, 2012 at 2:51 PM, admin wrote: > Hello everyone, > > In my quest to build bigger and better dynamic content, I am > putting forth a concept to see what you all think. > > Many times I come across customers who want drop down menus dynamically > built from database tables. > > > > Old way Example: > > Echo '--Please Select--'; > > $query = "SELECT * FROM personnel ORDER BY last_name"; > > $result = mysql_query($query); > > If(mysql_num_rows($result) >= 1) > > { > > While($row = mysql_fetch_assoc($result)) > > { > > Echo "".$row['first_name']." > ".$row['last_name'].""; > > } > > } > > Echo ''; > > * > > > > I am purposing a Method for this that has some flexibility. > > > > Initialize Object: $yourobject = new yourclass(); > > Call method: // The call design is just so you have a better understanding > of my concept > > $dropdown = $yourobject-> dropmenu('personnell','ID',array(0 => > 'first_name', 1 => 'last_name'), 'last_name'); > > > > Function dropmenu($table,$fieldforvalue,$fieldstodisplay,$fieldorder) // > Yes you could add some WHERE filters as well > > { > > $arraytoreturn = array(); > > If(strlen($table) >= 3){ > > if(is_array($fieldstodisplay)){ > > $count = 0; > > foreach($fieldstodisplay as $key=>$values){ > > if(strlen($values) >=3){ > > If($count == 0){ > > $fields = $values; > > }else{ > > $fields . = ",".$values; > > } > > $count++; > > } > > > } > > }else{ > > If(strlen(($fieldstodisplay) >= 1){ > > $fields = $fieldstodisplay; > > $fieldstodisplay = array(0 > =>$fieldstodisplay); > > }else{ > > Return $arraytoreturn; // Return nothing > because no field was selected. > > } > > } > > }else{ > > Return $arraytoreturn; // Return nothing because no table was selected. > > } > > If(strlen($fieldorder) >= 3) { > > $orderfilter = " ORDER BY ".$fieldorder." "; > > }else{ > > $orderfilter = ""; > > } > > $query = "SELECT ".$fields." FROM ".$table." ".$orderfilter." "; > > $result = mysql_query($query); > > If(mysql_num_rows($result) >= 1) > > { > > $arraytoreturn[] = "--Please Select--"; > > While($row = mysql_fetch_assoc($result)) > > { > > $display_fields = ""; > > Foreach($fieldstodisplay as $key=>$values){ > > $display_fields .= $row[$values]." "; > > } > > If(strlen($fieldforvalue >= 3){ > > $arraytoreturn[] = " value='".$row[$fieldforvalue]."'>".$display_fields .""; > > }else{ > > $arraytoreturn[] = "".$display_fields .""; > > } > > } > > Return $arraytoreturn; > > }else{ > > Return $arraytoreturn; // Nothing to return. > > } > > } > > > > Now I can call the drop downs driven by database tables dynamically and It > saves me a TON of time. > > Echo ''; > > Foreach($dropdown as $key=>$values){ > > Echo $values; > > } > > Echo ''; > > > > > > Richard L. Buskirk > > "Some of the world's greatest feats were accomplished by people not smart > enough to know they were impossible" Some things you may want to consider in extending this: * The separation of code and data is important to consider; this sort of function, for me, falls into the grey area in between; I often have built up the array of options and other elements of the and then have passed it onto the portion of the app that handles views, keeping any sort of HTML out of the way of the database queries, etc. Encapsulating this in a single class brings up the issues of data base agnosticism as well. * Often times, on a form, one may want to include a for the select statement. * At some point, you may want to use the "selected" attribute in one of the options. My HTML selects typically have the following form: Select the appropriate item: Item One Item Two The code I use that generates this is at http://pastebin.com/SZYN5qgv The call would be something like: echo dynamic_select(array('opt1'=>'Item One','opt2'=>'Item Two'),'dyn_select','Select the appropriate item:','opt2'); The first parameter can obviously be an array created from a database query using whatever database methods you'd like: mysql, mysqli, pg_*, PDO, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 10:11 AM, Samuel Lopes Grigolato wrote: > Do you mean the ">" quotation marks? Have you tried to create a simple > Notepad++ macro? I do this for things like formatting SQL from SQL Editor to > SQL String in code, and vice versa. No, I mean the way the code is mangled with premature line breaks, bad indenting, and other such things. As I tend to view my email via a webmail interface (sucks, but there I am) it is subject to whatever whims and fancies of the originator's program and gmail's output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 10:16 AM, Jim Lucas wrote: > On 08/24/2012 08:01 AM, tamouse mailing lists wrote: >> >> OT Reply -- just frustrated with the way email screws up program >> listings. It's a royal pain to have to strip out code and then put it >> in an editor and tidy it up just to be able to make heads or tails out >> of something. There are lots of code pasting sites around, but that >> breaks up the continuity of the list archive. No solution, just >> frustrated >> > > This list does allow attachments, but that breaks things too, because they > are not shown on archive web sites. Wow, I did not know it even allowed attachments. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 10:47 AM, Matijn Woudt wrote: > On Fri, Aug 24, 2012 at 5:33 PM, Jim Lucas wrote: >> On 08/24/2012 08:25 AM, Matijn Woudt wrote: >>> >>> On Fri, Aug 24, 2012 at 5:22 PM, Jim Lucas wrote: >>>> >>>> Two simple guide lines will help everybody here. >>>> >>>> 1) Limit your lines to 80 characters >>>> 2) Use spaces instead of Tabs >>>> >>> >>> Are we going to discuss coding guidelines again? The 80-character >>> limit is outdated, 100 or 120 is more common today. >>> And while I do agree with the spaces, do you also insist on 2, 4 or .. >>> spaces? ;) >>> Oh and I'd like everybody to put the opening brackets on the same line.. >>> bla bla >>> >>> My point is: It's not going to happen. >>> >>> - Matijn >> >> >> This has absolutely nothing to do with your own personal coding styles. >> This has only to do with how you are going to present code to the list >> members. > > So you expect people to convert all their code to a 'mailing list > standard' before posting? Still not going to see that happen.. > >> >> Personally, I let my code ramble on as long a line as it needs. I use tabs >> (set to 8 chars) in my code. That is because the other developers that I >> work with have editors that can display the tabs in whatever width they >> desire. I also do not wrap at 80 chars. >> >> But if you look back at any of my code examples that I have written, none of >> them are longer then 80 characters, and uses two spaces for indentation. >> Simply because my email client is set to plain text and wraps at 80 chars. > > I can see that you do that indeed, but that does *not* guarantee that > it is also seen that way. I think most of us use a 'smart' mail > client, that automatically makes emails more readable by undoing these > stupid line breaks at 80 chars. Gmail for example shows your mail as > lines with approx 175 chars on my 17" notebook.. I'm not sure how > Gmail sends my messages, but looking at the 'Show original' option, it > seems it breaks long lines but might be at a different length too. See, now this is what gets me. Gmail is folding my mail at some indeterminant length that seems *much* shorter than even 80 characters, but it willingly lets email from non-gmail sources play across the page as they see fit. I don't see why Gmail doesn't just make it a QP item and not force line breaks upon me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 10:12 AM, Matijn Woudt wrote: > On Fri, Aug 24, 2012 at 5:01 PM, tamouse mailing lists > wrote: >> OT Reply -- just frustrated with the way email screws up program >> listings. It's a royal pain to have to strip out code and then put it >> in an editor and tidy it up just to be able to make heads or tails out >> of something. There are lots of code pasting sites around, but that >> breaks up the continuity of the list archive. No solution, just >> frustrated > > You're absolutely right, it frustrates me too pretty often. Perhaps we > should make it a guideline to do both? The active followers will be > able to read the code at one of the code pasting sites, and the > archives still have the code. > > - Matijn I'm wondering if it might make sense to have a code-pasting site specifically for PHP lists? Is that asking too much? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 10:20 AM, David OBrien wrote: > In gmail if I see something is totally screwed up visually I click the > little dropdown where you'd select reply to all and then choose show > original... > It shows the source of the email in monospaced font so if looks like it was > meant to *Sometimes* that works. If you do that with the sample from the OP, it still has several indentation/alignment issues. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Content thoughts
On Fri, Aug 24, 2012 at 1:24 PM, Jim Lucas wrote: > Well, not to talk bad about Gmail (I use it for personal accounts), but I > like using a client that I do have some control over what it does to my > email. Making sure that it retains my formatting is one of my first > requirements. I'd like that as well, however, I access my various gmail and other email accounts from so many different machines, I can't rely on any one particular client or even machine. Thus, I'm pretty much stuck with the web interface. FWIW, I am pretty sure sending out email from a standard client to a gmail account doesn't suffer the same issues. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UTC on php log bug
On Fri, Aug 24, 2012 at 8:48 PM, Martín Marqués wrote: > Whats up with this bug?: https://bugs.php.net/bug.php?id=60723 perhaps direct the query (such as it is) to php-development -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error breaking in and out of php into html code
On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan wrote: > On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote: > >> Can you tell us what is the error shown in browser or CLI? >> >> On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan >> wrote: >> >> > I've just inherited some (pretty awful code) that I have to make some >> > edits to, and came across a bit of a problem. A lot of the code breaks >> > in and out of PHP and into HTML code: >> > >> > > > while(condition) >> > { >> > ?> >> > some html here >> > > > } >> > ?> >> > >> > But when I check this my PHP parser is saying that this is a syntax >> > error (checked in the browser and CLI). I know this is code from a >> > working site, so it must be a setting within my PHP configuration. >> > >> > Now, I'm intending to re-write this anyway, as the logic is all over the >> > place (SQL queries within the HTML, no separation of code and content, >> > dozens of warnings all over the place) but I was wondering what setting >> > causes this. It's mostly a curiosity thing really, as this thing is >> > going to be re-written faster than an school project the eve before >> > hand-in. >> > >> > -- >> > Thanks, >> > Ash >> > http://www.ashleysheridan.co.uk >> > >> > >> > >> >> > > > Through the browser I get: > > Parse error: syntax error, unexpected $end > in /var/www/html/siteinquestion/index.php on line 356 > > Through the CLI I get: > > PHP Parse error: syntax error, unexpected $end in index.php on line 356 > > Parse error: syntax error, unexpected $end in index.php on line 356 > > Errors parsing index.php > > I've narrowed it down to the lines that used the breaking in and out of > PHP style. As soon as I comment out those it runs fine, albeit without > the content that code was intended to add. > > -- > Thanks, > Ash > http://www.ashleysheridan.co.uk > > I guess I would suspect errant spaces, or a missing closing tag, or even maybe a short code or something... very hard to say... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error breaking in and out of php into html code
On Sun, Aug 26, 2012 at 5:02 AM, Ashley Sheridan wrote: > > On Sun, 2012-08-26 at 04:36 -0500, tamouse mailing lists wrote: > > On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan > wrote: > > On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote: > > > >> Can you tell us what is the error shown in browser or CLI? > >> > >> On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan > >> wrote: > >> > >> > I've just inherited some (pretty awful code) that I have to make some > >> > edits to, and came across a bit of a problem. A lot of the code > >> > breaks > >> > in and out of PHP and into HTML code: > >> > > >> > >> > while(condition) > >> > { > >> > ?> > >> > some html here > >> > >> > } > >> > ?> > >> > > >> > But when I check this my PHP parser is saying that this is a syntax > >> > error (checked in the browser and CLI). I know this is code from a > >> > working site, so it must be a setting within my PHP configuration. > >> > > >> > Now, I'm intending to re-write this anyway, as the logic is all over > >> > the > >> > place (SQL queries within the HTML, no separation of code and > >> > content, > >> > dozens of warnings all over the place) but I was wondering what > >> > setting > >> > causes this. It's mostly a curiosity thing really, as this thing is > >> > going to be re-written faster than an school project the eve before > >> > hand-in. > >> > > >> > -- > >> > Thanks, > >> > Ash > >> > http://www.ashleysheridan.co.uk > >> > > >> > > >> > > >> > >> > > > > > > Through the browser I get: > > > > Parse error: syntax error, unexpected $end > > in /var/www/html/siteinquestion/index.php on line 356 > > > > Through the CLI I get: > > > > PHP Parse error: syntax error, unexpected $end in index.php on line 356 > > > > Parse error: syntax error, unexpected $end in index.php on line 356 > > > > Errors parsing index.php > > > > I've narrowed it down to the lines that used the breaking in and out of > > PHP style. As soon as I comment out those it runs fine, albeit without > > the content that code was intended to add. > > > > -- > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > I guess I would suspect errant spaces, or a missing closing tag, or > even maybe a short code or something... very hard to say... > > > None of the above. This is a working copy of code. It's just to do with > these lines breaking in and out of PHP. Byte encodings? Line endings? Sorry, I'm sure you've thought of all this.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple forms one page
On Sun, Aug 26, 2012 at 11:08 PM, Rosie Williams wrote: > > Hi all, > I am a newbie to PHP. I have several php forms which were originally on > separate pages now included in the one page. Each form had the following code > in it: > function mysql_fix_string($string){ if (get_magic_quotes_gpc()) $string = > stripslashes($string);return mysql_real_escape_string($string);} > function mysql_entities_fix_string($string){return > htmlentities(mysql_fix_string($string));} > However I am only able to include it in one of the forms on the new page with > multiple scripts due to the fatal error that I can only declare the function > once. So for testing I have commented these lines out of the other scripts. I > need to know what the security implications of this are? Do the scripts that > do not contain these lines run without it or is it included automatically > every time the database is accessed regardless of which script is accessing > it? > If not how do I deal with it? > thanks in advanceRosie Hi, Rosie, welcome! This is something you will likely encounter again, so it is good to learn it now. You can put the two functions into another php file, and include that file in your main script using include_once or require_once (there is a difference that you might want to read up on at some point). If you include this before you start your form processing, the functions will be available to you at the point you need them. You only need do this once in the php script where you will be using them, so you can safely delete all the other occurances of the function definitions. The nice part is, really, that you can use that same include file in other projects as you go along, saving retyping the code. This is something that you may want to think about for other such functions as well. Modularity and code reuse are one of the big ways to achieving more efficiency in your work. http://us.php.net/manual/en/function.include-once.php http://us.php.net/manual/en/function.require-once.php (cf. http://us.php.net/manual/en/function.require.php to learn how the "require" differs from the "include") Best of luck, Tamara aka tamouse__ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include selectively or globally?
What do your performance measurements show so you have actual data comparisons to make a valid decsion? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT (maybe not): Drupal vs WordPress
On Tue, Aug 28, 2012 at 3:36 PM, Adam Richardson wrote: > On Tue, Aug 28, 2012 at 3:07 PM, Larry Garfield > wrote: >> Only semi-joking line that's been making the rounds lately: >> >> If you want to build a blog, use Wordpress. >> If you want to build Wordpress, use Drupal. >> If you want to build Drupal, use Symfony2. > > Here's another semi-joking line :) > > If build a blog using Wordpress, build Wordpress using Drupal, build a > Drupal using Symfony2, I'd feel the same way I feel after drinking > several beers, eating a pizza, snacking on some hot wings, and > polishing it all off with a banana split: bloated :) > > Adam > > -- > Nephtali: A simple, flexible, fast, and security-focused PHP framework > http://nephtaliproject.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Is that the analog to Sagan's "how to make an apple pie" ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract Occurrences AFTER ... and before "-30-"
On Sun, Sep 2, 2012 at 11:31 AM, John Taylor-Johnston wrote: > I'll never get it. Newest work on top of the pile, instead of digging :)) Usually order reverse in flow conversations your do? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract Occurrences AFTER ... and before "-30-"
On Sun, Sep 2, 2012 at 7:57 PM, John Taylor-Johnston wrote: > Just to prove me right, our mail clients start quoting from the top too :)p Exactly. The quoting starts from the *top*. The problem is that the cursor to start typing is also put there by default. Step back before MS Outlook started that trend, which, of course, one could *change* if one wanted to. The standard proforma for mail, usenet, notes, bbs's, and most other forms (c.f. the Well, etc) were all bottom post, or even better intermingled with ONLY the relevant parts used, not the entire message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load rtf file
On Mon, Sep 3, 2012 at 12:23 AM, John Taylor-Johnston wrote: > I have a big giant RTF file. I could convert it to plain text. BUT can PHP > do it for me? Not directly, although there might be libraries out there to do it, but none that I'm aware of off-hand. Perl, of course does this with RTF::TEXT::Converter < http://search.cpan.org/~sargie/RTF-Parser-1.09/lib/RTF/TEXT/Converter.pm >. To use this, you'd have to hand off the processing to a perl script using shell_exec, proc_open, etc. > I want to read the text file into a string. This does the job well, right? > http://php.net/manual/en/function.file-get-contents.php > > This is it? Not more complicated? > > | $homepage = file_get_contents('http://www.example.com/text.txt'); > echo $homepage; > ?> | Not really complicated, *however* there is a php.ini option that must be set for this to work: < http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen > > What about this? > http://www.php.net/manual/en/function.file.php > > || |$lines = file('http://www.example.com/');| > |echo $lines; > ?>| > > Is there any big difference? *HUGE* difference: * file_get_contents returns a single *string* with the entire content. * file returns an *array* of lines. Change your above snippets to use 'var_dump($lines);' instead of 'echo $lines;' to see the structural difference. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load rtf file
On Mon, Sep 3, 2012 at 6:04 PM, Micky Hulse wrote: > On Mon, Sep 3, 2012 at 3:52 PM, Tedd Sperling wrote: >> Maybe if I was on a Windoze machine, but I'm on a Mac. > > What about TextEdit.app? Or Open/Libre Office? As for the OP, I know you can script Open/Libre Office with python to do things like batch convert RTF to Text. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] templeting
On Mon, Sep 3, 2012 at 8:49 PM, David McGlone wrote: > On Monday, September 03, 2012 09:45:23 PM David OBrien wrote: >> On Sep 3, 2012 9:15 PM, "David McGlone" wrote: >> > Does anyone use any templeting system for any projects? If so what would >> > anyone recommend? I looked at Code Ignitor, but it seems the templeting >> >> system is optional and left out by default. > >> I use smarty > > I've used smarty in the past and was thinking about that, but PEAR is absolete > anymore and I don't really know of a good replacement. :-/ I use Smarty as well, but I've never used it from PEAR. I just use the version downloadable from http://www.smarty.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php