コード例 #1
0
ファイル: system.class.php プロジェクト: bqq1986/efront
 /**
  * Backup system
  *
  * This function is used to backup the system. There are 2 types of backup, database only and full.
  * In the first case (the default), only the database is backed up, while in the second case, files
  * are backed up as well.
  * <br/>Example:
  * <code>
  * $backupFile = EfrontSystem :: backup('13_3_2007');			//Backup database only
  * </code>
  *
  * @param string $backupName The name of the backup
  * @param int $backupType Can be either 0 or 1, where 0 siginifies database only backup and 1 is for including backup files as well
  * @return EfrontFile The compressed file of the backup
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function backup($backupName, $backupType = 0)
 {
     $tempDir = G_BACKUPPATH . 'temp/';
     if (is_dir($tempDir)) {
         $dir = new EfrontDirectory($tempDir);
         $dir->delete();
     }
     mkdir($tempDir, 0755);
     mkdir($tempDir . 'db_backup', 0755);
     $directory = new EfrontDirectory($tempDir);
     $tables = $GLOBALS['db']->GetCol("show tables");
     //Get the database tables
     foreach ($tables as $table) {
         if (!preg_match("/^\\w+_view\$/", $table)) {
             $data = eF_getTableData($table, "count(*)");
             $unfold = 1000;
             $limit = ceil($data[0]['count(*)'] / $unfold);
             for ($i = 0; $i < $limit; $i++) {
                 $data = eF_getTableData($table, "*", "", "'' limit {$unfold} offset " . $i * $unfold);
                 file_put_contents($tempDir . 'db_backup/' . $table . '.' . $i, serialize($data), FILE_APPEND);
             }
             $result = eF_ExecuteNew("show create table {$table}");
             $temp = $result->GetAll();
             $definition[] = "drop table " . $temp[0]['Table'];
             $definition[] = $temp[0]['Create Table'];
         }
     }
     /*
     		 foreach ($tables as $table) {
     $data = eF_getTableData($table);
     file_put_contents($tempDir.'db_backup/'.$table, serialize($data));
     $result       = eF_ExecuteNew("show create table $table");
     $temp         = $result -> GetAll();
     $definition[] = "drop table ".$temp[0]['Table'];
     $definition[] = $temp[0]['Create Table'];
     }
     */
     file_put_contents($tempDir . 'db_backup/sql.txt', implode(";\n", $definition));
     file_put_contents($tempDir . 'db_backup/version.txt', G_VERSION_NUM);
     if ($backupType == 3 && checkFunction('system') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         system('mkdir ' . $tempDir . 'lessons');
         system('cp -R ' . G_LESSONSPATH . '* ' . $tempDir . 'lessons');
         system('mkdir -p ' . $tempDir . 'upload');
         system('cp -R ' . G_UPLOADPATH . '* ' . $tempDir . 'upload');
         system('mkdir -p ' . $tempDir . 'certificate_templates');
         system('cp -R ' . G_ROOTPATH . "www/certificate_templates/" . '* ' . $tempDir . 'certificate_templates');
         system('mkdir -p ' . $tempDir . 'editor_templates');
         system('cp -R ' . G_ROOTPATH . "www/content/editor_templates/" . '* ' . $tempDir . 'editor_templates');
     } else {
         if ($backupType == 1 || $backupType == 3) {
             $lessonsDir = new EfrontDirectory(G_LESSONSPATH);
             $lessonsDir->copy($tempDir . 'lessons');
             $uploadsDir = new EfrontDirectory(G_UPLOADPATH);
             $uploadsDir->copy($tempDir . 'upload');
             $certificatesDir = new EfrontDirectory(G_ROOTPATH . "www/certificate_templates/");
             $certificatesDir->copy($tempDir . 'certificate_templates');
             $editorTemplatesDir = new EfrontDirectory(G_ROOTPATH . "www/content/editor_templates/");
             $editorTemplatesDir->copy($tempDir . 'editor_templates');
         } else {
             if ($backupType == 2) {
                 $rootDir = new EfrontDirectory(G_ROOTPATH);
                 $rootDir->copy($tempDir . 'efront_root');
             }
         }
     }
     if ($backupType == 3 && checkFunction('system') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         $compressedFile = $directory->compress($backupName, false, false, true);
     } else {
         $compressedFile = $directory->compress($backupName, false);
     }
     $directory->delete();
     return $compressedFile;
 }
