Beispiel #1
0
function changeFromFtp()
{
    global $message;
    global $specialchars;
    $success = false;
    $dirgallery = getDirAsArray(GALLERIES_DIR_REL, "dir");
    foreach ($dirgallery as $currentgalerien) {
        $change = false;
        if (true !== ($error = setChmod(GALLERIES_DIR_REL . $currentgalerien))) {
            $message .= returnMessage(false, $error);
            return;
        }
        $test_galerie = $specialchars->replaceSpecialChars($specialchars->rebuildSpecialChars($currentgalerien, false, false), false);
        if ($test_galerie != $currentgalerien) {
            $nr = 0;
            $new_name = $test_galerie;
            while (in_array($new_name, $dirgallery)) {
                $new_name = "%23_" . $nr . "_" . $test_galerie;
                $nr++;
            }
            if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien, GALLERIES_DIR_REL . $new_name))) {
                $message .= returnMessage(false, $error);
                return;
            }
            $change = true;
            $currentgalerien = $new_name;
        }
        if (!is_dir(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME)) {
            if (true !== ($error = mkdirMulti(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME))) {
                $message .= returnMessage(false, $error);
                return;
            }
            $change = true;
        }
        if (!file_exists(GALLERIES_DIR_REL . $currentgalerien . "/texte.conf.php")) {
            if (false === newConf(GALLERIES_DIR_REL . $currentgalerien . "/texte.conf.php")) {
                $message .= returnMessage(false, getLanguageValue("gallery_error_subtitle_conf"));
                return;
            }
            $change = true;
        }
        $dirimg = getDirAsArray(GALLERIES_DIR_REL . $currentgalerien, "img");
        foreach ($dirimg as $currentimg) {
            if (true !== ($error = setChmod(GALLERIES_DIR_REL . $currentgalerien . "/" . $currentimg))) {
                $message .= returnMessage(false, $error);
                return;
            }
            $test_img = cleanUploadFile($currentimg);
            if ($test_img != $currentimg) {
                $nr = 0;
                $new_name = $test_img;
                while (in_array($new_name, $dirimg)) {
                    $new_name = "_" . $nr . "_" . $test_img;
                    $nr++;
                }
                if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien . "/" . $currentimg, GALLERIES_DIR_REL . $currentgalerien . "/" . $new_name))) {
                    $message .= returnMessage(false, $error);
                    return;
                }
                $change = true;
                if (is_file(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $currentimg)) {
                    if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $currentimg, GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $new_name))) {
                        $message .= returnMessage(false, $error);
                        return;
                    }
                    $change = true;
                }
            }
        }
        if ($change) {
            $success .= "<b>" . $specialchars->rebuildSpecialChars($currentgalerien, false, true) . "</b><br />";
        }
    }
    if ($success) {
        $message .= returnMessage(true, getLanguageValue("gallery_messages_from_ftp") . "<br /><br />" . $success);
    } else {
        $message .= returnMessage(true, getLanguageValue("gallery_messages_from_ftp_no") . "");
    }
}
Beispiel #2
0
function saveContentToPage($content, $page, $new = false)
{
    // Existenz prüfen
    if ($new and file_exists($page)) {
        return returnMessage(false, getLanguageValue("error_exists_file_dir"));
    }
    global $page_protect;
    $chmod = false;
    # nee neue datei wird angelegt da brauchen wir chmod
    if (!is_file($page)) {
        $chmod = true;
    }
    if (false === file_put_contents($page, $page_protect . $content, LOCK_EX)) {
        return returnMessage(false, getLanguageValue("editor_content_error_save"));
    }
    if ($chmod) {
        return setChmod($page);
    }
    return true;
}
Beispiel #3
0
function plugin_install($zip = false)
{
    if (!function_exists('gzopen')) {
        return;
    }
    global $debug;
    @set_time_limit(600);
    global $message, $specialchars;
    $dir = PLUGIN_DIR_REL;
    if ($zip === false) {
        $zip_file = $dir . $specialchars->replaceSpecialChars($_FILES["plugin-install-file"]["name"], false);
    } else {
        if (getChmod() !== false) {
            setChmod($dir . $zip);
        }
        $zip_file = $dir . $zip;
    }
    $debug .= $zip_file . "<br />";
    #    if(true === (move_uploaded_file($_FILES["plugin-install-file"]["tmp_name"], $zip_file))) {
    if ($zip !== false and strlen($zip_file) > strlen($dir) or $zip === false and true === move_uploaded_file($_FILES["plugin-install-file"]["tmp_name"], $zip_file)) {
        require_once BASE_DIR_ADMIN . "pclzip.lib.php";
        $archive = new PclZip($zip_file);
        if (0 != ($file_list = $archive->listContent())) {
            uasort($file_list, "helpUasort");
            $find = installFindPlugins($file_list, $archive);
            if (count($find) > 0) {
                foreach ($find as $liste) {
                    if (strlen($liste['index']) > 0) {
                        $debug .= '<pre>';
                        $debug .= var_export($liste, true);
                        $debug .= '</pre>';
                        if (getChmod() !== false) {
                            $tmp1 = $archive->extractByIndex($liste['index'], PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_ADD_PATH, $liste['name'], PCLZIP_OPT_REMOVE_PATH, $liste['remove_dir'], PCLZIP_OPT_SET_CHMOD, getChmod(), PCLZIP_CB_PRE_EXTRACT, "PclZip_PreExtractCallBack", PCLZIP_OPT_REPLACE_NEWER);
                            setChmod($dir . $liste['name']);
                        } else {
                            $tmp1 = $archive->extractByIndex($liste['index'], PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_ADD_PATH, $liste['name'], PCLZIP_OPT_REMOVE_PATH, $liste['remove_dir'], PCLZIP_CB_PRE_EXTRACT, "PclZip_PreExtractCallBack", PCLZIP_OPT_REPLACE_NEWER);
                        }
                    } else {
                        # die file strucktur im zip stimt nicht
                        $message .= returnMessage(false, getLanguageValue("error_zip_structure"));
                    }
                }
            } else {
                # die file strucktur im zip stimt nicht
                $message .= returnMessage(false, getLanguageValue("error_zip_structure"));
            }
        } else {
            # scheint kein gühltiges zip zu sein
            $message .= returnMessage(false, getLanguageValue("error_zip_nozip") . "<br />" . $zip_file);
        }
        unlink($zip_file);
    } else {
        # das zip konnte nicht hochgeladen werden
        $message .= returnMessage(false, getLanguageValue("error_file_upload") . "<br />" . $zip_file);
    }
}
     if (setChmod('/media/', 0777)) {
         $chmod++;
     } else {
         $errfile[] = 'Could not chmod() /media/';
     }
     if (setChmod('/media/albums/', 0777)) {
         $chmod++;
     } else {
         $errfile[] = 'Could not chmod() /media/albums/';
     }
     if (setChmod('/media/files/', 0777)) {
         $chmod++;
     } else {
         $errfile[] = 'Could not chmod() /media/files/';
     }
     if (setChmod('/lib/includes/cache/', 0777)) {
         $chmod++;
     } else {
         $errfile[] = 'Could not chmod() /lib/includes/cache/';
     }
     if ($chmod > 0) {
         $log[] = '<abbr title=".htaccess, config.inc.php, ./content/, ./lib/includes/cache/, back-up folder &amp; 2 media folders">Confirmed correct chmod() on ' . $chmod . ' files/directories.</abbr>';
     }
     if ($chmod == 0 || count($errfile) > 0) {
         $errors[] = 'Warning: could not chmod() all files.';
         foreach ($errfile as $key => $value) {
             $errors[] = $value;
         }
         $errors[] = 'Either use the <a href="index.php?do=ftp">built-in FTP chmod function</a>, or manually perform chmod().';
     }
 }
