Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. isnt hat a mod rewrite question? Well mod rewrite should be able to handle that without much problem anyhow
  2. question is why are u using insert? if the record is already in the db......
  3. htaccess is controlled by apache not php. so either, implement a system with apache authentication/bypassing or use php for authentication/bypassiing
  4. #3 should have 5 columns, userid as well
  5. Sorry, wasnt meant towards u Abra, just clarifying. Ya got your post snuck in right before mine. so appears i was responding to you, rather than the intended. Personally I agree with you Abra, getting to know your terms greatly affects what responses u will get.
  6. This line if (isset($_POST['username'])&&($_POST['password'])) should be if (isset($_POST['username']) && isset($_POST['password'])) both username & password u have allowed every character. Bad idea, use a whitelist of characters that are allowed. this can be done easily with preg_match if(!preg_match('@^[A-Za-z][A-Za-Z0-9_\.]{2,19}$@',$username)) ( Echo "Invalid Username"; } The preg string ^ Start of string [A-Za-z] First character is alpha [A-Za-Z0-9_\.]{2,19} Characters must be alpha, numerc, _ or . (period) min length 2, max length 19 $ End of string So this allows usernames a length of 3-20 characters, and restricts them to a certain format, and allowable characters Password, I would do the same, except allow more characters. This i would do at signup as well. doing whitelists, u don't need to use stripslashes/striptags/htmlspecialchars or wut have u. usernames should have a format to follow and abide by Its very hard to read your code, when you don't use the forums [code] tags.
  7. $value=-5 $sign=($mod<0)?'-':'+'; $value=abs($value); echo "Sign: {$sign} Value: $value". PHP_EOL; $value=7 $sign=($value<0)?'-':'+'; $value=abs($value); echo "Sign: {$sign} Value: $value". PHP_EOL;
  8. RewriteRule ^catalog/([^/]+)/(\d+) catalog.php?category=$1&prodID=$2 transforms the first to the second, thats all rewrite does.
  9. within echo or string concatenation use the trenary operator instead. which works like a if...else statement so echo "You have {$amt} item"; if($amt>1) echo 's'; can be written with a trenary operator as echo "You have {$amt} item". ($amt>1?'s':''); if lookes like this: {expression} ? {true result} : {false result}
  10. wow that is a convoluted if. I woulda opted for a simpler design, like <?php date_default_timezone_set('PST8PDT'); $date1=date('Y-m-d H:i:s',$ct=time()); $date2=date('Y-m-d H:i:s',$ct+=rand(1,20000)-10000); $date3=date('Y-m-d H:i:s',$ct+=rand(1,20000)-10000); for($i=1;$i<=3;$i++) { $di="date{$i}"; $d[$i]=$$di; } foreach($d as $dt) echo $dt.PHP_EOL; sort($d); echo PHP_EOL; foreach($d as $dt) echo $dt.PHP_EOL; Even tho the data is convoluted, php does has some features which make things like this possible
  11. <?php echo ltrim(number_format ($f15,3),"0"); ; ?>
  12. No probs, glad ya likes that piece of code Works like a dandy for me as u can see why i love the trenary operator, it cut down the if...elseif...else block to one line. but that was a intermediate example of what it can do. some of my other trenary statements get nested 3 levels deep, setting variables along the way. it gets pretty crazy, so using the parens helps when making the trenary statements.
  13. $midrange=intval(floor($range/2)); // find the middle of the range // FInd the starting range if(($curpage-$midrange)<1) // If we subtract midrange from the current page, is it below page 1? $range_s=1; // Yes, well put the start at page 1 then elseif(($curpage+$midrange)>$pages) // No, Well than If we add the midrange to the current page, are we above the highest page? $range_s=($pages-$range+1) // Yes, well start at the lowest possible range than else $range_s=$curpage-$midrange; // No, than go ahead subtract midrange from the current page // find the ending range if(($curpage+$midrange)>$pages) // If we add the current page to our midrange, are we above the page count? $range_e=$pages; // Yes, Well use the page count elseif(($curpage-$midrange<1) // No, Well than does the Lowest page invalid? $range_e=$range; // Yes, Well than use the Range instead of calculating else $range_e=$curpage+$midrange; // No, than go ahead add midrange to the current page
  14. I have to agree with Pikachu on this, keep each msg seperate, add a replythread to field and a loop which gets the the previous messages. Pretty simple pseudo code. $replythread=$msg['replythread) while(!empty($msg['replythread']) { $next_msg=get_msg($replythread); if(!empty($next_msg)) { $msg['body'].="+++++\n".$next_msg['body']; $replythread=$next_msg['replythread']; } else $replythread=0; } [/code] another option is to store all the ids into replythread (as a string) About the only bad thing of this method is that the field should be large enough to hold a very long list of ids. pseudo code. [/code] $replythread=explode(',',$msg['replythread']) foreach($replythread as $thread) { $next_msg=get_msg($thread); $msg['body'].="+++++\n".$next_msg['body']; $replythread=$next_msg['replythread']; } [/code]
  15. dunno could be some internal processing of the tag try using \#
  16. myloop.php <?php echo "Hello World!"; ?> main.php function mainloop() { require_once('myloop.php'); } while(1) { mainloop(); } about only problem with this setup, is that your loop code loses access to the variables such as $_GET/$_POST etc etc etc
  17. wont keep it from going into negatives tho, just a thought UPDATE table SET qty=qty-1 WHERE name=vouchercode AND qty>0 That should fix it
  18. Wrote this for a pagination routine awhile back the variables needed $range = Amount of numbers to display $curpage = Current number $pages = Highest Page count $midrange=intval(floor($range/2)); $range_s=(($curpage-$midrange)<1?1:(($curpage+$midrange)>$pages?($pages-$range+1):$curpage-$midrange)); $range_e=(($curpage+$midrange)>$pages?$pages:($curpage-$midrange<1?($range):$curpage+$midrange)); I love the trenary operator keeps me from using a bunch of if...elseif..else statements
  19. made much simpler with 1 query UPDATE table SET qty=qty-1 WHERE name=vouchercode [/code
  20. the header follows a jpeg style header, while in the metadata is the php code. this can happen with gif/pngs as well. but since most sites just do jpegs, i found this http://www.ozhiker.com/electronics/pjmt/library/documentation/edit_write_file_info.html
  21. not really, the method i just gave will work as well, but your crop.php must be designed more as a function, and return the link. for example removal of the $_GET params to variables.
  22. replace the echo with return and use something like this <?php function img_src() { include("img_src.php"); } echo img_src();
  23. You are too funny mj sumtimes the best answers are the easiest to implement... Yeah, I like that number validation technique over the formmated technique.
  24. Not so Ignace, as u see this recursion system already builds yer closure system on the fly, so it wouldnt take much to convert the on the fly recursion system, into a closure system, by moving that array into a table for itself. Yes, that recursion system is fast as easy to implement, as it is flexible to upgrade when u do have them 1000+ hits or more. But if that recursion system is all thats needed, than there is is real need to beef it up. Yeah, I gave it some thought about the recursion system that i use, and found the similarities with the closure system. the biggest difference between the two is that one builds the referances on the fly, and the other stores em for subsequent access
  25. a converter works on server side, so that is irrelevant. video capture is client side, so u need a client side language, java/flash come to mind.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.