Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Your numbers are stored as Varchar's, thus 99 is > than 95. It does not evaluate the actual numbers. Store them as int's and the problem should be solved EDIT: That's twice today rhod, I would highly suggest not doing that again >
  2. Found this online, maybe it will be helpful to you $command = "echo '$MessageBody' ¦ `/var/www/html/ers/emailsender.php >> /dev/null 2>&1 &'`"; Maybe that will work.
  3. After some testing, there must be "whitespaces" in the email portion "s:22:"email@wi.rr.com" is not 22 characters. <?php $string = 'a:7:{s:10:"country_id";s:3:"226";s:5:"email";s:15:"email@wi.rr.com";s:10:"last_visit";s:19:"2009-02-20 10:22:58";s:7:"created";s:19:"2009-02-20 10:22:58";s:8:"modified";s:19:"0000-00-00 00:00:00";s:3:"URI";s:5:"/home";s:17:"FreakAuth_captcha";s:5:"sqqpi";}'; $arr = unserialize($string); print_r($arr); ?> It may work out of the box for him as the string may be formatted right, just not copied right. If it does not work, changing that email to be 15 makes it work just fine with the unserialize function. Interesting that it is that picky. EDIT: lol you found it out, oh well. I worked hard on finding that out, it deserved to be posted again
  4. Take a look at the different exec functions. If you cannot find anything there, you may want to look into threading, as I believe that is what this is doing (not sure I never looked into multi-threading with php before). There should also be a way you can start a unix command and send it to it's own process (again google may help and I do not know if this is possible).
  5. This looks like a serialized array string. Why not simply unserialize it wham all data is back in an array.
  6. I am not sure of putty's command lines, but I believe you would have to issue an exit command to kill the process. Exec is setup to just run a program. shell_exec is setup to return output after script has run, so that is probably more of what you are looking for. If not play around with the different ways you can do it listed in the exec manual.
  7. Cron Job using PHP CLI (Command Line Interface). Basically the cron job is set to run every x minutes or hours or days etc. (Google Cron Job to read more up on that). What a cron job does (or scheduled task) is automatically run some code at the times specified. An example of a line for a script that runs every day in a cron job would be: 0 0 * * * /usr/bin/php -f /home/username/deleteDaily.php Then the code for your script to erase the entries would be something like this: deleteDaily.php <?php // mysql connection info mysql_query("DELETE FROM table_name WHERE datecol > " . strtotime('+1 week')); ?> This "should" (test it without deleting before using) delete any entry that is > 1 week old. I do not know how MySQL different date fields handle a unix timestamp, so that may or may not work. But that is the basic gist, for a cron job running via PHP CLI check out this Tutorial. For how to do this on a windows server, look into Scheduled tasks.
  8. Are you doing this on your local server? Or a remote server? Opening an application like that creates a process that essentially will not die. Thus it hangs. This will not open anything on the client PC, it does it on the webserver. In order to access programs on a clients PC you need to have them install ActiveX controls for you to do that. What you are wanting is not possible with php (thank god) without the user downloading/installing software to allow that.
  9. $sql = "SELECT id, date_added, date_start, date_end, title, spaw1, featured FROM $table_name WHERE featured=1 ORDER by rand() LIMIT 3"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $row['id']; $date_added = $row['date_added']; $date_start = $row['date_start']; That would work. Mysql has it's own rand() function. Putting that in the order by should randomize the order/results.
  10. Sorry, I tested the above with a bad string to test with. This should work (I had the params for stristr reversed.) <?php /* Modified by Scott Riggs at www.cybernetec.com */ $path = '/home/pathname/public_html/'; // Name of referrer log file $reflog = $path . 'reflog.txt'; // Name of semaphore file $semaphore = $path . 'semaphore.ref'; // Maximum number of referrers to log $maxref = 15; // Domain name of this site (minus "http://") $mydomain = array('lee-stewart.co.uk', 'blah2.com', 'blah3.com'); // From whence did Bunky come? $ref = getenv("HTTP_REFERER"); $log = true; foreach ($mydomain as $domain) { if (stristr($ref, $domain) !== false) { // fixed this, they were reversed. $log = false; break; // exit the loop no need to continue. } } // Cover me. I'm going in. if (!empty($ref) && $log) { // if there's a referrer, and it's not someone bouncing around this site $ref .= "\n"; // append a line feed $sp = fopen($semaphore, "w"); // open the semaphore file if (flock($sp, 2)) { // lock the semaphore; other processes will stop and wait here $rfile = file($reflog); // read the referrer log into an array if ($ref <> $rfile[0]) { // if this referrer is different from the last one if (count($rfile) == $maxref) // if the file is full array_pop($rfile); // pop the last element array_unshift($rfile, $ref); // push the new referrer onto the front $r = join("", $rfile); // make the array into a string $rp = fopen($reflog, "w"); // open the referrer log in write mode $status = fwrite($rp, $r); // write out the referrer URLs $status = fclose($rp); // close the log } } $status = fclose($sp); // close the semaphore (and release the lock) } ?>
  11. Yep, using a Cron Job if on Linux or Scheduled Tasks if on Windows. Given that the table you want to clear data from has a Datetime field this is entirely possible. If it does not you should look into adding one.
  12. <?php /* Modified by Scott Riggs at www.cybernetec.com */ $path = '/home/pathname/public_html/'; // Name of referrer log file $reflog = $path . 'reflog.txt'; // Name of semaphore file $semaphore = $path . 'semaphore.ref'; // Maximum number of referrers to log $maxref = 15; // Domain name of this site (minus "http://") $mydomain = array('lee-stewart.co.uk', 'blah2.com', 'blah3.com'); // From whence did Bunky come? $ref = getenv("HTTP_REFERER"); $log = true; foreach ($mydomain as $domain) { if (stristr($domain, $ref) !== false) { $log = false; break; // exit the loop no need to continue. } } // Cover me. I'm going in. if (!empty($ref) && $log) { // if there's a referrer, and it's not someone bouncing around this site $ref .= "\n"; // append a line feed $sp = fopen($semaphore, "w"); // open the semaphore file if (flock($sp, 2)) { // lock the semaphore; other processes will stop and wait here $rfile = file($reflog); // read the referrer log into an array if ($ref <> $rfile[0]) { // if this referrer is different from the last one if (count($rfile) == $maxref) // if the file is full array_pop($rfile); // pop the last element array_unshift($rfile, $ref); // push the new referrer onto the front $r = join("", $rfile); // make the array into a string $rp = fopen($reflog, "w"); // open the referrer log in write mode $status = fwrite($rp, $r); // write out the referrer URLs $status = fclose($rp); // close the log } } $status = fclose($sp); // close the semaphore (and release the lock) } ?> The above is tested and working. Make sure you are not just seeing an old entry an thinking it was newly created.
  13. I do not think it is possible. You can use class outer extends inner { As far as doing that, yea doubtful. You can however include a class from another file. class outer { function out() { include('class.inner.php'); $doit=new inner(); return $this->doit->two(); } } $test=new outer(); echo $test->out(); Should work. You could also just define that class on the same page and that should work as well. EDIT: I do not think you had the function "two" defined in the inner class (I think that is what you caught and solved it). Just decided to point it out EDITEDIT: Fatal error: Class declarations may not be nested in C:\wamp\www\test.php on line 4 Returned that when trying to nest
  14. // Cover me. I'm going in. if (($ref) && $log) { // if there's a referrer, and it's not someone bouncing around this site $ref .= "\n"; // append a line feed $sp = fopen($semaphore, "w"); // open the semaphore file if (flock($sp, 2)) { // lock the semaphore; other processes will stop and wait here $rfile = file($reflog); // read the referrer log into an array if ($ref <> $rfile[0]) { // if this referrer is different from the last one if (count($rfile) == $maxref) // if the file is full array_pop($rfile); // pop the last element array_unshift($rfile, $ref); // push the new referrer onto the front $r = join("", $rfile); // make the array into a string $rp = fopen($reflog, "w"); // open the referrer log in write mode $status = fwrite($rp, $r); // write out the referrer URLs $status = fclose($rp); // close the log } } $status = fclose($sp); // close the semaphore (and release the lock) } Should do it.
  15. The title should be escaped as well and you need single quotes around $review. $sql="INSERT INTO Reviews (Title, Rating, Review) VALUES('$_POST[title]','$_POST[rating]','$review')";
  16. Shared would effect your permissions. I do not know if they allow htaccess, but you can try setting them there. I would also change the session save folder to be located inside your portion of the host so no one can hi-jack sessions easily. Again I do not know how much your host allows, but yea. You can always email them and ask.
  17. Since you only posted half the script, here is a rough example. <?php /* Modified by Scott Riggs at www.cybernetec.com */ $path = '/home/path/public_html/'; // Name of referrer log file $reflog = $path . 'reflog.txt'; // Name of semaphore file $semaphore = $path . 'semaphore.ref'; // Maximum number of referrers to log $maxref = 9; // Domain name of this site (minus "http://vimixx.net") $mydomain = array('yoursite.co.uk', 'blahblah.com', 'blahblah2.com'); // From whence did Bunky come? $ref = getenv("HTTP_REFERER"); $log = true; foreach ($mydomain as $domain) { if (stristr($domain, $ref) !== false) { $log = false; break; // exit the loop no need to continue. } } if ($log) { //log to file } Use stristr to test if a domain listed in the array of $mydomain if it is simply set the log to false, exit the loop then use an if to see if you log the referrer to file or not. I do not know how the rest of the script works, but hopefully you can take that idea and implement it on your own.
  18. I never thought windows had permissions, but you are not putting quotes around what you are executing, this may or may not be the problem but you should quote strings, as that can be taken as a constant. This "should" work in a windows environment, unless apache has been set without having execute access to regedit (which may be as that is an operating system deal that could allow someone to mess up your system.) A better test, in my opinion, is to try and open "notepad.exe" as that should be allowed by all users.
  19. Maybe if you provide me with the requested information I can help.
  20. Look into jQuery, they have examples online and it is great framework for AJAX and other Javascript needs.
  21. It does have it's uses. Let's say you want to create a mysql class where you want to use 1 function to fetch a query but have 2 functions that access that to say row or assoc (essentially this is most likely what mysql_fetch_assoc and mysql_fetch_row do). You could have each function call this 1 common function (without repetitious code) and that can use those to determine what to pull. IE: <?php function commonFetch($result, $type=MYSQL_ASSOC) { return mysql_fetch_array($result, $type); } function fetchAssoc($result) { return commonFetch($result); } function fetchRow($result) { return commonFetch($result, MYSQL_NUM); } function fetchBoth($result) { return commonFetch($result, MYSQL_BOTH); } ?> Something like that (it is a real basic example, but you get the point). As far as @ definitely is not good practice. Remove any and all, it is better to just set display_errors to 0 on production servers, on development servers you want to see you errors so you can fix them. Doing the display_errors method, you can easily turn off or on the errors vs having to remove all the @'s to see your errors.
  22. You can limit the mysql_fetch_array to only return the assoc if you prefer. The 2nd parameter is type (which to return). MYSQL_NUM will return an indexed array only, MYSQL_ASSOC will return an associative array. As for me, I tend to stick with just using the mysql_fetch_assoc as it saves less time typing. Just thought you might want to know that.
  23. You do realize that the "HTTP_REFERER" variable is highly un-reliable. Anyone can spoof it, unfortunately. If a spammer (I take it that is the aim of this script to prevent) wants to he just adds it to hist browser and that being the default referrer and wham, he has access. Just noticed it logs it. So you want to add more websites to "not" log. List 2-3 of the websites you do not want to be logged and this is an easy fix.
  24. Now that is helpful. Your variable ($maxposts) does not contain a value. Make sure it is being assigned a value. SQL Was(result2): SELECT * FROM topics WHERE fid = 'ghel' AND pinned = 'No' AND rid = '0' AND deleted = 'No' order by updatetimestamp desc LIMIT 0, (notice just the empty ,).
  25. mysql_fetch_assoc mysql_fetch_array The manual has examples/explains it.
×
×
  • 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.