Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. if((isset($_POST['timeout']) && (time() > $_POST['timeout'])) { $firstname = $_POST['firstname']; $location = $_POST['location']; $comment_date = date("m-d-Y"); $comment = $_POST['comment']; $id = $_POST['id']; // setup our query $query ="INSERT INTO comments (firstname, location, comment_date, comment, id) VALUES ('$firstname', '$location', '$comment_date', '$comment', '$id')"; $result=mysql_query($query) or die(mysql_error()); // run our query // end code for inserting comments } the html <p><form method="POST" action="display.php?id=<?php echo $row['id']."#comments"; ?>">INPUT TYPE=HIDDEN NAME="timeout" value="<?=time()+5;?>">
  2. setup a cookie/POST with a timeout value; in your form (note this for html code) <INPUT TYPE=HIDDEN NAME="timeout" value="<?=time()+5;?>"> [code] now in yer processing ya can do [code] if(isset($_POST['timeout'])) { if(time() < $_POST['timeout']) unset($_POST); } which invalidates the whole re-submission.[/code][/code]
  3. [code]<?php function textbetweenarray($s1,$s2,$s) { $matches=array(); preg_match_all("@$s1(.*)$s2@imsU",$s,$matches); return $matches[1]; } $oldcode= ' function textbetweenarray($s1,$s2,$s){ $myarray=array(); $s1=strtolower($s1); $s2=strtolower($s2); $L1=strlen($s1); $L2=strlen($s2); $scheck=strtolower($s); do{ $pos1 = strpos($scheck,$s1); if($pos1!==false){ $pos2 = strpos(substr($scheck,$pos1+$L1),$s2); if($pos2!==false){ $myarray[]=substr($s,$pos1+$L1,$pos2); $s=substr($s,$pos1+$L1+$pos2+$L2); $scheck=strtolower($s); } } } while (($pos1!==false)and($pos2!==false)); return $myarray; } '; header("Content-type: text/plain"); $matches=textbetweenarray('\(','\)',$oldcode); print_r($matches); ?>
  4. The script u posted already pulls the variables from the text file. it's just designing yer html output page with those variables.
  5. if ya are including it from a variable than easier to attch an echo or add to log file right after the include include($inc="$page.php"); mylog("include($inc)"); function mylog($msg) { if ($fp = @fopen("my.log", "a")) { $msg="$msg\n"; fwrite($fp, $msg, strlen($msg)); fclose($fp); } } might be a bit ugly but works
  6. what ya ask for yer script already does in the first portion up to the: ?> <HTML> this is where ya want it to display the variables $AHT, $SLA, $CW, and $AA just design yer new page, with tables and when u need one of the above variables, add <?=$AHT;?> (keep the stuff in bold just change the variable.
  7. whoops, that shudda been array_values
  8. that all depends if file_get_contents can fit the file into memory. if not ya will prolly end up doing file chunking, reading a chunk of the file checking it, than cycle until eof.
  9. u prolly will need a custom function to seperate the fields. function csv_array($file,$delim) { $fh=fopen($file,"r"); while(!feof($fh)) { $line=fgets($fh); $row=explode($delim,$line); foreach($row as $key => $val) { if(($ch=substr($val,0,1))=='"' || $ch=="'") { // we got a string delimeter $skey=$key+1; do { $sl=strlen($val); if(substr($val,$sl-1,1)==$ch) break; // we got a matching delimeter $val .= $row[$skey] unset $row[$skey++]; } while(true); $sl=strlen($val); $row[$key]=substr($val,1,$sl-2); // remove the quote delimeter } } $newrow[]=$values($row); // Rebuild our array removing empty sets (ones we removed with unset); } fclose($fh); return $newrow; } now not shure, but the unset command may have to be outside the foreach loop, depends on how foreach works internally. if that is they case, create a new array with those items for removal. this code not tested, just code that got pumped out of my head into this post;
  10. u can do this in the function or outside the function. i will do it outside the function $searchdate="2007-12-31"; $keysofitems=md_search($array,'Date',$searchdate); if(empty($keysofitems)) { $searchdate = date("Y-m-d",strtotime($searchdate) - (60*60*24)); $keysofitems=md_search($array,'Date',$searchdate); } as u can see, if we get no results, we take the search date, and subtract 1 day (60 secs * 60 Mins * 24 hrs). Which wud be the previous day of $date. u can of course use a do loop to find the last date used $searchdate="2007-12-31"; $counter=0; do { $counter++; if($counter>30) break; // limit our back date search to 30 days $keysofitems=md_search($array,'Date',$searchdate); if(!empty($keysofitems)) break; // exit our loop; $searchdate = date("Y-m-d",strtotime($searchdate) - (60*60*24)); }
  11. actually that is the best way of going about it rev, nice tip.
  12. When do you actually load up the font. gd supports two type of font files GD fonts (use imageloadfont) and PostScript Type 1 (use imagepsloadfont) not shure about True Type fonts, but found this Difference between TTF and PSF Well good luck
  13. That's what I'm getting as well. first ya need to build a list of keywords ya dun want to allow. than either use preg_match or stripos (case insensitive str matching) to find those keywords. But first is building yer list of disallowed keywords.
  14. I encountered much of the same. Confusion. than i found a nice tool Expresso - Regex development tool its a great tool if yer starting out with regex. the thing to note, when using preg and expresso preg uses start and end delimeters followed by options /pattern/options or @pattern@options while Expresso just uses patterns (checkboxes for the options)
  15. u can keep them as they are and using foreach to go thru the array foreach($xmlvars as $key => $val) echo "$key: $val<br>";
  16. No probs, hope ya gets yer project going
  17. believe me it does help out a lot
  18. if(preg_match("@<H3>(.*)</h3>(.*)@i",$document,$matches)) { $header=$match[1]; $body=$match[2]; } else if(!isset($matches[1]) || !isset($matches[2])) { echo "Unknown document"; die(); }
  19. replace include("error.htm") with something like { ?> <H2>ERROR!</H2> <H1>Unknown page reference</H1> <? exit(); } just change everything between the php short tags (?> and <?) as standard html code
  20. if($res=mysql_query("SELECT COUNT(*) FROM posts WHERE user='x';")) { $row=mysql_result($res,0); } else $posts=0; shud do it
  21. instead of print_r use something like $xmlvals=array_combine($matches[1],$matches[2]); now u have a spanking new array with $key => $val equivalents echo "Title: $xmlvars[title]<BR>"; echo "Date: $xmlvars[date]<BR>"; enjoy
  22. CSV format is seperated by columns, one row per line Col1,Col2,Col3,Col4,Col5 if u want everything in Col1, than output yer data as mydata,,,, notice that i leave the , for the other columns you can skip columns as well, by doing the same thing, say we want data in col3 ,,mydata,, it's not all that hard
  23. SELECT COUNT(*) FROM posts WHERE user='x';
  24. it logically puts the page together piece by piece noticing the different outputs you can have. as well as testing the $_GET for '.' and '/' which can be used to access other files outside the confines of yer public html folder consider http://my.url/showpage.php?level=../otherpage and it cuts down on the file_exists
×
×
  • 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.