Guest User

Untitled

a guest
Jan 19th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <?php
  2. // LAST FILES UPDATE
  3. function getAllFiles($directory, $recursive = true) {
  4. $result = array();
  5. $handle = opendir($directory);
  6. while ($datei = readdir($handle))
  7. {
  8. if (($datei != '.') && ($datei != '..'))
  9. {
  10. $file = $directory.$datei;
  11. if (is_dir($file)) {
  12. if ($recursive) {
  13. $result = array_merge($result, getAllFiles($file.'/'));
  14. }
  15. } else {
  16. $result[] = $file;
  17. }
  18. }
  19. }
  20. closedir($handle);
  21. return $result;
  22. }
  23.  
  24. function getHighestFileTimestamp($directory, $recursive = true) {
  25. $allFiles = getAllFiles($directory, $recursive);
  26. $highestKnown = 0;
  27. foreach ($allFiles as $val) {
  28. $currentValue = filemtime($val);
  29. if ($currentValue > $highestKnown) $highestKnown = $currentValue;
  30. }
  31. return $highestKnown;
  32. }
  33.  
  34. echo '<div align="center" style=" padding-top:5px; margin-top:5px; border-top:dotted #777; border-width:1px;">Last Update Date:<br>';
  35.  
  36. date_default_timezone_set('Europe/Athens');
  37. setlocale(LC_ALL, array('el_GR.UTF-8','el_GR@euro','el_GR','greek'));
  38. echo strftime('%d %b %Y, %H:%M:%S', getHighestFileTimestamp('../'));
  39. echo '</div>';
  40.  
  41. $host="localhost"; // Host name
  42. $username="..."; // Mysql username
  43. $password="..."; // Mysql password
  44. $db_name="..."; // Database name
  45. $tbl_name="..."; // Table name
  46.  
  47. // Connect to server and select database.
  48. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  49. mysql_select_db("$db_name")or die("cannot select DB");
  50.  
  51. // update data in mysql database
  52. $sql="UPDATE $tbl_name SET date='HUMMMM HERE HOW TO PULL THE VALUE?' WHERE id='1'";
  53. $result=mysql_query($sql);
  54.  
  55. // if successfully updated.
  56. if($result){
  57. echo "Successful";
  58. echo "<BR>";
  59. }
  60. else {
  61. echo "ERROR";
  62. }
  63.  
  64. ?>
  65.  
  66. $sql = "UPDATE {$tbl_name} SET date='{$date}' WHERE id='{$id}';";
  67.  
  68. $sql = "UPDATE " . $tbl_name . " SET date='" . $date . "' WHERE id='1';";
  69.  
  70. // use the function to calculate highest timestamp
  71. $highestdate = getHighestFileTimestamp("../");
  72.  
  73. // Insert the highest timestamp into the db
  74. $sql= sprintf("UPDATE $tbl_name SET date='%s' WHERE id='1'",
  75. $highestdate);
  76.  
  77. $sql = "UPDATE {$tbl_name} SET date='{$date}' WHERE id='{$id}';";
  78.  
  79. $sql = "UPDATE " . $tbl_name . " SET date='" . $date . "' WHERE id='1';";
Add Comment
Please, Sign In to add comment