RE: [PHP] Round
I believe there is some confusion on what ABS actually does. Ignoring all the rounding that you are trying to do ABS is a very simple function. ABS definition: Returns the absolute value of number. What that means is. Abs(1) = 1 Abs(2) = 2 Abs(3) = 3 Abs(0) = 0 Abs(-1) = 1 Abs(-2) = 2 Abs(-3) = 3 Simply put, returns the positive value of the number given. Thus if you put it on a negative number it will always return positive. This most likely doesn't help what your trying to do, but I wanted to clarify this as you keep stating you are expecting a -1 when you use the ABS function. Unless someone has some trick that I don't know about, ABS will NEVER return a negative number. -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 29, 2007 1:43 PM To: Daniel Brown Cc: Zoltán Németh; php-general@lists.php.net Subject: Re: [PHP] Round Daniel Brown wrote: On 8/29/07, Zoltán Németh [EMAIL PROTECTED] wrote: Think this through before you respond... Try this ?php var_dump( round(-0.26) ); var_dump( abs( round(-0.26) ) ); var_dump( round(-1.26) ); var_dump( abs( round(-1.26) ) ); ? does this give you the desired results? What if I expected -1 for the last answer? It didn't take much thinking this time if you were expecting -1 for the last answer, you'd be wrong. ;-P The very nature of abs() is to return an absolute number, which is never a negative. Exactly my point, abs() is not the answer if he had any negative number that did not round to zero, say it would round to -2, then having the abs() in the calculations would return 2 instead of -2, which would be wrong. From what I read from the OP, I don't think this is what he was looking for. the op was asking why he got -0 instead of 0. not for a solution to fix it. ok, better example. plaintext?php $list[] = 1; # I expect to get 1 and I get 1 $list[] = -1; # I expect to get -1 but I get 1 $list[] = -1.2; # I expect to get -1 but I get 1 $list[] = -0.23;# I expect to get 0 and I get 0 $list[] = -0.75;# I expect to get -1 and I get 1 foreach ($list AS $value) { var_dump( abs( round($value) ) ); } ? But, from what the OP says, he would get -0 instead of 0 for the 4th entry. Am I correct with this? if so, you could try casting it as an int like so var_dump( (int)round(-0.26) ); That might fix the problem -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- 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] urlencode - urldecode
Hi, I am using a header(location:) to send a rawurlencod'ed string to another script...then I tried decode it and use those values...but its not working... snippets of my code: // sending file: $one=rawurlencode(dir_name=$dir_nameimgs_dir=$imgs_dirthumb_pre=$thumb_pretn_width=$tn_widthtn_height=$tn_heightwrite_text=$write_textcolors=$colorsx_pos=$x_posy_pos=$y_poslink1=$link1link2=$link2link3=$link3img_src1=$img_src1img_src2=$img_src2); header(location: process.php?a=.$one); Am totally confused as to how to use urldecode to get back my values to do other operations in my script.. I tried the example from php.net: (example 1) http://se2.php.net/manual/en/function.urldecode.php but am unable to adapt it to give me my variables/values. The reason I am using rawurlencode is because $link1 and $link2 will contain html tags... Thanks for your time. -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urlencode - urldecode
Hi, Thanks again John, point taken...will not trust the browser, will use sessions :-) Cheers, -Mag --- John Holmes [EMAIL PROTECTED] wrote: PHP Gen wrote: // sending file: $one=rawurlencode(dir_name=$dir_nameimgs_dir=$imgs_dirthumb_pre=$thumb_pretn_width=$tn_widthtn_height=$tn_heightwrite_text=$write_textcolors=$colorsx_pos=$x_posy_pos=$y_poslink1=$link1link2=$link2link3=$link3img_src1=$img_src1img_src2=$img_src2); header(location: process.php?a=.$one); Am totally confused as to how to use urldecode to get back my values to do other operations in my script.. You don't have to decode it on the other end. Everything as you've got above (that whole string) will be in $_GET['a'] on process.php. Since you asked, though, you use urldecode() like this: $decoded = urldecode($_GET['a']); That's a lot of information to be sending through the URL, btw. I think there's a max of 1024 characters, generally, although each browser is different. Just something to note. Maybe sessions would be better? -- John Holmes php|architect - The magazine for PHP professionals - http://www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex help and file question
Hi, I am just starting out with regex (and classes) so am not sure how to do this... I am seeing if a HTML file exists, if yes, I am using file_get_contents to get the entire HTML file into a string. In the HTML file I already have this: !-- Start header -- html body whatever you want comes here !-- End header -- How do I use a regex to span these multiple lines and simply cut everything (including the start..end part)from !-- Start header -- to !-- End header -- Second question: I am using file_get_contents, is it better to use this than file() or fread() ? Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Flush()....go to bottom of page (might be 0T)
Hi, I am using flush() and ob_flush() in one of my scripts and its working great.., just one problem, as it keeps outputting x on the screen the page just stays on top...is there anyway (I am not sure via php...but maybe JavaScript? ) to make the browser follow the output below eg: keep the scroll below right next to the text. This is what i am using: for($i=0; $i1000;$i++) { echo somethingbr; echo str_repeat( , 256); flush(); ob_flush(); sleep(1); } Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: regex help and file question
Hi, I can't answer your regexp question but some thoughts on file() etc.: - file() returns the contents line by line as an array, so this makes only sense if you need the contents in this form, e.g. for looping through each line and applying a function or whatever - fread() requires a file handle that you have to create with fopen(), so file_get_contents() is kind of a shortcut for fopen()/fread() Hey, Thanks for replying and the answer to my second Q, sounds like file_get_contents() is good for me now. I think i found a solution for the regex too, just have to modify some parts. Cheers, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flush()....go to bottom of page (might be 0T)
--- John Holmes [EMAIL PROTECTED] wrote: PHP Gen wrote: Hi, I am using flush() and ob_flush() in one of my scripts and its working great.., just one problem, as it keeps outputting x on the screen the page just stays on top...is there anyway (I am not sure via php...but maybe JavaScript? ) to make the browser follow the output below Not with PHP. Use Javascript's scroll properties/methods/whatevers... :) Yeah, thought so. Dont know JS that well though (been a long time) so will have to search the web. Thanks anyway. Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sorting an array..dont know numeric or alpha-numeric
Hi, I have a function that reads jpg files (thumbnails) from a directory and puts all the files names into an array...I want to sort that array by the filename, problem is, I dont know if filenames will be pure numeric (eg 001.jpg,002.jpg) or alpha-numeric (asdf001,asdf002) It HAS to be sequential from small to big (eg: 0-10) as I am making static html pages from them further down the program. Looking in the manual I have tried sort() without any luck, then looking further I found natcasesort() which would be perfect for my needs right now, but cant get it to work :-( Below is the function (its not big) *** Start function function directory($dir,$filters){ $handle=opendir($dir); $files=array(); if ($filters == all){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != all){ $filters=explode(,,$filters); while (($file = readdir($handle))!==false) { for ($f=0;$fsizeof($filters);$f++): $system=explode(.,$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } $pics=directory(pics,jpg,JPG,JPEG,jpeg,png,PNG); *** End function I have tried putting natcasesort() in many places but not working Thanks in advance. -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sorting an array..dont know numeric or alpha-numeric
Hi Curt, Damn, looks like I (unintentionally) gave you guys quite a challenge! You're the first one to reply and looks like you sure worked on it! For starters, if your going to provide some code, make sure its readable by others.. trying to figure out what it is doing is nearly impossible the way it is written.. Sorry about that, I didnt write the code, I snipped it off from phpbuilder (i think, might have been another php help site) and since it was working I didnt touch or do anything. Will go through the modifications and advise you gave me and will write back if.. any problems. Thanks again, -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused...need some programming logic
Hi, I have 13 folders with a few thousand images each, now the client wants me to export the gallerys to another server that does not run phpso he wants plain .htm files. Below is how far I have come to porting this... the idea being: generate .html files then simply copy the images folders to the clients other server and dump the html files there and he has a gallery ready to go..this is how i thought of it: 1: read number of images from a directory (done) 2: After reading, divide the number by 100 (eg: 1348 images equals 14 pages...last page only 48 pics) (done) 3: Dynamically create the .html files via a fopen (done) 4: put 100 img tags to call 100 images per page (confused here) The images are numbered sequentially but dont start from 0 or 1, they start from something like 00047.jpg or 0024.jpg etc I think I will need a foreach (and tried a foreach...but didnt work) but am confused...ANY help appreciated. ** Start code ?php function directory($dir,$filters){ $handle=opendir($dir); $files=array(); if ($filters == all){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != all){ $filters=explode(,,$filters); while (($file = readdir($handle))!==false) { for ($f=0;$fsizeof($filters);$f++): $system=explode(.,$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } $pics=directory(pics,jpg,JPG,JPEG,jpeg,png,PNG); $total_pics=count($pics); $pages = ceil($total_pics / 100); // using ceil so 12.23 translates to 13 $content=Mag; /* foreach ($pics as $p) // $p is the name of the file {$content.=$content.img src='thumbs/tn_.$p.';} */ for($i=0; $i$pages;$i++) { if($i==0){$j=;}else{$j=$i;} $index=index.$j; if(!$handle = fopen($index..html, w)) {echo Cannot open file ($filename);exit;} if(fwrite($handle, $content) === FALSE) {echo Cannot write to file $filename);exit;} fclose($handle); } echo The end; ? ** End code The above code is working so far as to: 1.read from the dir 2.create the required number of pages while making sure the first page is index.html 3. Writing some content in..in this case just: Mag Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
--- Justin Patrin [EMAIL PROTECTED] wrote: 4: put 100 img tags to call 100 images per page (confused here) I put some code inline below. Should work. If you want a thumbnail gallery, you could also create thumbnails using the GD functions in PHP, same them, and create an img tag with the thumbnail with a link to the fill file. Hi, Thanks for replying. I think you misunderstood my problem, your code is just printing the images onto the screen...I need to take 100 img tags and write it to each of the .html pages... eg: if there 112 images in the folder, it should create 2 html files (index.htm and index1.htm - this is already done - THEN insert 100 img tags into the first file (index.htm) and balance 12 img tags into the second file) Ideas? Thanks, -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
Hey, Just change the echo to an fwrite. for($j = 0; $j 100; ++$j) { if($pics[$i * 100 + $j]) { fwrite($handle, 'img src='.$pics[$i * 100 + $j].'/br/'); } } Works like a charm, thanks a million. -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Write text on imge...AND save it to disk..
Hi, Have very little of idea of the GD functions (and dont ahve imagemagik) so am having problems 1. I need to read all the images from a dir and write something on it at the bottom right side of the picture 2.save this image in a diff folder keeping the originals as is. I have worked out the logic to fetch the imgs from the folder into an array but the rest is beyond me... I HAVE gotten a good class that does a lot but...it does not save the image, it outputs it to the browser (class below) can anybody help me save the file to a folder on my disk please? I have gone to http://se.php.net/image, searched the archives, http://www.hotscripts.com/PHP/Tips_and_Tutorials/Image_Manipulation/ and google...but am as confused as ever...maybe because its 5am ;-) and been working whole day. Solutions or URLs are most welcome, thanks in advance. -Mag * Class ** ? class img_add_txt{ /* Created by Richard Sumilang http://www.richard-sumilang.com object img_add_txt($array); This function adds text on top of an image Usage: $config=array( text = Coupon: Here is your free coupon, text_colors = 255 68 0, // RGB Seperated by spaces image_loc = example.jpg, image_type = JPEG, // PNG and GIF Supported // Optional arguments; default is center area on image x_pos = , y_pos = , ); $graphic=new img_add_txt($config); */ function img_add_txt($config){ // header //header(Content-Type: image/gif); $this-func_header($config['image_type']); // set up image $im = ImageCreateFromJPEG($config['image_loc']); // Set up text colors $text_colors=explode( , $config['text_colors']); $text_color = ImageColorAllocate($im, $text_colors['0'], $text_colors['1'], $text_colors['2']); // get font dimensiona $font_height = ImageFontHeight(3); $font_width = ImageFontWidth(3); // get image dimensiona $image_height = ImageSY($im); $image_width = ImageSX($im); // get string length $length = $font_width * strlen($config['text']); // set the x, y cords of where the text will be placed if(empty($config['x_pos'])){ // calculate start coordinates for string $image_center_x = ($image_width/2)-($length/2); }else{ $image_center_x = $config['x_pos']; } if(empty($config['y_pos'])){ // calculate start coordinates for string $image_center_y = ($image_height/2)-($font_height/2); }else{ $image_center_y = $config['y_pos']; } // write string ImageString($im, 3, $image_center_x, $image_center_y, $config['text'], $text_color); // output to browser $this-output_image($config['image_type'], $im); }// End img_add_txt /* Output the correct header based on file type */ function func_header($var){ switch($var){ case PNG: header(Content-Type: image/png); break;
Re: [PHP] Write text on imge...AND save it to disk..
--- Jason Wong [EMAIL PROTECTED] wrote: On Thursday 05 August 2004 10:36, PHP Gen wrote: Have very little of idea of the GD functions (and dont ahve imagemagik) so am having problems So RTFM. I *DID* RTFM, just am more confused after doing so, did you read my post or did you stop after the first 3 lines? -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Write text on imge...AND save it to disk..
Big clue: look up each of the image*() functions used in your class and find out what they do. Arn't you the genius? I dont know if you read my older posts (around 2-3 days ago) when I asked if someone could recommend a good place to learn about PHP classes... Still learning and still dont have a clue what the this- means...so sorry, but your clue isnt big enough, still reading -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Write text on imge...AND save it to disk..
Hey, Here's another big clue: have a look at the section of the class which does the output. I did, but forget it, I got another answer from Wudi that is far more helpful and I think a starting point. I guess knowing the answer and still playing games makes you feel all powerful, to each their own ...remember one thing though, everyone was a newbie at one time and what goes around..comes around. Please dont answer this thread with any more of your help as I wont be reading it or replying to it. Have a nice day. -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple checkboxes
--- John Nichel [EMAIL PROTECTED] wrote: Like I had a shot in hell of getting the answer in first with John and Curt trolling the list. ;) Yep, those two guys are the highrollers here...also known as the big guns so when they are aroundI keep my little pistol voice out of it :-) Not complaining though, both have helped me countless times. -M = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace a button by an image
Jay Blanchard wrote: Yes, anything is possible. Can I be the next Queen of England? -- John C. Nichel Anythings possible...and with all your choices you want to be an old fart?? :-) = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Y! Messenger - Communicate in real time. Download now. http://messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] str_replace: use multiple or array?
Hi, I need to use a couple of str_replace's in one of my programs and would like to know which is more resource friendly: 1) having multiple str_replace one after another eg: $text = str_replace(orange, apple, $text); $text = str_replace(black, white, $text); $text = str_replace(girl, guy, $text); $text = str_replace(woman, man, $text); $text = str_replace(plant, tree, $text); 2) by using an array eg: $bad = array(orange, black, girl, woman, plant); $good = array(apple, white, guy, man, tree); $text = str_replace($bad, $good, $text); Also, off topic, Anybody else getting a non delivery message from: MAILER-DAEMON@ rotonet.rsdb.nl Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using htaccess to show diff dir (0T)
Hi, instead of showing my index.php page located at / I want to show my index.html page located at /cached/ but I dont want to use javascript as the clients JS might be off...and I dont want to get blacklisted by the search engines for redirecting... I did read somewhere that you can redirect via a .htaccess and NOT get blacklisted by giving out certain status codes (document moved permantly...I think) I cant find that article searching google, but since its so useful I'm pretty sure someone else is using that method, mind helping me out? Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) ___ Do you Yahoo!? Express yourself with Y! Messenger! Free. Download now. http://messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE[PHP] Using htaccess to show diff dir (0T) (SOLVED)
Hey, Dont worry about it, found it: http://www.thinkhost.com/services/kb/301-redirect.shtml Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Learning Regex
This helped me get started with Perl-compatible regular expressions: http://www.weitz.de/regex-coach/ Thanks Jason, will try it immd. Cheers, Mag. = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] class help (PLEASE)
Hi, After searching the archives and google I found a class that does bb code conversions, although I know how to use classes (thanks to the docs the writers write) I dont really understand them too well. The class is REALLY good and covers all my needs (which is to display php code in colors) but unfortunatly if there is no carrage return in the text it screws up my entire table... eg: I have a table width=70% , after calling this class if I try to display this: $result = mysql_query(insert into the_articles (author, headline, content10, content1, content2, content3, content4, content5, content6, content7, content8, content9, date, confirm, pages, link10, link1, link2, link3, link4, link5, link6, link7, link8, link9, typeNews) values . it expands my table to more than 150% and screws up my whole page. If somebody could please just edit the classfile so it breaks long text strings to the next line and does not screw up my page layout I will be MOST grateful and sing your praises, plus name my first child after you (heck, if you're a woman will name my next girlfriend after you!) :-) The classfile is below (tried writing to the author but I dont think he speaks english coz his website's in Italian I think: http://www.3site.it/) *** Class file *** ?php /** * TEXT HTML's TAGS EMULATOR * Compatibility: PHP = 4.1 * Page Example: http://www.3site.it/varie/codeLighter/index.php * - * LAST FIXED: multiple URL inline, increase speed convertion, adjusted code, color and list tags, unclosed /* comment. * Totally rewrote and fixed wrap_convert() function with url/img/mail preservation. * LAST ADDS:[AS] tag with different highlight FlashMX like * you can add one or more personal tags * LAST CHANGES: IMG now use [IMG={url}]{comment}[/IMG] as quote and url. * Now [PHP] [AS] use monospace font on. * Now are right both [URL={URL}] , [URL={URL}] * * - * WHAT IS THIS: * HTML 4.01 W3C Strict Standard VAlidated tags emulator with: * personalizable style sheet * great [tag] engine * JavaScript crossbrowser for checks and helps * automatic form / textarea / buttons generation * * - * HOW TO USE: * $codeLighter = new codeLighter(); * echo $codeLighter-convert($text_var); * WARNING: the better way to use this script is give an htmlentities($text_var); * so if you haven't converted $text_var you need to do this. * Example: * echo $codeLighter-convert( htmlentities($text_var) ); * * - * WHAT YOU CAN DO WITH THIS: * Accepted tags: B, U, I, CODE, PHP, AS, QUOTE, LIST, MAIL, URL, IMG, FONT, SIZE, COLOR, CENTER, RIGHT * B = [b]{TEXT}[/b] * U = [u]{TEXT}[/u] * I = [i]{TEXT}[/i] * CENTER = [center]{center text}[/center] * RIGHT = [right]{right text}[/right] * CODE = [code]{code text}[/code] * PHP = [php]{php text}[/php] * ACTIONSCRIPT = [as]{action script text}[/as] * QUOTE = [quote]{quoted text}[/quote] | [quote=posted from]{quoted text}[/quote] * LIST = [list][*]{TEXT}[/list] | [list=1][*]{TEXT}[/list] * type: NULL = default, unordered list * 1 = numeric ordered list * [ for alphabetic list write to W3.org ... they wrote Safe for kids with DL sintax ... ] * * Example: [list] * [*]something * [*]something else * [/list] * Example: [list=1] * [*]something * [*]something else * [/list] * MAIL = {valid email addres} | [mail]{valid email addres}[/mail] | [mail={valid email addres}]{TEXT}[/mail] * Example: [EMAIL PROTECTED]/mail] * Example: [EMAIL PROTECTED] email[/mail] * URL = {valid url addres} | [url]{valid url addres}[/url] | [url={valid url addres}]{TEXT}[/url] | [url={valid url addres}]{TEXT}[/url] * Example: [url]http://www.3site.it/[/url]; * Example: [url=http://www.3site.it/]hello world![/url] * Example: [url=http://www.3site.it/]hello world![/url] * IMG = [img]{valid url addres with img}[/img] | [img={valid url addres with img}]{ALT/TITLE}[/img] | [img={WIDTHxHEIGHT}]{valid url addres with img}[/img] * Example: [img]http://www.3site.it/grafica/3site1.gif[/img]; * Example: [img=http://www.3site.it/grafica/3site1.gif]this is my site's logo[/img] * * Example: [IMG=100x38]http://www.3site.it/grafica/3site1.gif[/IMG]; * NOTE: you need to auth this last type of parsing with $codeLighter-imgSize(maxWidth, maxHeight); function. * FONT = [font={valid font type}]{TEXT}[/font] * Example: [font=courier]hello[/font] [font=arial]world[/font] ! * * SIZE = [size={number between 1 and 9}]{TEXT}[/size] * Example: [size=1]hello[/size]
Re: [PHP] Re: class help (PLEASE)
--- Jason Barnett [EMAIL PROTECTED] wrote: No offense intended, but I'm not going to read through all of that. Narrow down the code block that gives you problems and then post that one block here... not the entire class. Hey Jason, No offense at all taken, am happy you read part of my help-email. Problem is, like I said, I dont have a clue about the workings of a class and all the pointing like this $this- blah gets me totally confused so I really dont know which part IS the problem part. Anybody knowing of a good class tutorial...would be appreciated. I tried to figure it out by myself looking at the code, but I guess I have to learn about classes (have not come to that yet) before I know where the problem is, but having a look for the newline part I think this is the problem part: $preserve = md5( \n\r); $elaborate = preg_replace(/( )([\\n\\r]+){1}( )/, $preserve, $elaborate); $elaborate = preg_replace(/( )([\\n\\r^ ]+){1}/, $preserve, $elaborate); $elaborate .= */; I know the class looks massive but if you copy and paste it into a editor that colors PHP code (I use editplus), you will see that a s***load of it is comments on how to use the class and layouts,css, initialization etc (even I could understand that so I'm guessing it has to pretty simple), then comes the preg_replace and eregi which confuses the crap out of me. Thanks, -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: class help (PLEASE)
Thanks, Will first try learning RegEX then will move onto classes ore again will have problems in the future. Will screw around with the class and see what happens but if you do figure it out, please drop me a line. Thanks, Mag --- Jason Barnett [EMAIL PROTECTED] wrote: Hey Jason, No offense at all taken, am happy you read part of my help-email. Problem is, like I said, I dont have a clue about the workings of a class and all the pointing like this $this- blah (-) means blah is a property of the class. ($this) means an instance of the class. gets me totally confused so I really dont know which part IS the problem part. Anybody knowing of a good class tutorial...would be appreciated. phpfreaks have a lot of tutorials, so do codewalkers. You can probably find class tutorials at one of those sites. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Learning Regex
Hi, Does anybody know of a good place to learn how to work with regex? Google has quite a few links for learn pattern matching or learn php regex but none that start you on baby steps. Any recommendations? Thnx, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RSS and your opinion needed.
Hi, Some time back I came on the list and asked your advise for a class that gets RSS feeds from diff sites, I got quite a few good sites and a particular class that was really good. Unfortunatly I lost it in a webhost change but here is what it did: It got the feed and cached it for a day (or two - not too sure) so that speed and performance was improved instead of fetching it every time, it also allowed me to customize the links out (eg: open in new window) Any idea which class that is and where can I download it? if not that one, can you recommend one that is good? (and free) Lastly, I have never worked with RSS feeds before, can you tell me how many links are ok per page? E.g: I have a page with content and on the right the feeds links will display... I was thinking of putting 9 links per page(3 each from 3 diff sites)...or is that too much? Thanks, Mag __ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Include path
Hello, I am a bit confused :-(, this is my server path: /home/sites/site80/web/articles/myfile.php from myfile.php I want to include header.php which is located in: /home/sites/site80/web/templates/ /* eg: /home/sites/site80/web/articles/myfile.php /home/sites/site80/web/templates/header.php */ After searching on google I tried using: $_SERVER[PATH_TRANSLATED]; but I think I am using it wrong coz its not working.. Please help. Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include path
--- Jay Blanchard [EMAIL PROTECTED] wrote: [snip] /home/sites/site80/web/articles/myfile.php from myfile.php I want to include header.php which is located in: /home/sites/site80/web/templates/ /* eg: /home/sites/site80/web/articles/myfile.php /home/sites/site80/web/templates/header.php */ [/snip] in /home/sites/site80/web/articles/myfile.php place the following line include /home/sites/site80/web/templates/header.php; :-) Good solution, but the problem is once the program is completed it goes out of my hands and most prolly the client wont know the exact paths, the templates folder would *always* be one below...but the path before the /templates will change. Anyway, heres what I have come up with, comments are welcome: $pieces = explode(/, $_SERVER[PATH_TRANSLATED]); $a=count($pieces); $f=; for($i=1; $i $a-2; $i++) {$f=$f.$pieces[$i]./;} $include_path= /.$f; -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include path (SOLVED)
Hey everyone, ** Have you tried $_SERVER['DOCUMENT_ROOT'].'/'; ** Matt, DAMN! THATS what I was looking for. No, didnt try that, took the long route home instead, but atleast brushed up on php's explode function. ** $baseDir = $_SERVER[DOCUMENT_ROOT]; $templatesDir = $baseDir . /templates/; include($templatesDir . header.php); include($templatesDir . body.php); include($templatesDir . footer.php); ** Ed, perfect. ** Have you tried; Include ../templates/header.php; ** Warren, yep, tried that and also ../../templates/header.php; and more, it was going to the root (/home/sites/ etc) Thanks, everyone. Cheers, -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Enc and 0T Q
--- raditha dissanayake [EMAIL PROTECTED] wrote: PHP Gen wrote: how about using SSH tunneling instead. Never tried it, any examples for a win2k pro machine? There are some tutorials on this topic search term may be 'ssh tunnel howto' you do need to have an SSH client installed on your computer. The server will no doubt have ssh installed. Thanks, will google for it. -Mag = - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Zend Enc and 0T Q
Hi all, Our company has decided to encrypt the php programs that we sell, I have to choose which encryption package to buy. After a lot of seaching (on this list(archives), google, forums etc) I saw a quite a few products like ioncube, zend, codesecure, blender, mmCache encryptor etc etc unfortunatly blender is not yet ready for stable production use and althought I was leaning towards mmcache as its free, not every host will be too happy to install mmCache so I have decided to go with Zend encryptor (not too bad a price for the small business companies - companies that make less than $250k a year - which is what we currently fall under) I just wanted your comments on this, good idea? bad? any of you guys tried it? any problems with hosts not willing to install the optimiser to run encrypted scripts? stable? etc I have googled for these questions and it seems very favourable, but I figure it would be wise to ask you guys as you use php everyday/nearly everyday and can give me better feedback as the average joe (a lot of the sites recommending Zend Enc are linking to zend with a little affiliate tag...so i'm guessing some of them are biased). Off topic Q, My ISP has blocked me sending mail from my local machine (they have blocked port 25) any program (for windows (2000 pro)) that can send mail on another port? I used to use Merak mail server. Thanks in advance. -Mag = - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Enc and 0T Q
Hi, Thanks for replying. And the loss is entirely theirs. MMache really can take a load of your webserver. True, but its easier to tell a webhosting company to install a Zend product as they are the maker of PHP blah blah than to tell them to install an untrusted 3rd party app like mmCache. The above applies only to webhosts who are mostly half wits, my present webhost (hub.org) are very nice guys and know their business. (ps. I dont get anything from hub for the plug above) Correct me if I am wrong, but according to my understanding when an optimizer is installed it does not matter which encoder was used to encode the scripts. News to me, I thought each encryptor has its own style of encrypting the phpwill check up but I think thats true. Off topic Q, My ISP has blocked me sending mail from my local machine (they have blocked port 25) any program (for windows (2000 pro)) that can send mail on another port? I used to use Merak mail server. how about using SSH tunneling instead. Never tried it, any examples for a win2k pro machine? Please start your signature with the '--' sequence and not '' as you have used. Yahoo added the , will change it as you are the second person who has complained...just have to find the place where thats set. Thanks, Mag = - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php