Re: [PHP] Template style question
One idea that you might try. is XSL. instead of doing %var1% and doing a replace. you can do things like Doing this also completely separates presentation logic from the code. you can do other fun things like loops also. I will warn you by saying that XSL in the beginning is a real headache to figure out. but after you get things down, it's very nice. I currently have things in my sites setup to init an Object that when echo'd will do the XSL translation for me. After that all I do is gather the data into an XML document and stylize it. Simplifies websites considerably. Gather the data you need... stylize it how you want it.. and if you want to swap out the entire layout on the fly. On Saturday 05 November 2005 01:10 pm, Leonard Burton wrote: > Greetings, > > HI All, I hope all is well. > > I have set up a template parser. Basically, it parses the template > and finds tags with tag_name.dat file and then includes the > tag_name.dat file. I have considered a few other options but as of > now I think I like what I have come up with. > > The only problem that I have in my design is that I have to hard code > tables in the dat file mixing php and html. I would prefer to be able > to do something like: > > [[tag with db query]] > > colnamecolnamecolname > %var1%%var2%%var3% > > [[/tag with db query]] > > I would like it to be able to parse the line with the %var1% (which is > the column name with % or some other indicator on each side) in it and > then have it generate how many ever rows as nessecary. > > Currently, my parsing engine loads the template, preg_splits() it so > each template tag is on a new line, and then passes through the > resulting array and executes the code for whatever tag is chosen. > > There are a couple ideas that I have thought of but have not thought > of any real good way so I am turning to the list. > > Thanks for all of your help on this list! > > -- > Leonard Burton, N9URK > [EMAIL PROTECTED] > > > "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
[PHP] Mcrypt 3DES encrypt/decrypt Help
Hi all: I wan't to use php_mcrpyt to encrypt data,but have a problem in it ! Hint: Warning: mcrypt_encrypt(): Size of key is too large for this algorithm Algorithm : 3DES Key: 48bit -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Making functions available from another script
Hi PHP-ers, Here's an easy one: Q: How can I make a function available from within another php script? Eg. B.php contains: Which has a function fn($x); Later on, I want to include this function in B.php somewhere. In short: B.php wants to use fn($x) found in A.php. Regards, Richie ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg for unicode strings?
Andy, try that one: /^[a-zA-Z]{3}|\p{Sc}$/u You don't want to put \p{Sc} in square brackets as \p{Sc} itself already is a character class. Umm.. Kinda don't make myself clear here, do I? You just don't want to, it's 5am in the morning here I gotta go to the next bed ;p Regards, Niels Andy Pieters: > Hi > > Thank you for your reply. > > My regexp was > > /^([a-zA-Z]{3,}|[\W])/ > > Meaning match any string that is either > 3 letters > or > 1 word character > > I'd like to change this to > 3 letters > or > 1 currency character > > So I changed the regexp accordingly > /^([a-zA-Z]{3,}|[\p{Sc}])/u > > And I tested with £ > > but it fails. > > Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Line breaks in mail function?
Jasper Bryant-Greene wrote: On Mon, 2005-11-07 at 12:20 +1000, Murray @ PlanetThoughtful wrote: Example code: $body = 'From: ' . $name . '\r\n\r\n'; $body .= 'Email:' . $email . '\r\n\r\n'; $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n'; $body .= 'Feedback:\r\n\r\n'; $body .= $feedback; mail("[EMAIL PROTECTED]", "Feedback", $body, "From: $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion()); As I said above, I've also tried using "\n\n" instead of "\r\n\r\n". Can anyone give me some advive on how to get the linebreak characters interpreted as linebreaks? Use double quotes around the parts that have \r and \n characters if you want them to be interpreted. Ah, damn you Jasper, I should have noticed that myself. Don't you hate it when you've been staring at code too long to notice the obvious? Thank you! Much warmth, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysql & php & Load Data Infiles
While I think this is primarily a mysql syntax problem I have asked on the mysql forum but not got a reply. I am trying using php to set up a system for loading a new data base using the Load Data Infile statement. I could not get it to work properly with php so I thought I would try some command line test. Does anyone know the loaction of a suitable php script that would handle a list of files and tables for loading into a database (preferably doing an initial dummy run using temporary tables with an error report). If not when I get this wretched syntax issue solved I guess I might have one available fairly soon. Here are my notes: This exercise was a test in preparation for a plan to use Load Data Infile for initallising a new database comprising over 80 tables. The database currently has no data. The first field is auto-increment. What am I doing wrong here? If I cannot do it using Load Data Infile what alternatives would you suggest? ___ Here is mysql command line dialogue on a win XP development machine: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 85 to server version: 5.0.13-rc-nt-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use NewBuddies; Database changed mysql> load data local infile 'E:/Development/LBuddies/Documemntation/lbcm_diet_ types.txt' REPLACE into table lbcm_diet_types fields terminated by ',' ENCLOSED by '"'; ERROR 1265 (01000): Data truncated for column 'Help' at row 1 mysql> describe lbcm_diet_types; +-+-+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+-+--+-+-++ | Diet_Type_ID | int(11) | NO | PRI | NULL | auto_increment | | Diet_Type_Title | varchar(30) | NO | UNI | Enter Title | | | Diet_Type_Descr | text | NO | | | | | Help | int(11) | NO | | 1 | | +-+-+--+-+-++ 4 rows in set (0.01 sec) mysql> select * from lbcm_diet_types; Empty set (0.00 sec) mysql> ___ Here is the content of the first file created as a text file using editor macromedia: ___ "1","Unlimited","Anything goes","1" "2","Lacto-Vegetarian","Vegetarian consuming milk products, no meat, no fish","1" "3","Fish_Lacto-Vegetarian","Lacto Vegetarian plus fish","1" I then realized my obvious mistake two "'"s in the third field on line two. I removed "REPLACE" from the command and ran it again: mysql> load data local infile 'E:/Development/LBuddies/Documemntation/lbcm_diet_ types.txt' into table lbcm_diet_types fields terminated by ',' ENCLOSED by '"'; Query OK, 2 rows affected, 3 warnings (0.00 sec) Records: 2 Deleted: 0 Skipped: 0 Warnings: 3 mysql> select * from lbcm_diet_types; +--+---++--+ | Diet_Type_ID | Diet_Type_Title | Diet_Type_Descr | Help | +--+---++--+ | 1 | Unlimited | Anything goes | 1 | | 3 | Fish_Lacto-Vegetarian | Lacto Vegetarian plus fish | 0 | +--+---++--+ 2 rows in set (0.00 sec) /* OK we have progress BUT */ /*What happened to line 2? */ /* Why 0 for the help ID on line 3? */ /* So I amended the file to read: */ "4","Diabetic","See Diet Sheet","1" "5","Glutenfree","No wheat products or other glutenous grains","1" "6","Nut allergic","Avoid all nut products","1" /* and with the command:*/ mysql> load data local infile 'E:/Development/LBuddies/Documemntation/lbcm_diet_ types.txt' into table lbcm_diet_types fields terminated by ',' ENCLOSED by '"'; Query OK, 2 rows affected, 3 warnings (0.00 sec) Records: 2 Deleted: 0 Skipped: 0 Warnings: 3 /* I got:*/ mysql> select * from lbcm_diet_types; +--+---++--+ | Diet_Type_ID | Diet_Type_Title | Diet_Type_Descr | Help | +--+---++--+ | 1 | Unlimited | Anything goes | 1 | | 3 | Fish_Lacto-Vegetarian | Lacto Vegetarian plus fish | 0 | | 4 | Diabetic | See Diet Sheet | 1 | | 6 | Nut allergic | Avoid all nut products | 0 | +--+---++--+ 4 rows in set (0.00 sec) mysql> /* showing that the second line from this file is again being dropped and the last line gets 0 for help! - I must be missing something obvious but I am damned if I can see it /* So I realize it might be due to the windows CR/LF oddity therefore I try: */ mysql> load data local inf
RE: [PHP] Line breaks in mail function?
Hi Murray, Try doing something like this: --- $body = "From: $name Email: $email IP Address: $_SERVER['REMOTE_ADDR'] Feedback: $feedback "; $fromaddr = "$email Reply-To: $email X-Mailer: PHP/" . phpversion(); mail("[EMAIL PROTECTED]", "Feedback", $body, $fromaddr); --- I haven't tested this 'actual' piece of code, but I've used similar in other emailing scripts. Regards, Richie ! > -Original Message- > From: Murray @ PlanetThoughtful [mailto:[EMAIL PROTECTED] > Sent: Monday, 7 November 2005 10:21 am > To: php-general@lists.php.net > Subject: [PHP] Line breaks in mail function? > > Hi All, > > I'm building a site on a new web host and am currently working on > feedback forms. > > I'm using the mail() function to send the feedback to the destination > mail account, and I'm having problems getting the body of the email to > line break. > > I've tried constructing the body with both "\n\n" and "\r\n\r\n" > terminating lines where I want line breaks to appear, but both return an > email with the body in one long string showing the actual "\n\n" or > "\r\n\r\n" characters, as opposed to interpreting them as line breaks. > > Example code: > > $body = 'From: ' . $name . '\r\n\r\n'; > $body .= 'Email:' . $email . '\r\n\r\n'; > $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n'; > $body .= 'Feedback:\r\n\r\n'; > $body .= $feedback; > mail("[EMAIL PROTECTED]", "Feedback", $body, "From: > $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion()); > > As I said above, I've also tried using "\n\n" instead of "\r\n\r\n". > > Can anyone give me some advive on how to get the linebreak characters > interpreted as linebreaks? > > Many thanks and much warmth, > > Murray > > -- > 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] Line breaks in mail function?
On Mon, 2005-11-07 at 12:20 +1000, Murray @ PlanetThoughtful wrote: > Example code: > > $body = 'From: ' . $name . '\r\n\r\n'; > $body .= 'Email:' . $email . '\r\n\r\n'; > $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n'; > $body .= 'Feedback:\r\n\r\n'; > $body .= $feedback; > mail("[EMAIL PROTECTED]", "Feedback", $body, "From: > $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion()); > > As I said above, I've also tried using "\n\n" instead of "\r\n\r\n". > > Can anyone give me some advive on how to get the linebreak characters > interpreted as linebreaks? Use double quotes around the parts that have \r and \n characters if you want them to be interpreted. -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Line breaks in mail function?
Hi All, I'm building a site on a new web host and am currently working on feedback forms. I'm using the mail() function to send the feedback to the destination mail account, and I'm having problems getting the body of the email to line break. I've tried constructing the body with both "\n\n" and "\r\n\r\n" terminating lines where I want line breaks to appear, but both return an email with the body in one long string showing the actual "\n\n" or "\r\n\r\n" characters, as opposed to interpreting them as line breaks. Example code: $body = 'From: ' . $name . '\r\n\r\n'; $body .= 'Email:' . $email . '\r\n\r\n'; $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n'; $body .= 'Feedback:\r\n\r\n'; $body .= $feedback; mail("[EMAIL PROTECTED]", "Feedback", $body, "From: $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion()); As I said above, I've also tried using "\n\n" instead of "\r\n\r\n". Can anyone give me some advive on how to get the linebreak characters interpreted as linebreaks? Many thanks and much warmth, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.1 release ?
Hi there just wondering when there may be a php 5.1 release ? I just went into the downloads on the php site and the link to RC1 has been removed ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PGP 5 start up issue
On Sunday 06 November 2005 12:14, the author Unknown Unknown contributed to the dialogue on- Re: [PHP] PGP 5 start up issue: >I don't mean the php.ini file, I mean the extension directive setting in >php.ini Yep I thought that was what you meant -- it is not the cause.. I should have posted that I found a solution which was to use the pear functions dor those extensions. It seems, for some reason, that the extensions do not work on php5 but the pear equivalents do.. at least for me. david -- 40 yrs navigating and computing in blue waters. English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus. Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after completing engineroom refit. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PGP 5 start up issue
I don't mean the php.ini file, I mean the extension directive setting in php.ini
[PHP] use SMB share to run php files
Ok been looking into in and know a bit of terminology now. I have an SMB share on my mac which is my WWWROOT folder on my windows computer. These files have all permissions enabled so I can edit in dreamweaver (on mac). All I want to so is setup PHP/Apache so it recognises the WWWROOT folder and everything under it (folders and files) so it runs the php. Do I have to change the userdir in httpd.conf ?? If so how? Can I have my current folder (http://127.0.0.1/~myname/index.php) in my Sites folder and add an extra php enabled folder?? Thanks, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] italic, bold and underline with GD ?
Can we use some function with GD to make text italic, bold and/or underline? http://php.net/imagettftext I see we can change size and font, but not style it's not possible in PHP? Thanks in advance David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Template style question
On Sun, 2005-11-06 at 05:11, Petr Smith wrote: > Smarty sucks. Mixing presentation and logic is never good idea. I know > Smarty is very popular, but big popularity doesn't always mean quality. > > Back to original question: If you decided to reinvent the wheel, please > don't reinvent square wheel without tire. > > Mixing presentation and logic is bad. You should have no sqls, loops, > ifs or any other logic things in templates. Templates should be editable > by any stupid guy, anyone who knows just css/html. No sql, no php, no > other language. While I'm not a particularly great fan of Smarty myself (preferring pull versus push systems), I don't think that support for conditionals and loops within a templating system is a bad thing provided that such loops and conditionals are restricted to use for presentation logic only. To create a template system that only resembles HTML/CSS I think would put an extraneous burden on the developer since they are the one that would have to define/manage the unrolling of iterative data in such a way as to make it invisible to the template designer. Additionally, there's no way it could be entirely like CSS/HTML since at some point you need to place markers for the content to be expanded, and no matter how you slice the problem, those markers aren't going to be HTML. They might be HTMLish (a la XML) but they won't be HTML. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] filemtime doesn't always copy correctly
I am backing up a file (the path & filename of which are stored in $original; the path & filename of the copy are stored in $bkup). I would also like to copy the file modification time of $original, so, after copying the file itself, I use: touch($bkup, filemtime($original)); However, after I use the above "touch" function, filemtime($original) and filemtime($bkup) are often slightly different. For example, I might have: echo filemtime($original); // gives 1126191599 echo filemtime($bkup); // gives 1126191600 Why the small difference? (I'd like these two file modification times to be exactly the same because I want to compare file modification times when I do incremental backups, and copy a file only if the file modification times are different.) By the way, if it helps, I am using Windows XP. Thanks!
Re: [PHP] Register Globals (more)
John Taylor-Johnston wrote: Patience please :) See my html below. Basically, if type=checkbox is checked, I'm trying to build $to string in mail(). parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING line 4 How do I rebuild this peice of code to be register_globals=off friendly? Just when I thought I was getting good. This keeps up, I'm changing back the php.ini myself. John stop using eval()! (you know the film SAW? well it's people who use too much eval() that end up chained to the raditator) also find out what the difference is betwewen using single and double quotes. also learn how/why to use isset(), and initializing your variables before using them... now look at this, I'm pretty sure ti will do what you want: ,"; } } echo $to; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register Globals (more)
John Taylor-Johnston wrote: Patience please :) See my html below. Basically, if type=checkbox is checked, I'm trying to build $to string in mail(). parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING line 4 How do I rebuild this peice of code to be register_globals=off friendly? Just when I thought I was getting good. This keeps up, I'm changing back the php.ini myself. John stop using eval()! (you know the film SAW? well it's people who use too much eval() that end up chained to the raditator) also find out what the difference is betwewen using single and double quotes. also learn how/why to use isset(), and initializing your variables before using them... now look at this, I'm pretty sure ti will do what you want: ,"; } } echo $to; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Template style question
Petr Smith wrote: > Smarty sucks. Mixing presentation and logic is never good idea. I know > Smarty is very popular, but big popularity doesn't always mean quality. > > Back to original question: If you decided to reinvent the wheel, > please don't reinvent square wheel without tire. > > Mixing presentation and logic is bad. You should have no sqls, loops, > ifs or any other logic things in templates. Templates should be > editable by any stupid guy, anyone who knows just css/html. No sql, no > php, no other language. > > Back to original idea to parse table. Do not copy bad ideas from other > templating engines. Again - reinvent a better wheel or use some from > 1000s of existing libraries. Download some existing libraries, think > about good and bad things, make it better, make it different! > Otherwise we will end with 1000+1 stupid, same, useless templating > libraries. You don't need to mix presentation and logic with Smarty. If you create your custom tags with Smarty and use these instead of having the inline "Smarty PHP" code, you'll have separated them just fine. Then if the end user wants to use PHP inline, fine, either let them, or don't. Either way, Smarty is about the fastest and most versatile engine in the PEAR library, as far as I know. I'd rather use that, than build something custom from scratch. And, in combination with Tidy and Cache_Lite, you'll get a very fast and precise rendering engine... Just my $0.02. Regards, Torgny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Template style question
Smarty sucks. Mixing presentation and logic is never good idea. I know Smarty is very popular, but big popularity doesn't always mean quality. Back to original question: If you decided to reinvent the wheel, please don't reinvent square wheel without tire. Mixing presentation and logic is bad. You should have no sqls, loops, ifs or any other logic things in templates. Templates should be editable by any stupid guy, anyone who knows just css/html. No sql, no php, no other language. Back to original idea to parse table. Do not copy bad ideas from other templating engines. Again - reinvent a better wheel or use some from 1000s of existing libraries. Download some existing libraries, think about good and bad things, make it better, make it different! Otherwise we will end with 1000+1 stupid, same, useless templating libraries. Petr James Benson wrote: Give smarty a try rather than re-inventing the wheel http://smarty.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php