fork download
  1. <?php
  2. function fakeIsFile($file) {
  3. $isFile = (striPos($file, "test") === FALSE);
  4. echo("[INFO]: " . $file . ($isFile ? " exists." : " does not exist.") . "\n");
  5. return $isFile;
  6. }
  7.  
  8. $row["attachments"] = "angeleyes.jpg|test.rar|angeleyes2.png";
  9. $attachments = explode("|", $row["attachments"]);
  10. $newAttachments = array();
  11. $dir = "../uploads/";
  12.  
  13. if ($row["attachments"]) {
  14. echo("Old attachments: " . $row["attachments"] . "\n");
  15. forEach ($attachments as $file) {
  16. if (fakeIsFile($dir . $file)) {
  17. //echo('<a href="#">' . $file . '</a> ('
  18. // . filesize_formatted($dir . $file) . ') <br>');
  19. $newAttachments[] = $file;
  20. }
  21. }
  22.  
  23. $newAttachments = implode("|", $newAttachments);
  24. if (strCaseCmp($row["attachments"], $newAttachments) != 0) {
  25. echo("You need to update the DB !\n");
  26. echo("New attachments: " . $newAttachments);
  27. } else {
  28. echo("No need to update !");
  29. }
  30. }
  31. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Old attachments: angeleyes.jpg|test.rar|angeleyes2.png
[INFO]: ../uploads/angeleyes.jpg exists.
[INFO]: ../uploads/test.rar does not exist.
[INFO]: ../uploads/angeleyes2.png exists.
You need to update the DB !
New attachments: angeleyes.jpg|angeleyes2.png