Beispiel #5
0
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error)
 {
     if (!is_dir($this->options['upload_dir']) and (ACTION == "gallery" or ACTION == "files") and (strpos($this->options['upload_dir'], "/" . CONTENT_FILES_DIR_NAME) > 0 or strpos($this->options['upload_dir'], "/" . PREVIEW_DIR_NAME) > 0) and true !== ($tmp = mkdirMulti($this->options['upload_dir']))) {
         $error = $tmp;
     }
     $file = new stdClass();
     $file->name = $this->trim_file_name($name, $type);
     $file->size = intval($size);
     $file->type = $type;
     $error = $this->has_error($uploaded_file, $file, $error);
     if (!$error && $file->name) {
         $file_path = $this->options['upload_dir'] . "." . $file->name;
         $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
         clearstatcache();
         if ($uploaded_file && is_uploaded_file($uploaded_file)) {
             // multipart/formdata uploads (POST method uploads)
             if ($append_file) {
                 file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
             } else {
                 move_uploaded_file($uploaded_file, $file_path);
             }
         } else {
             // Non-multipart uploads (PUT method support)
             file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         }
         $file_size = filesize($file_path);
         if ($file_size === $file->size) {
             if (is_file($this->options['upload_dir'] . $file->name)) {
                 unlink($this->options['upload_dir'] . $file->name);
             }
             rename($file_path, $this->options['upload_dir'] . $file->name);
             $file_path = $this->options['upload_dir'] . $file->name;
             global $specialchars;
             if ($this->options['orient_image']) {
                 $this->orient_image($file_path);
             }
             $file->url = $this->options['upload_url'] . $specialchars->replaceSpecialChars($file->name, false);
             foreach ($this->options['image_versions'] as $version => $options) {
                 if ($this->create_scaled_image($file->name, $options)) {
                     if ($this->options['upload_dir'] !== $options['upload_dir']) {
                         $file->{$version . '_url'} = $options['upload_url'] . $specialchars->replaceSpecialChars($file->name, false);
                     } else {
                         clearstatcache();
                         $file_size = filesize($file_path);
                     }
                 }
             }
             if (ACTION == "gallery") {
                 $file->pixel_w = "";
                 $file->pixel_h = "";
                 if (false !== ($getimagesize = $this->is_image($file_path))) {
                     $file->pixel_w = $getimagesize[0];
                     $file->pixel_h = $getimagesize[1];
                 }
                 #                    $this->subtitle->set($file->name,"");
                 $file->subtitle = "";
             }
             setChmod($file_path);
         } else {
             if ($this->options['discard_aborted_uploads']) {
                 unlink($file_path);
                 $file->error = 'abort';
             }
         }
         $file->size = $file_size;
         $this->set_file_delete_url($file);
     } else {
         $file->error = $error;
     }
     return $file;
 }
