Re: [PHP] using require
On 10/14/05, Cima [EMAIL PROTECTED] wrote: hi all, i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site? any info will be highly appreciated!! thanx. -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using require
On 5/14/05, James Williams [EMAIL PROTECTED] wrote: On 10/14/05, Cima [EMAIL PROTECTED] wrote: hi all, i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site? any info will be highly appreciated!! thanx. A new connection will be established to the database for every time you run auth.php -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sleep function
Well the reason it worked on my site is because my webhost uses linux, and my localhost is windows. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hello, I'm new...
On 5/13/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, I have only recently started to look at php, I hope this list dose not mind 'noob' questions. no we don't mind it, we do mind poor spelling though ;) jk I have got 'Programming PHP' by Rasmus Lerdorf, Kevin Tatroe and 'Web Database Applications with PHP and MySQL' Hugh E. Williams, David Lane. I would like to create a 'community' website and was wondering if there was a framework available to get me started? Are you looking for a framework for building you're application, or an application that's already built for you that you just need to customize? IMO, I would start off with trying to write you're own application from scratch, like maybe a guestbook or something simple. Once you get the basics down you can expand you're horizons into whatever you feel like... Thanks. You're very welcome... Good Luck! -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner needs help!
On 5/12/05, Clinton, Rochelle A [EMAIL PROTECTED] wrote: Dear Much Needed Advisor, I am definitely a PHP novice and making some code changes to a PHP script. I need to change a declared output file to include the date as an extension. My file is declared at the beginning of the script as: var $exportFile = Export.txt; Is this a class? If not you don't need to declare you're variables with var. I need it to be, for instance, Export.051205.txt. I have played around with the date function many ways: Ex 1: var $exportFile = Export . date(mdy); Use a unix timestamp... var $exportFile = 'export' . time(); Ex 2: $file = Export; $ext = date(mdy); var $exportFile = $file . $ext; I can't seem to get anything to work. Also, could you point me to somewhere where I can learn the difference between declaring variables as: $exportFile = Export.txt; and var $exportFile = Export.txt Thank you! Thank you! Rochelle Clinton Bioinformatics Coordinator University of Kentucky 200 Thomas Hunt Morgan Building office: (859) 257-2161 cell: (406) 570-5383 email: [EMAIL PROTECTED] -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner needs help!
hmmm, well... If I could see the code I could probably fix it for you, the problem is everything changes depending on the context it's used and how the class is setup. For example, it's poor practice to assign values to vars when you declare them... It is recommended you assign them inside the class constructor. If you have no idea what I'm talking about with constructors and whatnot, check out a tutorial on OOP or classes... www.codewalkers.com I believe has a good one. I'd give you the link but my comp is messed right now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql injections (related question)
I'm pretty sure that, in order to use mysql_real_escape_string() you must have magic quotes off or use stripslashes first... the same as addslashes, so it should work if you just search and replace. Don't quote me on that though On 5/12/05, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, May 11, 2005 8:27 pm, James Williams said: On 5/11/05, Richard Lynch [EMAIL PROTECTED] wrote: Is mysql_real_escape_string *DIFFERENT* in some incredibly huge secure way that I want to stop working on all my current projects to go re-write the 10,000,000 lines of code? 2 words: Search Replace. 2 words: Magic Quotes -- Like Music? http://l-i-e.com/artists.htm -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sleep function
On 5/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I want to create a script that displays all names from a database once per second. A part of the script look like this. for ($i=0; $i$total_names; $i++) { echo namebr; sleep (1); } The scipt works fine but it displays all names at once. I want to display the first name, then refresh the browser and display the first name and the second, then the first name, the second and the third and so on. Can someone please tell me how can i do this? Thanks in advance for your help !!! You're gonna have to use output buffering... I have never used it so I'm no expert, but I figured I could point you in the right direction. http://ca3.php.net/outcontrol -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql injections (related question)
I couldn't tell you the technicals of it, but just from the php documentation: This function must always (with few exceptions) be used to make data safe before sending a query to MySQL. On 5/12/05, Richard Lynch [EMAIL PROTECTED] wrote: On Thu, May 12, 2005 12:39 pm, James Williams said: I'm pretty sure that, in order to use mysql_real_escape_string() you must have magic quotes off or use stripslashes first... the same as addslashes, so it should work if you just search and replace. Don't quote me on that though Well, yes, but you see it's no longer as simple as a global search and replace, since there is no addslashes all over the place. I have to hand-examine every file in, what, almost a decade's worth of code spread over several dozen websites? What is the CURRENT security advantage, if any, to mysql_real_escape_string versus Magic Quotes? -- Like Music? http://l-i-e.com/artists.htm -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sleep function
I just tried a couple of output_buffering on a test script I made and it won't work... It simply waits for 10 seconds then displays everything... Kinda sucks. On 5/12/05, Richard Lynch [EMAIL PROTECTED] wrote: On Thu, May 12, 2005 12:39 pm, [EMAIL PROTECTED] said: I want to create a script that displays all names from a database once per second. A part of the script look like this. for ($i=0; $i$total_names; $i++) { echo namebr; http://php.net/flush sleep (1); } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sleep function
Okay... the difference is between Apache + PHP for windows, and Apache + PHP for unix... it works on linux / unix... but not on windows... check it out. http://www.jamwil.com/misc/flush.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A couple questions about templating
Well, I made it work now, and I even got a cache built in there (kindof stupid though, I need to make it smarter.) I figured out to use the assign function to add the curly brackets, thank-you. I'll look into the file_*_contents() functions, thanks. On 5/11/05, Rory Browne [EMAIL PROTECTED] wrote: Anyways, I restructered my code, and as far as I can see there is nothing wrong with the code, except for that it simply doesn't work :) That's usually considered a fairly serious problem. I'm probably missing something blatently obvious but I'll post it and maybe someone can spot why this isn't working. Here be the code: I've had a fairly brief look through, and would recommend the following: Add error checking routines Don't do this:$fp = fopen($file, $mode); Do this instead: $fp = fopen($file, $mode) or die(can't open file $file with mode $mode); You might also want to have a look at www.php.net/asssert Recheck your strings/arrays, and your uses of them: function assign($var,$value) { if (isset($var) isset($value)) { $this-_var[] = $var; $this-_value[] = $value; // $this-_var, and $this-_value are arrays $this-_file = str_replace('{' . $this-_var . '}',$this-_value,$this-_file); Here you're trying to concatenate a string ('{') with an array ($this-_var) Probably the easiest solution would be to do a $this-_var[] = '{' . $var . '}'; in the assign() function. For Clarity sake, instead of using fopen/fread/fwrite/filesize/etc, I'd replace them with file_get_contents(), and if available file_put_contents() ?php class mm { // // PRIVATE CLASS VARIABLES // var $_file; var $_template; var $_var; var $_value; // // CLASS CONSTRUCTOR // function mm() { $this-_var = array(); $this-_value = array(); } // // ASSIGN A VARIABLE // function assign($var,$value) { if (isset($var) isset($value)) { $this-_var[] = $var; $this-_value[] = $value; } } // // RUN THE WEBPAGE // function run($template) { if (isset($template)) { $this-_template = 'tpl/' . $template . '.tpl'; if (file_exists($this-_template)) { $file = fopen($this-_template,'r'); $this-_file = fread($file,filesize($this-_template)); fclose($file); $this-_file = str_replace('{' . $this-_var . '}',$this-_value,$this-_file); print($this-_file); } else { print('pTemplate File Does Not Exists/p'); } } else { print('pTemplate is not sent/p'); exit; } } } ? The page that run's the script simply looks like this: ?php // // LOAD THE TEMPLATING CLASS // require_once('tpl.php'); $mm = new mm(); // // SET CONTENT // $sitename = 'Calgary Outdoor Paintball League raquo; Under Heavy Developement'; $header = 'Welcome to the Calgary Outdoor Paintball League\'s Official Website'; // // RUN THE PAGE // $mm-assign('sitename',$sitename); $mm-assign('header',$header); $mm-run('index'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A couple questions about templating
I took a look at those functions, and file_put_contents() is only php5... this needs to work w/ php4 so that's not an option. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql injections (related question)
On 5/11/05, Richard Lynch [EMAIL PROTECTED] wrote: Is mysql_real_escape_string *DIFFERENT* in some incredibly huge secure way that I want to stop working on all my current projects to go re-write the 10,000,000 lines of code? 2 words: Search Replace. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A couple questions about templating
Okay well I see I have reopened the can of worms lol. This has all been done before, and I'm assuming that the James knows, and has seen that before, since he used the same common method names, as is in many php templating systems. $class-assign has been used in any templating system I've ever seen(although to be honest I haven't seen that many). I don't think the fact that it has been done before should inhibit him from doing it again. Carrying out the process, is one of the most educational ways, and perhaps one of the most enlightening ways to see how a process works. Rory you are my hero! you took the words right out of my mouth, and yes, I am looking to create a small basic one that isn't bloated with useless features. Basically variable replacement mostly. Anyways, I restructered my code, and as far as I can see there is nothing wrong with the code, except for that it simply doesn't work :) I'm probably missing something blatently obvious but I'll post it and maybe someone can spot why this isn't working. Here be the code: ?php class mm { // // PRIVATE CLASS VARIABLES // var $_file; var $_template; var $_var; var $_value; // // CLASS CONSTRUCTOR // function mm() { $this-_var = array(); $this-_value = array(); } // // ASSIGN A VARIABLE // function assign($var,$value) { if (isset($var) isset($value)) { $this-_var[] = $var; $this-_value[] = $value; } } // // RUN THE WEBPAGE // function run($template) { if (isset($template)) { $this-_template = 'tpl/' . $template . '.tpl'; if (file_exists($this-_template)) { $file = fopen($this-_template,'r'); $this-_file = fread($file,filesize($this-_template)); fclose($file); $this-_file = str_replace('{' . $this-_var . '}',$this-_value,$this-_file); print($this-_file); } else { print('pTemplate File Does Not Exists/p'); } } else { print('pTemplate is not sent/p'); exit; } } } ? The page that run's the script simply looks like this: ?php // // LOAD THE TEMPLATING CLASS // require_once('tpl.php'); $mm = new mm(); // // SET CONTENT // $sitename = 'Calgary Outdoor Paintball League raquo; Under Heavy Developement'; $header = 'Welcome to the Calgary Outdoor Paintball League\'s Official Website'; // // RUN THE PAGE // $mm-assign('sitename',$sitename); $mm-assign('header',$header); $mm-run('index'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A couple questions about templating
Hey fellas, sorry to infest the list with another question about a templating engine, but I am looking for some professional opinions here... I am trying to make a small, fast, and simple templating class... Now I have mastered the art of variable replacement, and have made two versions. The first one I made simply used file() to load up the file into an array, str_replace() to replace variables, then it printed it back. I made a second one, which reads the file into an array, changes the variables the same way, but instead compiles the finished product into a compile directory and then reads the compiled file back to the page. the benefit to this being that I can easily create a simple cache system now. 1st question) I need a professionaly opinion on to which solution is better, considering speed, security, and expandability. 2nd question) Like I said before, I've mastered the art of variable replacement, but how would one go about adding support for if {} statements as well as loops. I'm a little bit lost when it comes to this. Thank-you guys very very much. -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A couple questions about templating
On 5/9/05, Rory Browne [EMAIL PROTECTED] wrote: I made a second one, which reads the file into an array, changes the variables the same way, but instead compiles the finished product into a compile directory and then reads the compiled file back to the page. the benefit to this being that I can easily create a simple cache system now. All I'd change here, is that instead of reading the file into an array, I'd load it into a string. That was a mistake on my part, it is loaded into a string. 2nd question) Like I said before, I've mastered the art of variable replacement, but how would one go about adding support for if {} statements as well as loops. I'm a little bit lost when it comes to this. You could use a full featured tokeniser/parser(and you'd probably IIRC find one in Pear), but it may perhaps be simpler, to simply use preg to replace something like {foreach:var:list}, or whatever your perfered syntax. The problem is that, I have no problem replacing the keyword with the proper php syntax for a loop or whatever, the problem is that it just shows up as a string when all is said and done. If you want to see the code I have right now, here it is (below). I'm thinking I'm going to have to combine the load() and run() methods, and then make assign() create an array of stuff that must be assigned, then do pretty much all the work in the combined method or load() and run(). That probably sounded pretty confusing, I hope you understand what I'm sayin. ?php class tpl { // // PRIVATE CLASS VARIABLES // var $file; var $template; var $compiled; // // LOAD A TEMPLATE FILE // function load($template) { $this-template = 'tpl/' . $template . '.tpl'; $this-compiled = 'compiled/' . $template . '.tplc'; if (file_exists($this-template) filemtime($this-template) filemtime($this-compiled)) { $file = fopen($this-template,'r'); $this-file = fread($file,filesize($this-template)); fclose($file); } elseif (file_exists($this-compiled) filemtime($this-template) filemtime($this-compiled)) { readfile($this-compiled); } else { print('/p' . $this-template . ' Does not exist/p'); } } // // ASSIGN THE VARIABLES // function assign($var,$value) { if (isset($var) isset($value)) { $this-file = str_replace('{' . $var . '}',$value,$this-file); } } // // DISPLAY THE TEMPLATE // function run() { if (filemtime($this-template) filemtime($this-compiled)) { $file = fopen($this-compild,'w'); fwrite($file,$this-file); fclose($file); readfile($this-compiled); } } } ? -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fastest templating mechanism
Hi everyone, Thanks for your replies. I Think I haven't been very clear about what I really need. First of all, I don't need an existing templating system, because I am working on my own templating system. And regarding Satyam's post. This looks a lot like what I'm developing right now, but also not my issue =) What I really need is a fast lookup mechanism, to 'translate' statements. For example: setOutputType('xhtml'); echo(translate('authorstart')); the function translate opens xhtml.data, which contains: authorstart : span class=author authorend : /span So, is you're entire website template going to just look like those keywords??? If you ask me that seems kinda pointless and if anything, just extra overhead for your app so, the translate function looks 'authorstart' up and returns 'span class=author' or if you had specified 'wml' as the outputtype, the file could like like: authorstart : b authorend : /b and the function would return 'b' This is all no problem, except that these lists can be pretty big. And I wouldn't like to load them all into the memory, or have to loop through the file every time translate is called. So I need a very fast mechanism to overcome this problem. If you're deadset on doing this, I would go with a database and str_replace(). str_replace() is always better than a regex solution because it doesn't incur the overhead of the regex engine. Only use regex when you need a complex solution. Any ideas? grt, Evert -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [suspicious - maybe spam] Re: [suspicious - maybe spam] [PHP] Simple question: How to declare Vars in PHP? (I know it's not necessary, but I still want to know)
No You don't declare variables in PHP. You just start using them. Perhaps you mean assign? Since your example of var = variableName; is actually an assignment in Javascript. In PHP you simply do: $one_var = $another_var; -Rasmus You are however, when dealing with OOP and classes required to declare you're variable, right? -- jamwil.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] plug-in forum
Ryan A wrote: Hi, a client wants me to add a forum to his existing site...which is not a problem, the problem is he wants it to work off his existing site eg: once someone logs in to the main site they dont have to relogin or create new accounts in the forum section a one login gets you total site access kind of deal. The second thing is, as clients go, these ar'nt too bright :-) a rea simple forum/forum admin is needed, I was looking at phpbb but after running a test install on my system i think it would be a little too complicated for them plus it has to sit into the existing design... recommendations please. Thanks, Ryan Hey Ryan... I am actually coding a forum that meets all of you're requirements, however it isn't done yet and I currently have another project which takes priority. I should have an alpha out by the end of april or may at the latest. When do you need this forum? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] plug-in forum
Ryan A wrote: Hey James, I've actually decided to go with FudForum as it has a lot of features and everything that this project requires...and some that it does not :-), but since its open source and free I cant really complain, once i get paid I plan to donate a few bucks to support the project. Its very generious of you to offer me your forum and if you want I can help test it for you on the site once its completed, but for now i will be installing FF because its needed in around 10 days. I know what you mean about priority projects, I have few of my own that are taking forever to complete because other more important stuff that comes up. Give me a shout when you are done though, I'm really curious to see it. Cheers, -Ryan That's no problem Ryan, I really appreciate it. Right now, I'm just workin on all the backend classes and I haven't really gotten any html down, but as soon as I finish the user management class (register / login / profile) I'll make a nice template and you can give it a try. Thank-you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Adding Loop / If support to a simple template engine
Hey fellas, I'm makin a forum right now and as a sub project, I'm making a template engine / class. Right now all it does is variable replacement, however I am curious as to how I can implement support for loops and if statements. I would appreciate any ideas that you may have, thank-you! Cheers! James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Loop / If support to a simple template engine
Richard Lynch wrote: On Wed, April 6, 2005 7:04 pm, James Williams said: Hey fellas, I'm makin a forum right now and as a sub project, I'm making a template engine / class. Right now all it does is variable replacement, however I am curious as to how I can implement support for loops and if statements. I would appreciate any ideas that you may have, thank-you! You'll have to write a parser. Or use something like bison/flex/yacc to create one for you. This is not something you want to try to knock out in an afternoon because you're bored. :-) Thank-you, but what exactly does a parser do? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] language files
Ryan A wrote: Hey, I was just wondering which is the best/most efficient way of having language files for a site? eg: if $lang=english then it should include lang.en.inc.php if $lang=swedish then it should include lang.se.inc.php etc One way I did it before was to have an array like so: $lang_en[0]=Enter username; $lang_en[1]=Enter password; etc and then in the main php files I include the above language files and in the print/echo statements I echo $lang_en[x]. It works quite well but just looking at the code its quite easy to get confused because of all the $lang_en[x] statements...and you have to constantly check the language file and the array number to know whats where, I though of using short workds like $get_user=Enter your username:; $get_pass=Enter your password:; but then sooner or later you are going to use the same variable and overwrite what you wrote before if you are not careful..esp if you have a lot of text on your site...or a large sitewhich will produce some weird results till you notice your mistake... So.how have you guys done itor any advise on doing it? pointers? tips? ideas? Cheers, Ryan Hey ryan! What I do is use an $lang array, but instead of using the traditional numers ([0], [1], [2]), I use $lang['hello'] or $lang['goodbye']. To prevent overwriting, I usually use the context in which they are used in as well: $lang['login_username'] = 'Username: '; $lang['login_password'] = 'Password: '; $lang['link_index'] = 'Go Home'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Loop / If support to a simple template engine
Thanks everybody, but is this not already a really simple parser? ?php class tpl { // // USER ACCESIBLE VARIABLES // // // PRIVATE CLASS VARIABLES // var $_template; // // USER DEFINED VARIABLES // var $tpl_directory; // REQUIRED - LOCATION OF THE TEMPLATES var $var_brace_open; // OPTIONAL - BRACE AROUND TEMPLATE KEYWORDS, DEFAULTS TO { var $var_brace_close; // OPTIONAL - BRACE AROUND TEMPLATE KEYWORDS, DEFAULTS TO } // // LOAD THE TEMPLATE PAGE // function load($tpl) { if (file_exists($this-tpl_directory . $tpl)) { $code = file($this-tpl_directory . $tpl); $this-_template = implode('!-- New Line --',$code); } else { print('pThe Template File Doesn\'t Exist/p'); } } // // ASSIGN A VARIABLE // function assign($var,$value) { if (isset($this-_template)) { if (!isset($this-var_brace_open) || !isset($this-var_brace_close)) { $this-var_brace_open = '{'; $this-var_brace_close = '}'; } $var = $this-var_brace_open . $var . $this-var_brace_close; $this-_template = str_replace($var,$value,$this-cls_template); } else { print('pPlease load the template file before assigning variables. use $tpl-load(\'file\'); to do this/p'); } } // // DISPLAY THE PAGE // function display() { $this-_template = explode('!-- New Line --',$this-cls_template); foreach ($this-cls_template as $line) { print($line); } } } ? Drewcore wrote: a parser is a program that i will take some preformatted text, extract the information from it, and then do work with that information. xml programs users parses to pull data from between the tags. in your case, you'd have to have some sort of declaration in your code that sets apart code blocks you want replaced, invent some sort of system of replacing that code on demand, then write that code that implements your system. a little difficult, and out of my scope, i'm sure. unless i spent two weeks with minimal sleep. drew On Apr 6, 2005 9:37 PM, James Williams [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Wed, April 6, 2005 7:04 pm, James Williams said: Hey fellas, I'm makin a forum right now and as a sub project, I'm making a template engine / class. Right now all it does is variable replacement, however I am curious as to how I can implement support for loops and if statements. I would appreciate any ideas that you may have, thank-you! You'll have to write a parser. Or use something like bison/flex/yacc to create one for you. This is not something you want to try to knock out in an afternoon because you're bored. :-) Thank-you, but what exactly does a parser do? -- 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] New Website for PHP Coders.. www,lifenit.com
God damn it this is really startin to piss me off... On 3/17/2005 8:22:17 PM, freshersworld .com ([EMAIL PROTECTED]) wrote: Hi All, This is a very interesting website. Visit www.lifenit.com Also I can refer one more sebsite for you.. www.merchantii.com Hope these were Useful. Rgds, Freshersworld First Job. Dream Job... Freshersworld.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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] Ad software
Ryan A wrote: Hey, I am looking for a software that just lists adverts... eg: Like ebay but without the bidding Requirements are simple, so simple that i am sure something like this exists and i dont have to write it myself: 0.They must register first then... 1.offer the person to put in his ad details, a few other details like his telephone number, asking price etc 2.(optional) add a photo 3. They can delete their ad if they want to later 4.normal visitors can search or browse by category or latest additions etc I can give you an example in the form of a swedish site: http://www.blocket.se I have found something very close in ASP but i dont trust MS products and would rather it be in PHP as i can tinker with it (i dont know ASP and my server does not support it) As you can see, it wouldnt take too long to build but i have little time so i would rather finish my lingering old projects than start on something new from scratchits for a pet site where people can sell (or barter/exchange) aquarium fish, fish food, aquariums, filters, stands etc Checking google and hot scripts just sends me to ad management software like banner rotators and bidding systems etc. Any help appreciated and thanks in advance. -Ryan Try photoposts classifieds at www.photopost.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a new it company
I agree entirely... *down with bansalsetech.com* Ryan A wrote: here here - I thought It was kind of humourous, I also bare in mind that these guys in the far east are just trying to make their way in the world too, they are at a disadvantage with the language also. besides which there is a quite a culture gap - I notice it alot in the way people from India/FarEast ask questions in general - its a totally different 'style' I agree but thats not a reason to write to this list with that crap, I replied to him with two words...the first word started with a F and was four letters, the second was a three letter word :-) I also agree with the bloke about boycotting that site and I vote we also write bad things about that site on all the websites we control :-D As for the spam part, writing one email to a person I think cannot be called spam...but I think this falls into spam as he wrote to the list which spills out to many many peopleits as good as if he copied all the addresses from the list and used a mass mailer to mail the message/crap/spam to all of us individually My $0.02 Cheers, Ryan -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] software catalog
What's up Ryan, I do believe that the cart software you choose should for the most part be independent upon what exactly your selling. There are a few big shopping cart solutions that work for selling anything and I'm sure there are features and / or plugins that will allow you to do discounts based on multiple product purchases. hit up sourceforge or hot scipts and you're sure to find plenty of awsome results. Good Luck! Ryan A wrote: Hey! Anybody know of a software catalog (or cart preferably) that is free? A site i am working for sells software, now they want to have a cart feature so people can put the packages in a cart and get discounts etc if they purchase more than 1 product...they are using 2checkout for processing. I checked the usual places and google of php software cart but got back garbled results, most of that carts are for tangible products :-( Any help or recommendations would be appreciated. Thanks in advance, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can i calculate total process time?
Eli wrote: On top use this: ?php $mtime = explode( ,microtime()); $starttime = $mtime[1] + $mtime[0]; ? On the end use this: ?php $mtime = explode( ,microtime()); $endtime = $mtime[1] + $mtime[0]; echo \n\n\nhrb.round($endtime-$starttime,3). sec/b; ? If you want a nice object oriented solution that's easy to use over and over again which does pretty much the same thing, give this class a whirl. class page_gen { // // PRIVATE - DO NOT MODIFY // var $cls_start_time; var $cls_stop_time; var $cls_gen_time; // // FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE // function start() { $microstart = explode(' ',microtime()); $this-cls_start_time = $microstart[0] + $microstart[1]; } // // FIGURE OUT THE TIME AT THE END OF THE PAGE // function stop() { $microstop = explode(' ',microtime()); $this-cls_stop_time = $microstop[0] + $microstop[1]; } // // CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND COLOR CODE THE RESULT // function gen() { $this-cls_gen_time = round($this-cls_stop_time - $this-cls_start_time,5); return $this-cls_gen_time; } } then, on the page you want to time, just put at the top: require('class.pagegen.php')// OR WHATEVE YOU NAMED IT $pagegen = new page_gen(); $pagegen-start(); // START TIMING then at the end... $pagegen-stop();// STOP TIMING $pagegen-gen(); // RETURN GENERATION TIME -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question: qutoes?
rory walsh wrote: Can anyone tell me if there is a difference between double quotes and single quotes? Cheers, Rory. What's up Rory... actually there *is* a difference. Double quotes are parsed by the php engine, meaning it goes through and finds variables and stuff which it can parse, ex. print(Here is a variable: $variable!); will print Here is a variable: The value of the variable! Single quotes are not parsed by the php engine, so the same code with single quotes (print('Here is a variable: $variable!'); will return Here is a variable: $variable! I hope that answeres your question -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cache engine
Mark Charette wrote: Evert - Rooftop Solutions wrote: I heard that shared memory is actually slower than writing and reading a file and it is not available on windows systems. Hmmm ... that's an interesting thing you heard concerning shared memory. Care to share _who_ told you that? I'd like to make sure I don't hire him/her in the future. Mark C. HaHa Burn! so you're saying that this is *not* true. I'm also interested in cacheing although I know nothing about it. I'm making a forum and it's small size and fast processing times are it's forte, so a cache system would be awesome, I'm thinking about incorporating it with my simple templating class. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unexplainable - page generation time class
Howdy! I've made a class which simply determines the page generation time of a php script... After pretty much an hour of straight examining the code and trying tons of different things, no good has come of it, however I can't find an error... anywhere. ?php class page_gen { // // PRIVATE - DO NOT MODIFY // var $cls_start_time; var $cls_stop_time; var $cls_gen_time; // // FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE // function start() { $microstart = explode(' ',microtime()); $this-cls_start_time = $microstart[0] + $microstart[1]; } // // FIGURE OUT THE TIME AT THE END OF THE PAGE // function stop() { $microstop = explode(' ',microtime()); $this-cls_stop_time = $microstop[0] + $microstop[1]; } // // CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND COLOR CODE THE RESULT // function gen() { $this-cls_gen_time = $this-cls_stop_time - $this-cls_start_time; return $this-cls_gen_time; } } ? What happens is it simply returns the $this-cls_start_time variable. Both the start() and stop() functions work fine because to test them I put print commands at the end and they both returned proper results, the error appears to be in the line where I minus the start time from the end time. It simply returns a negative start time instead of minusing the two. I tried changing the minus to a plus for testing sake and it just took out the negative. Does anybody have any idea what is going on here? Thanks-you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable Replacement
Hey guys, I'm coding a forum right now and I just decided that I needed to code some variable replacement to create a simple template system. This is the code I have but it doesn't work |?php $tpl = file http://php.net/file(tpl/head.tpl); $code = str_replace http://php.net/str_replace({sitename},$config['sitename'],$tpl); foreach ($code as $codeline) { print http://php.net/print($codeline); } ?| This simply results in a mess, with only the pictures showing up on my page... I know this code is horrible but I have no idea how to go about doing this. I've never worked with reading files and whatnot before -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php