[PHP] Anyone fancy getting paid to improve my PHP in London?
Do any experienced PHP programmers in London fancy helping me improve my PHP? I'd like to know where my code could be improved and to be shown how an experienced programmer would approach a new site. I'd rather pay the right person a high amount than find someone cheap! Thanks, Tom PS - May as well take this opportunity to thank to everyone on the list that's helped me out so far!
Re: [PHP] Anyone fancy getting paid to improve my PHP in London?
2009/3/13 Robert Cummings > On Fri, 2009-03-13 at 17:16 +0000, Tom Chubb wrote: > > Do any experienced PHP programmers in London fancy helping me improve my > > PHP? > > I'd like to know where my code could be improved and to be shown how an > > experienced programmer would approach a new site. > > I'd rather pay the right person a high amount than find someone cheap! > > Thanks, > > Send me a blank cheque-- if it clears then I'll get back to you... from > someplace warm... by a beach while drinking martinis... and getting a > massage... from more than one lady... > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > > Rob, if ($blank_cheque == "cleared") { $set_temp = "warm"; $drinks_order = "martini"; $service = "massage"; $num_ladies = $tasty . " & " . $robs_wife; } else { $blank_cheque = 0; } Think you should be looking at the latter ;) -- Tom Chubb t...@tomchubb.com | tomch...@gmail.com 07912 202846
Re: [PHP] Let me google that for you.
2009/4/17 Jay Blanchard > [snip] > I was thinking that you create a form with one input box, which would > insert > into the search box for the lmgtfy link. One of the questions I have is > how > would I convert or insert a + sign in between the search words. > > For example, if I created the input, someone insert "search, php, > forum", > how would I convert it to http://www.lmgtfy.com/?=search+php+forum...? > [/snip] > > You would start by RTFM; > > http://us3.php.net/manual/en/function.str-replace.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Shouldn't that be: http://lmgtfy.com/?q=php+function.str-replace.php ;)
Re: [PHP] templating engine options
"Sometimes I'm the windshield and sometimes I'm the bug" Ha ha! Love that!
Re: [PHP] forms problem
2009/6/3 PJ : > The code: > ...snip > > > accès client name="title" value="" size="10" /> > mot de passe > value=" entrez " /> > Inscription > > snip... > > PROBLEM 1: On Firefox3, the first input (accès client) does not accept > any input, does not show the cursor; the second input (mot de passe) > works fine. > > PROBLEM 2: The form does not appear on IE 6 > > Running FreeBSD 7.1, apache22, php 5, using sessions, CSS > > Am I doing something wrong? > > -- > Hervé Kempf: "Pour sauver la planète, sortez du capitalisme." > - > Phil Jourdan --- p...@ptahhotep.com > http://www.ptahhotep.com > http://www.chiccantine.com/andypantry.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I think the first problem is because both your inputs are defined as "title". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Google Calendar Integration
2009/6/5 Leonard Burton > HI All, > > Has anyone used Google Calendar (of course via PHP) to allow clients > to schedule appointments from the business's webpage? If so, would > you please tell me how you made it so it would only show the client > times which were available and of course not listing private client > details? > > Thanks, > > -- > Leonard Burton, N9URK > http://www.jiffyslides.com > serv...@jiffyslides.com > leonardbur...@gmail.com > > "The prolonged evacuation would have dramatically affected the > survivability of the occupants." > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Haven't done this yet, but this this link should help: http://framework.zend.com/download/gdata Apparently you don't have to use the whole Zend framework for it. HTH
Re: [PHP] difference between two times? Date_diff and DateTime::diff
The first example here may help: http://us3.php.net/manual/en/function.time.php 2009/6/16 Matthew Croud > Hi Dajve and Tom, > > Thanks again, I totally didn't realise that this function is yet to be > implemented in the mainstream PHP, > > So is there no function that exists in vanilla PHP that can take two > dates/times and supply the difference ? > If there isn't I do apologise, i've been talking to my friend who does > ASP.net and he said he was sure there is for PHP. > > > > > > > On 16 Jun 2009, at 13:11, Dajve Green wrote: > > >> Hi Matthew, >> >> A quick note on the DateTime::diff() method - it's only available as from >> PHP 5.3, which is currently in release candidate stage, meaning unless you >> have your own server running PHP, it won't be available to use (hopefully >> - >> I would be sceptical of any webhost which rolls out RCs on production >> servers). >> >> If you need to know what version of PHP you're running, use: >> phpversion() or phpinfo() >> >> -Original Message- >>> From: Matthew Croud [mailto:m...@obviousdigital.com] >>> Sent: 16 June 2009 12:42 >>> To: Tom Chubb >>> Cc: PHP General list >>> Subject: Re: [PHP] difference between two times? Date_diff and >>> DateTime::diff >>> >>> Hi Tom, >>> >>> Thanks for the reply, I believe I have a fair understanding of >>> functions, and I have followed the example on the PHP manual page ( >>> http://uk3.php.net/manual/en/function.date-diff.php >>> ), ideally I want to know how to use the class DateTime::diff, how >>> can I use the DateTime::diff to get the difference between two times/ >>> dates ? I suppose then I'm after the syntax >>> >>> would it be like this for example: >>> $DIfferenceInTime = DateTime::diff(10:00,12:32); >>> >>> Thanks again for helping me out. >>> >>> >>> >>> On 16 Jun 2009, at 12:33, Tom Chubb wrote: >>> >>> Matt, >>>> Do you understand how to use functions? >>>> A function is defined like this: >>>> >>>> function () { >>>> //code goes here >>>> } >>>> >>>> You can pass arguments to be used in a function like this: >>>> >>>> function($arg1, $arg2) { >>>> //code goes here >>>> } >>>> >>>> In the first example on the following page: >>>> >>> http://uk3.php.net/manual/en/function.date-diff.php >>> >>>> To call the function you need to provide two arguments: $dtTime1 & >>>> $dtTime2 >>>> >>>> To use in a script, you need to first define the function, as per >>>> the example: >>>> >>>> >>> >>>> function GetDeltaTime($dtTime1, $dtTime2) >>>> { >>>> $nUXDate1 = strtotime($dtTime1->format("Y-m-d H:i:s")); >>>> $nUXDate2 = strtotime($dtTime2->format("Y-m-d H:i:s")); >>>> >>>> $nUXDelta = $nUXDate1 - $nUXDate2; >>>> $strDeltaTime = "" . $nUXDelta/60/60; // sec -> hour >>>> >>>> $nPos = strpos($strDeltaTime, "."); >>>> if (nPos !== false) >>>> $strDeltaTime = substr($strDeltaTime, 0, $nPos + 3); >>>> >>>> return $strDeltaTime; >>>> } >>>> >>>> ?> >>>> >>>> Then you need to call the function like this: >>>> >>>> >>> GetDeltaTime("time1-goes-here", "time2-goes-here") >>>> ?> >>>> >>>> And it should spit out the difference. >>>> >>>> Code is untested and if you didn't follow that I suggest you read up >>>> on functions: http://www.w3schools.com/php/php_functions.asp >>>> >>>> Hope this helps - I'm probably in a similar situation to you and >>>> have been dabbling with PHP for a few years just as a hobby but >>>> thought I'd try and help out. >>>> You'll learn a lot from reading this list as well. >>>> >>>> Cheers and good luck, >>>> >>>> Tom >>>> >>>> >>>> 2009/6/16 Matthew Croud >>>> >>>> Hello, >>>> >>>> My journey of learning PHP is going well, so i've decided to make a >>>> small program which works o
Re: [PHP] Calendar
http://lmgtfy.com/?q=javascript+calendar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regarding Accesing mp3 with php
2009/6/26 Gautam Bhatia : > hello all, > Is there anyway in php by which i can get the total play > time of a mp3 , I found some information while doing the google thing > using some 3rd party plug ins like getID3 but without any luck, Any help > in this case would be helpful. Thank you. > Regards, > > Gautam Bhatia . > > > > I use this and find it very good: http://getid3.sourceforge.net/ Here is some code I'm using on one of my sites. Bit messy - but it works for me :) require_once('../public_html/audio/getid3/getid3.php'); function show_audio($type) { //Set path to audio files if ($type == "rmx") { $path = '/audio/productions/remixes/'; $DirectoryToScan = '../public_html/audio/productions/remixes/'; } elseif ($type == "pro") { $path = '/audio/productions/original/'; $DirectoryToScan = '../public_html/audio/productions/original/'; } $getID3 = new getID3; $dir = opendir($DirectoryToScan); while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_file($FullFileName)) { set_time_limit(30); $ThisFileInfo = $getID3->analyze($FullFileName); getid3_lib::CopyTagsToComments($ThisFileInfo); echo (!empty($ThisFileInfo['comments_html']['artist']) ? implode('', $ThisFileInfo['comments_html']['artist']) : ' ') . " - "; echo (!empty($ThisFileInfo['comments_html']['title']) ? implode('', $ThisFileInfo['comments_html']['title']) : ' '); echo " (" . (!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ') . ") - "; echo (!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ') . " - "; echo 'Download'; } } } Then I simply upload audio files to the right directory and I don't have to update the page that lists them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
2009/7/3 Luke > 2009/7/3 Daniel Brown > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson wrote: > > > Hello all, > > > > > > Do I have to add session_start() at the beginning of every page so that > > > the $_SESSION variables work on all pages or do I use session_start() > on > > > the first page and something else on other pages? > > > > Yes, unless you're using session autoloading. Also, in most > > cases, you will only need to call session_start() once (before > > referencing $_SESSION), even if $_SESSION is accessed in an included > > file. > > > > -- > > > > daniel.br...@parasane.net || danbr...@php.net > > http://www.parasane.net/ || http://www.pilotpig.net/ > > Check out our hosting and dedicated server deals at > > http://twitter.com/pilotpig > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Some people have a file called init.php, which would contain > session_start(); as well as other things that need to be done every page > load (connect to the database perhaps?) and they just 'require' that at the > top of every page. > > -- > Luke Slater > http://dinosaur-os.com/ > :O) > Never thought of that. Sounds like quite a good idea. Can anyone tell me if there's any reason for not doing that, even on pages that do not require session data? Or perhaps use an htaccess file to server side include a file file to all files under an admin folder or something and another to destroy the session. I'm thinking of smaller, low-traffic sites. I know people are going to say, if they're small sites, why can't you only start sessions on the relevant pages but it sounds like it could work well for me.
Re: [PHP] Sessions
2009/7/3 Ashley Sheridan > On Friday 03 July 2009 09:41:40 Tom Chubb wrote: > > 2009/7/3 Luke > > > > > 2009/7/3 Daniel Brown > > > > > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson > wrote: > > > > > Hello all, > > > > > > > > > > Do I have to add session_start() at the beginning of every page so > > > > > that the $_SESSION variables work on all pages or do I use > > > > > session_start() > > > > > > on > > > > > > > > the first page and something else on other pages? > > > > > > > > Yes, unless you're using session autoloading. Also, in most > > > > cases, you will only need to call session_start() once (before > > > > referencing $_SESSION), even if $_SESSION is accessed in an included > > > > file. > > > > > > > > -- > > > > > > > > daniel.br...@parasane.net || danbr...@php.net > > > > http://www.parasane.net/ || http://www.pilotpig.net/ > > > > Check out our hosting and dedicated server deals at > > > > http://twitter.com/pilotpig > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Some people have a file called init.php, which would contain > > > session_start(); as well as other things that need to be done every > page > > > load (connect to the database perhaps?) and they just 'require' that at > > > the top of every page. > > > > > > -- > > > Luke Slater > > > http://dinosaur-os.com/ > > > > > > :O) > > > > Never thought of that. Sounds like quite a good idea. > > Can anyone tell me if there's any reason for not doing that, even on > pages > > that do not require session data? > > Or perhaps use an htaccess file to server side include a file file to all > > files under an admin folder or something and another to destroy the > > session. I'm thinking of smaller, low-traffic sites. > > I know people are going to say, if they're small sites, why can't you > only > > start sessions on the relevant pages but it sounds like it could work > well > > for me. > > > It's easier to maintain if you use one include file like Luke said. You > won't > get much overhead from a call to session_start() on a page that doesn't use > sessions. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > Great, Cheers Ash, T -- Tom Chubb t...@tomchubb.com | tomch...@gmail.com
[PHP] MySQL Queries in PHP
Hi List, Just wanted to pick your brains please? I'm trying to standardise on the way I query databases and move away from the Dreamweaver built-in functions (which I know you all hate!) ;) I've been on this list for about 5 years now and I don't think I've ever heard anyone mention the Pear packages, eg: MDB_QueryTool and wondered if there was any reason why not? I found some classes on phpclasses and have already started using one of them by Henry Chen and there are plenty more. I am still using Dreamweaver as the text editor for PHP on a Mac and trying to code things manually but building SQL queries are one of the biggest problems I come across. To be honest, Dreamweaver used to be fine but for me, historically on both PC and Mac, after a while it decides that it can connect to the DB but cannot see any of the tables which prevent using the wizards which is why I'm moving away from it. All tutorials on the net are different and I'd like some info on the best practices that you guys follow when dealing with MySQL. Thanks in advance, Tom PS - I'm only dealing with simple queries: show, insert, update, delete, etc.
Re: [PHP] MySQL Queries in PHP
2009/7/14 Eddie Drapkin > On Tue, Jul 14, 2009 at 2:29 AM, Tom Chubb wrote: > > Hi List, > > Just wanted to pick your brains please? > > I'm trying to standardise on the way I query databases and move away from > > the Dreamweaver built-in functions (which I know you all hate!) ;) > > I've been on this list for about 5 years now and I don't think I've ever > > heard anyone mention the Pear packages, eg: MDB_QueryTool and wondered if > > there was any reason why not? > > I found some classes on phpclasses and have already started using one of > > them by Henry Chen and there are plenty more. > > I am still using Dreamweaver as the text editor for PHP on a Mac and > trying > > to code things manually but building SQL queries are one of the biggest > > problems I come across. > > To be honest, Dreamweaver used to be fine but for me, historically on > both > > PC and Mac, after a while it decides that it can connect to the DB but > > cannot see any of the tables which prevent using the wizards which is why > > I'm moving away from it. > > All tutorials on the net are different and I'd like some info on the best > > practices that you guys follow when dealing with MySQL. > > Thanks in advance, > > > > Tom > > > > PS - I'm only dealing with simple queries: show, insert, update, delete, > > etc. > > > > I've always enjoyed writing SQL myself, as it is sort of challenging > and interesting to do, so I've always written them by hand. I'd > recommend learning SQL yourself, as the queries tools generate, in my > experience, are never quite as useful as hand-written, nor as fast. > It's not that difficult to do and if you can't write queries yourself, > whether you do or not, no one is going to take you very seriously as a > web developer. So, my best suggestion to you is to just buck up and > learn SQL, as useless as that is. > That's still useful Eddie, and I suspect that's what a lot of people actually do. I do understand SQL (at a very basic level) but I'm trying to start using the same custom functions for future projects and thought, "I wonder if there's anything in Pear?"
Re: [PHP] Scrapping email content
2009/7/15 Areba Collins > Hello guys, i have a quick one: > > Im working on an app that reads email and converts it into a post on a > forum, everything works fine except the threaded comments at the > bottom. I would like to delete everything that is from a previous > email (which usually begins with on this ate, so and so wrote : and > then comments preceeded by >> > > Does anyone know a straightforward function to accomplish this? > > Regards, > Collins -Nairobi KE. > > -- > If you have an apple and I have an apple and we exchange these apples > then you and I will still each have one apple. But if you have an idea > and I have an idea and we exchange these ideas, then each of us will > have two ideas. > > George Bernard Shaw > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > How about marking the email as read and not deleting it. Compare following emails to previous read emails and strip out any common text and strip out "> " and any other common indentation, etc.
Re: [PHP] php.net down?
2009/7/16 Thijs Lensselink > Anybody noticed php.net is down? > > It's responding to pings. But no pages load. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > UK servers are working: uk2.php.net
[PHP] Directory Listing
Hi gang, I'm trying to create a script to read the files in a folder (approx 2000) and get the filename, path and last modified date in a tabulated format to copy into excel. (We have been issued a CD and need to get all files documented and assigned to an owner.) I've tried loads of different scripts but can't get them working with all the features. I think the best one to work with is this (although I'm having problems getting the date but don't worry about that at the moment) Here is an example of what I'm getting out from the $dirTree array: Array ( [./Tender] => Array ( [0] => 9216_100_REV_V1.0_bound.dwg ) [./Tender/Tender Docs] => Array ( [0] => BAA Works Terms v1.1 (22.05.08).pdf [1] => Contents of Volumes 1 and 2.pdf [2] => Cover Letter and Instructions.doc [3] => Form of Tender.doc ) [./Tender/Tender Docs/Health and Safety Questionnaire] => Array ( [0] => NT Baggage Tender Questionaire rev2.xls ) [./Tender/Tender Docs/NTB BH Lighting] => Array ( [0] => 3J-B-1 PIR.xls [1] => 3J-B-2B PIR.xls [2] => 3J-B-2R PIR.xls [3] => 3J-B-3R PIR.xls [4] => 3J-D PIR.xls [5] => 4G-G PIR.xls [6] => 4J-B-1B PIR.xls [7] => 4J-B-1R PIR.xls [8] => 4J-B-2B PIR.xls [9] => 4J-B-2R PIR.xls [10] => 4J-B-4 PIR.xls [11] => 5G-G PIR.xls ) I'm having problems getting my head round how to get access the array data so that I can format it how I want, eg: Folder Filename Tender 9216_100_REV_V1.0_bound.dwg Tender/Tender Docs BAA Works Terms v1.1 (22.05.08).pdf Tender/Tender Docs Contents of Volumes 1 and 2.pdf etc. I'm trying to do this at work (php is a hobby and this is the first time I've tried to use it in my electrical engineering job) in notepad without any code highlighting, etc. and tearing my hair out to try and avoid going through the CD manually! Could anybody please help or let me know which function I need to read up on? I've tried countless searches on array formatting, etc and not getting anywhere. Thanks in advance, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
2009/8/25 Ashley Sheridan : > On Tue, 2009-08-25 at 12:06 +0200, Ralph Deffke wrote: >> I would say >> foreach( $dirTree as $key => $value ){ >> echo $key .""; >> foreach( $value as $v){ >> echo $v ."; >> } >> } >> >> something like that >> >> ralph_def...@yahoo.de >> "Tom Chubb" wrote in message >> news:4577934f0908250241i195dc691x3f8c552e72791...@mail.gmail.com... >> Hi gang, >> I'm trying to create a script to read the files in a folder (approx >> 2000) and get the filename, path and last modified date in a tabulated >> format to copy into excel. (We have been issued a CD and need to get >> all files documented and assigned to an owner.) >> >> I've tried loads of different scripts but can't get them working with >> all the features. >> I think the best one to work with is this (although I'm having >> problems getting the date but don't worry about that at the moment) >> >> > error_reporting(E_ALL); >> ini_set('display_errors', true); >> function getDirectory($path = '.', $ignore = '') { >> $dirTree = array (); >> $dirTreeTemp = array (); >> $ignore[] = '.'; >> $ignore[] = '..'; >> >> $dh = @opendir($path); >> >> while (false !== ($file = readdir($dh))) { >> >> if (!in_array($file, $ignore)) { >> if (!is_dir("$path/$file")) { >> >> $dirTree["$path"][] = $file; >> >> } else { >> >> $dirTreeTemp = getDirectory("$path/$file", $ignore); >> if (is_array($dirTreeTemp))$dirTree = >> array_merge($dirTree, $dirTreeTemp); >> } >> } >> } >> closedir($dh); >> >> return $dirTree; >> } >> >> $ignore = array('.htaccess', 'error_log', 'cgi-bin', 'php.ini', >> '.ftpquota'); >> >> $dirTree = getDirectory('./Tender', $ignore); >> ?> >> >> > print_r($dirTree); >> ?> >> >> >> > getdirectory('./Tender'); >> //or >> //get_dir_iterative(/*etc.*/); >> ?> >> >> >> >> >> >> >> Here is an example of what I'm getting out from the $dirTree array: >> >> Array >> ( >> [./Tender] => Array >> ( >> [0] => 9216_100_REV_V1.0_bound.dwg >> ) >> >> >> [./Tender/Tender Docs] => Array >> ( >> [0] => BAA Works Terms v1.1 (22.05.08).pdf >> [1] => Contents of Volumes 1 and 2.pdf >> [2] => Cover Letter and Instructions.doc >> >> [3] => Form of Tender.doc >> ) >> >> [./Tender/Tender Docs/Health and Safety Questionnaire] => Array >> ( >> [0] => NT Baggage Tender Questionaire rev2.xls >> ) >> >> >> [./Tender/Tender Docs/NTB BH Lighting] => Array >> ( >> [0] => 3J-B-1 PIR.xls >> [1] => 3J-B-2B PIR.xls >> [2] => 3J-B-2R PIR.xls >> [3] => 3J-B-3R PIR.xls >> >> [4] => 3J-D PIR.xls >> [5] => 4G-G PIR.xls >> [6] => 4J-B-1B PIR.xls >> [7] => 4J-B-1R PIR.xls >> [8] => 4J-B-2B PIR.xls >> [9] => 4J-B-2R PIR.xls >> >> [10] => 4J-B-4 PIR.xls >> [11] => 5G-G PIR.xls >> ) >> >> I'm having problems getting my head round how to get access the array >> data so that I can format it how I want, eg: >> >> Folder Filename >> Tender 9216_100_REV_V1.0_bound.dwg >> Tender/Tender Docs BAA Works Terms v1.1 (22.05.08).pdf >> Tender/Tender Docs Contents of Volumes 1 and 2.pdf >> >> etc. >> >> I'm trying to do this at work (php is a hobby and this is the first >> time I've tried to use it in my electrical engineering job) in notepad >> without any code highlighting, etc. and tearing my hair out to try and >> avoid going through the CD manually! >> >> Could anybody please help or let me know which function I need to read >> up on? I've tried countless searches on array formatting, etc and not >> getting anywhere. >> >> Thanks in advance, >> >> Tom >> >> >> > Funnily eno
Re: [PHP] Re: Directory Listing
2009/8/25 Ralph Deffke : > I would say > foreach( $dirTree as $key => $value ){ > echo $key .""; > foreach( $value as $v){ > echo $v ."; > } > } > > something like that > > ralph_def...@yahoo.de > "Tom Chubb" wrote in message > news:4577934f0908250241i195dc691x3f8c552e72791...@mail.gmail.com... > Hi gang, > I'm trying to create a script to read the files in a folder (approx > 2000) and get the filename, path and last modified date in a tabulated > format to copy into excel. (We have been issued a CD and need to get > all files documented and assigned to an owner.) > > I've tried loads of different scripts but can't get them working with > all the features. > I think the best one to work with is this (although I'm having > problems getting the date but don't worry about that at the moment) > > error_reporting(E_ALL); > ini_set('display_errors', true); > function getDirectory($path = '.', $ignore = '') { > $dirTree = array (); > $dirTreeTemp = array (); > $ignore[] = '.'; > $ignore[] = '..'; > > $dh = @opendir($path); > > while (false !== ($file = readdir($dh))) { > > if (!in_array($file, $ignore)) { > if (!is_dir("$path/$file")) { > > $dirTree["$path"][] = $file; > > } else { > > $dirTreeTemp = getDirectory("$path/$file", $ignore); > if (is_array($dirTreeTemp))$dirTree = > array_merge($dirTree, $dirTreeTemp); > } > } > } > closedir($dh); > > return $dirTree; > } > > $ignore = array('.htaccess', 'error_log', 'cgi-bin', 'php.ini', > '.ftpquota'); > > $dirTree = getDirectory('./Tender', $ignore); > ?> > > print_r($dirTree); > ?> > > > getdirectory('./Tender'); > //or > //get_dir_iterative(/*etc.*/); > ?> > > > > > > > Here is an example of what I'm getting out from the $dirTree array: > > Array > ( > [./Tender] => Array > ( > [0] => 9216_100_REV_V1.0_bound.dwg > ) > > > [./Tender/Tender Docs] => Array > ( > [0] => BAA Works Terms v1.1 (22.05.08).pdf > [1] => Contents of Volumes 1 and 2.pdf > [2] => Cover Letter and Instructions.doc > > [3] => Form of Tender.doc > ) > > [./Tender/Tender Docs/Health and Safety Questionnaire] => Array > ( > [0] => NT Baggage Tender Questionaire rev2.xls > ) > > > [./Tender/Tender Docs/NTB BH Lighting] => Array > ( > [0] => 3J-B-1 PIR.xls > [1] => 3J-B-2B PIR.xls > [2] => 3J-B-2R PIR.xls > [3] => 3J-B-3R PIR.xls > > [4] => 3J-D PIR.xls > [5] => 4G-G PIR.xls > [6] => 4J-B-1B PIR.xls > [7] => 4J-B-1R PIR.xls > [8] => 4J-B-2B PIR.xls > [9] => 4J-B-2R PIR.xls > > [10] => 4J-B-4 PIR.xls > [11] => 5G-G PIR.xls > ) > > I'm having problems getting my head round how to get access the array > data so that I can format it how I want, eg: > > Folder Filename > Tender 9216_100_REV_V1.0_bound.dwg > Tender/Tender Docs BAA Works Terms v1.1 (22.05.08).pdf > Tender/Tender Docs Contents of Volumes 1 and 2.pdf > > etc. > > I'm trying to do this at work (php is a hobby and this is the first > time I've tried to use it in my electrical engineering job) in notepad > without any code highlighting, etc. and tearing my hair out to try and > avoid going through the CD manually! > > Could anybody please help or let me know which function I need to read > up on? I've tried countless searches on array formatting, etc and not > getting anywhere. > > Thanks in advance, > > Tom > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Ended up tidying it up and using Ralph's idea and now working nicely. (Need to 'view source' to see it properly as I was having issues copying into excel but this is fine for what I'm trying to do.) Now I'm having problems getting the file date. I'm using: $modDate["$file"][] = date ("d m Y", filemtime($file)); and trying to merge it into the array but I'm missing something. Any ideas? Refer to lines 5, 14, 17, New code: $folder ){ //echo $key . "\n"; //Don't need folders as they're shown with the files foreach( $folder as $file){ echo str_replace("./Tender", "", $key) . "/\t" . $file . "\n"; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
I've been playing about more and now I have the following code: $folder ){ echo "\n"; //Don't need folders as they're shown with the files foreach( $folder as $file){ echo str_replace("./", "", $key) . "\t" . $file . "\t\n"; //Pad out with a tab for easy import into excel } } print_r($dirTree); //Just using this for debugging ?> The output is fine for the paths and filenames but I still can't get the dates showing. It's getting the correct date for some but not all. I did something else earlier and found that all the dates were 01/01/1970 but at least there was a date for every file but can't remember how I go there! Here is a sample output result: Gatwick Tender Documents . 9216_100_REV_V1.0_bound.dwg Tender Docs BAA Works Terms v1.1 (22.05.08).pdf Tender Docs Contents of Volumes 1 and 2.pdf Tender Docs Cover Letter and Instructions.doc Tender Docs Form of Tender.doc Tender Docs/Health and Safety Questionnaire NT Baggage Tender Questionaire rev2.xls BAA Works Terms v1.1 (22.05.08).pdf 29/07/2009 Contents of Volumes 1 and 2.pdf 29/07/2009 Cover Letter and Instructions.doc 29/07/2009 Form of Tender.doc 29/07/2009 Tender Docs/NTB BH Lighting 3J-B-1 PIR.xls Tender Docs/NTB BH Lighting 3J-B-2B PIR.xls Tender Docs/NTB BH Lighting 3J-B-2R PIR.xls Tender Docs/NTB BH Lighting 3J-B-3R PIR.xls Tender Docs/NTB BH Lighting 3J-D PIR.xls Tender Docs/NTB BH Lighting 4G-G PIR.xls Tender Docs/NTB BH Lighting 4J-B-1B PIR.xls Tender Docs/NTB BH Lighting 4J-B-1R PIR.xls Tender Docs/NTB BH Lighting 4J-B-2B PIR.xls Tender Docs/NTB BH Lighting 4J-B-2R PIR.xls Tender Docs/NTB BH Lighting 4J-B-4 PIR.xls Tender Docs/NTB BH Lighting 5G-G PIR.xls Can anyone shed any light on it? I'm about to admit defeat! Thanks in advance and I'm not being lazy - I really am trying!!! :( Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
2009/8/26 Ashley Sheridan : > On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote: >> I've been playing about more and now I have the following code: >> >> > error_reporting(E_ALL); >> ini_set('display_errors', true); >> >> function getDirectory($path = '.', $ignore = '') { >> $dirTree = array (); >> $dirTreeTemp = array (); >> $fileDate = array (); >> $ignore[] = '.'; >> $ignore[] = '..'; >> $dh = @opendir($path); >> while (false !== ($file = readdir($dh))) { >> if (!in_array($file, $ignore)) { >> if (!is_dir("$path/$file")) { >> $dirTree["$path"][] = $file; >> $fileDate["$file"][] = date ("d/m/Y", >> filemtime("$path/$file")); >> } else { >> $dirTreeTemp = getDirectory("$path/$file", $ignore); >> if (is_array($dirTreeTemp))$dirTree = >> array_merge($dirTree, $dirTreeTemp, $fileDate); >> } >> } >> } >> closedir($dh); >> return $dirTree; >> } >> >> $ignore = array('.htaccess', 'Thumbs.db', 'index.php'); >> $dirTree = getDirectory('.', $ignore); >> getdirectory('.'); >> >> echo "Gatwick Tender Documents\n"; >> >> foreach( $dirTree as $key => $folder ){ >> echo "\n"; //Don't need folders as they're shown with the files >> foreach( $folder as $file){ >> echo str_replace("./", "", $key) . "\t" . $file . "\t\n"; //Pad >> out with a tab for easy import into excel >> >> } >> } >> print_r($dirTree); //Just using this for debugging >> ?> >> >> >> The output is fine for the paths and filenames but I still can't get >> the dates showing. It's getting the correct date for some but not all. >> I did something else earlier and found that all the dates were >> 01/01/1970 but at least there was a date for every file but can't >> remember how I go there! >> >> >> Here is a sample output result: >> >> Gatwick Tender Documents >> >> . 9216_100_REV_V1.0_bound.dwg >> >> Tender Docs BAA Works Terms v1.1 (22.05.08).pdf >> Tender Docs Contents of Volumes 1 and 2.pdf >> Tender Docs Cover Letter and Instructions.doc >> Tender Docs Form of Tender.doc >> >> Tender Docs/Health and Safety Questionnaire NT Baggage Tender >> Questionaire rev2.xls >> >> BAA Works Terms v1.1 (22.05.08).pdf 29/07/2009 >> >> Contents of Volumes 1 and 2.pdf 29/07/2009 >> >> Cover Letter and Instructions.doc 29/07/2009 >> >> Form of Tender.doc 29/07/2009 >> >> Tender Docs/NTB BH Lighting 3J-B-1 PIR.xls >> Tender Docs/NTB BH Lighting 3J-B-2B PIR.xls >> Tender Docs/NTB BH Lighting 3J-B-2R PIR.xls >> Tender Docs/NTB BH Lighting 3J-B-3R PIR.xls >> Tender Docs/NTB BH Lighting 3J-D PIR.xls >> Tender Docs/NTB BH Lighting 4G-G PIR.xls >> Tender Docs/NTB BH Lighting 4J-B-1B PIR.xls >> Tender Docs/NTB BH Lighting 4J-B-1R PIR.xls >> Tender Docs/NTB BH Lighting 4J-B-2B PIR.xls >> Tender Docs/NTB BH Lighting 4J-B-2R PIR.xls >> Tender Docs/NTB BH Lighting 4J-B-4 PIR.xls >> Tender Docs/NTB BH Lighting 5G-G PIR.xls >> >> >> Can anyone shed any light on it? >> I'm about to admit defeat! >> >> Thanks in advance and I'm not being lazy - I really am trying!!! :( >> >> Tom >> > > The only time I've ever noticed this problem was on a 32bit system where > the files were above 2GB each. When the files are that size, none of the > information functions seem to work correctly, including the filesize, > date, etc. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > > Cheers Ash, I read that too, but I was getting the error for over 90% of the files which I know are generally only a few MB. I've started from scratch again and come up with something that is easier to deal with but still having one last problem! The output I'm getting is: /9216_100_REV_V1.0_bound.dwg05/08/2009 /Tender Docs/BAA Works Terms v1.1 (22.05.08).pdf29/07/2009 /Tender Docs/Contents of Volumes 1 and 2.pdf29/07/2009 /Tender Docs/Cover Letter and Instructions.doc 29/07/2009 /Tender Docs/Form of Tender.doc 29/07/2009 /Tender Docs/Health and Safety Questionnaire/NT Baggage Tender Questionaire rev2.xls 29/07/2009 /Tender Docs/Health and Safety Questionnaire14/08/2009 /Tender Docs/NTB BH Lighting/3J-B-1 PIR.xls 13/05/2009 /Tender Docs/NTB BH Lighting/3J-B-2B PIR.xls13/05/2009 /Tender Docs/NTB BH Lighting/3J-B-2R PIR.xls13/05/2009 /Tender Docs/NTB BH Lighting/3J-B-3R PIR.xls13/05/2009 /Tender Docs/NTB BH Lighting/3J-D PIR.xls 13/05/2009 All I need to do now is get a tab between the filename & the path I'm thinking I need to explode on the "/" and somehow match the last value but stumped at the moment! Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
2009/8/26 Ashley Sheridan : > On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote: >> 2009/8/26 Ashley Sheridan : >> > On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote: >> >> I've been playing about more and now I have the following code: >> >> >> >> > >> error_reporting(E_ALL); >> >> ini_set('display_errors', true); >> >> >> >> function getDirectory($path = '.', $ignore = '') { >> >> $dirTree = array (); >> >> $dirTreeTemp = array (); >> >> $fileDate = array (); >> >> $ignore[] = '.'; >> >> $ignore[] = '..'; >> >> $dh = @opendir($path); >> >> while (false !== ($file = readdir($dh))) { >> >> if (!in_array($file, $ignore)) { >> >> if (!is_dir("$path/$file")) { >> >> $dirTree["$path"][] = $file; >> >> $fileDate["$file"][] = date ("d/m/Y", >> >> filemtime("$path/$file")); >> >> } else { >> >> $dirTreeTemp = getDirectory("$path/$file", $ignore); >> >> if (is_array($dirTreeTemp))$dirTree = >> >> array_merge($dirTree, $dirTreeTemp, $fileDate); >> >> } >> >> } >> >> } >> >> closedir($dh); >> >> return $dirTree; >> >> } >> >> >> >> $ignore = array('.htaccess', 'Thumbs.db', 'index.php'); >> >> $dirTree = getDirectory('.', $ignore); >> >> getdirectory('.'); >> >> >> >> echo "Gatwick Tender Documents\n"; >> >> >> >> foreach( $dirTree as $key => $folder ){ >> >> echo "\n"; //Don't need folders as they're shown with the files >> >> foreach( $folder as $file){ >> >> echo str_replace("./", "", $key) . "\t" . $file . "\t\n"; //Pad >> >> out with a tab for easy import into excel >> >> >> >> } >> >> } >> >> print_r($dirTree); //Just using this for debugging >> >> ?> >> >> >> >> >> >> The output is fine for the paths and filenames but I still can't get >> >> the dates showing. It's getting the correct date for some but not all. >> >> I did something else earlier and found that all the dates were >> >> 01/01/1970 but at least there was a date for every file but can't >> >> remember how I go there! >> >> >> >> >> >> Here is a sample output result: >> >> >> >> Gatwick Tender Documents >> >> >> >> . 9216_100_REV_V1.0_bound.dwg >> >> >> >> Tender Docs BAA Works Terms v1.1 (22.05.08).pdf >> >> Tender Docs Contents of Volumes 1 and 2.pdf >> >> Tender Docs Cover Letter and Instructions.doc >> >> Tender Docs Form of Tender.doc >> >> >> >> Tender Docs/Health and Safety Questionnaire NT Baggage Tender >> >> Questionaire rev2.xls >> >> >> >> BAA Works Terms v1.1 (22.05.08).pdf 29/07/2009 >> >> >> >> Contents of Volumes 1 and 2.pdf 29/07/2009 >> >> >> >> Cover Letter and Instructions.doc 29/07/2009 >> >> >> >> Form of Tender.doc 29/07/2009 >> >> >> >> Tender Docs/NTB BH Lighting 3J-B-1 PIR.xls >> >> Tender Docs/NTB BH Lighting 3J-B-2B PIR.xls >> >> Tender Docs/NTB BH Lighting 3J-B-2R PIR.xls >> >> Tender Docs/NTB BH Lighting 3J-B-3R PIR.xls >> >> Tender Docs/NTB BH Lighting 3J-D PIR.xls >> >> Tender Docs/NTB BH Lighting 4G-G PIR.xls >> >> Tender Docs/NTB BH Lighting 4J-B-1B PIR.xls >> >> Tender Docs/NTB BH Lighting 4J-B-1R PIR.xls >> >> Tender Docs/NTB BH Lighting 4J-B-2B PIR.xls >> >> Tender Docs/NTB BH Lighting 4J-B-2R PIR.xls >> >> Tender Docs/NTB BH Lighting 4J-B-4 PIR.xls >> >> Tender Docs/NTB BH Lighting 5G-G PIR.xls >> >> >> >> >> >> Can anyone shed any light on it? >> >> I'm about to admit defeat! >> >> >> >> Thanks in advance and I'm not being lazy - I really am trying!!! :( >> >> &
Re: [PHP] Re: Directory Listing
2009/8/26 hack988 hack988 : > "have a tab inserted in the middle of the path" ??? What it mean,I > can't find any diffrent between last one with other rows. > To clarify - this is what I was getting: /<<>>9216_100_REV_V1.0_bound.dwg<<>>05/08/2009 /Tender Docs/<<>>BAA Works Terms v1.1 (22.05.08).pdf<<>>29/07/2009 /Tender Docs/<<>>Health and Safety Questionnaire 14/08/2009 -- Tom Chubb t...@tomchubb.com | tomch...@gmail.com 07912 202846 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
2009/8/26 Ashley Sheridan : > On Wed, 2009-08-26 at 18:21 +0800, hack988 hack988 wrote: >> "have a tab inserted in the middle of the path" ??? What it mean,I >> can't find any diffrent between last one with other rows. >> > It might be because of the way that the mailing list software converts > the content? > > I tend to always make CSV files comma delimited, as it's easier on the > eye to open a file up in a ext editor and hack away at it, and you have > the benefit of being able to use other whitespace characters (tabs, > spaces, etc) to line up field data (although field values should really > be enclosed in quotation marks if you go down this route just in-case) > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > > Thanks Ash, I've learnt quite a lot trying to get this working! And yeah I think I might change it to csv now. -- Tom Chubb t...@tomchubb.com | tomch...@gmail.com 07912 202846 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Directory Listing
2009/8/26 hack988 hack988 : > your means "Health and Safety Questionnaire"is directory? > so you want it display like this > full dir path <> filename<>date > Yes. I did try using if(is_dir($file)) { insert tab } but couldn't get it to work. Also tried counting the length of the $file value and and comparing it to the position of the first "/" using strpos and if they matched then assume it was a directory but couldn't get it to work either. Out of the 2000 files there are less than 50 directories so it wasn't too much trouble to go through and sort them out manually but I'd love to hear a way of doing it properly -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [SOLVED] Re: Directory Listing
2009/8/26 Steve : > Ashley Sheridan wrote: >> >> On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote: >> >>> >>> 2009/8/26 Ashley Sheridan : >>> >>>> >>>> On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote: >>>> >>>>> >>>>> I've been playing about more and now I have the following code: >>>>> >>>>> >>>> error_reporting(E_ALL); >>>>> ini_set('display_errors', true); >>>>> >>>>> function getDirectory($path = '.', $ignore = '') { >>>>> $dirTree = array (); >>>>> $dirTreeTemp = array (); >>>>> $fileDate = array (); >>>>> $ignore[] = '.'; >>>>> $ignore[] = '..'; >>>>> $dh = @opendir($path); >>>>> while (false !== ($file = readdir($dh))) { >>>>> if (!in_array($file, $ignore)) { >>>>> if (!is_dir("$path/$file")) { >>>>> $dirTree["$path"][] = $file; >>>>> $fileDate["$file"][] = date ("d/m/Y", >>>>> filemtime("$path/$file")); >>>>> } else { >>>>> $dirTreeTemp = getDirectory("$path/$file", $ignore); >>>>> if (is_array($dirTreeTemp))$dirTree = >>>>> array_merge($dirTree, $dirTreeTemp, $fileDate); >>>>> } >>>>> } >>>>> } >>>>> closedir($dh); >>>>> return $dirTree; >>>>> } >>>>> >>>>> $ignore = array('.htaccess', 'Thumbs.db', 'index.php'); >>>>> $dirTree = getDirectory('.', $ignore); >>>>> getdirectory('.'); >>>>> >>>>> echo "Gatwick Tender Documents\n"; >>>>> >>>>> foreach( $dirTree as $key => $folder ){ >>>>> echo "\n"; //Don't need folders as they're shown with the files >>>>> foreach( $folder as $file){ >>>>> echo str_replace("./", "", $key) . "\t" . $file . "\t\n"; //Pad >>>>> out with a tab for easy import into excel >>>>> >>>>> } >>>>> } >>>>> print_r($dirTree); //Just using this for debugging >>>>> ?> >>>>> >>>>> >>>>> The output is fine for the paths and filenames but I still can't get >>>>> the dates showing. It's getting the correct date for some but not all. >>>>> I did something else earlier and found that all the dates were >>>>> 01/01/1970 but at least there was a date for every file but can't >>>>> remember how I go there! >>>>> >>>>> >>>>> Here is a sample output result: >>>>> >>>>> Gatwick Tender Documents >>>>> >>>>> . 9216_100_REV_V1.0_bound.dwg >>>>> >>>>> Tender Docs BAA Works Terms v1.1 (22.05.08).pdf >>>>> Tender Docs Contents of Volumes 1 and 2.pdf >>>>> Tender Docs Cover Letter and Instructions.doc >>>>> Tender Docs Form of Tender.doc >>>>> >>>>> Tender Docs/Health and Safety Questionnaire NT Baggage Tender >>>>> Questionaire rev2.xls >>>>> >>>>> BAA Works Terms v1.1 (22.05.08).pdf 29/07/2009 >>>>> >>>>> Contents of Volumes 1 and 2.pdf 29/07/2009 >>>>> >>>>> Cover Letter and Instructions.doc 29/07/2009 >>>>> >>>>> Form of Tender.doc 29/07/2009 >>>>> >>>>> Tender Docs/NTB BH Lighting 3J-B-1 PIR.xls >>>>> Tender Docs/NTB BH Lighting 3J-B-2B PIR.xls >>>>> Tender Docs/NTB BH Lighting 3J-B-2R PIR.xls >>>>> Tender Docs/NTB BH Lighting 3J-B-3R PIR.xls >>>>> Tender Docs/NTB BH Lighting 3J-D PIR.xls >>>>> Tender Docs/NTB BH Lighting 4G-G PIR.xls >>>>> Tender Docs/NTB BH Lighting 4J-B-1B PIR.xls >>>>> Tender Docs/NTB BH Lighting 4J-B-1R PIR.xls >>>>> Tender Docs/NTB BH Lighting 4J-B-2B PIR.xls >>>>> Tender D
Re: [PHP] List all files in directory
On 06/03/07, Helder Lopes <[EMAIL PROTECTED]> wrote: Hi people How to php give to me a list of all files in one directory to make an editor??? http://php.net/readdir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple page not found 404 script - PHP
I think I'm missing something, but this works: http://arubaguide.org/arubaguide/index.php?page=advertise and if I put in a type such as: http://arubaguide.org/arubaguide/index.php?page=advertisd I get the 404 error page. I think the problem with using $_GET[catcode]??? On 30/03/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote: indeed.. it should be catcode instead of page.:-(. but still its not working :S ""Zoltán Németh"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 2007. 03. 30, péntek keltezéssel 14.45-kor Dwayne Heronimo ezt írta: >> Dear All, >> >> I have made a simple php script that will show an 404.php error page when >> an >> item is removed. >> >> You can see the page here: >> http://arubaguide.org/arubaguide/categories.php?catcode=art >> >> But some how this is not working. It is displaying the 404 page and the >> normal page. > > in the above link you do not give a "page" parameter at all... so from > where should the script get it? > > greets > Zoltán Németh > >> >> >> > >> /* function to get an external file into a vatiable */ >> function get_include_contents($filename) { >>if (is_file($filename)) { >>ob_start(); >>include $filename; >>$contents = ob_get_contents(); >>ob_end_clean(); >>return $contents; >>} >>return false; >> } >> >> /* configuration file */ >> >> $errormsg = get_include_contents('404.php'); >> $pagename = $_GET['page']; >> >> /* end configuration file */ >> >> if(file_exists("$pagename")) >> { >> include "$pagename"; >> } >> else >> { >> echo "$errormsg"; >> } >> ?> >> >> is the $pagename not enough for this script? >> >> Let me know.. >> >> Dwayne >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] warning message to hide
Look at http://devzone.zend.com/node/view/id/652 It explains it there. On 14/04/07, Alain Roger <[EMAIL PROTECTED]> wrote: Hi, Today i discovered that when my host webserver has some issue with PostgreSQL database, my code displays the following error message : *"Warning*: pg_connect() [function.pg-connect<http://www.immense.sk/function.pg-connect>]: Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "pgsql.exohosting.sk" and accepting TCP/IP connections on port 5432? in */www/.php* on line yyy." I would like instead of that, to display my own error message... in fact, i would like to display something like : "We are sorry but temporary we have some technical issues. Please try again later". how can i do that ? i tried to do : $conn = pg_connect($conn_string); if ($conn) // check if database is online { // close database connection pg_close($conn); } else { // impossible to connect to DB die('Maintenance in progress... Try later.'); } but it still display the previous warning message. thanks for your help. -- Alain Windows XP SP2 PostgreSQL 8.1.4 Apache 2.0.58 PHP 5 -- Tom Chubb [EMAIL PROTECTED]
[PHP] PHP Dynamic Form Generator
Dear list, I'm currently reviewing a load of scripts to dynamically generate a form for a membership system. I have designed a registration form, and once registered and logged in there are a load of different options relevant to people's profile (which will all be radio check boxes) in a 2nd form. As the number of these check-boxes may change, I'd like to be able to read the structure of the relevant table and generate the form from that. I just wanted to ask everyone for any advice on this and which scripts you use? I'm not being lazy, but currently I'm looking at 8 of them from phpclasses.org and sourceforge and I'm sure someone out there knows exactly what I'm looking for. Thanks in advance, Tom -- Tom Chubb [EMAIL PROTECTED]
Re: [PHP] Converting URL's to hyperlinks.
2009/9/4 Daevid Vincent > > > > -Original Message- > > From: Lupus Michaelis > > [mailto:mickael+...@lupusmic.org > ] > > Sent: Friday, September 04, 2009 7:46 AM > > To: php-general@lists.php.net > > Subject: Re: [PHP] Converting URL's to hyperlinks. > > > > Daevid Vincent a écrit : > > > Maybe I misunderstood the OP, > >OP ? > > Original Poster > > > > but wouldn't this (or something like it) be > > Note the "something like it". I didn't write his app, just provided a > starting point. > > > > $url = preg_replace("/(\...@\w+\.[a-za-z]{2,3})/i", " > > href='mailto:$1'>$1", $url); > >This violate the numerous RFC about mail addresses, and some other > > stuffs. > > Blah blah blah. > I've used this code for about 6 years now and have yet to find emails that > it didn't work for. If someone has some funky (whacky) RFC extremity, then > so be it. That's their problem. Most people have NORMAL emails that follow > the above. > > But you are correct, I have revised it to be a little more forgiving of > some > allowed characters... > > preg_replace("/([\w\.\-...@[\w\.\-_]+\.\w{2,6})/i", > > > > > > > $url = > > preg_replace("/\s(http:\/\/)?(\w*\.?\w*\.[a-zA-Z]{2,3}.*?\s)/i", " > > href='http://$2' target='_blank'>$2", $url); > > > >Same as previously. What about .info, .museum and so on tld ? > > What about them? It's going to depend on how/where you use this. In my > case, > 2 and 3 letter domains are all I encounter. It's trivial to make it {2,6} > if > you really are going to encounter a .museum domain. DOUBTFUL, but sure, > I'll > concede the three extra letters. ;-) > > However, you point out a few edge cases and so I optimized mine and now use > this one: > http://snipplr.com/view/2371/regex-regular-expression-to-match-a-url/ > > > > Oh, and your regex isn't > > smart (you use the case insensitivity flag, but seek A-Z > > characters...) :D > > Noted. Thanks for the optimization. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Thanks for posting that! Will be really handy for me!
Re: [PHP] String scrambling
!niBgo /* $str = "Bingo!"; str_shuffle($str); */ :)
Re: [PHP] PHP broadcast mailer
2009/10/18 Paul M Foster > On Sat, Oct 17, 2009 at 01:41:03AM -0400, Brian Hazelton wrote: > > > I am in charge of an email newsletter list and making sure it gets sent > > out in time. My problem is I have never done broadcast emailing and > > right now we have 400 subscribers but want to build a system that can > > scale well regardless of the number of subscribers. Right now I use > > mysql to store the email and use phpmailer in a loop to send an email to > > each of the emails in the db, it is already slow with just 400(takes > > around 10 min (i think that's slow isnt it?). Has anyone built a > > broadcast email script and willing to help me? > > > > Use PHPList. It's free. > > Paul > > I second that and make sure you add an SPF Key to your domain: http://old.openspf.org/wizard.html You should be able to get the SMTP limits from your host and these can be configured in PHPlist. The bounce handling takes away a lot of admin work once your list starts getting larger and people's email addresses change/stop working. Tom
[PHP] Trouble with using isset and form posting
I think I'm missing something here really obvious! I am using a script where you get a variable from one page and post to another. I've just realised that some people are jumping straight to the second page (it rates higher in search engines) so the variable (yourname) remains unset. I want to use isset so that if there is no variable the field is pre-filled to prompt for Your Name? A simplified version of the code is shown below and is posting to itself. Any idea what I'm doing wrong? Thanks in advance, Tom Untitled Document Please Enter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What is the GD library and what can I do with it ?
Pete, I thought I should send you another reply as I felt that depending on your experience, you may not fully understand the resonses from other members. Firstly, create a new .php file and using the following source code: * Untitled Document ** Upload this to your webspace and then view your .php page and it will tell you everything you need to know about your server's PHP install. Regards, Tom -Original Message- From: Pete [mailto:[EMAIL PROTECTED] Sent: 11 May 2004 09:15 To: [EMAIL PROTECTED] Subject: [PHP] What is the GD library and what can I do with it ? Hi, What is the GD library ? How can I install it. I have PHP integrated as a module. Judging by the discussion that people have here the GD library sounds interesting. How do I know if my shared host has it ? Thank you. -- 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] tracking ip and its location
Try: http://www.1phpstreet.com/vb/scripts/ShowCode.asp?txtCodeId=318&lngWId=8 Regards, Tom -Original Message- From: adwinwijaya [mailto:[EMAIL PROTECTED] Sent: 14 May 2004 07:39 To: PHP Subject: [PHP] tracking ip and its location Hello PHP, Is there any function/class to search the location based on ip address ? For example, I got ip 144.xxx.xxx.xxx and it can displaying that IP comes from X country. thxs -- Best regards, adwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Sockets
This may sound a bit cheeky, but I've spent most of today looking for some examples of sockets. I've managed to create a socket and it's connecting ok, but next I need to find a way of sending an ASCII string to the remote computer and echo-ing the results back to my screen. (Using a text box to submit the ascii string) This is for simulating comms between a UNIX server and a piece of electrical equipment (for which I'm using my laptop). Does anyone know of similar examples. Thanks in advance, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to find path for PHP script
Does anyone know a quick way to find the full path on a shared hosting plan to use in an include file? Thanks, Tom
[PHP] File Upload within form
I am trying to design a custom form script and I've stumbled across a small problem. I want to implement a file upload into the form, but rather than posting to another file I want to refresh the form and then show that there has been a file uploaded. I know about changing the form action to: But, what do I need to change to update the script? I'm a newbie, but trying hard to learn! Thanks in advance for any help. Tom /n"); print("File size: $file_size bytes/n"); if(copy($file, "$path/$filename")){ print("Your File was uploaded successfully"); }else{ print("ERROR, your file was not successfully uploaded"); } unlink($file); } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ISSET problem with Form
If you use ISSET together with a hidden field when posting a form to itself to enter a second-state, is there a way of using it again to get to a third-state. Basically, I'm trying to convert a 3 file script into a single file and first I check to see if it's been submitted and then using ELSE I echo out the second form. But how do I use isset again? Do I need to unset the variable from the first stage of the form? If so, how do I do this and prevent the form going back to the first form state? I've had the script working with two states but can't get the third state working!!! Any help or alternative ideas much appreciated as this is causing me a serious headache!!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Test Email
Sorry if anyone else gets this, but I'm not receiving any emails at the moment and wanted to check my subscription.
[PHP] Posting Data to MySQL
I am trying to design a form that posts the data to a DB, but being new to PHP/MySQL, it takes me ages to hand write the code and I'm sure there must be an easier way to do it? My form has 100 fields using 20 rows and 5 columns and it's taking me ages to write the code for it. Can anyone advise how they code large forms like that and if you know of any software to make it easier? I've searched Google for hours and checked loads of Database scripts on sites like Hotscripts, but can't find anything. Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Posting Data to MySQL
I have had quite a lot of response from this, so I felt I should elaborate. Basically, I am a DJ and every week I submit a chart of the Top 20 records I am playing. I want a form with 5 columns (Position, Artist, Title, Label, Misc) And then obviously I am entering that for all 20 tracks. The database table also has a datepost so I can select from the week ending when I posted them. Thanks to everyone who has responded. Tom -Original Message- From: Robert Sossomon [mailto:[EMAIL PROTECTED] Sent: 24 June 2004 15:30 To: 'Tom Chubb'; [EMAIL PROTECTED] Subject: RE: [PHP] Posting Data to MySQL I actually found the perfect answer to this task in Google Answers. First you will need to know how your database tables are set up, secondly you need to figure out field names and such, thirdly you grab the data from the form and dump it into an insert statement (or update if the information was in the DB before). If you pass me some specifics I might be able to give you a hand. Robert -Original Message----- From: Tom Chubb [mailto:[EMAIL PROTECTED] Sent: Thursday, June 24, 2004 9:19 AM To: [EMAIL PROTECTED] Subject: [PHP] Posting Data to MySQL I am trying to design a form that posts the data to a DB, but being new to PHP/MySQL, it takes me ages to hand write the code and I'm sure there must be an easier way to do it? My form has 100 fields using 20 rows and 5 columns and it's taking me ages to write the code for it. Can anyone advise how they code large forms like that and if you know of any software to make it easier? I've searched Google for hours and checked loads of Database scripts on sites like Hotscripts, but can't find anything. Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Select
How can I query a MySQL table to get the latest results from a date field? Basically, I am inserting several records at a time at the end of each week. I want to have a page that displays the results for the last week only. The date format in the field is -MM-DD
[PHP] RE: [PHP-DB] Date Select
Jeffrey, Thanks for this, I've just realised that it's always the same no of inserts, so perhaps I should just order by date then my previous sort field and then limit the result to 20? (It's all 20 results that I need displayed) Thanks, Tom -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 25 June 2004 12:15 To: Tom Chubb Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Date Select >How can I query a MySQL table to get the latest results from a date field? >Basically, I am inserting several records at a time at the end of each week. >I want to have a page that displays the results for the last week only. >The date format in the field is -MM-DD if you want the latest row - select * from table order by max(date_column) limit 1; if you want rows in a range of dates there are lots o ways, and instead of showing one or two, I'd suggest taking a look at the manual on dates http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html, and seeing what fits your needs best. Seems like you may want to look at BETWEEN And if you don't want to use those, you are always free to use select * from table where date_column < '-mm-dd' and date_column < '-mm-dd' order by date_col desc HTH Jeff -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error Reporting
I ave a strange problem with my error reporting! I have set php.ini to: error_reporting = E_ALL but I don't see any errors. (After I was happy things were working on my Apache Test Server, I uploaded to my web host and discovered errors.) Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Send a page using mail()
I've read the manual for the mail function and extensively searched google, but I can't work out how I can email an html page (actually a php page). I want to query a DB and the email the displayed table to the user. Any help most appreciated. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best table structure
Please can someone let me know their opinion on the following: I have written some code for submitting a top 20 music chart online. I use the following to insert into mysql: INSERT INTO chart (name, chartpos, artist, title, label) VALUES ('$name', '1', '$artist', '$title', '$label'), ('$name', '2', '$artist2', '$title2', '$label2'), ('$name', '3', '$artist3', '$title3', '$label3'), -- repeat til - ('$name', '20', '$artist20', '$title20', '$label20'), Another page queries the table and sorts by name (multiple people submit charts) and latest date. My question is this: Would I be better keeping this format and inserting multiple rows on each submit, or to have one row for all 81 variables ($name, 20 x Position, 20 x Artists, 20 x Titles, 20 x Labels.) I know that the latter will be easier to query. Also, without maintenance, the size of the table for the current method will get extremely large. Will that affect server performance? I am still a newbie, so plain explanations would be most appreciated. Thanks very much in advance. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Merging PDF Documents
Please can someone tell me if this is easy to do or whether I should use a package already available... I want to upload a pdf file to a folder then for each subsequent upload, I want it to be appended to the original file. Each pdf is a timesheet, so I want to end up with one file for all timesheets instead of different files every week. What I'd like to know is which function I can use on PHP4? Is it PDF_begin_page_ext? Any help appreciated. Thanks, Tom -- Tom Chubb [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Merging PDF Documents
Unfortunately I can't use shell or install anything on my shared box. Any other suggestions? On 24/09/2007, George Pitcher <[EMAIL PROTECTED]> wrote: > Tom, > > I use a Java app called itext to merge PDFs. In my case, it's to add a PDF > cover created in PHP to a file produced in a wp/ocr package. You need to be > able to run exec() or shell() to use itext, but its free and quick. Let me > know if you want more info. > > George in Edinburgh > > > -Original Message- > > From: Tom Chubb [mailto:[EMAIL PROTECTED] > > Sent: 24 September 2007 1:24 pm > > To: PHP General List > > Subject: [PHP] Merging PDF Documents > > > > > > Please can someone tell me if this is easy to do or whether I should > > use a package already available... > > > > I want to upload a pdf file to a folder then for each subsequent > > upload, I want it to be appended to the original file. Each pdf is a > > timesheet, so I want to end up with one file for all timesheets > > instead of different files every week. > > > > What I'd like to know is which function I can use on PHP4? > > Is it PDF_begin_page_ext? > > Any help appreciated. > > > > Thanks, > > > > Tom > > > > -- > > Tom Chubb > > [EMAIL PROTECTED] > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- Tom Chubb [EMAIL PROTECTED] 07912 202846 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trouble trying to connect to gmail server.
This may not be relevant as I'm only glancing over this as I have to leave for a meeting, but you have to enable POP access in Gmail before you can download to another email client like Thunderbird or Outlook, so maybe the same applies? Anyway, I'm looking to find a way of accessing my gmail as I am unable to access it at work as the Gmail site is blocked so please let me know if you find a successful way of connecting! Thanks, Tom On 27/09/2007, Fábio Generoso <[EMAIL PROTECTED]> wrote: > *Hi Cris,* > > *I have tried to use:* > > *$mbox = > imap_open('{**pop.gmail.com:995/pop3}INBOX<http://pop.gmail.com:995/pop3%7DINBOX> > **<**http://pop.gmail.com:995/pop3%7DINBOX**>',* > > *> '@**gmail.com**', ');* > > *As you suggest but it didn't work. * > > > > *The time out is not for the function:* > > *imap_num_recent($mbox);* > > *It is for the function:* > > *imap_open('{pop.gmail.com:995/pop3}INBOX', '@**gmail.com**', > '**);* > > > > *In order to confirm that, I have created a new account with just 5 e-mails > and I have gotten the same problem.* > > *And... I also check that using the code without the function*: > imap_num_recent($mbox); *as* *bellow:* > > *$mbox = imap_open('{pop.gmail.com:995/pop3}INBOX','[EMAIL PROTECTED]', > 'O3S/4o1*');* > > *print_r(imap_alerts());* > > *print_r(imap_errors());* > > > > *I got the same message error:* > > *Warning**: imap_open(): Couldn't open stream > {pop.gmail.com:995/pop3}INBOXin c:\arquivos > de programas\easyphp1-8\www\index.php on line 4 > > Fatal error: Maximum execution time of 30 seconds exceeded in c:\arquivos de > programas\easyphp1-8\www\index.php on line 4 > > Notice: (null)(): POP3 connection broken in response (errflg=2) in > Unknownon line > 0* > > * * > > *So I have tried to use the function* *set_time_limit(0);* *to suppress the > time out but it still didn't work:* > > *set_time_limit(0);* > > *$mbox = imap_open('{pop.gmail.com:995/pop3}INBOX','[EMAIL PROTECTED]', > 'O3S/4o1*');* > > *print_r(imap_alerts());* > > *print_r(imap_errors());* > > > > *I got these errors:* > > *Warning**: imap_open(): Couldn't open stream > {pop.gmail.com:995/pop3}INBOXin c:\arquivos > de programas\easyphp1-8\www\index.php on line 4 > Array ( [0] => POP3 connection broken in response )* > > > > *Looks like I have reached the gmail server but for same configuration or > network issue, I'm not able to receive the answer. * > > *Any suggestion?* > > * * > > *Tks.* > > > On 9/24/07, Chris <[EMAIL PROTECTED]> wrote: > > > > > > > Array ( [0] => Host not found (#11001): pop3.gmail.com ) > > > > So pop3.gmail.com doesn't exist. > > > > > > > $mbox = imap_open('{pop.gmail.com:995/pop3}INBOX< > > http://pop.gmail.com:995/pop3%7DINBOX>', > > > '@gmail.com', '); > > > print_r(imap_alerts()); > > > print_r(imap_errors()); > > > $num_mens_not_read = imap_num_recent($mbox); > > > imap_close($mbox); > > > ?> > > > > > > I get these errors: > > > > > > Warning: imap_open(): Couldn't open stream { > > > pop.gmail.com:995/pop3}INBOX<http://pop.gmail.com:995/pop3%7DINBOX>in > > > c:\arquivos de programas\easyphp1-8\www\index.php on line 4 > > > Fatal error: Maximum execution time of 30 seconds exceeded in > > c:\arquivos de > > > programas\easyphp1-8\www\index.php on line 4 > > > Notice: (null)(): POP3 connection broken in response (errflg=2) in > > Unknown > > > on line 0 > > > > > > > > > This second code looks like ok for me, but for some reason I get this > > time > > > out. Do you have any idea what's going on? Did I miss some > > configuration? > > > > Line 4 is > > > > $num_mens_not_read = imap_num_recent($mbox); > > > > so it's taking too long to work out how many are recent. > > > > How many unread messages are there in your account? How many messages in > > total? > > > > -- > > Postgresql & php tutorials > > http://www.designmagick.com/ > > > -- Tom Chubb [EMAIL PROTECTED] 07912 202846 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help securing a server : Owned by W4n73d H4ck3r
Me too. Guess a lot of us can learn something here from another's misfortune. Thanks Robert and good luck On 09/11/2007, Edward Kay <[EMAIL PROTECTED]> wrote: > > > > > > I'd be interested in reading this thread. OK with me to keep it > > on the list. > > > > Ditto. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
[PHP] Gallery Script
Hi all, I have a working gallery script which reads a directory then shows all thumbnails, each linking to the full size image. I'm trying to change it so that the page shows an image (fullsize) then links to the previous/next images in the sequence & then all the thumbnails below (the bit that's working fine at the moment). The filenames are straight from the camera (eg DSC102834.jpg or something) so I know that I need to get all the filenames into an array then use the key indexing or something, but I'm not sure how to do it? Also I'm not sure if I should be using readdir or glob? I've modified the code below so that it just displays the text of the filename rather than the actual image to speed up testing/reduce bandwidth. If anyone could point me in the right direction I'd really appreciate it Here is my code: \r\n\r\n"; $count = 0; if(is_dir($folder)) { if($handle = opendir($folder)) { while(($file = readdir($handle)) !== false) { //Filter out any unwanted files if ($file !="thumbs.db" && $file !="_notes" && !is_dir($file)) { echo "" . $file . "\r\n"; $count++; if (($count % 4) == 0) { echo "\r\n"; echo "\r\n"; } } } closedir($handle); } } echo "\r\n\r\n"; echo "\r\n"; echo "There are " . $count . " photos"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Gallery Script
On 27/11/2007, Colin Guthrie <[EMAIL PROTECTED]> wrote: > Tom Chubb wrote: > > Hi all, > > I have a working gallery script which reads a directory then shows all > > thumbnails, each linking to the full size image. > > I'm trying to change it so that the page shows an image (fullsize) > > then links to the previous/next images in the sequence & then all the > > thumbnails below (the bit that's working fine at the moment). The > > filenames are straight from the camera (eg DSC102834.jpg or something) > > so I know that I need to get all the filenames into an array then use > > the key indexing or something, but I'm not sure how to do it? > > Also I'm not sure if I should be using readdir or glob? > > > > I've modified the code below so that it just displays the text of the > > filename rather than the actual image to speed up testing/reduce > > bandwidth. > > > > If anyone could point me in the right direction I'd really appreciate it > > If you don't mind relying on javascript then take a look at lightbox or > thickbox and similar soltuions. > > These are solutions where you only need to generate a gallery page with > the thumbnails and it will do the rest for you complete with > previous/next links and even thumbnails... > > Col > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I'm not against using Javascript, but I'd like to learn more about how to do it in PHP. (Admittedly it would probably be better in Javascript!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Gallery Script
On 27/11/2007, Andrew Peterson <[EMAIL PROTECTED]> wrote: > I'm assuming that everytime you page refreshes, it pulls in ALL the contents > of the directory? > > If you are, you could dynamically create the Prev/Next buttons. When you > create the link for each individual pictures, you could add the prev and > next files to the link: > > > $pictureLink = " href="picture.php?picture=pic2.jpeg&prev=pic1.jpeg&next=pid3.jpeg">Picture > 2 > > Make sense? > > -Andrew > > > PS - You could also google "PHP Photo Gallery", there are TON of scripts out > there. > > > > > On Nov 27, 2007 7:20 AM, Tom Chubb <[EMAIL PROTECTED]> wrote: > > > > > > > > On 27/11/2007, Colin Guthrie <[EMAIL PROTECTED]> wrote: > > > Tom Chubb wrote: > > > > Hi all, > > > > I have a working gallery script which reads a directory then shows all > > > > thumbnails, each linking to the full size image. > > > > I'm trying to change it so that the page shows an image (fullsize) > > > > then links to the previous/next images in the sequence & then all the > > > > thumbnails below (the bit that's working fine at the moment). The > > > > filenames are straight from the camera (eg DSC102834.jpg or something) > > > > so I know that I need to get all the filenames into an array then use > > > > the key indexing or something, but I'm not sure how to do it? > > > > Also I'm not sure if I should be using readdir or glob? > > > > > > > > I've modified the code below so that it just displays the text of the > > > > filename rather than the actual image to speed up testing/reduce > > > > bandwidth. > > > > > > > > If anyone could point me in the right direction I'd really appreciate > it > > > > > > If you don't mind relying on javascript then take a look at lightbox or > > > thickbox and similar soltuions. > > > > > > These are solutions where you only need to generate a gallery page with > > > the thumbnails and it will do the rest for you complete with > > > previous/next links and even thumbnails... > > > > > > Col > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > I'm not against using Javascript, but I'd like to learn more about how > > to do it in PHP. (Admittedly it would probably be better in > > Javascript!) > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- Tom Chubb [EMAIL PROTECTED] 07912 202846 Thanks Andrew, It's the link for the first image I'm having problems with. I can create a table with all the images, but I can't work out how to specify a single image to use as the main (larger image) Let's say that I've got 4 images called img1, img2, img3, img4. The script gets the filenames using readdir() but how do I associate the results with one image, eg img3? I thought it would be something like $files[2] then the prev/next would be $files[1] & $files[2] The section of code is: if ($file !="thumbs.db" && $file !="_notes" && !is_dir($file)) { echo "" . $file . "\r\n"; $count++; if (($count % 4) == 0) { echo "\r\n"; echo "\r\n"; } } } Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Glob
Please can someone help me understand the following: I have 4 images with a .jpg extension in a folder. The following reads all four: $files = glob("thumbs/{*.gif,*.jpg,}",GLOB_BRACE); All good, however, I noticed that if the extension is in capital letters, eg .JPG it doesn't work. Apparently this is because when using *. in glob it's case-sensitive (I have RTFM/STFW) So, I would expect the following to work, but it's reading each image twice! $files = glob("thumbs/{*.gif,*.jpg,*.jpeg,*,png}",GLOB_BRACE); What am I missing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Glob
On 29/11/2007, Robert Cummings <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-29 at 17:19 +0000, Tom Chubb wrote: > > Please can someone help me understand the following: > > I have 4 images with a .jpg extension in a folder. > > The following reads all four: > > $files = glob("thumbs/{*.gif,*.jpg,}",GLOB_BRACE); > > > > All good, however, I noticed that if the extension is in capital > > letters, eg .JPG it doesn't work. Apparently this is because when > > using *. in glob it's case-sensitive (I have RTFM/STFW) > > > > So, I would expect the following to work, but it's reading each image twice! > > $files = glob("thumbs/{*.gif,*.jpg,*.jpeg,*,png}",GLOB_BRACE); > > > > What am I missing? > > You have *,png when you should have *.png. The * is matching everything. > > Cheers, > Rob. > -- > ... > SwarmBuy.com - http://www.swarmbuy.com > >Leveraging the buying power of the masses! > ... > Wll spotted Rob, Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why is Japan not highlighted
On 31/12/2007, Mary Anderson <[EMAIL PROTECTED]> wrote: > in my scrolling list? > > Here is the offending code (abbreviated) > > Italy > Japan > Jersey > Jiangsu > Jiangxi > > I have data series which have a location specified. I wish to edit the > data series. I select the location from the database (Note: database > stuff is not a problem) and display a scrolling list with the location > specified by that data series highlighted. Problem is, even though the > option is marked selected, the Japan entry in the scrolling list does > not highlight. > > The offending page may be viewed at > > http://www.demog.berkeley.edu/~maryfran/memdev/edit_series.php?sr_data_series_id=2 > > > Sometimes when it loads, Japan is highlighted correctly. Sometimes > nothing is highlighted. Sometimes some random option in the list is > highlighted. Similar behavior is observed in the data series types > scrolling list next to the locations list on the page. > > I have been using Firefox 2.0.0.3. I just tried it out on IE7 and it > seems to work OK. Maybe it is a browser problem, but the XDynamic HTML > Definitive Reference seems to say that the selected attribute on option > works OK with mozilla. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > This is not PHP related, but I'll point you in the right direction. I have looked at your code and it is different to the source on the page found online. The line; Japan (Online version) Is different to: Japan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking user input of MM-DD-YYYY
On 15/01/2008, Adam Williams <[EMAIL PROTECTED]> wrote: > > I'm having users enter dates in MM-DD- format. is there a way to > check if what they have entered is invalid (like if they enter 1-15-2008 > instead of 01-15-2008) ? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You could use check boxes to make sure you get the right format first time and concatenate the results, or use strlen() to check there are enough characters and/or a regular expression.
[PHP] Word Wrap on highlight_file
Can anyone tell me how to wrap the results of highlight_file so it doesn't mess up the size of my table div? I tried the following and doesn't work! if ($ext == "phps") { $showcode = highlight_file($pathtoscripts . $_GET['file']); echo wordwrap($showcode, 70); } else { echo "Nice try, but you are not authorised to view the source of files with a $ext extension! ;)\n"; } Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Word Wrap on highlight_file
On 16/01/2008, Jochem Maas <[EMAIL PROTECTED]> wrote: > Tom Chubb schreef: > > Can anyone tell me how to wrap the results of highlight_file so it > > doesn't mess up the size of my table div? > > use CSS to control the visual display in the browser. > not to mention that 'table div' doesn't make much sense as a concept. > > probably you'll want to do something with the CSS property 'overflow'. > > > I tried the following and doesn't work! > > > > > > if ($ext == "phps") { > >$showcode = highlight_file($pathtoscripts . $_GET['file']); > > you are not santizing the request data, you need to be doing something > like the following (maybe someone else can check my example and > offer even better sanitizing code?): > > > $file = basename($_GET['file']); > > if (!$file) die('nice try'); > > $ext = explode('.', $file); > $ext = array_pop($ext); > > if ($ext != 'phps') die('nice try'); > > $file = $pathtoscripts . basename($_GET['file']); > > if (is_dir($file) || !is_readable($file)) die('nice try'); > > > > >echo wordwrap($showcode, 70);x > > } else { > >echo "Nice try, but you are not authorised to view the source of > > files with a $ext extension! ;)\n"; > > } > > > > Thanks, > > > > Tom > > > > Jochem, Thanks for that. So presumably it's not possible to do it in PHP? Haven't come across array_pop before - that's much quicker than what I was doing before. Thanks :) And thanks for the pointers about sanitizing. That was my next step! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (Slightly OT) are email address could be spammed
On 24/01/2008, Stut <[EMAIL PROTECTED]> wrote: > > > On 24 Jan 2008, at 15:42, Eric Butera wrote: > > I used to be hardcore pop only but now that I use gmail I don't care > > about any other mail client. It beats Thunderbird and Mail.app hands > > down. If you don't look at the right hand side you won't see the ads. > > :) I even have it set up now to pull my pop mail account and slap it > > in a filter. Plus I enjoy all the people complaining about how users > > shouldn't change the subject. The gmail thread grouping takes care of > > all that for me. :D The only real downside is you can't view the raw > > source of messages or get the headers. > > Top-right of any message, the down arrow next to the Reply link, > select Show Original... voila, the raw message complete with all > headers. > > I'm almost exclusively using Google Apps for all my mail (just a > couple of accounts left to move), and nothing much has changed about > what I do. I still have the choice between Thunderbird (IMAP) or > Webmail (Gmail), and I still have a complete archive of all my mail > since 1996. I have no complaints at all. > > -Stut > > -- > http://stut.net/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Has anyone found a way of getting Gmail to download from your pop mailbox every time you click refresh instead of going to accounts > check mail? Sometimes it doesn't check it for up to an hour!
Re: [PHP] Need assistance using sendmail or mail()
On 30/01/2008, Per Jessen <[EMAIL PROTECTED]> wrote: > > philip wrote: > > > Hi everyone, > > > > I need assistance using sendmail or mail() as my web hosting service > > does not allow opening sockets. > > > > This is the code I use: > > Philip, please state what sort of problems you are having. mail() and > sendmail are both easy to use from php. > And please don't post another 2000 lines of code. No-one is going to > read them. > > > > /Per Jessen, Zürich > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > He's just trying to get a nice share of the bytes on Dan's weekly posting summary ;)
Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....
On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote: > > I have been using: > > $nextSaturday= date("m/d/Y",strtotime("next saturday")); > > For months long time now with out problems, but in the last two days, it > went kind of funky. It is now returning: > > 02/09/2008 instead of the expected 02/02/2008. I have tried the same code > on another server and different version of PHP,and it works ok. > > More info: > > Shell date: Thu Jan 31 09:44:50 EST 2008 > echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST > echo date("Y-m-d g:i A T", strtotime("next saturday")); = 2008-02-09 12:00 > AM EST > > version: 4.3.9 (highest version we can have at the moment) > > I could not find this in the known bugs from this version > > So - is this something that is server or version specific? > > TIA! > > -- > Cheers > > Mike Morton > > > * > * Tel: 905-465-1263 > * Email: [EMAIL PROTECTED] > * > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > The manual says: *Warning* In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as +2. A typical solution to this is to use *"+1"*. Dunno if that helps you out? Is the other server > 4.4.0? http://uk3.php.net/strtotime
Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....
On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote: > > Ya - the other server is 4.4.7 > > However - this does not seem to be the problem necessarily: > > print date("m/d/Y",strtotime("next saturday")); > 02/09/2008 > > print date("m/d/Y",strtotime("next sunday")); > 02/10/2008 > > print date("m/d/Y",strtotime("next monday")); > 02/11/2008 > > print date("m/d/Y",strtotime("next tuesday")); > 02/12/2008 > > print date("m/d/Y",strtotime("next wednesday")); > 02/13/2008 > > print date("m/d/Y",strtotime("next thursday")); > 02/07/2008 > > So from today to next Thursday, the dates are all 1 week off? > > On 1/31/08 11:03 AM, "Tom Chubb" <[EMAIL PROTECTED]> wrote: > > > On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote: > >> > >> I have been using: > >> > >> $nextSaturday= date("m/d/Y",strtotime("next saturday")); > >> > >> For months long time now with out problems, but in the last two days, > it > >> went kind of funky. It is now returning: > >> > >> 02/09/2008 instead of the expected 02/02/2008. I have tried the same > code > >> on another server and different version of PHP,and it works ok. > >> > >> More info: > >> > >> Shell date: Thu Jan 31 09:44:50 EST 2008 > >> echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST > >> echo date("Y-m-d g:i A T", strtotime("next saturday")); = 2008-02-09 > 12:00 > >> AM EST > >> > >> version: 4.3.9 (highest version we can have at the moment) > >> > >> I could not find this in the known bugs from this version > >> > >> So - is this something that is server or version specific? > >> > >> TIA! > >> > >> -- > >> Cheers > >> > >> Mike Morton > >> > >> > >> * > >> * Tel: 905-465-1263 > >> * Email: [EMAIL PROTECTED] > >> * > >> > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > > The manual says: > > *Warning* > > > > In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as +2. > A > > typical solution to this is to use *"+1"*. > > > > Dunno if that helps you out? Is the other server > 4.4.0? > > http://uk3.php.net/strtotime > > -- > Cheers > > Mike Morton > > > * > * Tel: 905-465-1263 > * Email: [EMAIL PROTECTED] > * > > > > > An example that may help: when using strtotime("wednesday"), you will get different results whether you ask before or after wednesday, since strtotime always looks ahead to the *next* weekday. strtotime() does not seem to support forms like "this wednesday", "wednesday this week", etc. the following function addresses this by always returns the same specific weekday (1st argument) within the *same* week as a particular date (2nd argument). function weekday($day="", $now="") { $now = $now ? $now : "now"; $day = $day ? $day : "now"; $rel = date("N", strtotime($day)) - date("N"); $time = strtotime("$rel days", strtotime($now)); return date("Y-m-d", $time); } example use: weekday("wednesday"); // returns wednesday of this week weekday("monday, "-1 week"); // return monday the in previous week ps! the ? : statements are included because strtotime("") without gives 1 january 1970 rather than the current time which in my opinion would be more intuitive...
[PHP] [Slightly OT] Apple MacBook MAMP and Logic
I am looking to buy a Mac in a couple of weeks primarily for writing music using Apple Logic Studio 8 which will run absolutely fine on a MacBook. However, I am considering installing something like MAMP and using that as my development server too at which point I'm wondering whether I should invest in a MacBook Pro or whether I can get away with the lower spec MacBook. So I guess what I'm asking is, does having Apache, MySQL & PHP installed on a Mac use much system resources?
Re: [PHP] Need assistance using sendmail or mail()
On 31/01/2008, philip <[EMAIL PROTECTED]> wrote: > > > > Nathan Nobbe wrote: > > On Jan 30, 2008 2:47 AM, Per Jessen <[EMAIL PROTECTED]> wrote: > > > >> Philip, please state what sort of problems you are having. mail() and > >> sendmail are both easy to use from php. > >> And please don't post another 2000 lines of code. No-one is going to > >> read them. > >> > > > > amen to that brother! :) > > > > -nathan > Hi guys, > > I'm new to both this newsgroups and PHP. I need to get the form > submission working by Friday (Feb. 1). Any help with sendmailor mail() > will be appreciated. > > Philip > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You won't get any help unless you tell us what problems you're having? What errors do you see when you try and call the script? Have you gone to the FAQ on Sourceforge? Have you RTFM for the problem you're having? You won't get good responses unless you can show that you've made the initial effort
Re: [PHP] [Slightly OT] Apple MacBook MAMP and Logic
On 31/01/2008, Richard Lynch <[EMAIL PROTECTED]> wrote: > > On Thu, January 31, 2008 11:29 am, Tom Chubb wrote: > > I am looking to buy a Mac in a couple of weeks primarily for writing > > music > > using Apple Logic Studio 8 which will run absolutely fine on a > > MacBook. > > However, I am considering installing something like MAMP and using > > that as > > my development server too at which point I'm wondering whether I > > should > > invest in a MacBook Pro or whether I can get away with the lower spec > > MacBook. > > So I guess what I'm asking is, does having Apache, MySQL & PHP > > installed on > > a Mac use much system resources? > > They will use virtually NO system resources until you start developing > something that, errr, uses a lot of resources... :-) > > If you load up a million-row database and start writing monster select > queries in PHP against it, you'll probably strain any laptop. > > If you just install them and develop some simple pages with modest > queries, I don't think you can BUY a new laptop that won't handle > that. > > If you're doing music, get a bigger hard drive. You'll need it. > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some indie artist. > http://cdbaby.com/from/lynch > Yeah, I get a buck. So? > > Thanks for all your responses. Rich, I guess you're right! Anyway PHP is only a hobby for personal sites, so I shouldn't really worry too much but wanted to get a general feel from people. The only big advantage for the MBP is that it has Firewire 800 which would be better for that big hard-drive that I'll need ;)
Re: [PHP] Re: [Slightly OT] Apple MacBook MAMP and Logic
On 31/01/2008, Colin Guthrie <[EMAIL PROTECTED]> wrote: > > Tom Chubb wrote: > > Thanks for all your responses. > > Rich, I guess you're right! Anyway PHP is only a hobby for personal > sites, > > so I shouldn't really worry too much but wanted to get a general feel > from > > people. > > The only big advantage for the MBP is that it has Firewire 800 which > would > > be better for that big hard-drive that I'll need ;) > > I don't use a mac myself but a colleague does. He seems to have apache > and PHP installed on the machine but he generally uses the Xampp > package. I don't know if this is the official home page or but but start > here: http://www.apachefriends.org/en/xampp-macosx.html > > > HTH > > Col > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Thanks Colin, That's what I use on PC so it will probably do me fine on Mac too.
Re: [PHP] Re: Quick email address check
Can anyone recommend anything that would be good to use on an existing mailing list that is a few years old and didn't have any bounce handling? On 27/03/2008, Manuel Lemos <[EMAIL PROTECTED]> wrote: > > Hello, > > on 03/26/2008 02:28 PM Al said the following: > > I'm scripting a simple registry where the user can input their name and > > email address. > > > > I'd like to do a quick validity check on the email address they just > > inputted. I can check the syntax, etc. but want check if the address > > exists. I realize that servers can take a long time to bounce etc. I'll > > just deal with this separately. > > > > Is there a better way than simply sending a test email to see if it > > bounces? > > You may want to try this E-mail validation PHP class that does just > that. It simulates an attempt to send a message to the SMTP server of > the e-mail domain. It does not finish to send the message. The message > could still bounce later, but at least you will still detect some > invalid addresses. > > http://www.phpclasses.org/emailvalidation > > > -- > > Regards, > Manuel Lemos > > PHP professionals looking for PHP jobs > http://www.phpclasses.org/professionals/ > > PHP Classes - Free ready to use OOP components written in PHP > http://www.phpclasses.org/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Big companies that use PHP?
On 23/04/2008, Thiago Pojda <[EMAIL PROTECTED]> wrote: > Hey guys, > > > > I've been asked this common question: What big companies use PHP in big > apps? > > > > I don't know where to find this kind of stuff and, well. here I am :) > > > > > > Do any of you know? > > > > And what % of the web market share does PHP take? > > > > > > Thanks, > > Thiago Pojda > > Wasn't there something you could append to any file in the URL that would show if it had been parsed using PHP? -- Tom Chubb [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_put() problem??
On 24/05/07, Al <[EMAIL PROTECTED]> wrote: Can anyone help with this. On a Linux/Apache server. I want to simply copy a file with ftp_put() from one dir to another. To make certain I'm pointing to the correct dirs, I'm using this: print_r(ftp_nlist($conn_id, FTP_EP_DIR)); //It is the correct dir print_r(ftp_nlist($conn_id, $rpdir)); //It is the correct dir Then I'm: ftp_put($conn_id, FTP_EP_DIR .'/' . $file, $rpdir. '/' . $file, FTP_ASCII); Error msg: Warning: ftp_put(/home/x/public_html/test/EditPageIndexer.php) [ function.ftp-put]: failed to open stream: No such file or directory in /home/x/public_html/EditPage/ep_functions.inc on line 227 And the files are not copied. Owner and permissions are correct. I can make a new dir [mkdir()] in the destination dir without a problem. Manual is confusing when it calls the files "remote" and "local". Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you using the correct syntax? Make sure you are specifying the remote file first, then the local file. ftp_put($conn_id, $remote_file, $file, FTP_ASCII) -- Tom Chubb [EMAIL PROTECTED]
[PHP] Changing URLs from Relative to Absolute
Dear list, I was recently trying to write a script where a user copy and pastes their HTML code to display something on a listings site and tried to find a way to change the URL of an image from relative to absolute. For example becomes http://domain.com/images/1.jpg";>. That is easy enough and I created a regexp, but I found that some people call the img tag differently such as: Does anyone have experience of this? How can I create a regexp that will find it in every case? Thanks in advance. Tom -- Tom Chubb [EMAIL PROTECTED]
Re: [PHP] PHP 5, Windows, and MySQL
I use apache2triad (http://apache2triad.net/) which is an AMP package with PHP 5. I vaguely remember the first time I installed it (on Win XP Pro though) I got similar problems with MySQL. I uninstalled it and reinstalled as I wasn't sure if I accidentally clicked a dialog box without reading what it said then it worked ok. HTH... PS - I had GD working ok on a simple thumbnail generation script. On 26/06/06, Beauford <[EMAIL PROTECTED]> wrote: Aside from my previous gd problems, here's another problem. It appears that PHP5 (for Windows anyways) does not support MySQL (which in itself is riduculous), but here's my problem. I have a script I just downloaded that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget about the errors, does anyone have any idea how to get PHP5 and MySQL to work on Windows. I have already tried 100 different variations of things from information I found searching out this problem, but maybe someone has a new idea. If it were me I'd just run this site on Linux, but this is for a friend who wants to use IIS. If your curious the errors are below. Thanks B Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 207 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at G:\Websites\Webtest\caalogin\include\database.php:207) in G:\Websites\Webtest\caalogin\include\session.php on line 46 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at G:\Websites\Webtest\caalogin\include\database.php:207) in G:\Websites\Webtest\caalogin\include\session.php on line 46 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 207 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] What's the regex for this...?
h a lot in the actual pattern (especially if you're dealing with pathnames) you might want to use something else: !/root/home/random! To make a match case-insensitive, all you need to do is append the option i to the pattern: /colou?r/i Perl-style functions support these extra metacharacters (this is not a full list): \b A word boundary, the spot between word (\w) and non-word (\W) characters. \B A non-word boundary. \d A single digit character. \D A single non-digit character. \n The newline character. (ASCII 10) \r The carriage return character. (ASCII 13) \s A single whitespace character. \S A single non-whitespace character. \t The tab character. (ASCII 9) \w A single word character - alphanumeric and underscore. \W A single non-word character. Example: /\bhomer\b/ Have a donut, Homer no match A tale of homeric proportions! no match Do you think he can hit a homer? match Corresponding to ereg() is preg_match(). Syntax: preg_match(pattern (string), target (string), optional_array); Example: $pattern = "/\b(do(ugh)?nut)\b.*\b(Homer|Fred)\b/i"; $target = "Have a donut, Homer."; if (preg_match($pattern, $target, $matches)) { print(" Match: $reg[0] "); print(" Pastry: $reg[1] "); print(" Variant: $reg[2] "); print(" Name: $reg[3] "); } else { print("No match."); } Results: Match: donut, Homer Pastry: donut Variant: [blank because there was no "ugh"] Name: Homer If you use the $target "Doughnut, Frederick?" there will be no match, since there has to be a word boundary after Fred. but "Doughnut, fred?" will match since we've specified it to be case-insensitive. Contributed code which is applicable (and very useful!) mkr at binarywerks dot dk A (AFAIK) correct implementation of Ipv4 validation, this one supports optional ranges (CIDR notation) and it validates numbers from 0-255 only in the address part, and 1-32 only after the / function valid_ipv4($ip_addr) { $num="([0-9]|1?\d\d|2[0-4]\d|25[0-5])"; $range="([1-9]|1\d|2\d|3[0-2])"; if(preg_match("/^$num\.$num\.$num\.$num(\/$range)?$/",$ip_addr)) { return 1; } return 0; } $ip_array[] = "127.0.0.1"; $ip_array[] = "127.0.0.256 "; $ip_array[] = "127.0.0.1/36"; $ip_array[] = " 127.0.0.1/1"; foreach ($ip_array as $ip_addr) { if(valid_ipv4($ip_addr)) { echo "$ip_addr is valid \n"; } else { echo "$ip_addr is NOT valid \n"; } } ?> plenque at hotmail dot com I wrote a function that checks if a given regular expression is valid. I think some of you might find it useful. It changes the error_handler and restores it, I didn't find any other way to do it. Function IsRegExp ($sREGEXP) { $sPREVIOUSHANDLER = Set_Error_Handler ("TrapError"); Preg_Match ($sREGEXP, ""); Restore_Error_Handler ($sPREVIOUSHANDLER); Return !TrapError (); } Function TrapError () { Static $iERRORES; If (!Func_Num_Args ()) { $iRETORNO = $iERRORES; $iERRORES = 0; Return $iRETORNO; } Else { $iERRORES++; } } PHP Get_title tag code which uses simple regex and nice php string functions (As from Zend PHP) function get_title_tag($chaine){ $fp = fopen ($chaine, 'r'); while (! feof ($fp)){ $contenu .= fgets ($fp, 1024); if (stristr($contenu, '<\title>' )){ break; } } if (eregi("", $contenu, $out)) { return $out[1]; } else{ return false; } } ?> My Own 'Visitor Trac' code which uses regex XML parsing methods $referer = $_SERVER['HTTP_REFERER']; $filename = $_SERVER[REMOTE_ADDR] . '.txt'; //print_r($_SERVER); if (file_exists($filename)){ $lastvisit = filectime($filename); $currentdate = date('U'); $difference = round(($currentdate - $lastvisit)/84600); if ($difference > 7) { unlink($filename); $fp = fopen($filename, "a"); } else $fp = fopen($filename, "a"); } else $fp = fopen($filename, "a"); if (!$_SERVER['HTTP_REFERER']) $url_test = ' http://dinki.mine.nu/weblog/'; else $url_test = $_SERVER['HTTP_REFERER']; $new_title = return_title ($url_test); //print $new_title; $new_name = stripslashes("$new_title\n"); $new_URL = stripslashes("$referer\n"); fwrite($fp,$new_URL); fwrite($fp,$new_name); fclose($fp); $fp = fopen($filename, "r"); $file = implode('', file ($filename)); $foo = preg_split("//",$file); $number = count($foo); //print $number; if ($number > 11) { fclose($fp); $fp = fopen($filename, "w"); $count = $number - 10; while ($count < $number) { $print1 = $foo[$count]; $print2 = $foo[$count+1]; print " "; print " $print2 <http://arif-blog.blogspot.com$print1/>"; //print $count; $count += 2; $new_name = stripslashes("$print2"); $new_URL = stripslashes("$print1"); fwrite($fp,$new_URL); fwrite($fp,$new_name); } fclose($fp); } //print_r($foo); else { $count = 1; while ($count <= $number) { $print1 = $foo[$count]; $print2 = $foo[$count+1]; print " "; print " $print2 <http://arif-blog.blogspot.com$print1/>"; //print $count; $count += 2; } fclose($fp); } ?> On 05/07/06, Brian Dunning <[EMAIL PROTECTED]> wrote: I have the source of a web page stored in $here and I want to set $this to whatever appears between '' and ''. Example: $here contains (amid tons of other stuff): This is a statement. I want to set $this to "This is a statement." Seems simple but I'm banging my head against a wall and can't figure out how to do it... can anyone help out a dude on the 4th of July?? :) :) - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tom Chubb [EMAIL PROTECTED] 07915 053312
[PHP] Image Destroy
I know this will be really simple, but I'm struggling to get my head round the use of imagedestroy() I have some code which uploads an image, resizes to create a smaller image and thumbnail then deletes the source image. My question is which images need to be destroyed? I've read the even reusing a variable name still keeps the old one in memory. Here is the code... $image1 = basename($_FILES['image1']['name']); $image2 = basename($_FILES['image2']['name']); $image3 = basename($_FILES['image3']['name']); $uploaddir = '/home/public_html/images/upload/'; $uploadfile1 = $uploaddir . basename($_FILES['image1']['name']); $uploadfile2 = $uploaddir . basename($_FILES['image2']['name']); $uploadfile3 = $uploaddir . basename($_FILES['image3']['name']); // echo ''; if (move_uploaded_file($_FILES['image1']['tmp_name'], $uploadfile1)) { echo "Image1 is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; echo ""; } // echo ''; if (move_uploaded_file($_FILES['image2']['tmp_name'], $uploadfile2)) { echo "Image2 is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; echo ""; } // echo ''; if (move_uploaded_file($_FILES['image3']['tmp_name'], $uploadfile3)) { echo "Image3 is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; echo ""; } echo "Car inserted into database"; // Now Resize Images /* resizeToFile resizes a picture and writes it to the harddisk * * $sourcefile = the filename of the picture that is going to be resized * $dest_x = X-Size of the target picture in pixels * $dest_y = Y-Size of the target picture in pixels * $targetfile = The name under which the resized picture will be stored * $jpegqual = The Compression-Rate that is to be used */ function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual) { /* Get the dimensions of the source picture */ $picsize=getimagesize("$sourcefile"); $source_x = $picsize[0]; $source_y = $picsize[1]; $source_id = imageCreateFromJPEG("$sourcefile"); /* Create a new image object (not neccessarily true colour) */ $target_id=imagecreatetruecolor($dest_x, $dest_y); /* Resize the original picture and copy it into the just created image object. Because of the lack of space I had to wrap the parameters to several lines. I recommend putting them in one line in order keep your code clean and readable */ $target_pic=imagecopyresampled($target_id,$source_id, 0,0,0,0, $dest_x,$dest_y, $source_x,$source_y); /* Create a jpeg with the quality of "$jpegqual" out of the image object "$target_pic". This will be saved as $targetfile */ imagejpeg ($target_id,"$targetfile",$jpegqual); return true; } //Set Quality to Max $jpegqual = '100'; //Resize Main Image $sourcefile = $uploadfile1; $targetfile = $uploaddir . 'main_' . basename($_FILES['image1']['name']); $dest_x = '570'; $dest_y = '428'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); $sourcefile = $uploadfile2; $targetfile = $uploaddir . 'main_' . basename($_FILES['image2']['name']); $dest_x = '570'; $dest_y = '428'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); $sourcefile = $uploadfile3; $targetfile = $uploaddir . 'main_' . basename($_FILES['image3']['name']); $dest_x = '570'; $dest_y = '428'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); //Create Thumbnails $sourcefile = $uploadfile1; $targetfile = $uploaddir . 'thumb_' . basename($_FILES['image1']['name']); $dest_x = '120'; $dest_y = '90'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); $sourcefile = $uploadfile2; $targetfile = $uploaddir . 'thumb_' . basename($_FILES['image2']['name']); $dest_x = '120'; $dest_y = '90'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); $sourcefile = $uploadfile3; $targetfile = $uploaddir . 'thumb_' . basename($_FILES['image3']['name']); $dest_x = '120'; $dest_y = '90'; resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual); //Delete Uploaded Source Files as no longer required if(file_exists($uploadfile1)) unlink($uploadfile1); if(file_exists($uploadfile2)) unlink($uploadfile2); if(file_exists($uploadfile3)) unlink($uploadfile3); Should I be using imagedestroy($sourcefile) each time I create an image or imagedestroy($targetfile) or both? Many thanks in advance. Tom
Re: [PHP] readdir() question
On 15/08/06, John Meyer <[EMAIL PROTECTED]> wrote: I have a script to list the files in a directory: And all I am getting are "1"s. I think I'm doing it right, what is the disconnect? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Straight from the PHP readdir help... http://uk2.php.net/readdir It does however strip out '.' or '..' but I'm sure you'll get the hang of it. HTH
[PHP] Max File Upload Size
This is a really stupid question, but I've not been able to find an answer for it. I have always thought that your max upload size is limited to the value in the php.ini file. However I recently changed a site to a new server which had problems with memory on one of the image resizing scripts. I managed to work around it by inserting one line at the start of the problem script: ini_set("memory_limit","32M"); Can a similar thing be done with the upload_max_filesize? Assuming that it can't, what is a good workaround? Using FTP within a script? This is for uploading an audio file, typically 4MB. Thanks in advance, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Call to undefined function
I have just encountered a fatal error using file_put_contents() on a PHP4 box. After a bit of research I found a simple function within the php.net user comments. I just wanted to know what happens if I then tried to run this script on a PHP 5 box, whereby I'd be defining a function that already exists. Should I be changing the name of the function just in case it moves to PHP5 in the future? Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] Highjack?
Posts like this are what makes this list so great! It's better to read this here than experience it first hand! Thanks Tedd, for highlighting the problem. Tom On 14/11/06, tedd <[EMAIL PROTECTED]> wrote: At 9:13 PM + 11/14/06, Stut wrote: >Ok, so badscript.php is a bad name for this script. Let's say >show.php is a script you've written. You were tired, the kids were >running around you screaming and shouting, and you wrote something >like the following without really thinking about it... > > require($_GET['path'].'commonfuncs.inc.php'); > // Do other stuff here, using functions in commonfuncs.inc.php >?> > >The *bad guy* can now hit the URL... > >http://yoursite.com/show.php?path=http://badguys.net/injectionscript.txt?ignored= > >This causes show.php to include (i.e. execute!!) the remote file >injectionscript.txt from badguys.net at this URL... > >http://badguys.net/injectionscript.txt?ignored=commonfuncs.inc.php > >Since this gets executed on your server it can do anything one of >your scripts can do. The only symptom would be that show.php will >not work for that request. Do the bad guys care? Probably not, >because by the time it fails they've already replaced your index.php >and potentially installed a rootkit, backdoors and whatever else >(depending, of course, on how locked down the web server is and your >file permissions). > >Hope that makes sense now. > >-Stut -Stut: Yes, I believe that the "require($_GET[])" is one of the things Chris Shiflett talks about in his book. I should have guessed that was what everyone was talking about. But, considering that I never do that and my site was highjacked, I was thinking it must have been something different. It all makes sense now. Sorry for being so dense. Thanks everyone. tedd PS: My kids are too old to scream -- it's grand-kids now. -- --- http://sperling.com http://ancientstones.com http://earthstones.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] Function Misbehaving
On 15/11/06, Programmer <[EMAIL PROTECTED]> wrote: Problem solved: the reason print($url) caused the program to work is because the page calling Secure_Login no longer existed and therefore the print forced a die--I assume. I included a die in the redirect function and all was well. Including die in the redirect function made sure the page that was redirected stop executing. The final question to the PHP community with this issue is: if a page myphppage.php has a redirect in it, how can it execute code after the redirect if it no longer exists? Is it because the server side code cares not that it has been redirected and only what is happing inside the php code? Thanks, Jeremy Schreckhise M.B.A. -Original Message- From: Programmer [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:53 AM To: php-general@lists.php.net; 'Brandon Stewart' Subject: [PHP] Function Misbehaving The following function is a basic user auth prep procedure for multiple pages. If the url desired is different than the default a url is supplied. This function works most of the time flawlessly; except, on some pages when the url has a value that was passed, the function still thinks url is NULL until it is used, such as printing it or assigning another variable its contents. Another way to eliminate this sporadic problem is to rename the parameter url to something else, such as url2. There are no global or session vars with the url name. Why does php think url is null when it is not, but only fault in this manner part of the time. Any help would be appreciated. // Code function Secure_Login($user,$pass,$db,$pg,$url=NULL) { //print($url); if I uncomment this url is no longer null or if I rename url to url2 $checkuser = is_user($user,$pass,$db); if (!$checkuser) { Secure_Email($pg); if(isset($url)) { Go_Page($url); } else { Go_Page("./login.php?login_error=2"); } } } Jeremy Schreckhise, M.B.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Do you have exit after the redirect? Try: http://www.example.com/";); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> See http://uk.php.net/header for more info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file_get_contents
I am trying to read the contents of a "PHP" page for an audio player and put it into a textarea to be copied and pasted into an "HTML" page. The trouble is the textarea shows unparsed PHP code and I just want the HTML. The code is: $player = file_get_contents('player.php'); //Strip out unnecessary HTML Code if(preg_match('/(.*)/s', $player, $matches)) { $code = $matches[1]; } echo "" . $code . ""; echo ""; echo "Click Here to view the player \n"; Looked at using eval() but found this: Kepp the following Quote in mind: If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf, BDFL of PHP (Hmmm...) Any help much appreciated. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents
Thanks Jochem, Tried that, but it's still showing php code in the text area! Any other ideas? The url is http://www.tnhosting.co.uk/scripts/gclub/updateplaylist.php and you see it on submission. Feel free to post. It's a testing server. On 16/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote: Tom Chubb wrote: > I am trying to read the contents of a "PHP" page for an audio player > and put it into a textarea to be copied and pasted into an "HTML" > page. > The trouble is the textarea shows unparsed PHP code and I just want the > HTML. > The code is: > > $player = file_get_contents('player.php'); file_get_content('http://blabla.com/player.php'); // requires allow_url_fopen to be set to On. > > //Strip out unnecessary HTML Code > if(preg_match('/(.*)/s', $player, $matches)) { > $code = $matches[1]; > } > echo "" . $code . htmlentities($code) > ""; > echo ""; > echo "Click Here to view the player \n"; > > Looked at using eval() but found this: > > Kepp the following Quote in mind: > If eval() is the answer, you're almost certainly asking the > wrong question. -- Rasmus Lerdorf, BDFL of PHP indeed eval is probably not the answer. > > (Hmmm...) > > Any help much appreciated. > > Tom > -- Tom Chubb [EMAIL PROTECTED] 07915 053312 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents
Confused! I'm now getting: file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php) [function.file-get-contents]: failed to open stream: Connection refused in /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php on line 75 How come you can access it and I can't?!? Permissions are 755. Obviously I was getting it when using file_get_contents('player.php') but when using the URL I get connection refused. (Don't think that it makes any difference, but allow_url_fopen is on) BTW, Brad, I was stripping the HTML tags around the object ok, but I'm echoing variables in player.php. $song_url & $song_title, are read from a seperate file after upload and that is what's being updated by this script, but the textarea was showing the php code. Thanks for your patience, guys. T On 16/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote: Tom Chubb wrote: > Thanks Jochem, > Tried that, but it's still showing php code in the text area! > Any other ideas? vanilla sky (go search for the tagline) ... if I request the following I get a page with a player into: http://www.tnhosting.co.uk/scripts/gclub/player.php if you do the following you will get the same html source as my browser does - if it doesn't then you are doing something wrong - quite simply php is transparently making a http request to the webserver there is no way the webserver will differentiate between your script and every other request and give your the scrip the source code while everyone else is recieving the result of running the script: file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php";); below is the oneliner I used to prove this: php -r 'echo file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php";);' OUTPUT: (oh look no php) == Test Audio Player http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"; width="400" height="15"> http://www.tnhosting.co.uk/scripts/gclub/xspf_player_slim.swf?song_url= http://www.tnhosting.co.uk/scripts/gclub/audio/faith.mp3&song_title=Another Stomping Funker!&autoplay=true "/> http://www.tnhosting.co.uk/scripts/gclub/xspf_player_slim.swf?song_url= http://www.tnhosting.co.uk/scripts/gclub/audio/faith.mp3&song_title=Another Stomping Funker!&autoplay=true " width="400" height="15" align="center" quality="high" bgcolor="#E6E6E6" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer";> > > The url is http://www.tnhosting.co.uk/scripts/gclub/updateplaylist.php > and you see it on submission. Feel free to post. It's a testing > server. > > > > On 16/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote: >> Tom Chubb wrote: >> > I am trying to read the contents of a "PHP" page for an audio player >> > and put it into a textarea to be copied and pasted into an "HTML" >> > page. >> > The trouble is the textarea shows unparsed PHP code and I just want the >> > HTML. >> > The code is: >> > >> > $player = file_get_contents('player.php'); >> >> file_get_content('http://blabla.com/player.php'); >> // requires allow_url_fopen to be set to On. >> >> > >> > //Strip out unnecessary HTML Code >> > if(preg_match('/(.*)/s', $player, $matches)) { >> > $code = $matches[1]; >> > } >> > echo "" . $code . >> >> htmlentities($code) >> >> > ""; >> > echo ""; >> > echo "Click Here to view the player \n"; >> > >> > Looked at using eval() but found this: >> > >> > Kepp the following Quote in mind: >> > If eval() is the answer, you're almost certainly asking the >> > wrong question. -- Rasmus Lerdorf, BDFL of PHP >> >> indeed eval is probably not the answer. >> >> > >> > (Hmmm...) >> > >> > Any help much appreciated. >> > >> > Tom >> > >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hide Warnings
Choose one of the following, but if you are getting warnings, something is wrong and you should address it. On 16/11/06, Stein Ivar Johnsen <[EMAIL PROTECTED]> wrote: Hi.. How can I hide Warning messages so they are not shown on screen..: Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /home/users/kivugog/Blog/index.php on line 69 I will appreciate all help on this... -- Regards sijo http://www.dyg.no -- 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] file_get_contents
On 17/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote: Tom Chubb wrote: > Confused! > I'm now getting: > file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php) > [function.file-get-contents]: failed to open stream: Connection > refused in > /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php > on line 75 > How come you can access it and I can't?!? no php script can withstand me. ;-) seriously I don't know I don't doubt it! ;-) > Permissions are 755. > Obviously I was getting it when using file_get_contents('player.php') > but when using the URL I get connection refused. > > (Don't think that it makes any difference, but allow_url_fopen is on) it makes a difference, and it sounds likes it's off - another possibility is that safe_mode is on (and that safe_mode blocks allow_url_fopen), but I don't know about that - you'll have to test it. phpinfo() says that allow_url_fopen is on and safe mode is off you can double check that you can reach your site from the box itself by doing a very simple 'wget' check from the commandline (assuming you have ssh access): wget http://www.tnhosting.co.uk/scripts/gclub/player.php if that downloads a page then the problem is very like to be php. > Don't have shell access on my shared server ... Did manage to get it working though using $player = file_get_contents('player.php'); //Strip out unnecessary HTML if(preg_match('/(.*)/s', $player, $matches)) { $content = $matches[1]; } function phpWrapper($content) { ob_start(); $content = str_replace('<'.'?php','<'.'?',$content); eval('?'.'>'.trim($content).'<'.'?'); $content = ob_get_contents(); ob_end_clean(); return $content; } echo "" . phpWrapper($content) . ""; Bit messy, but it works at least. :D Thanks for your help though. T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents
Very interesting! I have a reseller account and on another site, the DNS entries were messed up by the host. Could be a similar problem. Thanks On 17/11/06, Stut <[EMAIL PROTECTED]> wrote: Tom Chubb wrote: > Confused! > I'm now getting: > file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php) > [function.file-get-contents]: failed to open stream: Connection > refused in > /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php > on line 75 > How come you can access it and I can't?!? > Permissions are 755. > Obviously I was getting it when using file_get_contents('player.php') > but when using the URL I get connection refused. The domain www.tnhosting.co.uk is probably not resolving to the right IP when used from that box. Can't think of any other reason that would work remotely but not locally. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents
The host support team told me that: Our servers do not allows a HTTP connection onto itself. This is a security precaution to stop recursive code. You can try to reference the code by path rather than HTTP ...which works fine! On 17/11/06, Tom Chubb <[EMAIL PROTECTED]> wrote: Very interesting! I have a reseller account and on another site, the DNS entries were messed up by the host. Could be a similar problem. Thanks On 17/11/06, Stut <[EMAIL PROTECTED]> wrote: > Tom Chubb wrote: > > Confused! > > I'm now getting: > > file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php) > > [function.file-get-contents]: failed to open stream: Connection > > refused in > > /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php > > on line 75 > > How come you can access it and I can't?!? > > Permissions are 755. > > Obviously I was getting it when using file_get_contents('player.php') > > but when using the URL I get connection refused. > > The domain www.tnhosting.co.uk is probably not resolving to the right IP > when used from that box. Can't think of any other reason that would work > remotely but not locally. > > -Stut > -- Tom Chubb [EMAIL PROTECTED] 07915 053312 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Readdir
What would be the best way to retrieve a list of files from an upload folder that are called "id" where the extension could be .doc .txt or .pdf For example, I have a folder where people can upload a document and the document is renamed as their user id. They can upload a PDF, DOC or TXT file. They may wish to upload one of each. I am using file_exists for each case, but is there an easier/tidier way of doing it? Thanks in advance, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir
Thanks guys, Looks like just what I need. Will test it out later. Tom On 28/11/06, Vincent DUPONT <[EMAIL PROTECTED]> wrote: yes, glob works well. here is an example to get pictures inside a folder ($path) foreach(glob($path."/*/{*.gif,*.jpg,*.JPG,*.jpeg,*.JPEG,*.png}", GLOB_BRACE) as $filename){ $pics[]=$filename; } vincent -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Tue 28/11/2006 10:59 To: Tom Chubb Cc: [php] PHP General List Subject: Re: [PHP] Readdir Tom Chubb wrote: > What would be the best way to retrieve a list of files from an upload > folder that are called "id" where the extension could be .doc .txt or > .pdf > For example, I have a folder where people can upload a document and > the document is renamed as their user id. They can upload a PDF, DOC > or TXT file. They may wish to upload one of each. I am using > file_exists for each case, but is there an easier/tidier way of doing > it? > Thanks in advance, > > Tom > try the glob() function, something like: $id = getUserId(); foreach (glob("/path/to/user/files/$id.*") as $file) { echo $file,""; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting naughty sites
On 28/11/06, Dave Goodchild <[EMAIL PROTECTED]> wrote: Hi all. I am building a web app and as part of it advertisers can upload their ad image and website URL to go with their ad. Is there a good way to detect whether that site is a porn site via php? -- http://www.web-buddha.co.uk I remember seeing something that used GD to detect colours similar to flesh within an image and thinking it was funny that someone had taken so much time to to it, but I can't remember where it was. I think it was on phpclasses.org but can't find it. Maybe someone else remembers it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir
Got it working fine. Thanks Vincent and Jochem for pointing me in the right direction. Here is the code I used in case anyone's interested... $cv"; echo ""; } echo "\n"; $i++; } ?> On 28/11/06, Tom Chubb <[EMAIL PROTECTED]> wrote: Thanks guys, Looks like just what I need. Will test it out later. Tom On 28/11/06, Vincent DUPONT <[EMAIL PROTECTED]> wrote: > > yes, glob works well. > here is an example to get pictures inside a folder ($path) > > foreach(glob($path."/*/{*.gif,*.jpg,*.JPG,*.jpeg,*.JPEG,*.png}", GLOB_BRACE) as $filename){ >$pics[]=$filename; >} > > vincent > -Original Message----- > From: Jochem Maas [mailto:[EMAIL PROTECTED] > Sent: Tue 28/11/2006 10:59 > To: Tom Chubb > Cc: [php] PHP General List > Subject: Re: [PHP] Readdir > > Tom Chubb wrote: > > What would be the best way to retrieve a list of files from an upload > > folder that are called "id" where the extension could be .doc .txt or > > .pdf > > For example, I have a folder where people can upload a document and > > the document is renamed as their user id. They can upload a PDF, DOC > > or TXT file. They may wish to upload one of each. I am using > > file_exists for each case, but is there an easier/tidier way of doing > > it? > > Thanks in advance, > > > > Tom > > > > try the glob() function, something like: > > $id = getUserId(); > foreach (glob("/path/to/user/files/$id.*") as $file) { >echo $file,""; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Question
Please can you help me. I've created a page where problems are posted into a database and I am using the datetime format in MySQL and trying to find the best way to display it in the 17/03/06 format. I've found a way of doing it (so you don't think I haven't googled, RTFM) but don't think it's the best way. Any help would be appreciated. (Current Code:)
Re: [PHP] Re: Date Question [SOLVED]
Thanks guys. On 17/03/06, João Cândido de Souza Neto <[EMAIL PROTECTED]> wrote: > > select date_format(date,"%d/%m/%y") as date from table > > It'll show in 17/03/06 format > > select date_format(date,"%d/%m/%Y") as date from table > > It'll show in 17/03/2006 format > > > Tom Chubb wrote: > > > Please can you help me. I've created a page where problems are posted > into > > a database and I am using the datetime format in MySQL and trying to > find > > the best way to display it in the 17/03/06 format. > > I've found a way of doing it (so you don't think I haven't googled, > RTFM) > > but don't think it's the best way. > > Any help would be appreciated. > > > > (Current Code:) > > > > > $datestr = $row_rsSnags['date']; > > $arr1 = str_split($datestr, 2); > > echo $arr1 [2]; > > echo "/"; > > echo $arr1 [1]; > > echo "/"; > > echo $arr1 [0]; > > // echo $row_rsSnags['date']; > > ?> > > -- > --- > João Cândido de Souza Neto > Web Developer > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] Here is a silly question
I'm very interested to see the best option for this. Currently I set 2 variables in the include file (header.inc) $siteurl = "http://www.yourdomain.com/ <http://www.yourdomain.com/psp/>"; $pathto = "/home/location_on_server/public_html/"; Then for includes I do something like: include($pathto."functions.php"); And for images, links, etc. wrote: > > works like a charm for me, but your > mileage may vary depending on who has set up your website and what > server it is being run on. > > FYI: I build my menu's with HTML and javascript, hence the .html call, > but it should be fine as php as well. > > Robert > > Philip Thompson wrote: > > I'm not exactly sure... but I think that include() may not work this > way: > > > > > > > > I don't think it knows to go to the root and then look for menu.php. > > That's why you have to tell it exactly where the menu.php is found - 1 > > level back: > > > > > > > > Maybe it should be labeled as a bug? Hehehe! ;) > > > > ~Philip > > > > > > On Apr 3, 2006, at 11:18 AM, Mace Eliason wrote: > > > >> Okay I gave it a try and this is one thing I ran into. > >> > >> in my menu file I changed all the links to href="/index.php">Home > >> > >> then in a file in another directory I added this >> include("/menu.php"); ?> This didn't work > >> > >> if I changed it to > >> This worked and the links work fine. > >> > >> Seems strange the first include didn't work. Shouldn't it goto the > >> root of the website and look from there? > >> > >> > >> > >> > >> Philip Thompson wrote: > >>> On Apr 3, 2006, at 10:54 AM, Mace Eliason wrote: > >>> > >>>> Hi, > >>>> > >>>> This is come thing that I have struggled with now and again. I > >>>> usaually us php code to make it work, but was wondering how others > >>>> deal with this > >>>> > >>>> I use includes in most of the web applications that I work on to > >>>> include the header, footer, menu etc. > >>>> > >>>> The problem that I always run into as a project gets bigger is my > >>>> links to pages. If all the files are in the root directory theres > >>>> no problem. > >>>> > >>>> If I have some files in a folder and call my menu for example >>>> include("../menu.php"); ?> I have to call if from the parent > >>>> directory. But then of course > >>>> all the links are wrong. Root becomes the calling directory. > >>>> > >>>> I usually use a php variable to place the ../ if its needed. > >>>> > >>>> How does everyone else deal with this type of problem. I have a > >>>> times places an extra copy of the footer, menu, header etc in each > >>>> directory but it is a pain to change links > >>>> when you have multiple locations to do it in. > >>>> > >>>> Thanks for any suggestions. > >>>> > >>>> I would be nice to have a simple way to have my include files in a > >>>> common place that works and keeps the links right. > >>>> > >>>> Scandog > >>> > >>> > >>> Ok, I this may only help part of your problem. Within your "menu.php" > >>> file, you could make all the links absolute: > >>> > >>> Place A > >>> Place B > >>> > >>> instead of relative: > >>> > >>> Place A > >>> Place B > >>> > >>> That means you can use only 1 menu.php file and all the links will > >>> work from wherever. Of course, this does not fix this issue: > >>> > >>> or > >>> or > >>> > >>> > >>> for each of your files that includes the menu. Maybe another clever > >>> person has an idea. > >>> > >>> ~Philip > > > > --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 > > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] Here is a silly question
Great - thanks Chris - that's the answer I've been looking for! On 04/04/06, Chris <[EMAIL PROTECTED]> wrote: > > Mace Eliason wrote: > > Hi, > > > > This is come thing that I have struggled with now and again. I usaually > > us php code to make it work, but was wondering how others deal with this > > > > I use includes in most of the web applications that I work on to include > > the header, footer, menu etc. > > > > The problem that I always run into as a project gets bigger is my links > > to pages. If all the files are in the root directory theres no > problem. > > > > If I have some files in a folder and call my menu for example > include("../menu.php"); ?> I have to call if from the parent > > directory. But then of course > > all the links are wrong. Root becomes the calling directory. > > > > I usually use a php variable to place the ../ if its needed. > > > > How does everyone else deal with this type of problem. I have a times > > places an extra copy of the footer, menu, header etc in each directory > > but it is a pain to change links > > when you have multiple locations to do it in. > > > > Thanks for any suggestions. > > > > I would be nice to have a simple way to have my include files in a > > common place that works and keeps the links right. > > > > Scandog > > > > I didn't see anybody else mention this, so: > > $mydir = dirname(__FILE__); > include($mydir . '/../nav/menu.php'); > > works every time and you don't have to rely on document_root being set > properly etc. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
[PHP] Parse Error on SQL Insert
I'm working on an insert record page with a multiple file upload script of which I understand the fundamentals. However, on submission I am getting the following error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34 Where line 34 is... $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1, image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'], $_POST['details'], $_POST['price'], $_FILE['image']['name'][0], $_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])"; For info, the HTML for the form is as follows: Image1: Image2: Image3: I've been slaving away for an hour and it's probably something really obvious but I'd really appreciate it if someone could point it out to me please? Previously I was getting an "image1 cannot be null" error which I couldn't work out either. That's gone, but I still can't work out what's going on. Many thanks, Tom -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] Parse Error on SQL Insert
Complete code... http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> Untitled Document Model: Year: Details: Price: Image1: Image2: Image3: Forsale: The reason for the single quotes around the year is something to do with Dreamweaver's insert wizard. On 07/04/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote: > > why do you have single quotes around year? > -B > > Tom Chubb wrote: > > >I'm working on an insert record page with a multiple file upload script > of > >which I understand the fundamentals. > >However, on submission I am getting the following error: > > > >Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, > expecting > >T_STRING or T_VARIABLE or T_NUM_STRING in > >C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34 > > > >Where line 34 is... > > > >$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1, > >image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'], > >$_POST['details'], $_POST['price'], $_FILE['image']['name'][0], > >$_FILE['image']['name'][1], $_FILE['image']['name'][2], > $_POST['forsale'])"; > > > > > >For info, the HTML for the form is as follows: > > > > > > Image1: > > > > > > > > Image2: > > > > > > > > Image3: > > > > > > > >I've been slaving away for an hour and it's probably something really > >obvious but I'd really appreciate it if someone could point it out to me > >please? > >Previously I was getting an "image1 cannot be null" error which I > couldn't > >work out either. That's gone, but I still can't work out what's going on. > > > >Many thanks, > > > >Tom > > > > > > > >-- > >Tom Chubb > >[EMAIL PROTECTED] > >07915 053312 > > > > > > > > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] Parse Error on SQL Insert [Solved]
Sorry guys - knew it would be obvious! I was using $_FILE['image']['name'][0], instead of $_FILES['image']['name'][0] However, thanks for all your help. Tom On 07/04/06, Joe Henry <[EMAIL PROTECTED]> wrote: > > On Friday 07 April 2006 1:56 pm, Chrome wrote: > > Backticks (`) encapsulate table or database names > > > > I was thinking maybe if the array references were encapsulated in curly > > braces {}: > > > > $_POST['model'] to {$_POST['model']} > > > > Of course if the field in the DB isn't numeric this would be > > '{$_POST['model']}' > > > > Dan > > > > --- > > http://chrome.me.uk > > > > > > -Original Message- > > From: Joe Henry [mailto:[EMAIL PROTECTED] > > Sent: 07 April 2006 20:53 > > To: php-general@lists.php.net; [EMAIL PROTECTED] > > Subject: Re: [PHP] Parse Error on SQL Insert > > > > On Friday 07 April 2006 1:37 pm, Tom Chubb wrote: > > > $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1, > > > > Not sure if this is your problem, but those look like backticks around > year > > instead of single quotes. Should there even be quotes there? > > > > HTH > > -- > > Joe Henry > > www.celebrityaccess.com > > [EMAIL PROTECTED] > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > __ NOD32 1.1475 (20060406) Information __ > > > > This message was checked by NOD32 antivirus system. > > http://www.eset.com > > Good to know. Thanks. > > -- > Joe Henry > www.celebrityaccess.com > [EMAIL PROTECTED] > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
Re: [PHP] Bar codes
Under the GD Image Functions within the PHP Help file (on php.net) there is an example for barcodes. It also refers to barcodeisland.com which may be of use to you. HTH On 13/04/06, Emil Edeholt <[EMAIL PROTECTED]> wrote: > Hi, > > I've never used bar codes before. And now I need to print out bar codes, > and I've been told it should be in the format K39 Normal (I could have > misunderstood since I can't find that on google. Maybe Code 39 Normal?). > Any idea how to find that bar code font or what it's called? And what > shall I use to print it out? Is it just as a regulat font, or do I need > some special bar code lib? > > Thanks for your time > > Best regards Emil > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Tom Chubb [EMAIL PROTECTED] 07915 053312
[PHP] HTML Mail script reading text from MySQL
I can't work out how to load the text from a recordset result into a variable for sending using mail in a script. I have a script which creates a dynamic table then I want to load the table's HTML into a variable which will be echoed in the mail function. I can't work out how to do this. I've tried calling the file using exec and fopen but I don't get any result. I have googled and RTFM (especially variable scope) but just can't work out how to do it. Any help would be greatly appreciated. PS - I know there are many Mail classes out there, but I also realise that this is something I will want to know how to do at a later time. Thanks, Tom