Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. What value is suppose to be held in the $ipaddr? The full IP? If so, the issue here is the IP is actually a string time, and you are trying to use an int to check against a string value. If the string value is = "0" this is of course > 0 due to that. You can always try using (int) if it is just part of the IP... if (!empty($_POST['ipaddr'])) { $ipaddr = intval($_POST['ipaddr']); if ($ipaddr < 1 || $ipaddr > 254) { $msg = "IP # must be in range 1-254<br>"; send_error($msg); } } That assume $_POST will contain "xxx" and not "xxx.xxx.xxx.xxx" If that does not solve your problem please post more code, such as where you define $ipaddr and what $ipaddr should contain.
  2. Eh sorry my mistake... if (!empty($_POST['ipaddr'])) { $ipaddr = $_POST['ipaddr']; if ($ipaddr < 1 || $ipaddr > 254) { $msg = "IP # must be in range 1-254<br>"; send_error($msg); } } You were never setting $ipaddr to the post data. It is just one of those forgetful, quick to post days =)
  3. if (!empty($_POST['ipaddr']) && $_POST['ipaddr'] != 0) { if ($ipaddr < 1 || $ipaddr > 254) { $msg = "IP # must be in range 1-254<br>"; send_error($msg); } }
  4. I will have to look at the code I wrote. I know it worked at one time, but you are probably right. I will see if I cannot find it and figure out what I changed to make it work. Actually I found it, I was using ob_flush and flush... <?php set_time_limit(505); $sizeTime = 500; // set size time to 500 seconds for fun $x=true; $i=0; while ($x) { echo "."; ob_flush(); flush(); sleep(30); // sleep for 30 seconds. if (($i*30) > $sizeTime) { $x = false; } $i++; } echo "<br />Finished"; ?> That seems to work for me.... EDIT: Forgot the i increment =) EDIT:EDIT: also changed the == to > due to another possible infinite loop =) EDIT:EDIT:EDIT: I would say it was more of me taking a CSV file with over 10,000 lines in it and converting it to MySQL to be entered into a new database. I wanted it done on the fly so I could just let the process run (I did not even think about using the CLI at this time) but yea that worked like a charm for me to run through that whole database and convert it from CSV to the new MySQL db version (columns different names etc).
  5. You can use $_SESSION to do that, or set the $filename as a global. http://us3.php.net/manual/en/language.variables.scope.php for more details on the global part.
  6. Yea, I did not think so. I know it worked for me with large queries I was trying to do via php, but that is not a file upload obviously =)
  7. lol or a simplier version foreach ($_POST as $val) { if (strstr($val, 'format') !== false) { $str .= str_replace("format", "", $val); } } Without all the messy substr =) Just curious though, why not make format an array of it's own? <input type="checkbox" name="format[]" value="<?php echo $value; ?>" id="format<?php echo $f_i + 1; ?>"/> Then you could just access it like: if (isset($_POST['format'])) { foreach ($_POST['format'] as $val) { $str .= $val; } } That way you do not have to worry about appending numbers to it etc =)
  8. It is the actual user's browser causing the issue, not the server.
  9. What I do is have a drop down with "sort by" option, on change I do a post to the same change and set a session variable $_SESSION['sortby'] then add that the end of the query using the ORDER BY statement. That seems to be the easiest and does not require a whole lot of code change, so if select option = 1 "ORDER BY date_added" etc...
  10. I've just done a bit of research on set_time_limit but it looks like it doesn't override the HTTP timeout The only way (which may not work I have mixed results) is set an increment timer in the code, and after x seconds echo a "." to the screen to keep the browser session alive... Something like this: <?php $sizeTime = 1000; // set size time to 1,000 seconds for fun while ($x) { echo "."; sleep(30); // sleep for 30 seconds. if (($i*30) == $sizeTime) { $x = false; } } echo "Finished"; ?> After the 1,000 seconds it should exit the loop and display "Finished" Granted I have never used this with an upload script, only a large loop script. You may want to look into an AJAX/Flash uploader as I think you can keep those alive and upload about any size file you want...I have never used either but yea.
  11. He has already said that this didn't work... He probably literally tried it like $_server['server_ADDR']; Of course that WILL NOT work due to the fact that php is CasE SeNsItIve....Next time post the exact way he should access it. Edit, my bad, just noticed the 3rd post. But the same goes for the above, if he was trying that it probably would fail due to the case sEnSitIvE issue. Sorry for the rude remark I made.
  12. what do u mean by test cases? people could enter anything from cms, so i never know whats gonna be $text. You should have some idea of what the user is entering, you always test what users should enter in and validate input. A huge part of programming is testing and create test cases so you can make sure some weird code would not break your code. As far as them creating a new line, for each letter, what does it matter if the read more is on its own line? You could always put a break before displaying the the "read more" as in above.
  13. Place the chmod before the move_uploaded_file portion...
  14. <?php $text = "This is some random text that I am writing here to demonstrate a point. It just has to be longer than 100 characters for this to actually work properly.\nHowever there is a line break now and hopefully that is also counted as part of the string length\n\n to help this point be proven. Next time I will just copy and paste a nice description from some unknown site so that I do not have to type this much information here. \n\nCause yea it just really sucks!"; if (strlen($text) > 100) { $shortText = substr($text, 0, 100); $shortText .= '... (<a href="article.php?id=' . $id . '">Read More</a>)'; }else { $shortText = $text; } echo $shortText; ?> Just create test cases with different scenarios such as the modified above.
  15. He has already said that this didn't work... He probably literally tried it like $_server['server_ADDR']; Of course that WILL NOT work due to the fact that php is CasE SeNsItIve....Next time post the exact way he should access it.
  16. If you are on a shared, potentially, if you are on dedicated doubtful. The only other option is to try to use the chmod function in php to change the folder permission for upload than change them back after upload.
  17. I know on my server, I cannot send emails from my server to any of the domains hosted on my server's email account. I am not sure why (never really digged into it). But that could be the same problem. What I did was setup a gmail account that I put a filter to forward any emails that came in from my server to the "admin@mydomain.com" account and that works very well for me.
  18. No clue, it is not my code I am trying to get working. Thus I would look through the usage of zip_open and zip_read and see how it should be used. Or look through the user comments and see if anyone already built an extractor. I will not do this for you cause you can read and test just as well as I can.
  19. <script type="text/javascript"> function GetClientUTC() { var now = new Date(); var offset = now.getTimezoneOffset(); return offset; } </script> Unsure if that works, but yea, you could use that and post the offset to your script on user login and use that via session to change the offset.
  20. Do you know the user's time? If not you may have to use Javascript to get the user's time and display that, cause PHP cannot tell you what the user's time is unless you have them fill out their timezone and then change the time accordingly...
  21. Ok, so let's say after 100 characters you want to cut off the text and display a link and ... <?php $text = "This is some random text that I am writing here to demonstrate a point. It just has to be longer than 100 characters for this to actually work properly.\nHowever there is a line break now and hopefully that is also counted as part of the string length to help this point be proven. Next time I will just copy and paste a nice description from some unknown site so that I do not have to type this much information here. Cause yea it just really sucks!"; if (strlen($text) > 100) { $shortText = substr($text, 0, 100); $shortText .= '... (<a href="article.php?id=' . $id . '">Read More</a>)'; }else { $shortText = $text; } echo $shortText; ?>
  22. But that is really not what I am after, Where does the data get inserted into the database? Also you send them to "session->register" but no where in that register function are you setting the variables to session data....or even updating the $_POST data...that just confuses me...
  23. The main difference I see is the email. Are you sure your GMail account is not setup to trash/send the message to spam? Add the from domain to your safelist. I would also try it with a different email and see. Just to make sure, you are running this script on the same server, right? And not your local one...
  24. Post more code so I can see where you are going wrong.
  25. http://us3.php.net/manual/en/function.zip-open.php I bet that would be the only way to do it without using exec.
×
×
  • 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.