function find_html_files() { global $group_sql; $disk_paths = array(); $public_paths = array(); $file_ids = array(); $q = Database::get()->queryArray("SELECT id, path, filename FROM document WHERE $group_sql AND (format = 'html' OR format = 'htm')"); foreach ($q as $row) { $disk_paths[] = $row->path; $public_paths[] = public_file_path($row->path, $row->filename); $file_ids[] = $row->id; } array_multisort($public_paths, $disk_paths, $file_ids); $id_map = array_flip($file_ids); return array(&$disk_paths, &$public_paths, &$file_ids, &$id_map); }
function directory_list() { global $group_sql; $dirArray = array(); $r = Database::get()->queryArray("SELECT filename, path FROM document WHERE {$group_sql} AND format = '.dir'"); foreach ($r as $row) { $dirArray[] = array($row->path, $row->filename, public_file_path($row->path, $row->filename)); } setlocale(LC_COLLATE, $GLOBALS['langLocale']); usort($dirArray, function ($a, $b) { return strcoll($a[2], $b[2]); }); foreach ($dirArray as $dir) { $sortedDirs[$dir[0]] = $dir[1]; } return $sortedDirs; }
WHERE ebook.id = $ebook_id AND ebook.course_id = $course_id AND ebook_section.ebook_id = ebook.id AND ebook_section.id = ebook_subsection.section_id AND document.id = ebook_subsection.file_id AND document.course_id = $course_id AND document.subsystem = $subsystem ORDER BY CONVERT(psid, UNSIGNED), psid, CONVERT(pssid, UNSIGNED), pssid"); if (!$q) { not_found($uri); } $last_section_id = null; $sections = array(); foreach ($q as $row) { $url_filename = public_file_path($row->path, $row->filename); $sid = $row->sid; $ssid = $row->ssid; if (!isset($current_sid)) { $current_sid = $sid; } if ($current_sid == $sid and !isset($current_ssid)) { $current_ssid = $row->ssid; } if (!isset($current_display_id) and isset($current_sid) and isset($current_ssid)) { $current_display_id = $sid . ',' . $ssid; } $display_id = $sid . ',' . $ssid; if ($last_section_id != $row->sid) { $sections[] = array('id' => $display_id, 'title' => $row->section_title,
/** * * @global type $course_code * @global type $urlServer * @global type $group_id * @global type $ebook_id * @param type $path * @param type $filename * @param type $courseCode * @return type */ function file_playurl($path, $filename = null, $courseCode = null) { global $course_code, $urlServer, $group_id, $ebook_id; $courseCode = $courseCode == null ? $course_code : $courseCode; if (defined('EBOOK_DOCUMENTS')) { return htmlspecialchars($urlServer . "modules/ebook/play.php/{$courseCode}/{$ebook_id}/_" . public_file_path($path, $filename), ENT_QUOTES); } else { $gid = defined('GROUP_DOCUMENTS') ? ",{$group_id}" : ''; if (defined('COMMON_DOCUMENTS')) { $courseCode = 'common'; } return htmlspecialchars($urlServer . "modules/document/play.php/{$courseCode}{$gid}" . public_file_path($path, $filename), ENT_QUOTES); } }