コード例 #2
0
 /**
  *
  * @return unknown_type
  */
 public function export()
 {
     if (!$this->remote) {
         global $currentUser;
         $directory = new EfrontDirectory(G_THEMESPATH . $this->{$this->entity}['path']);
         $file = $directory->compress();
         $file = $file->copy($currentUser->getDirectory() . $file['name']);
         return $file;
     }
 }
コード例 #3
0
 public function scormExport()
 {
     $scormExportFolder = G_SCORMPATH . $this->lesson['id'] . "/";
     try {
         $dir = new EfrontDirectory($scormExportFolder);
         $dir->delete();
     } catch (Exception $e) {
     }
     $htmlExportFolder = $scormExportFolder . 'html/';
     $filesExportFolder = $scormExportFolder . 'html/files/';
     is_dir($filesExportFolder) or mkdir($filesExportFolder, 0755, true);
     //is_dir($htmlExportFolder)  OR mkdir($htmlExportFolder, 0755, true);
     $filelist = array();
     $content = new EfrontContentTree($this, true);
     foreach (new EfrontContentFilterIterator(new EfrontNoSCORMFilterIterator(new EfrontVisitableAndEmptyFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($content->tree, RecursiveIteratorIterator::SELF_FIRST))))) as $key => $unit) {
         $unitFiles = $unit->getFiles(true);
         $units[] = $unit;
         $data = $unit['data'];
         foreach ($unitFiles as $file) {
             $filePath = str_replace($this->getDirectory(), "/", EfrontFile::encode($file['path']));
             //Added this line in case of a space in path(urlencode makes it + and rawurlencode convers also slashes ) (#2143)
             $data = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']) . str_replace(' ', '%20', $filePath), "files" . str_replace(' ', '%20', $filePath), $data);
             $data = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']) . $filePath, "files" . $filePath, $data);
             $data = str_replace("view_file.php?file=" . $file['id'], "files" . $filePath, $data);
         }
         $unitContent = $this->createSCORMHtmlFiles($data);
         $unitFilename = $htmlExportFolder . str_replace('?', ' ', $unit['name']) . ".html";
         file_put_contents(EfrontFile::encode($unitFilename), $unitContent);
         $metadata = $this->getSCORMAssetMetadata($unit);
         $metadataFilename = $htmlExportFolder . str_replace('?', ' ', $unit['name']) . ".xml";
         //file_put_contents($metadataFilename, $metadata);
         file_put_contents(EfrontFile::encode($metadataFilename), $metadata);
         $filelist = array_merge($filelist, $unitFiles);
     }
     foreach ($filelist as $file) {
         $filePath = str_replace($this->getDirectory(), "", $file['path']);
         if (!is_dir($filesExportFolder . dirname($filePath))) {
             mkdir($filesExportFolder . dirname($filePath), 0755, true);
         }
         $file->copy($filesExportFolder . $filePath, true, false);
         $metadata = $this->getSCORMAssetMetadata($file);
         $metadataFilename = EfrontFile::encode($filesExportFolder . $filePath . ".xml");
         file_put_contents($metadataFilename, $metadata);
     }
     /*Create manifest*/
     $prerequisites = $this->getSCORMPrerequisites();
     $organizations_str = $this->buildSCORMManifestOrganizations($prerequisites);
     $resources_str = $this->buildSCORMManifestResources($units);
     $metadata_str = $this->buildSCORMManifestMetadata(0);
     $manifest = $this->buildSCORMManifestMain($metadata_str . $organizations_str . $resources_str);
     file_put_contents($scormExportFolder . "imsmanifest.xml", $manifest);
     /*Create functions files*/
     list($func1, $func2) = $this->getAPIFunctions();
     file_put_contents($scormExportFolder . "APIWrapper.js", $func1);
     file_put_contents($scormExportFolder . "SCOFunctions.js", $func2);
     $scormDirectory = new EfrontDirectory($scormExportFolder);
     if (eF_checkParameter($this->lesson['name'], 'path')) {
         $filename = $this->lesson['name'] . '.zip';
     } else {
         $filename = 'SCO.zip';
     }
     $compressedFile = $scormDirectory->compress($filename, false);
     $scormDirectory->delete();
     return $compressedFile;
 }
