Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. I use something like this $pid=$_GET['pid']>0?$_GET['pid']:0; just because rarely do u need a negative values, and setting up a failure conditional for yer messages if(!$pid) die('Invalid ID'); later in yer code. But I think u should think how each variable needs to be validated. some will have different requirements than others good luck
  2. question: what is this batch file supposed to accomplish that php can't? u can create a temp batch file within php, if u really needed to. Bypassing the need for sending parameters to a specific batch file.
  3. Yeah, its top of my head coding. I missed a end quote <?php echo getcwd() . '/test.bat does ' . (is_file('test.bat')?'':''not ') . 'exist.'; ?> if it exists, than ya may want to check safe mode in php.ini and disable it or create an executable dir so php can run external apps
  4. u may want to be shure its being called <?php echo getcwd() . '/test.bat does ' . (is_file('test.bat)?'':''not ') . 'exist.'; ?>
  5. I wudda opted for something slightly different. <?php $arrFiles = array( "http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.01.txt", "http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.02.txt", "http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.03.txt", "http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.04.txt" ); $content=''; foreach($arrFiles as $file) $content .= file_get_contents($file); file_put_contents ('/path/to/us-scs.html',$content); ?>
  6. Very easy script to make. But this looks more like a business venture, than a request for help. If ya dun have the skills nor desire to learn, best place for this is in the Freelancing forum here
  7. I think I might have seen the problem WHERE m_id=$en[m_id] note the m_id in the braces, there is a problem there, is this a mysql variable or a php one?
  8. Either tag it somehow, keeping an array list of files. or tag anything that starts with a . (files in linux that start with . are hidden) to not display if (($folder[0] != ".")) should do the trick
  9. function recdir($base) { $files=array(); if(is_dir($base) &&$ $dh=opendir($base)) { while($file=readdir($dh)) { if($file=='.' || $file== '..') continue; if(is_dir($file)) { $subfiles=recdir($base.'/'.$file); $tfiles=array_merge($files,$subfiles); $files=$tfiles; } else { $files[]=$base.'/'.$file; } } } return $files; } I think that shud work May require tweaking, not tested
  10. I dun have php in front of me. But when it comes to true and false bools ya shud be careful as false is always 0 however true can equate to a number of different things. !false flips all the bits in the word, and becomes -1. Which ya will see a lot of mention about. so it will fail the enum(0,1) portion as -1 isnt enumerated. And remember true/false value is dictated by the app. PHP true/false bools may be different than mysql so yer best bet, is to use a trenary operator. forcing to 1 (int)($en['m_ziphide'] == 'ON'?1:0)
  11. No Probs here There are a lot of php functions, some that even surprise me Good luck on yer project
  12. ya can perform a check within the for loop for($i=0;$i<=20;$i++) $slot[$i]="Slot{$i}"; for($l=17;$i<34 && issset($slot[$i]);$i++) echo $slot[$l]; but if u really need it within the loop, the lookahead (note that by program flow, the last valid entry wont display, as the lookahead breaks out of the loop) [/code] for($l=17;$i<34;$i++) { if(i!sset($slot[$i+1])) break; echo $slot[$l]; } [/code]
  13. what is $i? why is $l way out of the array bounds $whopro has three elements, starting with 0, 1, 2 so trying to reference $l=17 gives ya an notice, about a variable not being declared. php dusn assign non existant variables to null. if the variable dusn exist why not just use isset?
  14. well from there its just a simple file to array call I just understand the question differently. I understand that he wants a predetermined tab size to echo out before the file lines. which ya dun need to read in the whole file for, just prepend a string to each line so even with the above routine, a file to tabecho routine is just a simple function of function tabfile($filename,$indent=0) { $lines=file($filename); if(!empty($lines)) foreach($lines as $line) tabecho($line,$indent); } tabfile('NotherSample.txt'); See not hard at all
  15. why make it so complex function tabecho($string,$indent=0) { static $li=0; if($indent) $li=$indent if($li) echo strrepeat(' ',$indent); echo $string; } tabecho('Hi!',; tabecho('This is even cheesier'); Works just as well
  16. <?php $size=89; $tables=10; $peoplepertable=10; $curtable=0; $table=array(); for($person=0;$person<$size && $persion <= ($tables*$peoplepertable;;$person++) { $table[$curtable++][]=$person; $curtable*=(($curtable<$tables)?1:0); } I think thats right, if I understood ya correctly. we dun need to assign $seat since [] will allocate the next element in the array. so trick is keeping the table count and reset it once ya reach max number of tables; the trick here is knowing how to use the ++ operator $curtable++, adds one to the table count after the operation ++$curtable, adds one to the table count before the operation $curtable++ wud look like this in code $table[$cirtable][]=4; $curtable=$curtable+1; while ++$curtable would look like $curtable=$curtable+1; $table[$curtable][]=4; the other trick is resetting our table count when we reached the max several ways of doing that a simple if wudda worked as well if($curtable>=$tables) $curtable=0; Anyways have fun wif yer code
  17. That usually helps
  18. try using strrchr $file = md5(microtime(true)) . strtolower(strrchr($_$FILES['file']['name'],'.')); but ya may want to validate a proper extension maybe a pregmatch only dots and alpha num if(!preg_match('@^[\w.-=]+$@',$_FILES['file']['name']) die('Bad Filename'); well ya gets the picture
  19. Its all good viewpoints, cuz sometimes ya learn something that never crossed yer mind. I think the = was in the first couple of posts, so could be the mixup why it kept coming back to haunt us... Anyways, have a nice day all
  20. Been using sessions for awhile now. but ya shud read information on session fixation (security) as the session id is stored as a cookie, it is possible to steal/make id's. So to make it more secure 1) use session_regenerate_id() so cookie id changes 2) do not rely on the session info, use a hash of other various info provided, in my routines I generally use IP & Browser agent info (md5 these two). So if either changed the session becomes invalid. 3) Change The Session life span, (I give 15 minute lifespan for a session cookie). I see a lot of folks, who dont understand #2. and see something like if($_SESSION['loggedin']) when a little more thought ya can secure it with if($_SESSION['hash'] == md5($ip.$_SERVER["HTTP_USER_AGENT"])) as I said I use ip & browser agent info Anyways good luck
  21. well ya can make that whole process easier, just work on the idea of how it shud run. It sounds like u have some pages ya want to protect, and others are public. well than ya needs a way to let yer script know which pages are what. file: protect.php <?php session_start(); if(!isset($_SESSION['loggedin']) && !defined(PROTECTED)) { $_SESSION['last_page'=$_SERVER['PHP_SELF'] header("Location: login.php"); exit; } file: unprotected.php <?php // Sample Unprotected Page ?> <H1>UnProtected</H1> include("inlcude.php"); [/code] file: protected.php <?php define('PROTECTED',TRUE); include("inlcude.php"); ?> <H1>Protected</H1> good luck
  22. but the varchar month/date is disturbing.... 10 characters for a year storage is a bit much 20 characters for month storage, i think we using different calander systems here. U shud consider using DATE/DATETIME instead, ot just plain ole INT(11) and let php handle the timestamp. numerics searches/sorting will always be faster.
  23. Oh I'm not arguing that point. Its good to hear from different viewpoints of the same topic sometimes Ya learn a lot more than by a single viewpoint of the matter....
  24. this kinda depends how u want the data displayed 1-33 in col1 34-66 in col 2 66-99 in col 3 or in an across type table 1,4,7,10,..... in col1 2,5,8,11,.... in col2 3,6,9,12,.... in col3 in first style its all about the math. $cols=3; $max=100 for($i=0;$i<$max;$i++) $ar[$i]=$i; echo "<TABLE>"; for($i=$ctr=0;$i<$max;$i++) { if($ctr=0) echo "<TR>"; echo "<TD>".$ar[$i]."</TD>"; $ctr++; if($ctr>=$cols) { $ctr=0; echo "</TR>" } } while($ctr && $ctr++<$cols) echo "<TD>&nbsp</TD>"; if($ctr) echo "</TR>"; echo "</TABLE>"; The other way having the info on per row is same concept, but our counters change as well as the when the display code changes [code] $cols=3; $max=100 for($i=0;$i<$max;$i++) $ar[$i]=$i; echo "<TABLE>"; for($i=$ctr=0;$i<$max;$i++) { if($ctr=0) echo "<TR><TD>"; echo $ar[$i]."<BR>"; $ctr++; if($ctr>=$percol) { $ctr=0; echo "</TD></TR>" } } if($ctr) echo "</TD></TR>"; echo "</TABLE>"; I think that shud do it, but this code is just from scratch, but ya shud get the idea from both examples
  25. But yer missing the point I made. The whitelist method is better because ya know what characters ya want to accept a-z0-9_- so yer method only is stripping out 3 characters, but when ya add more, of the possible 256 characters in an ascii chart it just becomes ridiculous. so no longer are u looking at a simple pattern of '-/=' but a huge one to strip control characters, spaces, and symbols, when we know we just want 64 of the 256 characters. This is a prime example of when to use a whitelist over a blacklist.
×
×
  • 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.