/** * Return the Administration Tool Application modules the administrator has access to * * @param int $id The ID of the administrator * @access public * @return array */ public static function getUserLevels($id, $site = null) { if (empty($site)) { $site = OSCOM::getSite(); } $data = array('id' => $id); $applications = array(); foreach (OSCOM::callDB('GetAccessUserLevels', $data, 'Core') as $am) { $applications[] = $am['module']; } if (in_array('*', $applications)) { $applications = array(); $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application'); $DLapps->setIncludeFiles(false); foreach ($DLapps->getFiles() as $file) { if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) { // HPDL remove preg_match $applications[] = $file['name']; } } $DLcapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Custom/Site/' . $site . '/Application'); $DLcapps->setIncludeFiles(false); foreach ($DLcapps->getFiles() as $file) { if (!in_array($file['name'], $applications) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLcapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) { $applications[] = $file['name']; } } } $shortcuts = array(); foreach (OSCOM::callDB('GetAccessUserShortcuts', $data, 'Core') as $as) { $shortcuts[] = $as['module']; } $levels = array(); foreach ($applications as $app) { $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller'; if (class_exists($application_class)) { if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) { $OSCOM_Application = Registry::get('Application'); } else { Registry::get('Language')->loadIniFile($app . '.php'); $OSCOM_Application = new $application_class(false); } $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder()); } } return $levels; }
/** * Return the Administration Tool Application modules the administrator has access to * * @param int $id The ID of the administrator * @access public * @return array */ public static function getUserLevels($id, $site = null) { $OSCOM_Database = Registry::get('Database'); if (empty($site)) { $site = OSCOM::getSite(); } $applications = array(); $Qaccess = $OSCOM_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id'); $Qaccess->bindInt(':administrators_id', $id); $Qaccess->execute(); while ($Qaccess->next()) { $applications[] = $Qaccess->value('module'); } if (in_array('*', $applications)) { $applications = array(); $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application'); $DLapps->setIncludeFiles(false); foreach ($DLapps->getFiles() as $file) { if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) { // HPDL remove preg_match $applications[] = $file['name']; } } } $shortcuts = array(); $Qshortcuts = $OSCOM_Database->query('select module from :table_administrator_shortcuts where administrators_id = :administrators_id'); $Qshortcuts->bindInt(':administrators_id', $id); $Qshortcuts->execute(); while ($Qshortcuts->next()) { $shortcuts[] = $Qshortcuts->value('module'); } $levels = array(); foreach ($applications as $app) { $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller'; if (class_exists($application_class)) { if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) { $OSCOM_Application = Registry::get('Application'); } else { Registry::get('Language')->loadIniFile($app . '.php'); $OSCOM_Application = new $application_class(false); } $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder()); } } return $levels; }
/** * Read the Phar package contents * * @param array $key The version to read * @access public * @return mixed */ public static function getPackageContents() { $result = array('entries' => array()); $phar_can_open = true; try { $phar = new Phar(DIR_FS_WORK . 'updates/update.phar'); } catch (Exception $e) { $phar_can_open = false; trigger_error($e->getMessage()); } if ($phar_can_open === true) { $update_pkg = array(); foreach (new RecursiveIteratorIterator($phar) as $iteration) { if (($pos = strpos($iteration->getPathName(), 'update.phar')) !== false) { $update_pkg[] = substr($iteration->getPathName(), $pos + 12); } } natcasesort($update_pkg); $counter = 0; foreach ($update_pkg as $file) { $custom = false; // update the path with admin config value to account for a different admin/ dir $file = str_replace('admin/', DIR_WS_ADMIN, $file); $result['entries'][] = array('key' => $counter, 'name' => $file, 'exists' => file_exists(realpath(DIR_FS_CATALOG) . '/' . $file), 'writable' => self::isWritable(realpath(DIR_FS_CATALOG) . '/' . $file) && self::isWritable(realpath(DIR_FS_CATALOG) . '/' . dirname($file)), 'custom' => $custom, 'to_delete' => false); $counter++; } } $meta = $phar->getMetadata(); if (isset($meta['delete'])) { $files = array(); if (is_array($meta['delete']) && count($meta['delete']) > 0) { foreach ($meta['delete'] as $file) { // update the path with admin config value to account for a different admin/ dir $file = str_replace('admin/', DIR_WS_ADMIN, $file); if (file_exists(realpath(DIR_FS_CATALOG) . '/' . $file)) { if (is_dir(realpath(DIR_FS_CATALOG) . '/' . $file)) { $DL = new DirectoryListing(realpath(DIR_FS_CATALOG) . '/' . $file); $DL->setRecursive(true); $DL->setAddDirectoryToFilename(true); $DL->setIncludeDirectories(false); foreach ($DL->getFiles() as $f) { $files[] = $file . '/' . $f['name']; } } else { $files[] = $file; } } } } natcasesort($files); foreach ($files as $d) { $writable = false; $custom = false; $writable = self::isWritable(realpath(DIR_FS_CATALOG) . '/' . $d) && self::isWritable(realpath(DIR_FS_CATALOG) . '/' . dirname($d)); $result['entries'][] = array('key' => $counter, 'name' => $d, 'exists' => true, 'writable' => $writable, 'custom' => $custom, 'to_delete' => true); $counter++; } } $result['total'] = count($result['entries']); return $result; }
$steps = 1; } $percentage = round(100 * ($stage / $steps)); echo $text . " [{$percentage}]"; if ($newline) { echo "\n"; } else { echo "\r"; } } # This script runs best with a high memory limit # (You may wish to increase this further) ini_set('memory_limit', '1024M'); //TODO: would it be nice to automatically set the limit //based on the number of documents? I think so. $Listing = new DirectoryListing(); # First of all, delete the current index and file listing... echo "Deleting current index file: "; $index_path = $Cfg_FolderSecret . "/pitchfork-index.json"; unlink($index_path); echo "Done.\n"; # Take a directory listing echo "Analysing directories: "; $dir_paths = $Listing->ls_flat($Cfg_FolderLoc); $dir_count = count($dir_paths); echo "Done.\n"; # Generate the path hashes for these files echo "Generating directory hashes:\r"; $dir_hashes = array(); for ($i = 0; $i < $dir_count; $i++) { Percentage("Generating directory hashes:", $i, $dir_count);
public function PaginatedListing() { $paginatedList = new PaginatedList(DirectoryListing::get(), $this->request); $paginatedList->setPageLength(3); return $paginatedList; }
imagegif($newImg); } imagedestroy($newImg); die; } private function __formatSize($bytes) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, 2) . ' ' . $units[$pow]; } } $listing = new DirectoryListing(); $successMsg = null; $errorMsg = null; if (isset($_POST['password'])) { $listing->login(); if (isset($_SESSION['evdir_loginfail'])) { $errorMsg = 'Login Failed! Please check you entered the correct password an try again.'; unset($_SESSION['evdir_loginfail']); } } elseif (isset($_FILES['upload'])) { $uploadStatus = $listing->upload(); if ($uploadStatus == 1) { $successMsg = 'Your file was successfully uploaded!'; } elseif ($uploadStatus == 2) { $errorMsg = 'Your file could not be uploaded. A file with that name already exists.'; } elseif ($uploadStatus == 3) {