コード例 #4
0
ファイル: modules.php プロジェクト: bqq1986/efront
                }
            } else {
                $message = _NOMODULECLASSFOUND . ' "' . $className . '" : ' . G_MODULESPATH . $module_folder;
                $message_type = 'failure';
                //$dir = new EfrontDirectory(G_MODULESPATH.$module_folder.'/');
                //$dir -> delete();
                //eF_deleteFolder(G_MODULESPATH.$module_folder.'/');
            }
        }
    } elseif (isset($_GET['export_module']) && eF_checkParameter($_GET['export_module'], 'filename')) {
        if (isset($currentUser->coreAccess['modules'])) {
            throw new EfrontSystemException(_UNAUTHORIZEDACCESS, EfrontSystemException::UNAUTHORIZED_ACCESS);
        }
        $className = $_GET['export_module'];
        $directory = new EfrontDirectory(G_MODULESPATH . $className);
        $file = $directory->compress(false, false);
        echo $file['url_path'];
        exit;
    }
} catch (Exception $e) {
    handleAjaxExceptions($e);
}
$modulesList = eF_getTableData("modules", "*", "", "active desc");
// Check for errors in modules
foreach ($modulesList as $key => $module) {
    $folder = $module['position'];
    $className = $module['className'];
    $permissions = explode(",", $module['permissions']);
    // Check if module folder exists
    $modulesList[$key]['folder_exists'] = is_dir(G_MODULESPATH . $folder);
    if (!$modulesList[$key]['folder_exists']) {
コード例 #5
0
 public function unitExport(EfrontUnit $unit)
 {
     $currentLesson = $this->getCurrentLesson();
     $unitExportFolder = $this->moduleBaseDir . "assets/";
     try {
         $dir = new EfrontDirectory($unitExportFolder);
         $dir->delete();
     } catch (Exception $e) {
     }
     $htmlExportFolder = $unitExportFolder . 'html/';
     $filesExportFolder = $unitExportFolder . 'html/files/';
     is_dir($filesExportFolder) or mkdir($filesExportFolder, 0755, true);
     //is_dir($htmlExportFolder)  OR mkdir($htmlExportFolder, 0755, true);
     $filelist = array();
     $unitFiles = $unit->getFiles(true);
     $units[] = $unit;
     $data = $unit['data'];
     foreach ($unitFiles as $file) {
         $filePath = str_replace($currentLesson->getDirectory(), "/", EfrontFile::encode($file['path']));
         //Added this line in case of a space in path(urlencode makes it + and rawurlencode convers also slashes ) (#2143)
         $data = str_replace("content/lessons/" . ($currentLesson->lesson['share_folder'] ? $currentLesson->lesson['share_folder'] : $currentLesson->lesson['id']) . str_replace(' ', '%20', $filePath), "files" . str_replace(' ', '%20', $filePath), $data);
         $data = str_replace("content/lessons/" . ($currentLesson->lesson['share_folder'] ? $currentLesson->lesson['share_folder'] : $currentLesson->lesson['id']) . $filePath, "files" . $filePath, $data);
         $data = str_replace("view_file.php?file=" . $file['id'], "files" . $filePath, $data);
     }
     $unitContent = $data;
     $unitFilename = $htmlExportFolder . $unit['name'] . ".html";
     file_put_contents(EfrontFile::encode($unitFilename), $unitContent);
     $filelist = array_merge($filelist, $unitFiles);
     foreach ($filelist as $file) {
         $filePath = str_replace($currentLesson->getDirectory(), "", $file['path']);
         if (!is_dir($filesExportFolder . dirname($filePath))) {
             mkdir($filesExportFolder . dirname($filePath), 0755, true);
         }
         $file->copy($filesExportFolder . $filePath);
     }
     $unitDirectory = new EfrontDirectory($unitExportFolder);
     if (eF_checkParameter($unit['name'], 'file')) {
         $filename = $unit['name'] . '.zip';
     } else {
         $filename = 'unit.zip';
     }
     $compressedFile = $unitDirectory->compress($filename, false);
     //$unitDirectory -> delete();
     return $compressedFile;
 }
コード例 #6
0
ファイル: ims.php プロジェクト: bqq1986/efront
            }
            $ims_filename = "ims_lesson" . $lessons_id . ".zip";
            if (is_file(IMS_FOLDER . "/" . $ims_filename)) {
                unlink(IMS_FOLDER . "/" . $ims_filename);
            }
            $lessons_id = $currentLesson->lesson['id'];
            try {
                $filesystem = new FileSystemTree($currentLesson->getDirectory());
                foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST)) as $key => $value) {
                    $value instanceof EfrontDirectory ? $filelist[] = preg_replace("#" . $currentLesson->getDirectory() . "#", "", $key) . '/' : ($filelist[] = preg_replace("#" . $currentLesson->getDirectory() . "#", "", $key));
                }
                $lesson_entries = eF_getTableData("content", "id,name,data", "lessons_ID=" . $lessons_id . " and ctg_type!='tests' and active=1");
                require_once "ims_tools.php";
                create_manifest($lessons_id, $lesson_entries, $filelist, IMS_FOLDER);
                $imsDirectory = new EfrontDirectory(IMS_FOLDER . "/lesson" . $lessons_id . "/");
                $compressedFile = $imsDirectory->compress(false, false, true);
                $imsDirectory->delete();
                $smarty->assign("T_IMS_EXPORT_FILE", $compressedFile);
                $smarty->assign("T_MESSAGE", _SUCCESSFULLYEXPORTEDIMSFILE);
                $smarty->assign("T_MESSAGE_TYPE", "success");
            } catch (Exception $e) {
                $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                $message = _SOMEPROBLEMEMERGED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                $message_type = "failure";
            }
        }
        $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
        $form->accept($renderer);
        $smarty->assign('T_EXPORT_IMS_FORM', $renderer->toArray());
    }
}
コード例 #7
0
ファイル: projects.php プロジェクト: bqq1986/efront
         if (!is_dir($projectDir)) {
             mkdir($projectDir, 0755);
         }
         $projectDirectory = new EfrontDirectory($projectDir);
         foreach ($projectFiles as $title => $file) {
             try {
                 $projectFile = new EfrontFile($file['id']);
                 $newFileName = EfrontFile::encode($title . '_' . date("d.m.Y", $file['upload_timestamp']) . '_' . $projectFile['name']);
                 $projectFile->copy($projectDir . '/' . $newFileName);
             } catch (EfrontFileException $e) {
                 //Don't halt for a single file
                 $message .= $e->getMessage() . ' (' . $e->getCode() . ')';
             }
         }
         $zipFileName = $currentUser->user['directory'] . '/projects/' . EfrontFile::encode($_GET['compress_user']) . '.zip';
         $zipFile = $projectDirectory->compress($zipFileName, false, true);
         $projectDirectory->delete();
         eF_redirect("view_file.php?file=" . urlencode($zipFile['path']) . "&action=download");
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _FILESCOULDNOTBEDOWNLOADED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } else {
     if ((isset($_GET['add_project']) || isset($_GET['edit_project']) && in_array($_GET['edit_project'], array_keys($projects))) && $_professor_) {
         //ajax request for inserting file in editor
         //This page has a file manager, so bring it on with the correct options
         $basedir = $currentLesson->getDirectory();
         //Default options for the file manager
         if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') {
             $options = array('lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0);