Beispiel #6
0
function send_backup_zip()
{
    $tmp_date = date('Y_m_d_H-i-s');
    $incl = "";
    $make_zip = true;
    $send = false;
    $dirs = array();
    if (getRequestValue('backup_include_cms', 'post') == "true") {
        $dirs[] = BASE_DIR_ADMIN;
        $dirs[] = BASE_DIR_CMS;
        $dirs[] = BASE_DIR . "index.php";
        if (is_file(BASE_DIR . "install.php")) {
            $dirs[] = BASE_DIR . "install.php";
        }
        if (is_file(BASE_DIR . "update.php")) {
            $dirs[] = BASE_DIR . "update.php";
        }
        if (is_file(BASE_DIR . "robots.txt")) {
            $dirs[] = BASE_DIR . "robots.txt";
        }
        if (is_file(BASE_DIR . "sitemap.xml")) {
            $dirs[] = BASE_DIR . "sitemap.xml";
        }
        if (is_file(BASE_DIR . "sitemap_addon.xml")) {
            $dirs[] = BASE_DIR . "sitemap_addon.xml";
        }
        if (is_file(BASE_DIR . ".htaccess")) {
            $dirs[] = BASE_DIR . ".htaccess";
        }
    }
    if (getRequestValue('backup_include_catpage', 'post') == "true") {
        $dirs[] = CONTENT_DIR_REL;
        $incl .= "catpage_";
    }
    if (getRequestValue('backup_include_gallery', 'post') == "true") {
        $dirs[] = GALLERIES_DIR_REL;
        $incl .= "gallery_";
    }
    if (getRequestValue('backup_include_layouts', 'post') == "true") {
        $dirs[] = BASE_DIR . LAYOUT_DIR_NAME;
        $incl .= "layouts_";
    }
    if (getRequestValue('backup_include_plugins', 'post') == "true") {
        $dirs[] = BASE_DIR . PLUGIN_DIR_NAME;
        $incl .= "plugins_";
    }
    if (getRequestValue('backup_include_docu', 'post') == "true") {
        $dirs[] = BASE_DIR . "docu/";
        $incl .= "docu_";
    }
    if (strlen($incl) > 1) {
        $incl = "Include_" . $incl;
    }
    if (count($dirs) < 1) {
        $make_zip = false;
        global $message;
        $message .= returnMessage(false, getLanguageValue("admin_error_no_backups_select"));
    }
    if ($make_zip) {
        if (!is_dir(BASE_DIR . BACKUP_DIR_NAME)) {
            @mkdir(BASE_DIR . BACKUP_DIR_NAME);
            setChmod(BASE_DIR . BACKUP_DIR_NAME);
        }
        $filename = 'moziloCMS_Backup_' . $incl . $tmp_date . '.zip';
        $file = BASE_DIR . BACKUP_DIR_NAME . '/' . $filename;
        define("PCLZIP_TEMPORARY_DIR", BASE_DIR . BACKUP_DIR_NAME . '/');
        require_once BASE_DIR_ADMIN . "pclzip.lib.php";
        $backup = new PclZip($file);
        if (0 != $backup->create($dirs, PCLZIP_OPT_REMOVE_PATH, BASE_DIR, PCLZIP_OPT_ADD_PATH, 'moziloCMS_Backup_' . $tmp_date)) {
            $send = true;
        } else {
            global $message;
            $message .= returnMessage(false, "Error : " . $backup->errorInfo());
            $dh = opendir(BASE_DIR . BACKUP_DIR_NAME);
            while (($entry = readdir($dh)) !== false) {
                if ($entry == "." or $entry == "..") {
                    continue;
                }
                @unlink(BASE_DIR . BACKUP_DIR_NAME . '/' . $entry);
            }
            closedir($dh);
        }
    }
    if ($send) {
        $filesize = filesize($file);
        // Header schreiben
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Type: application/zip");
        header("Content-Disposition: inline; filename=\"" . $filename . "\";");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . $filesize);
        # bei grossen dateien senden in kleinen stücken damit der speicherunter browserdialog schnell aufgeht
        if ($filesize > 1048576 * 10) {
            # 1048576 = 1mb
            $fp = fopen($file, "r");
            while (!feof($fp)) {
                echo fread($fp, 65536);
                flush();
                // this is essential for large downloads
            }
            fclose($fp);
        } else {
            @readfile($file);
        }
        @unlink($file);
        exit;
    }
}