function addFolderToZip($dir, $zipArchive, $rep = '.') { if (is_dir($dir) && ($dh = opendir($dir))) { if ($rep != '.') { $zipArchive->addEmptyDir($rep); } while (($file = readdir($dh)) !== false) { $temp = $rep != '.' ? $rep . '/' . $file : $file; if (is_file($dir . '/' . $file)) { $zipArchive->addFile($dir . '/' . $file, $temp); } else { if ($file != "." && $file != ".." && $file != "sav") { addFolderToZip($dir . '/' . $file, $zipArchive, $temp); } } } } }
function addFolderToZip($dir, $zipArchive, $zipdir = '') { if (is_dir($dir)) { if ($dh = opendir($dir)) { // Loop through all the files while (($file = readdir($dh)) !== false) { //If it's a folder, run the function again! if (!is_file($dir . $file)) { // Skip parent and root directories if ($file !== "." && $file !== "..") { addFolderToZip($dir . $file . "/", $zipArchive, $zipdir . $file . "/"); } } else { // Add the files $zipArchive->addFile($dir . $file, $zipdir . $file); } } } } }
function addFolderToZip($dir, $zipArchive, $flag) { if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory $zipArchive->addEmptyDir($dir); // Loop through all the files while (($file = readdir($dh)) !== false) { // Omit .svn, .project, eclipse and the zip files/folders if (strstr($file, '.svn') == false && strstr($file, '.project') == false && strstr($file, '~') == false && strstr($file, 'zips') == false) { if ($flag == '0') { if (strstr($file, 'php') == false) { //If it's a folder, run the function again! if (!is_file($dir . $file)) { // Skip parent and root directories if ($file !== "." && $file !== "..") { addFolderToZip($dir . $file . "/", $zipArchive, $flag); } } else { // Add the files $zipArchive->addFile($dir . '/' . $file); } } } else { //If it's a folder, run the function again! if (!is_file($dir . $file)) { // Skip parent and root directories if ($file !== "." && $file !== "..") { addFolderToZip($dir . $file . "/", $zipArchive, $flag); } } else { // Add the files $zipArchive->addFile($dir . $file); } } } } } } }
if (class_exists("ZipArchive")) { include_once('functions/misc_functions.php'); $zipArchive = new ZipArchive(); if ($zipArchive->open($zipFile, ZIPARCHIVE::CREATE) !== TRUE) { include_once('functions/error_functions.php'); trigger_error('can not open zip-file ' . $zipFile, E_USER_WARNING); } // write to zip $tempDir = getcwd(); chdir($timestampFolder); $zipArchive = addFolderToZip(".", $zipArchive); chdir($tempDir); $zipArchive->close(); $fileName = $zipFile; } else { include_once('functions/error_functions.php'); trigger_error('can not initiate ZIP class, please contact your system administrator',E_USER_WARNING); } } // send header and file header("Content-Disposition: attachment; filename=" . urlencode($fileNameDeliver)); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream");
$messageStack->add(GEN_BACKUP_FILE_ERROR . $dest_dir, 'error'); $error = true; break; } if ($dl_type == 'db') { $zip->addFile($db_save_full_path); // exec("cd $dest_dir; zip $compressed_dbname.zip $db_filename 2>&1", $output, $res); } else { // compress all $result = @rename($db_save_full_path, $db_temp_full_path); // move the sql file to the company directory to include in backup if ($result === false) { $messageStack->add(sprintf(GEN_BACKUP_MOVE_ERROR, $db_temp_full_path), 'error'); $error = true; } else { addFolderToZip($company_dir, $zip); // exec("cp $db_save_full_path $db_temp_full_path", $output, $res); // exec("cd " . DIR_FS_MY_FILES . "; zip -r $dest_dir/$compressed_dirname.zip " . $_SESSION['company'] . " 2>&1", $output, $res); } } $zip->close(); if (file_exists($db_save_full_path)) { unlink($db_save_full_path); } if (file_exists($db_temp_full_path)) { unlink($db_temp_full_path); } break; default: // No compression (db only) $backup_filename = $db_filename;
$disc_manager->setContextID($environment->getCurrentContextID()); unset($disc_manager); if ( class_exists('ZipArchive') ) { include_once('functions/misc_functions.php'); $zip = new ZipArchive(); $filename_zip = $zipfile; if ( $zip->open($filename_zip, ZIPARCHIVE::CREATE) !== TRUE ) { include_once('functions/error_functions.php'); trigger_error('can not open zip-file '.$filename_zip,E_USER_WARNNG); } $temp_dir = getcwd(); chdir($backuppath); $zip = addFolderToZip('.',$zip,'files'); chdir($temp_dir); $zip->addFile($filename, basename($filename)); $zip->close(); unset($zip); } else { include_once('functions/error_functions.php'); trigger_error('can not initiate ZIP class, please contact your system administrator',E_USER_WARNNG); } $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $link = $class_factory->getClass(TEXT_VIEW,$params); unset($params);
private function _changeZIP ($zip_name) { $retour = ''; // change ZIP if ( file_exists($zip_name) ) { $zip = new ZipArchive(); if ( $zip->open($zip_name) !== TRUE ) { include_once('functions/error_functions.php'); trigger_error('can not modify zip',E_USER_WARNING); } else { // extract zip global $export_temp_folder; if ( !isset($export_temp_folder) ) { $export_temp_folder = 'var/temp/zip_export'; } $voyeur_dir = $export_temp_folder.'/'.str_replace('.zip','_voyeur',basename($zip_name)); if ( !is_dir($voyeur_dir) ) { mkdir($voyeur_dir, 0777); if ( is_dir($voyeur_dir) ) { $zip->extractTo($voyeur_dir); $zip->close(); // delete folder $disc_manager = $this->_environment->getDiscManager(); $disc_manager->removeDirectory($voyeur_dir.'/css'); $disc_manager->removeDirectory($voyeur_dir.'/images'); } else { include_once('functions/error_functions.php'); trigger_error('can not make directory ('.$voyeur_dir.')',E_USER_ERROR); } } // make zip $zip = new ZipArchive(); $voyeur_zip_name = str_replace('.zip','_voyeur.zip',$zip_name); if ( $zip->open($voyeur_zip_name, ZIPARCHIVE::CREATE) !== TRUE ) { include_once('functions/error_functions.php'); trigger_error('can not open zip-file '.$voyeur_zip_name,E_USER_WARNNG); } $temp_dir = getcwd(); chdir($voyeur_dir); $zip = addFolderToZip('.',$zip); chdir($temp_dir); $zip->close(); unset($zip); $disc_manager = $this->_environment->getDiscManager(); $disc_manager->removeDirectory($voyeur_dir); $retour = $voyeur_zip_name; } } else { include_once('functions/error_functions.php'); trigger_error('can not open zip ('.$zip_name.')',E_USER_ERROR); } return $retour; }
//allow lots of time (an hour) to create the ZIP archive //or for the client to download the file set_time_limit(3600); // If the file is actually a directory, we're going to create a zip archive // to allow an easy download. if (is_dir($filePath)) { // We're going to need the zip function. require_once 'lib/zip.php'; // We create our zip archive ... $zipfile = "{$filePath}.zip"; $zip = new ZipArchive(); if ($zip->open($zipfile, ZIPARCHIVE::OVERWRITE) !== true) { die("Couldn't create zip archive."); } // ... And we're going to add the entire directory to it. addFolderToZip($filePath . '/', $zip, ''); // DEBUG // echo 'The zip archive contains ',$zip->numFiles, // ' files with a status of ',$zip->status; $zip->close(); // We're going to give the zip archive to our user. $filePath = $zipfile; $fileName = "{$fileName}.zip"; $deleteAfterSend = true; } ob_end_clean(); // We're going to stream the file to the user (this way, there is no way // for him to know where other files are stored) if ($xmlConfig->getAllowDirectDownload() == 'no') { $file = fopen($filePath, 'rb'); header('Pragma: ');
public function _createZIP($folder) { $retour = ''; // create ZIP File global $export_temp_folder; if (!isset($export_temp_folder)) { $export_temp_folder = 'var/temp/zip_export'; } if (isset($this->_item_id)) { $item_manager = $this->_environment->getItemManager(); $item_type = $item_manager->getItemType($this->_item_id); $zipfile = $export_temp_folder . DIRECTORY_SEPARATOR . $item_type . '_' . $this->_item_id . '.zip'; } else { $translator = $this->_environment->getTranslationObject(); if ($this->_environment->getCurrentModule() == 'announcement') { $current_module = $translator->getMessage('ANNOUNCEMENT_EXPORT_ZIP'); } elseif ($this->_environment->getCurrentModule() == 'material') { $current_module = $translator->getMessage('MATERIAL_EXPORT_ZIP'); } elseif ($this->_environment->getCurrentModule() == 'date') { $current_module = $translator->getMessage('DATE_EXPORT_ZIP'); } elseif ($this->_environment->getCurrentModule() == 'discussion') { $current_module = $translator->getMessage('DISCUSSION_EXPORT_ZIP'); } elseif ($this->_environment->getCurrentModule() == 'todo') { $current_module = $translator->getMessage('TODO_EXPORT_ZIP'); } else { $current_module = $this->_environment->getCurrentModule(); } //$zipfile = $export_temp_folder.DIRECTORY_SEPARATOR.$this->_environment->getCurrentModule().'_'.$this->_environment->getCurrentFunction().'_'.$this->_environment->getCurrentContextID().'_'.time().'.zip'; $zipfile = $export_temp_folder . DIRECTORY_SEPARATOR . $current_module . '_' . $this->_environment->getCurrentFunction() . '_' . $this->_environment->getCurrentContextID() . '_' . time() . '.zip'; } if (file_exists(realpath($zipfile))) { unlink($zipfile); } if (class_exists('ZipArchive')) { include_once 'functions/misc_functions.php'; $zip = new ZipArchive(); $filename = $zipfile; if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { include_once 'functions/error_functions.php'; trigger_error('can not open zip-file ' . $filename, E_USER_WARNNG); } $temp_dir = getcwd(); chdir($folder); $zip = addFolderToZip('.', $zip); chdir($temp_dir); $zip->close(); unset($zip); if (empty($this->_folder_existing)) { $disc_manager = $this->_environment->getDiscManager(); $disc_manager->removeDirectory($folder); } $retour = $filename; } else { include_once 'functions/error_functions.php'; trigger_error('can not initiate ZIP class, please contact your system administrator', E_USER_WARNNG); } return $retour; }
public function actionAction() { /************************************************************************************ * This will generate the downloadable content ************************************************************************************/ $currentContext = $this->_environment->getCurrentContextItem(); $currentUser = $this->_environment->getCurrentUserItem(); // get item $itemId = $_GET["iid"]; $itemManager = $this->_environment->getItemManager(); $item = $itemManager->getItem($itemId); $type = $item->getItemType(); $manager = $this->_environment->getManager($type); // get export temp folder global $export_temp_folder; if (!isset($export_temp_folder)) { $export_temp_folder = "var/temp/zip_export"; } $exportTempFolder = $export_temp_folder; // create directory structure if needed $directorySplit = explode("/", $exportTempFolder); $doneDir = "./"; foreach ($directorySplit as $dir) { if (!is_dir($doneDir . "/" . $dir)) { mkdir($doneDir . "/" . $dir, 0777); } $doneDir .= "/" . $dir; } $directory = "./" . $exportTempFolder . "/" . uniqid("", true); mkdir($directory, 0777); // material version specific if ($type === CS_MATERIAL_TYPE && isset($_GET["versionId"])) { $item = $manager->getItemByVersion($itemId, $_GET["versionId"]); } else { $item = $manager->getItem($itemId); } // check access if ($currentContext->isProjectRoom() && $currentContext->isClosed() || $itemId === "NEW" || isset($item) && !$item->maySee($currentUser)) { continue; } // init needed values $cid = $this->_environment->getCurrentContextID(); $fct = "detail"; // label item if ($type == 'label') { $mod = $item->getLabelType(); } else { $mod = $type; } /************************************************************************************ * We need to create a new instance of smarty and set some environment variables * to load the detail page separatly ************************************************************************************/ // set output mode $this->_environment->setOutputMode("print"); // get a new smarty instance - this is copied from commsy.php require_once 'classes/cs_smarty.php'; global $c_theme; if (!isset($c_theme) || empty($c_theme)) { $c_theme = 'default'; } // room theme $color = $this->_environment->getCurrentContextItem()->getColorArray(); $theme = $color['schema']; if ($theme !== 'default') { $c_theme = $theme; } $smarty = new cs_smarty($this->_environment, $c_theme); $this->_environment->setTemplateEngine($smarty); // setup controller $controller_name = 'cs_' . $mod . '_' . $fct . '_controller'; require_once 'classes/controller/' . $fct . '/' . $controller_name . '.php'; // invoke module and function $this->_environment->setCurrentModule($mod); $this->_environment->setCurrentFunction($fct); $controller = new $controller_name($this->_environment); $controller->processTemplate(); // write output in buffer and fetch ob_start(); $controller->displayTemplate(); $output = ob_get_clean(); // create HTML-File $fileName = $directory . "/index.html"; $fileHandle = fopen($fileName, "a"); /************************************************************************************ * Next step is to adjust the html output for the zip package and copy all * the needed files to temporary export folder ************************************************************************************/ // create folder mkdir($directory . "/css", 0777); mkdir($directory . "/images", 0777); mkdir($directory . "/files", 0777); // get all linked css paths $linkedCSS = array(); preg_match_all("=<link.*?href\\=\"(.*?)\"=", $output, $matches); list($matches, $linkedCSS) = $matches; foreach ($linkedCSS as $css) { // extract css filename $fileName = basename($css); // prepend a unique id to all file names $newLinkedCSS = "css/" . uniqid("", true) . $fileName; // replace links in HTML output $output = str_replace($css, $newLinkedCSS, $output); // copy css files copy("htdocs/" . $css, $directory . "/" . $newLinkedCSS); } // get all images $images = array(); preg_match_all("=<img.*?src\\=\"(.*?)\"=", $output, $matches); list($matches, $images) = $matches; foreach ($images as $image) { // extract image filename $fileName = basename($image); $newImage = "images/" . $fileName; // replace links in HTML output $output = str_replace($image, $newImage, $output); // copy images copy("htdocs/" . $image, $directory . "/" . $newImage); } // TODO: getimage, etc... // get files if ($type === CS_MATERIAL_TYPE) { $fileList = $item->getFileListWithFilesFromSections(); } elseif ($type === CS_DISCUSSION_TYPE) { $fileList = $item->getFileListWithFilesFromArticles(); } elseif ($type === CS_TODO_TYPE) { $fileList = $item->getFileListWithFilesFromSteps(); } else { $fileList = $item->getFileList(); } $file = $fileList->getFirst(); while ($file) { // copy files copy($file->getDiskFileName(), $directory . "/files/" . $file->getFileName()); $file = $fileList->getNext(); } $files = array(); preg_match_all("=<a.*?href\\=\"commsy\\.php/(.*?)\\?.*\"=", $output, $matches); list($matches, $files) = $matches; foreach ($files as $file) { $newFile = "files/" . $file; $output = preg_replace("=\"commsy\\.php/" . $file . ".*?\"=", "\"" . $newFile . "\"", $output); } // write output to file fwrite($fileHandle, $output); fclose($fileHandle); /* var_dump($images); var_dump($output); var_dump($linkedCSS); var_dump($newLinkedCSS); */ /************************************************************************************ * All files are ready now, create a ZIP archive and set headers for downloading ************************************************************************************/ // create zip file $zipFile = $exportTempFolder . DIRECTORY_SEPARATOR . $mod . "_" . $itemId . ".zip"; if (file_exists(realpath($zipFile))) { unlink($zipFile); } if (class_exists("ZipArchive")) { include_once 'functions/misc_functions.php'; $zipArchive = new ZipArchive(); if ($zipArchive->open($zipFile, ZIPARCHIVE::CREATE) !== TRUE) { include_once 'functions/error_functions.php'; trigger_error('can not open zip-file ' . $zipFile, E_USER_WARNING); } $tempDir = getcwd(); chdir($directory); $zipArchive = addFolderToZip(".", $zipArchive); chdir($tempDir); $zipArchive->close(); } else { include_once 'functions/error_functions.php'; trigger_error('can not initiate ZIP class, please contact your system administrator', E_USER_WARNING); } // send zipfile by header $translator = $this->_environment->getTranslationObject(); if ($mod == 'announcement') { $current_module = $translator->getMessage('ANNOUNCEMENT_EXPORT_ITEM_ZIP'); } elseif ($mod == 'material') { $current_module = $translator->getMessage('MATERIAL_EXPORT_ITEM_ZIP'); } elseif ($mod == 'date') { $current_module = $translator->getMessage('DATE_EXPORT_ITEM_ZIP'); } elseif ($mod == 'discussion') { $current_module = $translator->getMessage('DISCUSSION_EXPORT_ITEM_ZIP'); } elseif ($mod == 'todo') { $current_module = $translator->getMessage('TODO_EXPORT_ITEM_ZIP'); } elseif ($mod == 'group') { $current_module = $translator->getMessage('GROUP_EXPORT_ITEM_ZIP'); } elseif ($mod == 'topic') { $current_module = $translator->getMessage('TOPIC_EXPORT_ITEM_ZIP'); } elseif ($mod == 'user') { $current_module = $translator->getMessage('USER_EXPORT_ITEM_ZIP'); } else { $current_module = $mod; } $downloadFile = $current_module . "_" . $itemId . ".zip"; header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="' . $downloadFile . '"'); readfile($zipFile); $fileManager = $this->_environment->getFileManager(); }
function addFolderToZip($dir, $zipArchive, $newdir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory $zipArchive->addEmptyDir($newdir); // Loop through all the files while (($file = readdir($dh)) !== false) { //If it's a folder, run the function again! if (!is_file($dir . "/" . $file)) { //echo "DIR: ".$dir ."/".$file."<br/>"; // Skip parent and root directories and zip_file if ($file !== "." && $file !== ".." && $file !== "zip_file") { addFolderToZip($dir . "/" . $file, $zipArchive, $newdir . "/" . $file); } } else { //echo "FILE: ".$dir ."/".$file."<br/>"; // Add the files $zipArchive->addFile($dir . "/" . $file, $newdir . "/" . $file); } } } } }
public function _createZIP($folder) { // create ZIP File global $export_temp_folder; if (!isset($export_temp_folder)) { $export_temp_folder = 'var/temp/zip_export'; } $item_manager = $this->_environment->getItemManager(); $item_type = $item_manager->getItemType($this->_item_id); if (isset($this->_item_id)) { $zipfile = $export_temp_folder . DIRECTORY_SEPARATOR . $item_type . '_' . $this->_item_id . '.zip'; } else { $zipfile = $export_temp_folder . DIRECTORY_SEPARATOR . $this->_environment->getCurrentModule() . '_' . $this->_environment->getCurrentFunction() . '.zip'; } if (file_exists(realpath($zipfile))) { unlink($zipfile); } if (class_exists('ZipArchive')) { include_once 'functions/misc_functions.php'; $zip = new ZipArchive(); $filename = $zipfile; if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { include_once 'functions/error_functions.php'; trigger_error('can not open zip-file ' . $filename, E_USER_WARNNG); } $temp_dir = getcwd(); chdir($folder); $zip = addFolderToZip('.', $zip); chdir($temp_dir); $zip->close(); unset($zip); if (empty($this->_folder_existing)) { $disc_manager = $this->_environment->getDiscManager(); $disc_manager->removeDirectory($folder); } } else { include_once 'functions/error_functions.php'; trigger_error('can not initiate ZIP class, please contact your system administrator', E_USER_WARNNG); } }
include_once('functions/error_functions.php'); trigger_error('can not make directory ('.$voyeur_dir.')',E_USER_ERROR); } } // make zip $zip = new ZipArchive(); if ( $zip->open($voyeur_zip_name, ZIPARCHIVE::CREATE) !== TRUE ) { include_once('functions/error_functions.php'); trigger_error('can not open zip-file '.$filename_zip,E_USER_WARNNG); } $temp_dir = getcwd(); chdir($voyeur_dir); $zip = addFolderToZip('.',$zip); chdir($temp_dir); $zip->close(); unset($zip); $disc_manager = $environment->getDiscManager(); $disc_manager->removeDirectory($voyeur_dir); } } else { include_once('functions/error_functions.php'); trigger_error('zip for '.$item_type.' with id ('.$_GET['iid'].')',E_USER_ERROR); } } // to sender
public function save($form_data, $additional = array()) { $current_context = $this->_environment->getCurrentContextItem(); $current_portal_item = $this->_environment->getCurrentPortalItem(); // check context if (false) { } else { if (false) { } else { $tab = $additional['part']; switch ($tab) { /**** ACCOUNT ****/ case 'account_merge': if ($this->_popup_controller->checkFormData('merge')) { $authentication = $this->_environment->getAuthenticationObject(); global $c_annonymous_account_array; $currentUser = $this->_environment->getCurrentUserItem(); if (!empty($c_annonymous_account_array[mb_strtolower($currentUser->getUserID(), 'UTF-8') . '_' . $currentUser->getAuthSource()]) && $currentUser->isOnlyReadUser()) { $this->_popup_controller->setErrorReturn("1014", "anonymous account"); exit; } else { if ($currentUser->getUserID() == $form_data['merge_user_id'] && (empty($form_data['auth_source']) || $currentUser->getAuthSource() == $form_data['auth_source'])) { $this->_popup_controller->setErrorReturn("1015", "invalid account"); } else { $user_manager = $this->_environment->getUserManager(); $user_manager->setUserIDLimitBinary($form_data['merge_user_id']); $user_manager->select(); $user = $user_manager->get(); $first_user = $user->getFirst(); $current_user = $this->_environment->getCurrentUserItem(); if (!empty($first_user)) { if (empty($form_data['auth_source'])) { $authManager = $authentication->getAuthManager($current_user->getAuthSource()); } else { $authManager = $authentication->getAuthManager($form_data['auth_source']); } if (!$authManager->checkAccount($form_data['merge_user_id'], $form_data['merge_user_password'])) { $this->_popup_controller->setErrorReturn("1016", "authentication error"); exit; } } else { $this->_popup_controller->setErrorReturn("1015", "invalid account"); exit; } } } $currentUser = $this->_environment->getCurrentUserItem(); if (isset($form_data['auth_source'])) { $authSourceOld = $form_data['auth_source']; } else { $authSourceOld = $this->_environment->getCurrentPortalItem()->getAuthDefault(); } ini_set('display_errors', 'on'); error_reporting(E_ALL); $authentication->mergeAccount($currentUser->getUserID(), $currentUser->getAuthSource(), $form_data['merge_user_id'], $authSourceOld); // set return $this->_popup_controller->setSuccessfullItemIDReturn($currentUser->getItemID()); } break; case "account_lock_room": $current_user = $this->_environment->getCurrentUserItem(); $current_user->reject(); $current_user->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_delete_room": $current_user = $this->_environment->getCurrentUserItem(); $current_user->delete(); // remove link from group room if ($current_context->isGroupRoom()) { $group_item = $current_context->getLinkedGroupItem(); $group_item->removeMember($current_user->getRelatedUserItemInContext($group_item->getContextID())); } // set return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_lock_portal": $current_user = $this->_environment->getCurrentUserItem(); $portalUser_item = $current_user->getRelatedCommSyUserItem(); $portalUser_item->reject(); $portalUser_item->save(); // delete session $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_manager->delete($session->getSessionID()); $this->_environment->setSessionItem(null); // return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_delete_portal": $current_user = $this->_environment->getCurrentUserItem(); $portalUser_item = $current_user->getRelatedCommSyUserItem(); $authentication = $this->_environment->getAuthenticationObject(); $authentication->delete($portalUser_item->getItemID()); // delete session $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_manager->delete($session->getSessionID()); $this->_environment->setSessionItem(null); // return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case 'account': if ($this->_popup_controller->checkFormData('account')) { $authentication = $this->_environment->getAuthenticationObject(); $currentUser = $this->_environment->getCurrentUserItem(); // get portal user if in room context if (!$this->_environment->inPortal()) { $portalUser = $this->_environment->getPortalUserItem(); } else { $portalUser = $this->_environment->getCurrentUserItem(); } $translator = $this->_environment->getTranslationObject(); // Datenschutz if ($current_portal_item->getPasswordGeneration() > 0) { if (!$portalUser->isPasswordInGeneration(md5($form_data['new_password']))) { // password if (!empty($form_data['new_password'])) { $auth_manager = $authentication->getAuthManager($currentUser->getAuthSource()); $auth_source = $currentUser->getAuthSource(); $old_password = $auth_manager->getItem($form_data['user_id'])->getPasswordMD5(); if ($old_password == md5($form_data['old_password'])) { $change_pw = true; // if password options are set, check password $auth_source_manager = $this->_environment->getAuthSourceManager(); $auth_source_item = $auth_source_manager->getItem($currentUser->getAuthSource()); $error_array = array(); if ($auth_source_item->getPasswordLength() > 0) { if (strlen($form_data['new_password']) < $auth_source_item->getPasswordLength()) { $error_array[] = $translator->getMessage('PASSWORD_INFO_LENGTH', $auth_source_item->getPasswordLength()); //$this->_popup_controller->setErrorReturn('1022', 'new password too short'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureBigchar() == 1) { if (!preg_match('~[A-Z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_BIG'); //$this->_popup_controller->setErrorReturn('1023', 'new password no big character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSmallchar() == 1) { if (!preg_match('~[a-z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SMALL'); //$this->_popup_controller->setErrorReturn('1026', 'new password no small character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureNumber() == 1) { if (!preg_match('~[0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_NUMBER'); //$this->_popup_controller->setErrorReturn('1027', 'new password no number'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSpecialchar() == 1) { if (!preg_match('~[^a-zA-Z0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SPECIAL'); //$this->_popup_controller->setErrorReturn('1024', 'new password no special character'); $change_pw = false; } } unset($auth_source); if ($change_pw) { $portalUser->setPasswordExpireDate($current_portal_item->getPasswordExpiration()); $portalUser->save(); $auth_manager->changePassword($form_data['user_id'], $form_data['new_password']); } else { $this->_popup_controller->setErrorReturn('1022', $error_array); } } else { $error_array[] = $translator->getMessage('PASSWORD_OLD_NOT_EQUAL'); $this->_popup_controller->setErrorReturn('1023', $error_array); #$this->_popup_controller->setErrorReturn('1009', 'password change error'); } $error_number = $auth_manager->getErrorNumber(); if (!empty($error_number)) { // TODO:$error_string .= $translator->getMessage('COMMON_ERROR_DATABASE').$error_number.'<br />'; } else { $portalUser->setNewGenerationPassword($old_password); } } } else { $this->_popup_controller->setErrorReturn('1025', 'password generation error'); } } else { if (!empty($form_data['new_password'])) { $auth_manager = $authentication->getAuthManager($currentUser->getAuthSource()); $old_password = $auth_manager->getItem($form_data['user_id'])->getPasswordMD5(); if ($old_password == md5($form_data['old_password'])) { $change_pw = true; // if password options are set, check password $auth_source_manager = $this->_environment->getAuthSourceManager(); $auth_source_item = $auth_source_manager->getItem($currentUser->getAuthSource()); $error_array = array(); if ($auth_source_item->getPasswordLength() > 0) { if (strlen($form_data['new_password']) < $auth_source_item->getPasswordLength()) { $error_array[] = $translator->getMessage('PASSWORD_INFO_LENGTH', $auth_source_item->getPasswordLength()) . '<br>'; //$this->_popup_controller->setErrorReturn('1022', 'new password too short'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureBigchar() == 1) { if (!preg_match('~[A-Z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_BIG'); //$this->_popup_controller->setErrorReturn('1023', 'new password no big character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSmallchar() == 1) { if (!preg_match('~[a-z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SMALL'); //$this->_popup_controller->setErrorReturn('1026', 'new password no small character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureNumber() == 1) { if (!preg_match('~[0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_NUMBER'); //$this->_popup_controller->setErrorReturn('1027', 'new password no number'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSpecialchar() == 1) { if (!preg_match('~[^a-zA-Z0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SPECIAL'); //$this->_popup_controller->setErrorReturn('1024', 'new password no special character'); $change_pw = false; } } unset($auth_source); if ($change_pw) { $portalUser->setPasswordExpireDate($current_portal_item->getPasswordExpiration()); $portalUser->save(); $auth_manager->changePassword($form_data['user_id'], $form_data['new_password']); } else { $this->_popup_controller->setErrorReturn('1022', $error_array); } } else { $error_array[] = $translator->getMessage('PASSWORD_OLD_NOT_EQUAL'); $this->_popup_controller->setErrorReturn('1023', $error_array); #$this->_popup_controller->setErrorReturn('1008', 'password change error'); } $error_number = $auth_manager->getErrorNumber(); if (!empty($error_number)) { // TODO:$error_string .= $translator->getMessage('COMMON_ERROR_DATABASE').$error_number.'<br />'; } else { $portalUser->setNewGenerationPassword($old_password); } } } // user id if (!empty($form_data['user_id']) && $form_data['user_id'] != $portalUser->getUserID()) { $check = true; $auth_source = $portalUser->getAuthSource(); if (!empty($auth_source)) { $authentication = $this->_environment->getAuthenticationObject(); if (!$authentication->is_free($form_data['user_id'], $auth_source)) { $this->_popup_controller->setErrorReturn("1011", "user id error(duplicated)", array()); $check = false; } elseif (withUmlaut($form_data['user_id'])) { $this->_popup_controller->setErrorReturn("1012", "user id error(umlaut)", array()); $check = false; } } else { $this->_popup_controller->setErrorReturn("1013", "user id error(auth source error)", array()); $check = false; } if ($check === true) { if ($authentication->changeUserID($form_data['user_id'], $portalUser)) { $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_id_old = $session->getSessionID(); $session_manager->delete($session_id_old, true); $session->createSessionID($form_data['user_id']); $cookie = $session->getValue('cookie'); if ($cookie == 1) { $session->setValue('cookie', 2); } $session_manager->save($session); unset($session_manager); $portalUser->setUserID($form_data['user_id']); $currentUser->setUserID($form_data['user_id']); require_once 'functions/misc_functions.php'; plugin_hook('user_save', $portalUser); } } else { $this->_popup_controller->setErrorReturn("117", "user id error(duplicated, umlaut, etc)", array()); } } else { // $success_1 = true } $save = false; // language if (!empty($form_data['language']) && $form_data['language'] != $portalUser->getLanguage()) { $portalUser->setLanguage($form_data['language']); $save = true; if ($this->_environment->inPrivateRoom()) { $currentUser->setLanguage($form_data['language']); $currentUser->save(); } } if (isset($form_data['mail_account'])) { $currentUser->setAccountWantMail('yes'); $currentUser->save(); #$save = true; } else { $currentUser->setAccountWantMail('no'); $currentUser->save(); #$save = true; } if (isset($form_data['mail_room'])) { $currentUser->setOpenRoomWantMail('yes'); $currentUser->save(); #$save = true; } else { $currentUser->setOpenRoomWantMail('no'); $currentUser->save(); #$save = true; } // mail settings // if(!empty($form_data['mail_account'])) { // if($portalUser->getAccountWantMail() == 'no') { // $portalUser->setAccountWantMail('yes'); // $save = true; // } // } else { // if($portalUser->getAccountWantMail() == 'yes') { // $portalUser->setAccountWantMail('no'); // $save = true; // } // } // if(!empty($form_data['mail_room'])) { // if($portalUser->getOpenRoomWantMail() == 'no') { // $portalUser->setOpenRoomWantMail('yes'); // $save = true; // } // } else { // if($portalUser->getOpenRoomWantMail() == 'yes') { // $portalUser->setOpenRoomWantMail('no'); // $save = true; // } // } /* if(!empty($form_data['mail_delete_entry'])) { if($portalUser->getDeleteEntryWantMail() == 'no') { $portalUser->setDeleteEntryWantMail('yes'); $save = true; } } else { if($portalUser->getDeleteEntryWantMail() == 'yes') { $portalUser->setDeleteEntryWantMail('no'); $save = true; } } */ $change_name = false; $text_converter = $this->_environment->getTextConverter(); $form_data['forname'] = $text_converter->sanitizeHTML($form_data['forname']); $form_data['surname'] = $text_converter->sanitizeHTML($form_data['surname']); // forname if (!empty($form_data['forname']) && $portalUser->getFirstName() != $form_data['forname']) { $portalUser->setFirstName($form_data['forname']); $change_name = true; $save = true; } // surname if (!empty($form_data['surname']) && $portalUser->getLastName() != $form_data['surname']) { $portalUser->setLastName($form_data['surname']); $change_name = true; $save = true; } // auto save if (!empty($form_data['auto_save'])) { if ($form_data['auto_save'] == 'on') { $portalUser->turnAutoSaveOn(); } else { $portalUser->turnAutoSaveOff(); } $save = true; } else { $portalUser->turnAutoSaveOff(); $save = true; } global $c_email_upload; if ($c_email_upload && !$portalUser->isRoot()) { $own_room = $currentUser->getOwnRoom(); if (isset($form_data['email_to_commsy']) and !empty($form_data['email_to_commsy'])) { $own_room->setEmailToCommSy(); } else { $own_room->unsetEmailToCommSy(); } if (isset($form_data['email_to_commsy_secret']) and !empty($form_data['email_to_commsy_secret'])) { $own_room->setEmailToCommSySecret($form_data['email_to_commsy_secret']); } else { $own_room->setEmailToCommSySecret(''); } $own_room->save(); $save = true; } if ($save === true) { $portalUser->save(); } // change firstname and lastname in all other user_items of this user if ($change_name === true) { $user_manager = $this->_environment->getUserManager(); $dummy_user = $user_manager->getNewItem(); // forname $value = $form_data['forname']; if (empty($value)) { $value = -1; } $dummy_user->setFirstName($value); // surname $value = $form_data['surname']; if (empty($value)) { $value = -1; } $dummy_user->setLastName($value); $portalUser->changeRelatedUser($dummy_user); } // set return $this->_popup_controller->setSuccessfullItemIDReturn($portalUser->getItemID()); } break; /**** IMPORT ****/ /**** IMPORT ****/ case 'import': if ($this->_popup_controller->checkFormData('upload_import_private_room')) { if (!empty($additional["fileInfo"])) { $temp_stamp = time(); rename($additional["fileInfo"]["file"], 'var/temp/upload_' . $temp_stamp . '.zip'); $zip = new ZipArchive(); $res = $zip->open('var/temp/upload_' . $temp_stamp . '.zip'); if ($res === TRUE) { $zip->extractTo('var/temp/' . $temp_stamp); $zip->close(); $commsy_work_dir = getcwd(); chdir('var/temp/' . $temp_stamp); foreach (glob("commsy_xml_export_import_*.xml") as $filename) { $xml = simplexml_load_file($filename, null, LIBXML_NOCDATA); //el($xml); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml->asXML()); //el($dom->saveXML()); $options = array(); chdir($commsy_work_dir); $room_manager = $this->_environment->getRoomManager(); $room_manager->import_item($xml, null, $options); chdir('var/temp/' . $temp_stamp); $files = scandir('.'); foreach ($files as $file) { if (strpos($file, 'files') === 0) { $directory_name_array = explode('_', $file); $directory_old_id = $directory_name_array[1]; $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); $directory_new_id = $options[$directory_old_id]; if ($directory_new_id != '') { $disc_manager->setContextID($directory_new_id); $new_file_path = $disc_manager->getFilePath(); chdir($file); $files_to_copy = glob('./*'); foreach ($files_to_copy as $file_to_copy) { if (!(strpos($file, 'default_cs_gradient') === 0)) { $file_to_copy = str_ireplace('./', '', $file_to_copy); $file_name_array = explode('.', $file_to_copy); $file_old_id = $file_name_array[0]; $file_new_id = $options[$file_old_id]; if ($file_new_id != '') { $file_to_copy_temp = str_ireplace($file_old_id . '.', $file_new_id . '.', $file_to_copy); $file_to_copy_temp = './' . $file_to_copy_temp; $file_to_go = str_replace('./', $commsy_work_dir . '/' . $new_file_path, $file_to_copy_temp); copy($file_to_copy, $file_to_go); } } } chdir('..'); } } } } chdir($commsy_work_dir); } } } break; /**** USER PICTURE ****/ /**** USER PICTURE ****/ case 'user_picture': if ($this->_popup_controller->checkFormData('user_picture')) { /* handle user picture upload */ if (!empty($additional["fileInfo"])) { $currentUser = $this->_environment->getCurrentUserItem(); $portalUser = $currentUser->getRelatedCommSyUserItem(); $srcfile = $additional["fileInfo"]["file"]; $targetfile = $srcfile . "_converted"; $session = $this->_environment->getSessionItem(); $session->unsetValue("add_files"); // resize image to a maximum width of 150px and keep ratio $size = getimagesize($srcfile); list($x_orig, $y_orig, $type) = $size; $verhaeltnis = $y_orig / $x_orig; $max_width = 150; $ratio = 1.334; // 3:4 if ($verhaeltnis < $ratio) { // wider than 1:$ratio $source_width = $y_orig * $max_width / ($max_width * $ratio); $source_height = $y_orig; $source_x = ($x_orig - $source_width) / 2; $source_y = 0; } else { // higher than 1:$ratio $source_width = $x_orig; $source_height = $x_orig * ($max_width * $ratio) / $max_width; $source_x = 0; $source_y = ($y_orig - $source_height) / 2; } // create image switch ($type) { case '1': $im = imagecreatefromgif($srcfile); break; case '2': $im = imagecreatefromjpeg($srcfile); break; case '3': $im = imagecreatefrompng($srcfile); break; } $newimg = imagecreatetruecolor($max_width, $max_width * $ratio); imagecopyresampled($newimg, $im, 0, 0, $source_x, $source_y, $max_width, ceil($max_width * $ratio), $source_width, $source_height); imagepng($newimg, $targetfile); // clean up imagedestroy($im); imagedestroy($newimg); // determ new file name $filename_info = pathinfo($additional["fileInfo"]["name"]); $filename = 'cid' . $this->_environment->getCurrentContextID() . '_' . $currentUser->getItemID() . '.' . $filename_info['extension']; // copy file and set picture $disc_manager = $this->_environment->getDiscManager(); $disc_manager->copyFile($targetfile, $filename, true); $currentUser->setPicture($filename); $modifier = $this->_environment->getCurrentUserItem(); if (isset($portalUser)) { if ($disc_manager->copyImageFromRoomToRoom($filename, $portalUser->getContextID())) { $value_array = explode('_', $filename); $old_room_id = $value_array[0]; $old_room_id = str_replace('cid', '', $old_room_id); $valu_array[0] = 'cid' . $portalUser->getContextID(); $new_picture_name = implode('_', $value_array); $portalUser->setPicture($new_picture_name); $portalUser->setModificatorItem($modifier); $portalUser->setModificationDate(getCurrentDateTimeInMySQL()); $portalUser->save(); } } // save $currentUser->setModificatorItem($modifier); $currentUser->setModificationDate(getCurrentDateTimeInMySQL()); $currentUser->save(); } // set return $this->_popup_controller->setSuccessfullDataReturn($filename); } break; /**** USER ****/ /**** USER ****/ case 'user': $currentUser = $this->_environment->getCurrentUserItem(); $portalUser = $currentUser->getRelatedCommSyUserItem(); $text_converter = $this->_environment->getTextConverter(); $currentContext = $this->_environment->getCurrentContextItem(); if ($this->_popup_controller->checkFormData('user')) { function setValue($currentUser, $portalUser_item, $method, $value) { if (isset($value)) { // set for user call_user_func_array(array($currentUser, $method), array($value)); if (isset($portalUser_item)) { // set for portal user call_user_func_array(array($portalUser_item, $method), array($value)); } } } setValue($currentUser, $portalUser, 'setTitle', $text_converter->sanitizeHTML($form_data['title'])); setValue($currentUser, $portalUser, 'setBirthday', $text_converter->sanitizeHTML($form_data['birthday'])); $email_old = $portalUser->getEmail(); setValue($currentUser, $portalUser, 'setEmail', $text_converter->sanitizeHTML($form_data['mail'])); if ($portalUser->hasToChangeEmail() and $email_old != $form_data['mail']) { $portalUser->unsetHasToChangeEmail(); $form_data['mail_all'] = 1; } unset($email_old); if ($currentContext->isPortal()) { if ($form_data['mail_hide']) { $portalUser->setDefaultMailNotVisible(); } else { $portalUser->setDefaultMailVisible(); } if ($form_data['mail_hide_all']) { $user_list = $currentUser->getRelatedUserList(); $user_item = $user_list->getFirst(); while ($user_item) { if ($form_data['mail_hide']) { $user_item->setEmailNotVisible(); } else { $user_item->setEmailVisible(); } $user_item->save(); $user_item = $user_list->getNext(); } $currentUser->setDefaultMailNotVisible(); $currentUser->save(); } } else { if ($form_data['mail_hide']) { $currentUser->setEmailNotVisible(); } else { $currentUser->setEmailVisible(); } if ($form_data['mail_hide_all']) { $user_list = $currentUser->getRelatedUserList(); $user_item = $user_list->getFirst(); while ($user_item) { if ($form_data['mail_hide']) { $user_item->setEmailNotVisible(); } else { $user_item->setEmailVisible(); } $user_item->save(); $user_item = $user_list->getNext(); } $currentUser->setDefaultMailNotVisible(); $currentUser->save(); } } // im portal nur default wert // im raum default wert und raum wert? setValue($currentUser, $portalUser, 'setTelephone', $text_converter->sanitizeHTML($form_data['telephone'])); setValue($currentUser, $portalUser, 'setCellularphone', $text_converter->sanitizeHTML($form_data['cellularphone'])); setValue($currentUser, $portalUser, 'setStreet', $text_converter->sanitizeHTML($form_data['street'])); setValue($currentUser, $portalUser, 'setZipcode', $text_converter->sanitizeHTML($form_data['zipcode'])); setValue($currentUser, $portalUser, 'setCity', $text_converter->sanitizeHTML($form_data['city'])); setValue($currentUser, $portalUser, 'setRoom', $text_converter->sanitizeHTML($form_data['room'])); setValue($currentUser, $portalUser, 'setOrganisation', $text_converter->sanitizeHTML($form_data['organisation'])); setValue($currentUser, $portalUser, 'setPosition', $text_converter->sanitizeHTML($form_data['position'])); setValue($currentUser, $portalUser, 'setICQ', $text_converter->sanitizeHTML($form_data['icq'])); setValue($currentUser, $portalUser, 'setMSN', $text_converter->sanitizeHTML($form_data['msn'])); setValue($currentUser, $portalUser, 'setSkype', $text_converter->sanitizeHTML($form_data['skype'])); setValue($currentUser, $portalUser, 'setYahoo', $text_converter->sanitizeHTML($form_data['yahoo'])); setValue($currentUser, $portalUser, 'setJabber', $text_converter->sanitizeHTML($form_data['jabber'])); setValue($currentUser, $portalUser, 'setHomepage', $text_converter->sanitizeHTML($form_data['homepage'])); setValue($currentUser, $portalUser, 'setDescription', $form_data['description']); // delete picture handling if (isset($form_data['delete_picture']) && $currentUser->getPicture()) { $disc_manager = $this->_environment->getDiscManager(); // unlink file if ($disc_manager->existsFile($currentUser->getPicture())) { $disc_manager->unlinkFile($currentUser->getPicture()); } // set non picture $currentUser->setPicture(''); if (isset($portalUser)) { $portalUser->setPicture(''); } } // set modificator and modification date and save $modifier = $this->_environment->getCurrentUserItem(); $currentUser->setModificatorItem($modifier); $currentUser->setModificationDate(getCurrentDateTimeInMySQL()); $currentUser->save(); if (isset($portalUser)) { $portalUser->setModificatorItem($modifier); $portalUser->setModificationDate(getCurrentDateTimeInMySQL()); $portalUser->save(); } /* change all option */ // get a dummy user $user_manager = $this->_environment->getUserManager(); $dummy_user = $user_manager->getNewItem(); $changeAll = false; function setChangeAllValue($currentUser, $dummy_user_item, $method_set, $method_get, $checked) { if (isset($checked)) { $value = call_user_func_array(array($currentUser, $method_get), array()); if (empty($value)) { $value = -1; } call_user_func_array(array($dummy_user_item, $method_set), array($value)); } return $checked; } $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setTitle', 'getTitle', $form_data['title_all']); $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setBirthday', 'getBirthday', $form_data['birthday_all']); $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setEmail', 'getEmail', $form_data['mail_all']); if (isset($form_data['mail_all'])) { $changeAll = true; if (!$currentUser->isEmailVisible()) { $dummy_user->setEmailNotVisible(); } else { $dummy_user->setEmailVisible(); } } $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setTelephone', 'getTelephone', $form_data['telephone_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setCellularphone', 'getCellularphone', $form_data['cellularphone_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setStreet', 'getStreet', $form_data['street_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setZipcode', 'getZipcode', $form_data['zipcode_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setCity', 'getCity', $form_data['city_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setRoom', 'getRoom', $form_data['room_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setOrganisation', 'getOrganisation', $form_data['organisation_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setPosition', 'getPosition', $form_data['position_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setICQ', 'getICQ', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setMSN', 'getMSN', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setSkype', 'getSkype', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setYahoo', 'getYahoo', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setJabber', 'getJabber', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setHomepage', 'getHomepage', $form_data['homepage_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setDescription', 'getDescription', $form_data['description_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setPicture', 'getPicture', $form_data['picture_all']) || $changeAll; if ($changeAll === true) { $currentUser->changeRelatedUser($dummy_user); } $manager = $this->_environment->getLinkModifierItemManager(); $manager->markEdited($currentUser->getItemID()); // set return $this->_popup_controller->setSuccessfullItemIDReturn($currentUser->getItemID()); } break; /**** NEWSLETTER ****/ /**** NEWSLETTER ****/ case 'newsletter': if ($this->_popup_controller->checkFormData('newsletter')) { $currentUser = $this->_environment->getCurrentUserItem(); $room_item = $currentUser->getOwnRoom(); $set_to = 'none'; if (isset($form_data['newsletter']) && !empty($form_data['newsletter'])) { if ($form_data['newsletter'] == 2) { $set_to = 'weekly'; } elseif ($form_data['newsletter'] == 3) { $set_to = 'daily'; } } // set $room_item->setPrivateRoomNewsletterActivity($set_to); // save $room_item->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($room_item->getItemID()); } break; case 'cs_bar': if ($this->_popup_controller->checkFormData('cs_bar')) { $currentUser = $this->_environment->getCurrentUserItem(); $room_item = $currentUser->getOwnRoom(); //--- $wordpress_manager = $this->_environment->getWordpressManager(); $wiki_manager = $this->_environment->getWikiManager(); if ($additional['action'] == 'create_wordpress') { if (isset($form_data['use_comments']) and !empty($form_data['use_comments']) and $form_data['use_comments'] == 'yes') { $room_item->setWordpressUseComments(); } else { $room_item->unsetWordpressUseComments(); } if (isset($form_data['use_comments_moderation']) and !empty($form_data['use_comments_moderation']) and $form_data['use_comments_moderation'] == 'yes') { $room_item->setWordpressUseCommentsModeration(); } else { $room_item->unsetWordpressUseCommentsModeration(); } if (isset($form_data['wordpresslink']) and !empty($form_data['wordpresslink']) and $form_data['wordpresslink'] == 'yes') { $room_item->setWordpressHomeLink(); } else { $room_item->unsetWordpressHomeLink(); } if (isset($form_data['skin_choice']) and !empty($form_data['skin_choice'])) { $room_item->setWordpressSkin($form_data['skin_choice']); } if (isset($form_data['wordpresstitle']) and !empty($form_data['wordpresstitle'])) { $room_item->setWordpressTitle($form_data['wordpresstitle']); } else { $room_item->setWordpressTitle($room_item->getTitle()); } if (isset($form_data['wordpressdescription']) and !empty($form_data['wordpressdescription'])) { $room_item->setWordpressDescription($form_data['wordpressdescription']); } else { $room_item->setWordpressDescription(''); } if (isset($form_data['member_role']) and !empty($form_data['member_role'])) { $room_item->setWordpressMemberRole($form_data['member_role']); } else { $room_item->setWordpressMemberRole(); } $room_item->setWithWordpressFunctions(); $room_item->setWordpressExists(); $room_item->setWordpressActive(); // save $room_item->save(); // create or change new wordpress $success = $wordpress_manager->createWordpress($room_item); } else { if ($additional['action'] == 'delete_wordpress') { if ($wordpress_manager->deleteWordpress($room_item->getWordpressId())) { $current_user = $this->_environment->getCurrentUserItem(); $room_item->setModificatorItem($current_user); $room_item->setModificationDate(getCurrentDateTimeInMySQL()); $room_item->unsetWordpressExists(); $room_item->setWordpressInActive(); $room_item->setWordpressSkin('twentyten'); $room_item->setWordpressTitle($room_item->getTitle()); $room_item->setWordpressDescription(''); $room_item->setWordpressId(0); // Save item $room_item->save(); } } else { if ($additional['action'] == 'create_wiki') { // Set modificator and modification date #if ( isset($form_data['wikilink']) and !empty($form_data['wikilink']) and $form_data['wikilink'] == 'yes') { $room_item->setWikiHomeLink(); #} else { # $room_item->unsetWikiHomeLink(); #} if (isset($form_data['wikilink2']) and !empty($form_data['wikilink2']) and $form_data['wikilink2'] == 'yes') { $room_item->setWikiPortalLink(); } else { $room_item->unsetWikiPortalLink(); } if (isset($form_data['wiki_skin_choice']) and !empty($form_data['wiki_skin_choice'])) { $room_item->setWikiSkin($form_data['wiki_skin_choice']); } if (isset($form_data['wikititle']) and !empty($form_data['wikititle'])) { $room_item->setWikiTitle($form_data['wikititle']); } else { $room_item->setWikiTitle($room_item->getTitle()); } if (isset($form_data['admin']) and !empty($form_data['admin'])) { $room_item->setWikiAdminPW($form_data['admin']); } if (isset($form_data['edit']) and !empty($form_data['edit'])) { $room_item->setWikiEditPW($form_data['edit']); } else { $room_item->setWikiEditPW(''); } if (isset($form_data['read']) and !empty($form_data['read'])) { $room_item->setWikiReadPW($form_data['read']); } else { $room_item->setWikiReadPW(''); } #if ( isset($form_data['use_commsy_login']) ) { $room_item->setWikiUseCommSyLogin(); #} else { # $room_item->unsetWikiUseCommSyLogin(); #} if (isset($form_data['community_read_access'])) { $room_item->setWikiCommunityReadAccess(); } else { $room_item->unsetWikiCommunityReadAccess(); } if (isset($form_data['community_write_access'])) { $room_item->setWikiCommunityWriteAccess(); } else { $room_item->unsetWikiCommunityWriteAccess(); } if (isset($form_data['portal_read_access'])) { $room_item->setWikiPortalReadAccess(); } else { $room_item->unsetWikiPortalReadAccess(); } if (isset($form_data['room_mod_write_access'])) { $room_item->setWikiRoomModWriteAccess(); } else { $room_item->unsetWikiRoomModWriteAccess(); } if (isset($form_data['show_login_box'])) { $room_item->setWikiShowCommSyLogin(); } else { $room_item->unsetWikiShowCommSyLogin(); } #if ( isset($form_data['enable_fckeditor']) ) { $room_item->setWikiEnableFCKEditor(); #} else { # $room_item->unsetWikiEnableFCKEditor(); #} #if ( isset($form_data['enable_sitemap']) ) { $room_item->setWikiEnableSitemap(); #} else { # $room_item->unsetWikiEnableSitemap(); #} #if ( isset($form_data['enable_statistic']) ) { $room_item->setWikiEnableStatistic(); #} else { # $room_item->unsetWikiEnableStatistic(); #} #if ( isset($form_data['enable_search']) ) { $room_item->setWikiEnableSearch(); #} else { # $room_item->unsetWikiEnableSearch(); #} #if ( isset($form_data['enable_rss']) ) { $room_item->setWikiEnableRss(); #} else { # $room_item->unsetWikiEnableRss(); #} if (isset($form_data['enable_calendar'])) { $room_item->setWikiEnableCalendar(); } else { $room_item->unsetWikiEnableCalendar(); } if (isset($form_data['enable_gallery'])) { $room_item->setWikiEnableGallery(); } else { $room_item->unsetWikiEnableGallery(); } if (isset($form_data['enable_notice'])) { $room_item->setWikiEnableNotice(); } else { $room_item->unsetWikiEnableNotice(); } #if ( isset($form_data['enable_pdf']) ) { $room_item->setWikiEnablePdf(); #} else { # $room_item->unsetWikiEnablePdf(); #} if (isset($form_data['enable_rater'])) { $room_item->setWikiEnableRater(); } else { $room_item->unsetWikiEnableRater(); } #if ( isset($form_data['enable_listcategories']) ) { $room_item->setWikiEnableListCategories(); #} else { # $room_item->unsetWikiEnableListCategories(); #} if (isset($form_data['new_page_template']) && $_POST['new_page_template'] != '') { $room_item->setWikiNewPageTemplate($_POST['new_page_template']); } else { $room_item->unsetWikiNewPageTemplate(); } if (isset($form_data['enable_swf'])) { $room_item->setWikiEnableSwf(); } else { $room_item->unsetWikiEnableSwf(); } if (isset($form_data['enable_wmplayer'])) { $room_item->setWikiEnableWmplayer(); } else { $room_item->unsetWikiEnableWmplayer(); } if (isset($form_data['enable_quicktime'])) { $room_item->setWikiEnableQuicktime(); } else { $room_item->unsetWikiEnableQuicktime(); } if (isset($form_data['enable_youtube_google_vimeo'])) { $room_item->setWikiEnableYoutubeGoogleVimeo(); } else { $room_item->unsetWikiEnableYoutubeGoogleVimeo(); } include_once 'functions/development_functions.php'; // Discussion #if ( isset($form_data['enable_discussion']) ) { $room_item->setWikiEnableDiscussion(); if (isset($form_data['new_discussion'])) { $_POST['new_discussion'] = $form_data['new_discussion']; $room_item->WikiSetNewDiscussion($form_data['new_discussion']); } #} else { # $room_item->unsetWikiEnableDiscussion(); #} $enable_discussion_discussions = array(); $form_data_keys = array_keys($form_data); foreach ($form_data_keys as $form_data_key) { if (stristr($form_data_key, 'enable_discussion_discussions_')) { $enable_discussion_discussions[] = $form_data[$form_data_key]; } } $_POST['enable_discussion_discussions'] = $enable_discussion_discussions; if (isset($form_data['enable_discussion_notification'])) { $room_item->setWikiEnableDiscussionNotification(); } else { $room_item->unsetWikiEnableDiscussionNotification(); } if (isset($form_data['enable_discussion_notification_groups'])) { $room_item->setWikiEnableDiscussionNotificationGroups(); } else { $room_item->unsetWikiEnableDiscussionNotificationGroups(); } if (isset($form_data['wiki_section_edit'])) { $room_item->setWikiWithSectionEdit(); } else { $room_item->setWikiWithoutSectionEdit(); } if (isset($form_data['wiki_section_edit_header'])) { $room_item->setWikiWithHeaderForSectionEdit(); } else { $room_item->setWikiWithoutHeaderForSectionEdit(); } $room_item->setWikiExists(); $room_item->setWikiActive(); $wiki_manager->createWiki($room_item); // Save item - after createWiki() -> old discussions might be deleted $room_item->save(); $enable_wiki_groups = array(); $form_data_keys = array_keys($form_data); foreach ($form_data_keys as $form_data_key) { if (stristr($form_data_key, 'enable_wiki_groups_')) { $enable_wiki_groups[] = $form_data[$form_data_key]; } } // WSDL-xml hier noch nicht zugreifbar, daher weiterhin die alte Variante if (!empty($enable_wiki_groups)) { //global $c_use_soap_for_wiki; //if(!$c_use_soap_for_wiki){ $wiki_manager->setWikiGroupsAsPublic($enable_wiki_groups); //} else { // $wiki_manager->setWikiGroupsAsPublic_soap($_POST['enable_wiki_groups']); //} } else { //global $c_use_soap_for_wiki; //if(!$c_use_soap_for_wiki){ $wiki_manager->setWikiGroupsAsPublic(array()); //} else { // $wiki_manager->setWikiGroupsAsPublic_soap(array()); //} } } else { if ($additional['action'] == 'delete_wiki') { $room_item->setModificatorItem($currentUser); $room_item->setModificationDate(getCurrentDateTimeInMySQL()); $room_item->unsetWikiExists(); $room_item->setWikiInActive(); $room_item->setWikiSkin('pmwiki'); $room_item->setWikiTitle($room_item->getTitle()); $room_item->unsetWikiEnableDiscussion(); $room_item->unsetWikiEnableDiscussionNotification(); $room_item->unsetWikiEnableDiscussionNotificationGroups(); $room_item->unsetWikiDiscussionArray(); // Save item $room_item->save(); // delete wiki $wiki_manager->deleteWiki($room_item); } else { if ($additional['action'] == 'chat') { if (isset($form_data['chatlink']) and !empty($form_data['chatlink']) and $form_data['chatlink'] == 'yes') { $room_item->setChatLinkActive(); } else { $room_item->setChatLinkInactive(); } $room_item->save(); } elseif (substr($additional['action'], 0, 7) == 'plugin_') { $plugin = substr($additional['action'], 7); $plugin_class = $this->_environment->getPluginClass($plugin); if (!empty($plugin_class) and method_exists($plugin_class, 'isConfigurableInPortal')) { if ($this->_environment->inPortal() and $plugin_class->isConfigurableInPortal() or !$this->_environment->inServer() and method_exists($plugin_class, 'isConfigurableInRoom') and $plugin_class->isConfigurableInRoom(CS_PRIVATEROOM_TYPE) or !$this->_environment->inServer() and method_exists($plugin_class, 'isConfigurableInRoom') and $plugin_class->isConfigurableInRoom() and $plugin == 'voyeur') { if (!empty($form_data[$plugin . '_on']) and $form_data[$plugin . '_on'] == 'yes') { $room_item->setPluginOn($plugin); } else { $room_item->setPluginOff($plugin); } $values = $form_data; $values['current_context_item'] = $room_item; if ($this->_environment->inPortal() and method_exists($plugin_class, 'configurationAtPortal')) { $plugin_class->configurationAtPortal('save_config', $values); } elseif (!$this->_environment->inServer() and method_exists($plugin_class, 'configurationAtRoom')) { $plugin_class->configurationAtRoom('save_config', $values); } } } $room_item->save(); } else { if ($additional['action'] == 'export_private_room') { $currentUserItem = $this->_environment->getCurrentUserItem(); $privateroom_manager = $this->_environment->getPrivateRoomManager(); $privateroom_item = $privateroom_manager->getRelatedOwnRoomForUser($currentUserItem, $this->_environment->getCurrentPortalID()); $room_manager = $this->_environment->getRoomManager(); $xml = $room_manager->export_item($privateroom_item->getItemID()); //$xml = $room_manager->export_item(488); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml->asXML()); //el($dom->saveXML()); $filename = 'var/temp/commsy_xml_export_import_' . $privateroom_item->getItemID() . '.xml'; if (file_exists($filename)) { unlink($filename); } $xmlfile = fopen($filename, 'a'); fputs($xmlfile, $dom->saveXML()); fclose($xmlfile); //Location where export is saved $zipfile = 'var/temp/commsy_export_import_' . $privateroom_item->getItemID() . '.zip'; if (file_exists($zipfile)) { unlink($zipfile); } //Location that will be backuped $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); $backup_paths = array(); $room_item = $privateroom_manager->getItem($privateroom_item->getItemID()); $disc_manager->setContextID($room_item->getItemId()); $backup_paths[$room_item->getItemId()] = $disc_manager->getFilePath(); if (class_exists('ZipArchive')) { include_once 'functions/misc_functions.php'; $zip = new ZipArchive(); $filename_zip = $zipfile; if ($zip->open($filename_zip, ZIPARCHIVE::CREATE) !== TRUE) { include_once 'functions/error_functions.php'; trigger_error('can not open zip-file ' . $filename_zip, E_USER_WARNNG); } $temp_dir = getcwd(); foreach ($backup_paths as $item_id => $backup_path) { chdir($backup_path); $zip = addFolderToZip('.', $zip, 'files_' . $item_id); chdir($temp_dir); } $zip->addFile($filename, basename($filename)); $zip->close(); unset($zip); #header('Content-disposition: attachment; filename=commsy_export_import_'.$_POST['room'].'.zip'); #header('Content-type: application/zip'); #readfile($zipfile); //export_privateroom $this->_popup_controller->setSuccessfullDataReturn(array('commsy_export' => '/commsy.php?cid=' . $this->_environment->getCurrentPortalID() . '&mod=export_privateroom&fct=getfile')); } else { include_once 'functions/error_functions.php'; trigger_error('can not initiate ZIP class, please contact your system administrator', E_USER_WARNNG); } } } } } } } //--- if (isset($form_data['show_widget_view']) && !empty($form_data['show_widget_view'])) { if ($form_data['show_widget_view'] == 'yes') { $room_item->setCSBarShowWidgets('1'); } else { $room_item->setCSBarShowWidgets('-1'); } } else { $room_item->setCSBarShowWidgets('-1'); } if (isset($form_data['show_roomwide_search']) && !empty($form_data['show_roomwide_search'])) { if ($form_data['show_roomwide_search'] == 'yes') { $room_item->setPortletShowRoomWideSearchBox('1'); } else { $room_item->setPortletShowRoomWideSearchBox('-1'); } } else { $room_item->setPortletShowRoomWideSearchBox('-1'); } if (isset($form_data['show_newest_entries']) && !empty($form_data['show_newest_entries'])) { if ($form_data['show_newest_entries'] == 'yes') { $room_item->setPortletShowNewEntryList('1'); } else { $room_item->setPortletShowNewEntryList('-1'); } } else { $room_item->setPortletShowNewEntryList('-1'); } if (isset($form_data['show_active_rooms']) && !empty($form_data['show_active_rooms'])) { if ($form_data['show_active_rooms'] == 'yes') { $room_item->setPortletShowActiveRoomList('1'); } else { $room_item->setPortletShowActiveRoomList('-1'); } } else { $room_item->setPortletShowActiveRoomList('-1'); } if (isset($form_data['show_calendar_view']) && !empty($form_data['show_calendar_view'])) { if ($form_data['show_calendar_view'] == 'yes') { $room_item->setCSBarShowCalendar('1'); } else { $room_item->setCSBarShowCalendar('-1'); } } else { $room_item->setCSBarShowCalendar('-1'); } if (isset($form_data['show_stack_view']) && !empty($form_data['show_stack_view'])) { if ($form_data['show_stack_view'] == 'yes') { $room_item->setCSBarShowStack('1'); } else { $room_item->setCSBarShowStack('-1'); } } else { $room_item->setCSBarShowStack('-1'); } if (isset($form_data['show_portfolio_view']) && !empty($form_data['show_portfolio_view'])) { if ($form_data['show_portfolio_view'] == 'yes') { $room_item->setCSBarShowPortfolio('1'); } else { $room_item->setCSBarShowPortfolio('-1'); } } else { $room_item->setCSBarShowPortfolio('-1'); } // portal2portal if (isset($form_data['show_connection_view']) && !empty($form_data['show_connection_view'])) { if ($form_data['show_connection_view'] == 'yes') { $room_item->setCSBarShowConnection('1'); } else { $room_item->setCSBarShowConnection('-1'); } } else { $room_item->setCSBarShowConnection('-1'); } if (isset($form_data['show_old_room_switcher']) && !empty($form_data['show_old_room_switcher'])) { if ($form_data['show_old_room_switcher'] == 'yes') { $room_item->setCSBarShowOldRoomSwitcher('1'); } else { $room_item->setCSBarShowOldRoomSwitcher('-1'); } } else { $room_item->setCSBarShowOldRoomSwitcher('-1'); } // save $room_item->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($room_item->getItemID()); } break; } } // // save user // else { // $room_item = $environment->getCurrentContextItem(); // // Define rubric connections // $rubric_connection = array(); // $current_rubrics = $room_item->getAvailableRubrics(); // foreach ( $current_rubrics as $rubric ) { // switch ( $rubric ) { // case CS_GROUP_TYPE: // $rubric_connection[] = CS_GROUP_TYPE; // break; // case CS_INSTITUTION_TYPE: // $rubric_connection[] = CS_INSTITUTION_TYPE; // break; // } // } // $profile_view->setRubricConnections($rubric_connection); // $params = $environment->getCurrentParameterArray(); // unset($params['is_saved']); // $profile_view->setAction(curl($environment->getCurrentContextID(),$environment->getCurrentModule(),$environment->getCurrentFunction(),$params)); // if (!$currentUser->mayEditRegular($current_user)) { // $profile_view->warnChanger(); // $params = array(); // $params['environment'] = $environment; // $params['with_modifying_actions'] = true; // $params['width'] = 500; // $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); // unset($params); // $errorbox->setText($translator->getMessage('COMMON_EDIT_AS_MODERATOR')); // } // $profile_view->setForm($form); // } } }
function addFolderToZip($path, $zip) { $handler = opendir($path); while (($filename = readdir($handler)) !== false) { if ($filename != "." && $filename != "..") { if (is_dir($path . "/" . $filename)) { addFolderToZip($path . "/" . $filename, $zip); } else { $zip->addFile($path . "/" . $filename); } } } @closedir($path); }
} } if ( class_exists('ZipArchive') ) { include_once('functions/misc_functions.php'); $zip = new ZipArchive(); $filename_zip = $zipfile; if ( $zip->open($filename_zip, ZIPARCHIVE::CREATE) !== TRUE ) { include_once('functions/error_functions.php'); trigger_error('can not open zip-file '.$filename_zip,E_USER_WARNNG); } $temp_dir = getcwd(); foreach ($backup_paths as $item_id => $backup_path) { chdir($backup_path); $zip = addFolderToZip('.',$zip,'files_'.$item_id); chdir($temp_dir); } foreach ($backup_paths_files as $backup_paths_file) { $backup_paths_file_array = explode('/', $backup_paths_file); $zip->addFile($backup_paths_file, 'styles/'.array_pop($backup_paths_file_array)); } $zip->addFile($filename, basename($filename)); $zip->close(); unset($zip); header('Content-disposition: attachment; filename=commsy_export_import_'.$_POST['room'].'.zip'); header('Content-type: application/zip'); readfile($zipfile); exit;
$dirname = "./presentations/" . $_SESSION['step_all_2']['user_name'] . "/" . $_SESSION['step_all_4']['presentation_name']; $zipdir = "./presentations/" . $_SESSION['step_all_2']['user_name'] . "/" . $_SESSION['step_all_4']['presentation_name'] . "/zip_file"; umask(00); if (!file_exists($zipdir)) { mkdir($zipdir, 0777); } $zip = new ZipArchive(); $filename = $zipdir . "/" . $_SESSION['step_all_4']['presentation_name'] . ".zip"; // smazat soubor, pokud existuje if (file_exists($filename)) { unlink($filename); } if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { echo "<h2 class=\"error\">" . $webgen_send_to_zip_error[$language] . " " . $filename . "</h2>"; } addFolderToZip($dirname, $zip, $_SESSION['step_all_4']['presentation_name']); $zip->close(); chmod($filename, 0777); // odeslani emailu s prilohou include_once "./library/mime_mail.inc"; $content_type = "application/octet-stream"; # read a JPEG picture from the disk $fd = fopen($filename, "r"); $data = fread($fd, filesize($filename)); fclose($fd); # create object instance $mail = new mime_mail(); # set all data slots $mail->from = $from; $mail->to = $email; $mail->subject = $predmet;
function addFolderToZip($dir, $zipArchive, $zipdir = '') { if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory if ($dir !== ".") { $zipArchive->addEmptyDir($dir); } // Loop through all the files while (($file = readdir($dh)) !== false) { if ($dir !== ".") { $file_path = $dir . DIRECTORY_SEPARATOR . $file; } else { $file_path = $file; } if (!empty($zipdir)) { $zip_path = $zipdir . DIRECTORY_SEPARATOR . $file; } else { $zip_path = $file_path; } //If it's a folder, run the function again! if (!is_file($file_path)) { // Skip parent and root directories if ($file !== "." and $file !== "..") { addFolderToZip($file_path, $zipArchive, $zip_path); } } else { // Add the files $result = $zipArchive->addFile($file_path, $zip_path); } } } } return $zipArchive; }
function addFolderToZip($dir, $zipArchive) { if (is_dir($dir)) { if ($dh = opendir($dir)) { //Add the directory $zipArchive->addEmptyDir($dir); while (($file = readdir($dh)) !== false) { // Loop through all the files if (!is_file($dir . $file)) { //If it's a folder, run the function again! //echo 'directory = ' . $dir . $file . '<br />'; if ($file !== "." && $file !== "..") { addFolderToZip($dir . $file . "/", $zipArchive); } } else { // Add the files //echo 'file = ' . $dir . $file . '<br />'; $zipArchive->addFile($dir . $file); } } } } }