Example #1
0
 $values = $form->exportValues();
 try {
     $urlUpload = $form->exportValue('url_upload');
     $scormFiles = array();
     if ($urlUpload != "") {
         FileSystemTree::checkFile($urlUpload);
         $urlArray = explode("/", $urlUpload);
         $urlFile = preg_replace("/\\?.*/", "", urldecode($urlArray[sizeof($urlArray) - 1]));
         if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
             $error = error_get_last();
             throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
         } else {
             $scormFiles[] = new EfrontFile($currentLesson->getDirectory() . $urlFile);
         }
     } else {
         $filesystem = new FileSystemTree($currentLesson->getDirectory(), true);
         foreach ($_FILES['scorm_file']['name'] as $key => $value) {
             if (!in_array($value, $scormFiles)) {
                 //This way we bypass duplicates
                 try {
                     $scormFiles[$value] = $filesystem->uploadFile("scorm_file", $currentLesson->getDirectory(), $key);
                 } catch (EfrontFileException $e) {
                     if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                         throw $e;
                     }
                 }
             }
         }
     }
     //pr($scormFiles);exit;
     foreach ($scormFiles as $scormFile) {
Example #2
0
 }
 #cpp#endif
 $form->addElement('checkbox', 'options[modules]', _MODULES, null, 'class = "inputCheckBox"');
 $form->addElement('file', 'file_upload', null, 'class = "inputText"');
 //Lesson file
 $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
 //getUploadMaxSize returns size in KB
 $form->addElement('text', 'url_upload', _UPLOADFILEFROMURL, 'class = "inputText"');
 $form->addElement('checkbox', 'exclude_search', _EXCLUDESEARCH, null, 'class = "inputCheckbox"');
 $form->addElement('submit', 'submit_import_lesson', _SUBMIT, 'class = "flatButton"');
 $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
 if ($form->isSubmitted() && $form->validate()) {
     try {
         $values = $form->exportValues();
         $currentLesson->initialize(array_keys($values['options']));
         $filesystem = new FileSystemTree($currentLesson->getDirectory());
         $urlUpload = $values['url_upload'];
         if ($urlUpload != "") {
             FileSystemTree::checkFile($urlUpload);
             $urlArray = explode("/", $urlUpload);
             $urlFile = urldecode($urlArray[sizeof($urlArray) - 1]);
             if (!copy($urlUpload, $currentLesson->getDirectory() . $urlFile)) {
                 $error = error_get_last();
                 throw new Exception(_PROBLEMUPLOADINGFILE . ': ' . $error['message']);
             } else {
                 $uploadedFile = new EfrontFile($currentLesson->getDirectory() . $urlFile);
                 $currentLesson->import($uploadedFile, $values['options'], false, false, $values['exclude_search']);
             }
         } else {
             $uploadedFile = $filesystem->uploadFile('file_upload', $currentLesson->getDirectory());
             $currentLesson->import($uploadedFile, $values['options'], false, false, $values['exclude_search']);
Example #3
0
            //Build the form
            $form->addElement('file', 'import_content', _UPLOADLESSONFILE, 'class = "inputText"');
            $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
            //getUploadMaxSize returns size in KB
            $form->addElement('submit', 'submit_lesson', _SUBMIT, 'class = "flatButton"');
            try {
                if ($form->isSubmitted() && $form->validate()) {
                    //If the form is submitted and validated
                    $directionsTree = new EfrontDirectionsTree();
                    if (sizeof($directionsTree->tree) == 0) {
                        eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
                        exit;
                    }
                    //changed because of #1462
                    $newLesson = EfrontLesson::createLesson();
                    $filesystem = new FileSystemTree($newLesson->getDirectory(), true);
                    $file = $filesystem->uploadFile('import_content', $newLesson->getDirectory());
                    $newLesson->import($file, false, true, true);
                    $message = _OPERATIONCOMPLETEDSUCCESSFULLY;
                    $message_type = 'success';
                }
            } catch (EfrontFileException $e) {
                handleNormalFlowExceptions($e);
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
           		&nbsp;<span class = "formRequired">*</span>
            {/if}');
            $renderer->setErrorTemplate('{$html}{if $error}
	            <div class = "formError">{$error}</div>
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     if ($form->exportValue('remote_theme')) {
         $file = $form->exportValue('remote_theme');
         if (!fopen($file, 'r')) {
             throw new EfrontFileException(_FILEDOESNOTEXIST . ': ' . $file, EfrontFileException::FILE_NOT_EXIST);
         }
     } else {
         try {
             $filesystem = new FileSystemTree(G_THEMESPATH, true);
             $themeFile = $filesystem->uploadFile('theme_file', G_THEMESPATH);
             $filesList = $themeFile->listContents();
             if (mb_substr($filesList[0], 0, mb_strpos($filesList[0], "/")) == "default") {
                 throw new Exception(_DEFAULTTHEMECANNOTBEIMPORTED, EfrontThemesException::DEFAULT_IMPORTED);
             }
             $themeFile->uncompress(false);
             //$pathInfo = pathinfo($themeFile['path']);
             //copy(G_DEFAULTTHEMEPATH.'css/css_global.php', $pathInfo['dirname'].'/'.$pathInfo['filename'].'/css/css_global.php');
             $themeFile->delete();
             $file = new EfrontFile($themeFile['directory'] . '/' . str_replace('.zip', '', $themeFile['name']) . "/theme.xml");
         } catch (EfrontFileException $e) {
             //Don't halt if no file was uploaded (errcode = 4). Otherwise, throw the exception
             if ($e->getCode() != 4) {
                 throw $e;
             }
         }
     }
     if ($file) {
         $xmlValues = themes::parseFile($file);
         if ($_GET['add']) {
             $theme = self::create($xmlValues);
         }
         /*
         else {
             $this -> options = array_merge($this -> options, $xmlValues);
             $this -> layout  =
             $this -> persist();
         }
         */
     }
     //$smarty -> assign("T_RELOAD_ALL", 1);
 }
     $form->setDefaults(array('pdf_check' => 1));
     $smarty->assign("T_EDITPDFCONTENT", true);
 }
 //You can't change a unit's parent from this form. You must use the content tree management page
 if ($_GET['edit']) {
     $form->setDefaults(array('parent_content_ID' => $currentUnit['parent_content_ID']));
     $form->freeze(array('parent_content_ID'));
 }
 //If the form was submitted with pdf content, take special care
 if ($form->isSubmitted() && $form->validate()) {
     try {
         $values = $form->exportValues();
         if ($_FILES['pdf_upload']['name'] != "") {
             if (strpos($_FILES['pdf_upload']['name'], ".pdf") !== false) {
                 $destinationDir = new EfrontDirectory(G_LESSONSPATH . $_SESSION['s_lessons_ID']);
                 $filesystem = new FileSystemTree(G_LESSONSPATH . $_SESSION['s_lessons_ID']);
                 $uploadedFile = $filesystem->uploadFile('pdf_upload', $destinationDir);
                 $values['data'] = '<iframe src="view_file.php?file=' . $uploadedFile['id'] . '"  name="pdfaccept" width="100%" height="600"></iframe>';
                 //$values['data'] = '<iframe src="'.$currentLesson -> getDirectoryUrl().'/'.$uploadedFile["physical_name"].'"  name="pdfaccept" width="100%" height="600"></iframe>';
             } else {
                 throw new Exception(_YOUMUSTUPLOADAPDFFILE);
             }
         }
         $options = serialize(array('complete_unit_setting' => $values['complete_unit_setting'], 'hide_navigation' => $values['hide_navigation'], 'indexed' => $values['indexed'], 'maximize_viewport' => $values['maximize_viewport'], 'scorm_asynchronous' => $values['scorm_asynchronous'], 'scorm_times' => $values['scorm_times'], 'scorm_logging' => $values['scorm_logging'], 'object_ids' => $values['object_ids'], 'no_before_unload' => $values['no_before_unload'], 'reentry_action' => isset($values['reentry_action']) ? $values['reentry_action'] : false, 'complete_question' => $values['complete_question'] ? $values['complete_question'] : 0, 'complete_time' => $values['complete_time'] ? $values['complete_time'] : ''));
         if (isset($_GET['edit'])) {
             //You can't edit data in scorm units
             if (strpos($currentUnit['ctg_type'], 'scorm') === false && strpos($currentUnit['scorm_version'], 'tincan') === false) {
                 $currentUnit['data'] = applyEditorOffset($values['data']);
             } else {
                 if ($values['data'] != $currentUnit['data']) {
                     $currentUnit['data'] = $values['data'];
Example #6
0
 /**
  * Restore system
  *
  * This function is used to restore a backup previously taken
  * <br/>Example:
  * <code>
  * </code>
  *
  * @param EfrontFile $restoreFile The file restore from
  * @param boolean $force Force restore even if versions are incompatible
  * @since 3.5.2
  * @access public
  */
 public static function restore($restoreFile, $force = false)
 {
     if (!$restoreFile instanceof EfrontFile) {
         $restoreFile = new EfrontFile($restoreFile);
     }
     $tempDir = G_BACKUPPATH . 'temp/';
     if (is_dir($tempDir)) {
         $dir = new EfrontDirectory($tempDir);
         $dir->delete();
     }
     mkdir($tempDir, 0755);
     $restoreFile = $restoreFile->copy($tempDir . '/');
     $restoreFile->uncompress(false);
     $filesystem = new FileSystemTree($tempDir);
     $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST));
     foreach ($iterator as $key => $value) {
         if (strpos($key, 'version.txt') !== false) {
             $backupVersion = file_get_contents($key);
         }
     }
     if (version_compare($backupVersion, G_VERSION_NUM) != 0 && !$force) {
         throw new Exception(_INCOMPATIBLEVERSIONS . '<br/> ' . _BACKUPVERSION . ':' . $backupVersion . ' / ' . _CURRENTVERSION . ': ' . G_VERSION_NUM, EfrontSystemException::INCOMPATIBLE_VERSIONS);
     }
     $sql = file_get_contents($tempDir . 'db_backup/sql.txt');
     $sql = explode(";\n", $sql);
     $node = $filesystem->seekNode($tempDir . 'db_backup');
     for ($i = 0; $i < sizeof($sql); $i += 2) {
         preg_match("/drop table (.+)/", $sql[$i], $matches);
         if ($matches[1]) {
             $temp[$matches[1]] = array($sql[$i], $sql[$i + 1]);
         }
     }
     $sql = $temp;
     //For each one of the tables that have backup data, recreate its table and import data
     $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($node), RecursiveIteratorIterator::SELF_FIRST));
     $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=0");
     foreach ($iterator as $file => $value) {
         $tableName = preg_replace("/\\.\\d+/", "", basename($file));
         if (isset($sql[$tableName])) {
             try {
                 eF_executeNew($sql[$tableName][0]);
             } catch (Exception $e) {
                 /*Don't halt for missing tables that can't be deleted*/
             }
             eF_executeNew($sql[$tableName][1]);
             unset($sql[$tableName]);
         }
         if (strpos($file, 'sql.txt') === false && strpos($file, 'version.txt') === false) {
             $data = unserialize(file_get_contents($file));
             $tableExists = false;
             try {
                 $tableExists = eF_describeTable($tableName);
             } catch (Exception $e) {
             }
             if ($tableExists !== false && !preg_match("/^\\w+_view\$/", $tableName)) {
                 eF_insertTableDataMultiple($tableName, $data);
             }
         }
     }
     $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=1");
     //Turn off foreign key checks in order to be able to run "drop table" queries
     eF_executeNew("SET FOREIGN_KEY_CHECKS = 0;");
     //For each one of the tables that don't have backup data, simply recreate
     foreach ($sql as $tableName => $query) {
         try {
             eF_executeNew($query[0]);
         } catch (Exception $e) {
             /*Don't halt for missing tables that can't be deleted*/
         }
         eF_executeNew($query[1]);
     }
     eF_executeNew("SET FOREIGN_KEY_CHECKS = 1;");
     if (is_dir(G_BACKUPPATH . 'temp/upload')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/upload');
         $dir->copy(G_ROOTPATH . 'upload', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/lessons')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/lessons');
         $dir->copy(G_CONTENTPATH . 'lessons', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/efront_root')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/efront_root');
         $dir->copy(G_ROOTPATH, true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/certificate_templates')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/certificate_templates');
         $dir->copy(G_ROOTPATH . 'www/certificate_templates', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/editor_templates')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/editor_templates');
         $dir->copy(G_ROOTPATH . 'www/content/editor_templates', true);
     }
     $dir = new EfrontDirectory($tempDir);
     $dir->delete();
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache('user');
     }
     return true;
 }
 /**
  * Share file
  *
  * This function is used to make the current file available to the lesson's
  * students. A file can be made available to a single lesson only.
  * <br/>Example:
  * <code>
  * $file = new EfrontFile(43);
  * $file -> share();							//The file is now visible to the shared files list
  * $file -> unshare();							//The file was made hidden again
  * </code>
  *
  * @param int $lessonId A specific lesson to share this file for
  * @since 3.5.0
  * @access public
  */
 public function share($lessonId = false)
 {
     if (!$lessonId) {
         $result = eF_getTableData("lessons", "share_folder", "id=" . $_SESSION['s_lessons_ID']);
         $lessonId = !$result[0]['share_folder'] ? $_SESSION['s_lessons_ID'] : $result[0]['share_folder'];
     }
     if ($lessonId) {
         if ($this['id'] == -1) {
             //If the file does not have a database representation, create one for it
             $newList = FileSystemTree::importFiles($this['path']);
             $this['id'] = key($newList);
             $this->refresh();
         }
         $this['shared'] = $lessonId;
         $this->persist();
     } else {
         throw new EfrontFileException(_CANNOTSHAREFILE . ': ' . $this['path'], EfrontFileException::NOT_LESSON_FILE);
     }
 }
Example #8
0
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     $layout_form->accept($renderer);
     $smarty->assign('T_ADD_BLOCK_FORM', $renderer->toArray());
 } else {
     $form = new HTML_QuickForm("import_settings_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=themes&theme=' . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : ''), "", null, true);
     $form->addElement('file', 'file_upload', _SETTINGSFILE, 'class = "inputText"');
     $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
     //getUploadMaxSize returns size in KB
     $form->addElement('submit', 'submit_import', _SUBMIT, 'class = "flatButton"');
     $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
     if ($form->isSubmitted() && $form->validate()) {
         try {
             $values = $form->exportValues();
             $basedir = G_THEMESPATH . $layoutTheme->themes['path'] . 'external/';
             $filesystem = new FileSystemTree($basedir);
             $uploadedFile = $filesystem->uploadFile('file_upload', $basedir);
             $uploadedFile->uncompress();
             $uploadedFile->delete();
             $settings = file_get_contents($basedir . 'layout_settings.php.inc');
             if ($settings = unserialize($settings)) {
                 $layoutTheme->layout = $settings;
                 $layoutTheme->persist();
             }
             EfrontCache::getInstance()->delete(G_DBNAME . ':themes');
             eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=themes&theme=" . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : '') . "&message=" . rawurlencode(_SETTINGSIMPORTEDSUCCESFULLY) . "&message_type=success");
             //$message      = _SETTINGSIMPORTEDSUCCESFULLY;
             //$message_type = 'success';
         } catch (Exception $e) {
             handleNormalFlowExceptions($e);
         }
Example #9
0
 /**
  * Handle uploaded file associated with question
  *
  * This function is used to handle any uploaded files that have to do with the current question
  * <br/>Example:
  * <code>
  * $test = new EfrontTest(23);
  * foreach ($test -> questions as $id => $question) {
  *     if ($question -> question['type'] == 'raw_text') {
  *         $question -> handleQuestionFiles($this -> getDirectory());
  *     }
  * }
  * </code>
  *
  * @param mixed $uploadDirectory The directory to upload the file to, a string or an EfrontDirectory object
  * @since 3.5.2
  * @access public
  */
 public function handleQuestionFiles($uploadDirectory)
 {
     $uploadedFiles = array();
     if (!$uploadDirectory instanceof EfrontDirectory && !is_dir($uploadDirectory) && !mkdir($uploadDirectory, 0755)) {
         throw new EfrontTestException(_COULDNOTCREATETESTSDIRECTORY . ': ' . $uploadDirectory, EfrontTestException::ERROR_CREATING_DIRECTORY);
     } else {
         $filesystem = new FileSystemTree($uploadDirectory);
         foreach ($_FILES as $key => $value) {
             foreach ($value['name'] as $offset => $filename) {
                 if ($filename && str_replace('file_', '', $key) == $this->question['id']) {
                     $uploadedFile = $filesystem->uploadFile($key, $uploadDirectory, $offset);
                     $this->files[] = $uploadedFile['id'];
                 }
             }
         }
     }
 }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
Example #11
0
$appearanceFaviconForm->addElement('file', 'favicon', _FILENAME);
$appearanceFaviconForm->addElement("static", "", _EACHFILESIZEMUSTBESMALLERTHAN . ' <b>' . FileSystemTree::getUploadMaxSize() . '</b> ' . _KB);
$appearanceFaviconForm->addElement("advcheckbox", "default_favicon", _USEDEFAULTFAVICON, null, 'class = "inputCheckBox"  id = "set_default_favicon" onclick = "$(\'favicon_settings\').select(\'input\').each(function(s) {if (s.type != \'submit\' && s.id != \'set_default_favicon\') s.disabled ? s.disabled = \'\' : s.disabled = \'disabled\' })"', array(0, 1));
$appearanceFaviconForm->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $appearanceFaviconForm->freeze();
} else {
    $appearanceFaviconForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($appearanceFaviconForm->isSubmitted() && $appearanceFaviconForm->validate()) {
        try {
            //If the form is submitted and validated
            if ($appearanceFaviconForm->exportValue('default_favicon')) {
                EfrontConfiguration::setValue('favicon', '');
            } else {
                $faviconDirectory = new EfrontDirectory(G_LOGOPATH);
                $filesystem = new FileSystemTree(G_LOGOPATH);
                try {
                    $faviconFile = $filesystem->uploadFile('favicon', $logoDirectory);
                    if (strpos($faviconFile['mime_type'], 'image') === false) {
                        throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
                    }
                    EfrontConfiguration::setValue('favicon', $faviconFile['id']);
                    clearTemplatesCache();
                } catch (Exception $e) {
                    if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                        throw $e;
                    }
                }
            }
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=favicon&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
        } catch (Exception $e) {
         $uploadedFile = $filesystem->uploadFile('language_upload', G_ROOTPATH . 'libraries/language');
         if ($values['custom']) {
             $uploadedFile->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
         } else {
             $uploadedFile->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
         }
     }
     $fields = array("name" => $values['english_name'], "translation" => $values['translation'], "rtl" => $values['rtl']);
     eF_updateTableData("languages", $fields, "name='" . $values['selected_language'] . "'");
     EfrontCache::getInstance()->deleteCache('languages');
     //include "editor/tiny_mce/langs/language.php";
     //$RetValues = file(G_SERVERNAME."/editor/tiny_mce/langs/language.php?langname=".$values['english_name']);
     eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=languages&message=" . urlencode(_SUCCESSFULLYUPDATEDLANGUAGE) . "&message_type=success");
 } else {
     if ($_FILES['language_upload']['error'] == 0) {
         $filesystem = new FileSystemTree(G_ROOTPATH . 'libraries/language');
         $uploadedFile = $filesystem->uploadFile('language_upload', G_ROOTPATH . 'libraries/language');
         if ($uploadedFile['extension'] == "zip") {
             $lang_zip_file_temp = new EfrontFile($uploadedFile['path']);
             $lang_zip_file = $lang_zip_file_temp->uncompress(false);
             $lang_file_rename = new EfrontFile($lang_zip_file[0]);
             if ($values['custom']) {
                 $lang_file_rename->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
             } else {
                 $lang_file_rename->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
             }
         } else {
             if ($values['custom']) {
                 $uploadedFile->rename(dirname($uploadedFile['path']) . '/custom-' . $values['english_name'] . '.php.inc', true);
             } else {
                 $uploadedFile->rename(dirname($uploadedFile['path']) . '/lang-' . $values['english_name'] . '.php.inc', true);
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     $values = $form->exportValues();
     $forumUser = EfrontUserFactory::factory($_SESSION['s_login']);
     $forumAttachmentDirectory = $forumUser->getDirectory() . 'forum';
     if (!is_dir($forumAttachmentDirectory)) {
         mkdir($forumAttachmentDirectory, 0755);
     }
     $filesystem = new FileSystemTree($forumAttachmentDirectory);
     $attachmentBody = '';
     foreach ($_FILES['attachment_upload']['error'] as $key => $value) {
         if ($value != UPLOAD_ERR_NO_FILE) {
             $uploadedFile = $filesystem->uploadFile('attachment_upload', $certificateDirectory, $key);
             $attachmentid = $uploadedFile['id'];
             $attachmentBody .= '<p style="font-style:italic"><a href="view_file.php?action=download&file=' . $attachmentid . '">' . $uploadedFile['name'] . '</a></p>';
         }
     }
     if (isset($_GET['edit'])) {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody);
         if ($this->{$this->entity}['users_LOGIN'] != $_SESSION['s_login'] && strstr($fields['body'], _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login'])) === false) {
             $fields['body'] .= " " . _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login']) . " (" . formatTimestamp(time()) . ")";
         }
         $this->{$this->entity} = array_merge($this->{$this->entity}, $fields);
         $this->persist();
     } else {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody, "f_topics_ID" => $_GET['topic_id'], "users_LOGIN" => $_SESSION['s_login'], "timestamp" => time(), "replyto" => $values['replyto'] ? $values['replyto'] : 0);
         self::create($fields);
     }
 }
Example #14
0
             $video_return = mb_substr($file_insert['path'], mb_strlen(G_ROOTPATH . "www/"));
             echo '<object height="400" width="400" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b"><param name="src" value="' . $video_return . '" /><embed height="400" width="400" src="' . $video_return . '" type="video/quicktime"></embed></object>';
         } elseif (strpos($file_insert['mime_type'], "x-m4v") !== false) {
             $video_return = mb_substr($file_insert['path'], mb_strlen(G_ROOTPATH . "www/"));
             echo '<object height="400" width="500" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b"><param name="src" value="' . $video_return . '" /><embed height="400" width="400" src="' . $video_return . '" type="video/quicktime"></embed></object>';
         } else {
             echo "<a href=view_file.php?action=download&file=" . $file_id . ">" . $file_insert['physical_name'] . "</a>";
         }
     } catch (Exception $e) {
         header("HTTP/1.0 500 ");
         echo $e->getMessage() . ' (' . $e->getCode() . ')';
     }
     exit;
 } else {
     if (!isset($filesystem)) {
         $filesystem = new FileSystemTree($basedir, true);
     }
     $filesystem->handleAjaxActions($currentUser);
     if (!isset($options['table_id']) || !$options['table_id']) {
         $options['table_id'] = 'filesTable';
     }
     isset($filesystemIterator) or $filesystemIterator = '';
     isset($extraFileTools) or $extraFileTools = array();
     isset($extraHeaderOptions) or $extraHeaderOptions = array();
     isset($extraColumns) or $extraColumns = array();
     if (isset($_GET['ajax']) && $_GET['ajax'] == $options['table_id']) {
         try {
             isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
             if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
                 $sort = $_GET['sort'];
                 isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
//Set locale settings
//Replaced setlocale(LC_x) with LC_ALL so that international filenames work correctly (since basename() depends on current locale)
//setlocale(LC_COLLATE, _HEADERLANGUAGETAG);
//setlocale(LC_CTYPE, _HEADERLANGUAGETAG);
//setlocale(LC_MONETARY, _HEADERLANGUAGETAG);
//setlocale(LC_TIME, _HEADERLANGUAGETAG);
setlocale(LC_ALL, _HEADERLANGUAGETAG);
//Don't set LC_ALL, as this will set the LC_NUMERIC as well, which will automatically convert dots to commas if in greek
//Define theme-related constants and setup the default theme
$currentTheme = setupThemes();
/**The smarty libraries -- must be below themes!*/
require_once $path . "smarty/smarty_config.php";
//Assign the configuration variables to smarty
$smarty->assign("T_CONFIGURATION", $configuration);
//Assign global configuration values to smarty
$smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
//Initialize languages and notify smarty on weather we have an RTL language
$languages = EfrontSystem::getLanguages();
if ($languages[$setLanguage]['rtl']) {
    $smarty->assign("T_RTL", 1);
    $GLOBALS['rtl'] = true;
}
//$smarty -> assign("T_RTL", 1);$GLOBALS['rtl'] = true;
//Instantiate current theme
//$currentTheme = new themes(G_CURRENTTHEME);
$smarty->assign("T_THEME_SETTINGS", $currentTheme);
$smarty->assign("T_LOGO", EfrontSystem::setLogoFile($currentTheme));
$smarty->assign("T_FAVICON", EfrontSystem::setFaviconFile($currentTheme));
/**Initialize valid currencies
 * @todo: remove from here, move to a function or class*/
require_once $path . "includes/currencies.php";
Example #16
0
 try {
     if ($form->isSubmitted() && $form->validate()) {
         //If the form is submitted and validated
         $directionsTree = new EfrontDirectionsTree();
         if (sizeof($directionsTree->tree) == 0) {
             eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_TOCREATECOURSEYOUMUSTFIRSTCREATECATEGORY) . '&message_type=failure');
             exit;
         }
         $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
         if (!is_dir($userTempDir)) {
             //If the user's temp directory does not exist, create it
             $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
         } else {
             $userTempDir = new EfrontDirectory($userTempDir);
         }
         $filesystem = new FileSystemTree($userTempDir, true);
         $file = $filesystem->uploadFile('import_content', $userTempDir);
         $newCourse = EfrontCourse::createCourse();
         $exportedFile = $file;
         $newCourse->import($exportedFile, false, true);
     }
 } catch (EfrontFileException $e) {
     $file->delete();
     handleNormalFlowExceptions($e);
 }
 $renderer = prepareFormRenderer($form);
 $form->accept($renderer);
 //Assign this form to the renderer, so that corresponding template code is created
 $smarty->assign('T_IMPORT_COURSE_FORM', $renderer->toArray());
 //Assign the form to the template
 /** Calculate and display course ajax lists*/
         //By default, only 2 pairs of choices given.
         $form->addElement('text', 'grid[0]', null, 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'grid_column[0]', null, 'class = "inputText inputText_QuestionChoice"');
         //$form -> addElement('text', 'answers_explanation[0]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addElement('text', 'grid[1]', null, 'class = "inputText inputText_QuestionChoice"');
         $form->addElement('text', 'grid_column[1]', null, 'class = "inputText inputText_QuestionChoice"');
         //$form -> addElement('text', 'answers_explanation[1]', null, 'class = "inputText inputText_QuestionChoice" style = "display:none"');
         $form->addRule('grid[0]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
         $form->addRule('grid_column[0]', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client');
     }
     break;
 case 'hotspot':
     $form->addElement('button', 'generate_area', _CLEAR, 'class = "flatButton" onclick = "jQuery(\'#hotspot_answer\').val(\'\')"');
     $form->addElement('text', "answer", _COORDINATES, 'class = "inputText" id="hotspot_answer" style = "width:500px" readonly');
     //By default, only 2 pairs of choices given.
     $filter = array_keys(FileSystemTree::getFileTypes('image'));
     $filesystem = new FileSystemTree(G_LESSONSPATH . $_SESSION['s_lessons_ID'], false);
     $filesystem_initial = new FileSystemTree(G_LESSONSPATH . $_SESSION['s_lessons_ID'], true);
     foreach (new EfrontDirectoryOnlyFilterIterator($filesystem_initial->tree) as $key => $value) {
         if (is_file($value['path'] . '/imsmanifest.xml')) {
             unset($filesystem->tree[$key]);
         }
     }
     $tree = $filesystem->tree;
     $files[0] = _SELECTIMAGETOMARKAREA;
     foreach (new EfrontFileOnlyFilterIterator(new EfrontFileTypeFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST)), $filter, true)) as $key => $value) {
         $files[str_replace(G_LESSONSPATH, '', $value['path'])] = str_replace(G_LESSONSPATH . $_SESSION['s_lessons_ID'] . '/', '', $value['path']);
     }
     $form->addElement('select', 'options', null, $files, 'class = "inputSelectLong" onchange = "var prepend = \'' . G_LESSONSLINK . '/' . '\'; prepend=prepend.concat(this.options[this.selectedIndex].value); if (this.options[this.selectedIndex].value!=0){$(\'hotspotSpace\').src=prepend;$(\'hotspotSpace\').show()} else {$(\'hotspotSpace\').hide();jQuery(\'div[class^=imgareaselect-]\').hide();}"');
     if ($form->isSubmitted() || isset($currentQuestion)) {
         if (isset($currentQuestion) && !$form->isSubmitted()) {
Example #18
0
foreach (new EfrontDirectoryOnlyFilterIterator($modulesFolder->tree) as $value) {
    if (!in_array($value['name'], $existingModules)) {
        $modulesList[] = array('className' => $value['name'], 'not_installed' => 1, 'errors' => _MODULEFILESPRESENTNOTINSTALLED);
    }
}
$smarty->assign("T_MODULES", $modulesList);
$upload_form = new HTML_QuickForm("upload_file_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=modules', "", null, true);
$upload_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$upload_form->addElement('file', 'file_upload[0]', null, 'class = "inputText"');
$upload_form->addElement('checkbox', 'overwrite', _OVERWRITEIFFOLDEREXISTS);
$upload_form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
$upload_form->addElement('submit', 'submit_upload_file', _UPLOAD, 'class = "flatButton"');
if ($upload_form->isSubmitted() && $upload_form->validate()) {
    $filesystem = new FileSystemTree(G_MODULESPATH);
    $uploadedFile = $filesystem->uploadFile('file_upload', G_MODULESPATH, 0);
    if (isset($_GET['upgrade'])) {
        $prev_module_version = eF_getTableData("modules", "position", "className = '" . $_GET['upgrade'] . "'");
        $prev_module_folder = $prev_module_version[0]['position'];
        // The name of the temp folder to extract the new version of the module
        $module_folder = $prev_module_folder;
        //basename($filename[0], '.zip') . time();
        $module_position = $prev_module_folder;
        //basename($filename[0], '.zip');
    } else {
        $module_folder = basename($uploadedFile['path'], '.zip');
        $module_position = $module_folder;
    }
    if (is_dir(G_MODULESPATH . $module_folder) && !isset($_GET['upgrade']) && !isset($_POST['overwrite'])) {
        $message = _FOLDERWITHMODULENAMEEXISTSIN . G_MODULESPATH;
}
$smarty->assign("T_HELP_IMPORT_INFO", $help_info);
if (isset($_GET['csv_sample']) && $_GET['csv_sample'] == 1 && isset($_GET['sample_type'])) {
    $sample_type = $_GET['sample_type'];
    header("content-type:text/plain");
    header('content-disposition: attachment; filename= "csv_' . $sample_type . '_sample.csv"');
    echo implode(",", EfrontImport::getMandatoryFields($sample_type)) . "," . implode(",", EfrontImport::getOptionalFields($sample_type)) . "\n";
    exit;
}
if ($importForm->isSubmitted()) {
    try {
        if (!is_dir($currentUser->user['directory'] . "/temp")) {
            mkdir($currentUser->user['directory'] . "/temp", 0755);
        }
        $importForm->exportValue('import_keep') ? $replaceUsers = false : ($replaceUsers = true);
        $filesystem = new FileSystemTree($currentUser->user['directory'] . "/temp");
        $uploadedFile = $filesystem->uploadFile('import_file');
        $options = array("replace_existing" => $replaceUsers, "date_format" => $importForm->exportValue('date_format'), "replace_assignments" => $importForm->exportValue('replace_assignments'));
        $importer = EfrontImportFactory::factory("csv", $uploadedFile, $options);
        $importType = $importForm->exportValue('import_type');
        if ($importType == "anything") {
            $import_types = $import_export_types;
            unset($import_types['anything']);
            if (G_VERSIONTYPE == 'enterprise') {
                #cpp#ifdef ENTERPRISE
                $import_types['employees'] = 1;
            }
            #cpp#endif
            $log = array("success" => array(), "failure" => array());
            foreach ($import_types as $import_type => $import_name) {
                $templog = $importer->import($import_type);
 /**
  * Export lesson
  *
  * This function is used to export the current lesson's data to
  * a file, which can then be imported to other systems. Apart from
  * the lesson content, the user may optinally specify additional
  * information to export, using the $exportEntities array. If
  * $exportEntities is 'all', everything that can be exported, is
  * exported
  *
  * <br/>Example:
  * <code>
  * $exportedFile = $lesson -> export('all');
  * </code>
  *
  * @param array $exportEntities The additional data to export
  * @param boolean $rename Whether to rename the exported file with the same name as the lesson
  * @param boolean $exportFiles Whether to export files as well
  * @return EfrontFile The object of the exported data file
  * @since 3.5.0
  * @access public
  */
 public function export($exportEntities, $rename = true, $exportFiles = true)
 {
     if (!$exportEntities) {
         $exportEntities = array('export_surveys' => 1, 'export_announcements' => 1, 'export_glossary' => 1, 'export_calendar' => 1, 'export_comments' => 1, 'export_rules' => 1);
     }
     $data['lessons'] = $this->lesson;
     unset($data['lessons']['share_folder']);
     unset($data['lessons']['instance_source']);
     unset($data['lessons']['originating_course']);
     $content = eF_getTableData("content", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($content) > 0) {
         $contentIds = array();
         for ($i = 0; $i < sizeof($content); $i++) {
             $content[$i]['data'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $content[$i]['data']);
             $content[$i]['data'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $content[$i]['data']);
             $contentIds[] = $content[$i]['id'];
         }
         $content_list = implode(",", array_values($contentIds));
         $data['content'] = $content;
         $questions = eF_getTableData("questions", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($questions) > 0) {
             for ($i = 0; $i < sizeof($questions); $i++) {
                 $questions[$i]['text'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $questions[$i]['text']);
                 $questions[$i]['text'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $questions[$i]['text']);
             }
             $data['questions'] = $questions;
         }
         $tests = eF_getTableData("tests", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($tests)) {
             $testsIds = array();
             foreach ($tests as $key => $value) {
                 $testsIds[] = $value['id'];
             }
             $tests_list = implode(",", array_values($testsIds));
             $tests_to_questions = eF_getTableData("tests_to_questions", "*", "tests_ID IN ({$tests_list})");
             for ($i = 0; $i < sizeof($tests); $i++) {
                 $tests[$i]['description'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $tests[$i]['description']);
                 $tests[$i]['description'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $tests[$i]['description']);
             }
             $data['tests'] = $tests;
             $data['tests_to_questions'] = $tests_to_questions;
         }
         if (isset($exportEntities['export_rules'])) {
             $rules = eF_getTableData("rules", "*", "lessons_ID=" . $this->lesson['id']);
             if (sizeof($rules) > 0) {
                 $data['rules'] = $rules;
             }
         }
         if (isset($exportEntities['export_comments'])) {
             $comments = eF_getTableData("comments", "*", "content_ID IN ({$content_list})");
             if (sizeof($comments) > 0) {
                 $data['comments'] = $comments;
             }
         }
     }
     if (isset($exportEntities['export_calendar'])) {
         $calendar = calendar::getLessonCalendarEvents($this);
         $calendar = array_values($calendar);
         if (sizeof($calendar) > 0) {
             $data['calendar'] = $calendar;
         }
     }
     if (isset($exportEntities['export_glossary'])) {
         $glossary = eF_getTableData("glossary", "*", "lessons_ID = " . $this->lesson['id']);
         if (sizeof($glossary) > 0) {
             $data['glossary'] = $glossary;
         }
     }
     if (isset($exportEntities['export_announcements'])) {
         $news = eF_getTableData("news", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($news) > 0) {
             $data['news'] = $news;
         }
     }
     if (isset($exportEntities['export_surveys'])) {
         $surveys = eF_getTableData("surveys", "*", "lessons_ID=" . $this->lesson['id']);
         //prepei na ginei to   lesson_ID -> lessons_ID sti basi (ayto isos to parampsoyme eykola)
         if (sizeof($surveys) > 0) {
             $data['surveys'] = $surveys;
             $surveys_ = array();
             foreach ($surveys as $key => $value) {
                 $surveys_[$value['id']] = $value;
             }
             $surveys_list = implode(",", array_keys($surveys_));
             $questions_to_surveys = eF_getTableData("questions_to_surveys", "*", "surveys_ID IN ({$surveys_list})");
             // oposipote omos to survey_ID -> surveys_ID sti basi
             if (sizeof($questions_to_surveys) > 0) {
                 $data['questions_to_surveys'] = $questions_to_surveys;
             }
         }
     }
     $lesson_conditions = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($lesson_conditions) > 0) {
         $data['lesson_conditions'] = $lesson_conditions;
     }
     $projects = eF_getTableData("projects", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($projects) > 0) {
         $data['projects'] = $projects;
     }
     $lesson_files = eF_getTableData("files", "*", "path like '" . str_replace(G_ROOTPATH, '', EfrontDirectory::normalize($this->getDirectory())) . "%'");
     if (sizeof($lesson_files) > 0) {
         $data['files'] = $lesson_files;
     }
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             //Export scorm tables from here over
             $scormLessonTables = array('scorm_sequencing_adlseq_map_info', 'scorm_sequencing_content_to_organization', 'scorm_sequencing_maps_info', 'scorm_sequencing_organizations');
             foreach ($scormLessonTables as $table) {
                 $scorm_data = eF_getTableData($table, "*", "lessons_ID=" . $this->lesson['id']);
                 if (sizeof($scorm_data) > 0) {
                     $data[$table] = $scorm_data;
                 }
             }
             $scormContentTables = array('scorm_sequencing_completion_threshold', 'scorm_sequencing_constrained_choice', 'scorm_sequencing_control_mode', 'scorm_sequencing_delivery_controls', 'scorm_sequencing_hide_lms_ui', 'scorm_sequencing_limit_conditions', 'scorm_sequencing_maps', 'scorm_sequencing_map_info', 'scorm_sequencing_objectives', 'scorm_sequencing_rollup_considerations', 'scorm_sequencing_rollup_controls', 'scorm_sequencing_rollup_rules', 'scorm_sequencing_rules');
             if ($content_list) {
                 foreach ($scormContentTables as $table) {
                     $scorm_data = eF_getTableData($table, "*", "content_ID IN ({$content_list})");
                     if (sizeof($scorm_data) > 0) {
                         $data[$table] = $scorm_data;
                     }
                     if ($table == 'scorm_sequencing_rollup_rules' && sizeof($scorm_data) > 0) {
                         $ids = array();
                         foreach ($scorm_data as $value) {
                             $ids[] = $value['id'];
                         }
                         $result = eF_getTableData('scorm_sequencing_rollup_rule', "*", "scorm_sequencing_rollup_rules_ID IN (" . implode(",", $ids) . ")");
                         $data['scorm_sequencing_rollup_rule'] = $result;
                     }
                     if ($table == 'scorm_sequencing_rules' && sizeof($scorm_data) > 0) {
                         $ids = array();
                         foreach ($scorm_data as $value) {
                             $ids[] = $value['id'];
                         }
                         $result = eF_getTableData('scorm_sequencing_rule', "*", "scorm_sequencing_rules_ID IN (" . implode(",", $ids) . ")");
                         $data['scorm_sequencing_rule'] = $result;
                     }
                 }
             }
         }
         #cpp#endif
     }
     #cpp#endif
     //'scorm_sequencing_rollup_rule', 'scorm_sequencing_rule',
     // MODULES - Export module data
     // Get all modules (NOT only the ones that have to do with the user type)
     $modules = eF_loadAllModules();
     foreach ($modules as $module) {
         if ($moduleData = $module->onExportLesson($this->lesson['id'])) {
             $data[$module->className] = $moduleData;
         }
     }
     file_put_contents($this->directory . '/' . "data.dat", serialize($data));
     //Create database dump file
     if ($exportFiles) {
         $lessonDirectory = new EfrontDirectory($this->directory);
         $file = $lessonDirectory->compress($this->lesson['id'] . '_exported.zip', false);
         //Compress the lesson files
     } else {
         $dataFile = new EfrontFile($this->directory . '/' . "data.dat");
         $file = $dataFile->compress($this->lesson['id'] . '_exported.zip');
     }
     $newList = FileSystemTree::importFiles($file['path']);
     //Import the file to the database, so we can download it
     $file = new EfrontFile(current($newList));
     if (empty($GLOBALS['currentUser'])) {
         if ($_SESSION['s_login']) {
             $GLOBALS['currentUser'] = EfrontUserFactory::factory($_SESSION['s_login']);
             $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
         } else {
             $userTempDir = sys_get_temp_dir();
         }
     } else {
         $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
     }
     if (!is_dir($userTempDir)) {
         //If the user's temp directory does not exist, create it
         $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
         $userTempDir = $userTempDir['path'];
     }
     try {
         $existingFile = new EfrontFile($userTempDir . '/' . EfrontFile::encode($this->lesson['name']) . '.zip');
         //Delete any previous exported files
         $existingFile->delete();
     } catch (Exception $e) {
     }
     if ($rename) {
         $newName = str_replace(array('"', '>', '<', '*', '?', ':'), array('&quot;', '&gt;', '&lt;', '&#42;', '&#63;', '&#58;'), $this->lesson['name']);
         $file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true);
     }
     unlink($this->directory . '/' . "data.dat");
     //Delete database dump file
     return $file;
 }
Example #21
0
     $form->addRule('filename', _THEFIELD . ' "' . _FILE . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->setMaxFileSize($maxFileSize * 1024);
     $form->addElement('submit', 'submit_upload_project', _SENDPROJECT, 'class = "flatButton"');
 }
 $smarty->assign("T_MAX_FILE_SIZE", $maxFileSize);
 if ($form->isSubmitted() && $form->validate() && !$currentProject->expired) {
     try {
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects';
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects/' . $currentProject->project['id'];
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $filesystem = new FileSystemTree($projectDirectory);
         $uploadedFile = $filesystem->uploadFile('filename', $projectDirectory);
         //$uploadedFile -> rename($uploadedFile['directory'].'/project_'.$currentProject -> project['id'].'.'.$uploadedFile['extension']);
         $fields_update = array("filename" => $uploadedFile['id'], "upload_timestamp" => time());
         eF_updateTableData("users_to_projects", $fields_update, "users_LOGIN='******'login'] . "' AND projects_ID=" . $_GET['view_project']);
         EfrontEvent::triggerEvent(array("type" => EfrontEvent::PROJECT_SUBMISSION, "users_LOGIN" => $currentUser->user['login'], "lessons_ID" => $currentLesson->lesson['id'], "lessons_name" => $currentLesson->lesson['name'], "entity_ID" => $currentProject->project['id'], "entity_name" => $currentProject->project['title']));
         eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=projects&view_project=" . $_GET['view_project'] . "&message=" . urlencode(_FILEUPLOADED) . "&message_type=success");
     } catch (EfrontFileException $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } elseif ($currentProject->expired) {
     $message = _PROJECTEXPIRED;
     $message_type = 'failure';
 }
Example #22
0
 switch ($_GET['for_type']) {
     case 'image':
         $mode = true;
         $filter = array_keys(FileSystemTree::getFileTypes('image'));
         break;
     case 'java':
         $mode = true;
         $filter = array_keys(FileSystemTree::getFileTypes('java'));
         break;
     case 'media':
         $mode = true;
         $filter = array_keys(FileSystemTree::getFileTypes('media'));
         break;
     case 'document':
         $mode = true;
         $filter = array_keys(FileSystemTree::getFileTypes('document'));
         break;
     case 'files':
         $mode = false;
         $filter = array();
         break;
     default:
         $mode = true;
         $filter = array();
         break;
 }
 $filesystem = new FileSystemTree($directory['path'], true);
 //$directory != $rootDir ? $tree = $filesystem -> seekNode($directory['path']) : $tree = $filesystem -> tree; // Changed because of #2634
 $tree = $filesystem->tree;
 foreach (new EfrontDirectoryOnlyFilterIterator(new EfrontNodeFilterIterator(new ArrayIterator($tree, RecursiveIteratorIterator::SELF_FIRST))) as $key => $value) {
     $value['image'] = $value->getTypeImage();
Example #23
0
 // else the $recipients = $recipients
 // If only a massive sent selection was used and no employee was found
 if (isset($recipients)) {
     $pm = new eF_PersonalMessage($currentUser->user['login'], $recipients, $values['subject'], $values['body'], $values['bcc']);
     if ($_FILES['attachment']['name'][0] != "") {
         $maxFileSize = FileSystemTree::getUploadMaxSize();
         if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
             //	G_MAXFILESIZE is deprecated                                                          //If the directory could not be created, display an erro message
             $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . $maxFileSize . _KB;
             $message_type = 'failure';
         }
         //Upload user avatar file
         $pm->sender_attachment_timestamp = time();
         $user_dir = G_UPLOADPATH . $currentUser->user['login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
         mkdir($user_dir, 0755);
         $filesystem = new FileSystemTree($user_dir);
         try {
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         } catch (EfrontFileException $e) {
             //echo $e -> getMessage();
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . "<br />";
             $message_type = 'failure';
         }
     }
     if ($pm->send($values['email'], $values)) {
         $message .= _MESSAGEWASSENT;
         $message_type = 'success';
         if (!$popup) {
Example #24
0
 private function createCourseExportFile($courseTempDir)
 {
     $userTempDir = new EfrontDirectory($GLOBALS['currentUser']->user['directory'] . '/temp');
     $file = $courseTempDir->compress($this->course['id'] . '_exported.zip', false);
     //Compress the lesson files
     $newList = FileSystemTree::importFiles($file['path']);
     //Import the file to the database, so we can download it
     $file = new EfrontFile(current($newList));
     $newFileName = EfrontFile::encode($this->course['name']) . '.zip';
     if (!eF_checkParameter($newFileName, 'file')) {
         $newFileName = $file['name'];
     }
     $newFileName = str_replace(array('"', '>', '<', '*', '?', ':'), array('&quot;', '&gt;', '&lt;', '&#42;', '&#63;', '&#58;'), $newFileName);
     //$file -> rename($userTempDir['path'].'/'.$newFileName, true);
     //changed because of checkFile in rename
     if (is_file($userTempDir['path'] . '/' . $newFileName)) {
         $newfile = new EfrontFile($userTempDir['path'] . '/' . $newFileName);
         $newfile->delete();
     }
     rename($file['path'], $userTempDir['path'] . '/' . $newFileName);
     //FileSystemTree :: importFiles($userTempDir['path'].'/'.$newFileName);
     eF_updateTableData("files", array("path" => str_replace(G_ROOTPATH, '', $userTempDir['path'] . '/' . $newFileName)), "id=" . $file['id']);
     $returnFile = new EfrontFile($file['id']);
     //$file   -> rename($userTempDir['path'].'/'.EfrontFile :: encode($this -> course['name']).'.zip', true);
     $courseTempDir->delete();
     return $returnFile;
 }
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     $dir = $this->moduleBaseDir . 'assets/';
     if (!is_dir($dir)) {
         mkdir($dir, 0755);
     }
     if ($_SESSION['s_type'] == 'administrator') {
         try {
             $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('file', 'file', _UPLOADFILE);
             if (G_VERSIONTYPE == 'enterprise') {
                 $tree = new EfrontBranchesTree();
                 $pathString = $tree->toPathString();
                 //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''");
                 $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div>&nbsp;&nbsp;&nbsp;';
                 $form->addElement('static', 'sidenote', $handle);
                 $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"');
                 $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"');
             }
             $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
             $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"');
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 try {
                     if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) {
                         $branch = new EfrontBranch($values['leaflet_branch']);
                         if (!$branch->branch['url']) {
                             throw new Exception("You must assign a url to the selected branch to upload files for it");
                         }
                         $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url'];
                         mkdir($dir, 0755);
                     }
                     $filesystem = new FileSystemTree($dir);
                     $file = $filesystem->uploadFile("file", $dir);
                 } catch (Exception $e) {
                     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                     $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                     $message_type = failure;
                     $this->setMessageVar($message, $message_type);
                 }
             }
             $smarty->assign('T_UPLOAD_FORM', $form->toArray());
             $url = $this->moduleBaseUrl;
             $basedir = $dir;
             $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true);
             /**The file manager*/
             include "file_manager.php";
         } catch (Exception $e) {
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
             $message_type = 'failure';
             $this->setMessageVar($message, $message_type);
         }
     } else {
         if (defined('G_BRANCH_URL') && G_BRANCH_URL) {
             try {
                 $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL;
             } catch (Exception $e) {
                 //do nothing here if the directory doesn't exist
             }
         } else {
             $assets_path = $root_path = $this->moduleBaseDir . 'assets/';
         }
         $files = array();
         if (!empty($_GET['folder'])) {
             $folder = urldecode($_GET['folder']);
             if (is_dir($assets_path . $folder)) {
                 $folder = new EfrontDirectory($assets_path . $folder);
                 if (strpos(realpath($folder['path']), $root_path) === false) {
                     throw new Exception("Invalid folder");
                 }
                 $parent_folder = dirname($folder['path']);
                 $url = urlencode(str_replace($root_path, '', $folder['path']));
                 $assets_path = $folder['path'];
                 $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/'));
                 $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/';
                 $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url);
             }
         }
         //pr($url);pr($parent_url);
         //
         $filesystem = new FileSystemTree($assets_path, true);
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontDirectory) {
                 $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/')));
             }
         }
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontFile) {
                 if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) {
                     $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png';
                 } else {
                     $icon = $this->moduleBaseLink . 'ico/unknown.png';
                 }
                 $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key));
             }
         }
         $smarty->assign("T_FILES", $files);
     }
     return true;
 }
         $form->addElement('file', 'file_upload', null, 'class = "inputText"');
         //Lesson file
         $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
         //getUploadMaxSize returns size in KB
         $form->addElement('submit', 'submit_import_course', _SUBMIT, 'class = "flatButton"');
         $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
         if ($form->isSubmitted() && $form->validate()) {
             try {
                 $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
                 if (!is_dir($userTempDir)) {
                     //If the user's temp directory does not exist, create it
                     $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
                 } else {
                     $userTempDir = new EfrontDirectory($userTempDir);
                 }
                 $filesystem = new FileSystemTree($userTempDir);
                 $uploadedFile = $filesystem->uploadFile('file_upload', $userTempDir);
                 $currentCourse->import($uploadedFile);
                 $message = _COURSEIMPORTEDSUCCESFULLY;
                 $message_type = 'success';
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $message = _PROBLEMIMPORTINGFILE . ': ' . $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_IMPORT_COURSE_FORM', $renderer->toArray());
     }
 }
         }
     }
     $editedUser->user = array_merge($editedUser->user, $userProperties);
     $editedUser->persist();
     if ($currentUser->user['login'] == $editedUser->user['login'] && $_SESSION['s_password'] != $editedUser->user['password']) {
         $_SESSION['s_password'] = $editedUser->user['password'];
     }
     if ($currentUser->user['login'] == $editedUser->user['login'] && $_SESSION['s_language'] != $editedUser->user['languages_NAME']) {
         $_SESSION['s_language'] = $editedUser->user['languages_NAME'];
     }
 }
 if (!in_array('file_upload', $constrainAccess) && $constrainAccess != 'all') {
     $avatarDirectory = G_UPLOADPATH . $editedUser->user['login'] . '/avatars';
     is_dir($avatarDirectory) or mkdir($avatarDirectory, 0755);
     try {
         $filesystem = new FileSystemTree($avatarDirectory);
         $uploadedFile = $filesystem->uploadFile('file_upload', $avatarDirectory);
         if (strpos($uploadedFile['mime_type'], 'image') === false) {
             throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
         }
         eF_normalizeImage($avatarDirectory . "/" . $uploadedFile['name'], $uploadedFile['extension'], 150, 100);
         // Normalize avatar picture to 150xDimY or DimX x 100
         $editedUser->user['avatar'] = $uploadedFile['id'];
         //pr($editedUser -> user['avatar']);exit;
     } catch (Exception $e) {
         //pr($e);	exit;
         if ($e->getCode() == EfrontFileException::NOT_APPROPRIATE_TYPE) {
             $uploadedFile->delete();
         }
         if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
             throw $e;
Example #28
0
}
$form->addElement('text', "import_path[0]", _IMPORTFROMPATH, 'class = "inputText"');
for ($i = 1; $i < 10; $i++) {
    $form->addElement('text', "import_path[{$i}]", null, 'class = "inputText"');
}
$form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
$form->addElement('submit', 'import_submit', _IMPORT, 'class = "flatButton"');
if ($form->isSubmitted() && $form->validate()) {
    try {
        $values = $form->exportValues();
        $errors = $uploadedFiles = array();
        //Create, if it does not exist, the folder where the files will be uploaded
        //is_dir($uploadDir = $currentUser -> getDirectory().'temp/') OR mkdir($uploadDir, 0755);
        $uploadDir = $currentLesson->getDirectory();
        $filesystem = new FileSystemTree($uploadDir, true);
        //Perform any direct file uploads
        foreach ($_FILES['import_file']['name'] as $key => $name) {
            if (!in_array($name, $uploadedFiles)) {
                //This way we bypass duplicates
                try {
                    $uploadedFiles[$name] = $filesystem->uploadFile("import_file", $uploadDir, $key);
                } catch (EfrontFileException $e) {
                    if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
                        $errors[] = $e->getMessage();
                    }
                }
            }
        }
        //Perform any url uploads
        foreach ($values['import_url'] as $key => $urlUpload) {
Example #29
0
 $generalPHPForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
 if ($generalPHPForm->isSubmitted() && $generalPHPForm->validate()) {
     //If the form is submitted and validated
     $values = $generalPHPForm->exportValues();
     unset($values['submit']);
     if ($GLOBALS['configuration']['version_hosted']) {
         unset($values['memory_limit']);
         unset($values['max_execution_time']);
     }
     foreach ($values as $key => $value) {
         if ($value == '') {
             if ($key == 'memory_limit' || $key == 'max_execution_time') {
                 ini_restore($key);
                 EfrontConfiguration::setValue($key, str_ireplace("M", "", ini_get($key)));
             } elseif ($key == 'max_file_size') {
                 EfrontConfiguration::setValue($key, FileSystemTree::getUploadMaxSize());
             } else {
                 EfrontConfiguration::deleteValue($key);
             }
         } else {
             if ($key == 'memory_limit' || $key == 'max_execution_time') {
                 //You can't set these values below the php.ini setting
                 ini_restore($key);
                 EfrontConfiguration::setValue($key, $value);
             } else {
                 EfrontConfiguration::setValue($key, $value);
             }
         }
     }
     eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=php&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
 }