finddoc.php 892 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Script to find a document with a specific title or path in all courses
  4. */
  5. /**
  6. * Code init - comment die() call to enable
  7. */
  8. die();
  9. require '../../inc/global.inc.php';
  10. if (empty($_GET['doc'])) {
  11. echo "To add a document name to search, add ?doc=abc to the URL";
  12. } else {
  13. echo "Received param ".Security::remove_XSS($_GET['doc'])."<br />";
  14. }
  15. $courses_list = CourseManager::get_courses_list();
  16. foreach ($courses_list as $course) {
  17. $title = Database::escape_string($_GET['doc']);
  18. $td = Database::get_course_table(TABLE_DOCUMENT);
  19. $sql = "SELECT id, path FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' OR title LIKE '%$title%'";
  20. $res = Database::query($sql);
  21. if (Database::num_rows($res) > 0) {
  22. while ($row = Database::fetch_array($res)) {
  23. echo "Found doc ".$row['id']."-> ".$row['path']." in course ".$course['code']."<br />";
  24. }
  25. }
  26. }