예제 #1
0
 /**
  * Gets called on a authenication request. This method should check sessions or simmilar to
  * verify that the user has access to the backend.
  *
  * This method should return true if the current request is authenicated or false if it's not.
  *
  * @param ManagerEngine $man ManagerEngine reference that the plugin is assigned to.
  * @return bool true/false if the user is authenticated.
  */
 function ActualonAuthenticate(&$man)
 {
     $config =& $man->getConfig();
     // Support both old and new format
     $loggedInKey = isset($config['SessionAuthenticator.logged_in_key']) ? $config['SessionAuthenticator.logged_in_key'] : $config["authenticator.session.logged_in_key"];
     $userKey = isset($config['SessionAuthenticator.user_key']) ? $config['SessionAuthenticator.user_key'] : $config["authenticator.session.user_key"];
     $pathKey = isset($config['SessionAuthenticator.path_key']) ? $config['SessionAuthenticator.path_key'] : $config["authenticator.session.path_key"];
     $rootPathKey = isset($config['SessionAuthenticator.rootpath_key']) ? $config['SessionAuthenticator.rootpath_key'] : $config["authenticator.session.rootpath_key"];
     $configPrefix = (isset($config['SessionAuthenticator.config_prefix']) ? $config['SessionAuthenticator.config_prefix'] : "mcmanager") . ".";
     // Switch path
     if (isset($_SESSION[$pathKey])) {
         $config['filesystem.path'] = $_SESSION[$pathKey];
     }
     // Switch root
     if (isset($_SESSION[$rootPathKey])) {
         $config['filesystem.rootpath'] = $_SESSION[$rootPathKey];
     }
     $user = isset($_SESSION[$userKey]) ? $_SESSION[$userKey] : "";
     $user = preg_replace('/[\\\\\\/:]/i', '', $user);
     // Override by prefix
     foreach ($_SESSION as $key => $value) {
         if (strpos($key, $configPrefix) === 0) {
             $config[substr($key, strlen($configPrefix))] = $value;
         }
     }
     foreach ($config as $key => $value) {
         // Skip replaceing {$user} in true/false stuff
         if ($value === true || $value === false) {
             continue;
         }
         $value = str_replace('${user}', $user, $value);
         $config[$key] = $value;
     }
     return isset($_SESSION[$loggedInKey]) && checkBool($_SESSION[$loggedInKey]);
 }
 /**
  * Lists file.
  */
 function _getMediaInfo(&$man, $input)
 {
     $file =& $man->getFile($input["path"]);
     $config = $file->getConfig();
     $parent =& $file->getParentFile();
     $files = array();
     if ($parent->isDirectory()) {
         // Setup file filter
         $fileFilter = new Moxiecode_BasicFileFilter();
         //$fileFilter->setDebugMode(true);
         $fileFilter->setIncludeDirectoryPattern($config['filesystem.include_directory_pattern']);
         $fileFilter->setExcludeDirectoryPattern($config['filesystem.exclude_directory_pattern']);
         $fileFilter->setIncludeFilePattern($config['filesystem.include_file_pattern']);
         $fileFilter->setExcludeFilePattern($config['filesystem.exclude_file_pattern']);
         $fileFilter->setIncludeExtensions($config['filesystem.extensions']);
         $fileFilter->setOnlyFiles(true);
         // List files
         $files =& $parent->listFilesFiltered($fileFilter);
     }
     $match = false;
     $prev = "";
     $next = "";
     foreach ($files as $curfile) {
         if ($curfile->getAbsolutePath() == $file->getAbsolutePath()) {
             $match = true;
             continue;
         } else {
             if (!$match) {
                 $prev = $curfile->getAbsolutePath();
             }
         }
         if ($match) {
             $next = $curfile->getAbsolutePath();
             break;
         }
     }
     $ext = getFileExt($file->getName());
     // Input default size?
     $width = "425";
     $height = "350";
     // All types that getimagesize support
     $imagearray = array('gif', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'jpc', 'jp2', 'jpx', 'jb2', 'swc', 'iff', 'wbmp', 'xbm');
     if (in_array($ext, $imagearray)) {
         $sizeinfo = @getimagesize($file->getAbsolutePath());
         if ($sizeinfo) {
             $width = $sizeinfo[0];
             $height = $sizeinfo[1];
         }
     }
     $result = new Moxiecode_ResultSet("name,path,url,size,type,created,modified,width,height,attribs,next,prev,custom");
     $custom = array();
     $man->dispatchEvent("onCustomInfo", array(&$file, "info", &$custom));
     $attribs = ($file->canRead() && checkBool($config["filesystem.readable"]) ? "R" : "-") . ($file->canWrite() && checkBool($config["filesystem.writable"]) ? "W" : "-");
     $url = $man->removeTrailingSlash($config['preview.urlprefix']) . $man->convertPathToURI($file->getAbsolutePath());
     $result->add(utf8_encode($file->getName()), $man->encryptPath($file->getAbsolutePath()), utf8_encode($url), $file->getLength(), $ext, date($config['filesystem.datefmt'], $file->getCreationDate()), date($config['filesystem.datefmt'], $file->getLastModified()), $width, $height, $attribs, $man->encryptPath($next), $man->encryptPath($prev), $custom);
     return $result->toArray();
 }
예제 #3
0
 /**
  * Returns a logger instance.
  *
  * @return Logger New logger instance.
  */
 function &getLogger()
 {
     if (!$this->_logger) {
         $log = new Moxiecode_Logger();
         $null = null;
         // PHP why!!! Other languages can return null
         if (!checkBool($this->getConfigItem("log.enabled"))) {
             return $null;
         }
         // Set logger options
         $log->setLevel($this->getConfigItem("log.level", "fatal"));
         $log->setPath($this->toAbsPath($this->getConfigItem("log.path", "logs")));
         $log->setFileName($this->getConfigItem("log.filename", "{level}.log"));
         $log->setFormat($this->getConfigItem("log.format", "[{time}] [{level}] {message}"));
         $log->setMaxSize($this->getConfigItem("log.max_size", "100k"));
         $log->setMaxFiles($this->getConfigItem("log.max_files", "10"));
         $this->_logger = $log;
     }
     return $this->_logger;
 }
예제 #4
0
$templates = explode(',', $config['filesystem.file_templates']);
$data['templates'] = array();
foreach ($templates as $templateName) {
    if ($templateName != "") {
        $data['templates'][basename($templateName)] = $templateName;
    }
}
$data['previewurl'] = "";
$keys = array_keys($data['templates']);
if (count($keys) == 1) {
    $data['previewurl'] = $data['templates'][$keys[0]];
}
// Do action
if ($action == "submit" && $targetFile->canWrite() && checkBool($config["filesystem.writable"])) {
    // Do nothing in demo mode
    if (checkBool($config['general.demo'])) {
        trigger_error($config['general.demo_msg'], ERROR);
    }
    // No access, tool disabled
    if (in_array("createdoc", explode(',', $config['general.disabled_tools']))) {
        trigger_error("You don't have access to perform the requested action.", ERROR);
    }
    // No docname specified
    if (!$docname) {
        $data['errorMsg'] = "error_missing_document_name";
        renderPage("createdoc.tpl.php", $data);
    }
    // No template selected
    if (!$template && count(array_keys($templates)) > 1) {
        $data['errorMsg'] = "error_missing_template_selection";
        renderPage("createdoc.tpl.php", $data);
예제 #5
0
 // Do nothing in demo mode
 if (checkBool($config['general.demo'])) {
     trigger_error($config['general.demo_msg'], ERROR);
 }
 // No dirname specified
 if (!$dirname) {
     $data['errorMsg'] = "error_missing_name";
     renderPage("createdir.tpl.php", $data);
 }
 // No template selected
 if (!$template && count(array_keys($templates)) > 1 && checkBool($config['filesystem.force_directory_template'])) {
     $data['errorMsg'] = "error_invalid_template_selection";
     renderPage("createdir.tpl.php", $data);
 }
 // Only one template and forced, use that one
 if (count(array_keys($templates)) == 1 && $template == "" && checkBool($config['filesystem.force_directory_template'])) {
     $keys = array_keys($templates);
     $template = $templates[$keys[0]];
 }
 // No template defined, use first template
 /*		$keys = array_keys($data['templates']);
 		if (!$template && count($keys) > 0)
 			$template = $data['templates'][$keys[0]];*/
 if ($template != "") {
     $templateFile =& $fileFactory->getFile($template);
     if (!$templateFile->exists() || $template == "" || $template === false) {
         $data['errorMsg'] = "error_template_not_found";
         renderPage("createdir.tpl.php", $data);
     }
 }
 $file =& $fileFactory->getFile($path, $dirname, MC_IS_DIRECTORY);
예제 #6
0
/**
 * Returns the user path, the path that the users sees.
 *
 * @param String $path Absolute file path.
 * @return String Visual path, user friendly path.
 */
function getUserFriendlyPath($path, $max_len = -1)
{
    global $mcImageManagerConfig;
    if (checkBool($mcImageManagerConfig['general.user_friendly_paths'])) {
        $path = substr($path, strlen(removeTrailingSlash(getRealPath($mcImageManagerConfig, 'filesystem.rootpath'))));
        if ($path == "") {
            $path = "/";
        }
    }
    if ($max_len != -1 && strlen($path) > $max_len) {
        $path = "... " . substr($path, strlen($path) - $max_len);
    }
    // Add slash in front
    if (strlen($path) > 0 && $path[0] != '/') {
        $path = "/" . $path;
    }
    return $path;
}
예제 #7
0
$imageTools = array();
$imageTools = explode(',', $config['thumbnail.image_tools']);
$information = array();
$information = explode(',', $config['thumbnail.information']);
$data['js'] = getRequestParam("js", "");
$data['formname'] = getRequestParam("formname", "");
$data['elementnames'] = getRequestParam("elementnames", "");
$data['disabled_tools'] = $config['general.disabled_tools'];
$data['image_tools'] = $imageTools;
$data['toolbar'] = $tools;
$data['full_path'] = $path;
$data['root_path'] = $rootpath;
$data['errorMsg'] = "dfdf";
//addslashes($errorMsg);
$data['selectedPath'] = $selectedPath;
$data['dirlist'] = $dirList;
$data['anchor'] = $anchor;
$data['exif_support'] = exifExists();
$data['gd_support'] = $isGD;
$data['edit_enabled'] = checkBool($config["thumbnail.gd.enabled"]);
$data['demo'] = checkBool($config["general.demo"]);
$data['demo_msg'] = $config["general.demo_msg"];
$data['information'] = $information;
$data['extension_image'] = checkBool($config["thumbnail.extension_image"]);
$data['insert'] = checkBool($config["thumbnail.insert"]);
$data['filemanager_urlprefix'] = removeTrailingSlash($config["filemanager.urlprefix"]);
$data['thumbnail_width'] = $config['thumbnail.width'];
$data['thumbnail_height'] = $config['thumbnail.height'];
$data['thumbnail_border_style'] = $config['thumbnail.border_style'];
$data['thumbnail_margin_around'] = $config['thumbnail.margin_around'];
renderPage("images.tpl.php", $data);
예제 #8
0
 function _getConfig(&$man, $input)
 {
     $globalConfig = $man->getConfig();
     if (!isset($input['prefixes'])) {
         $input["prefixes"] = "*";
     }
     // If debug mode return all
     if (!isset($input['path']) && isset($input['debug']) && checkBool($globalConfig['general.debug'])) {
         return $man->getConfig();
     }
     if (!isset($input['path'])) {
         trigger_error("{#error.file_not_exists}", FATAL);
         die;
     }
     $file =& $man->getFile($input['path']);
     if (!$file->exists()) {
         trigger_error("{#error.file_not_exists}", FATAL);
         die;
     }
     $config = $file->getConfig();
     // If debug mode return all
     if (isset($input['debug']) && checkBool($globalConfig['general.debug'])) {
         return $config;
     }
     return $man->getJSConfig($config, $input["prefixes"]);
 }
예제 #9
0
}
$data['path'] = $file->getAbsolutePath();
$data['filename'] = basename(getUserFriendlyPath($file->getAbsolutePath()));
if ($data['filename'] == "") {
    $data['filename'] = "/";
}
$data['filesize'] = getSizeStr($file->length());
$fileType = getFileType($file->getAbsolutePath());
$data['icon'] = $fileType['icon'];
$data['type'] = $fileType['type'];
$data['preview'] = $fileType['preview'];
$data['previewurl'] = "";
$data['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified());
$data['creationdate'] = date($config['filesystem.datefmt'], $file->creationDate());
$data['readable'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "readable" : "not_readable";
$data['writable'] = $file->canWrite() && checkBool($config["filesystem.writable"]) ? "writable" : "not_writable";
$data['type'] = $file->isDirectory() ? "dir" : "file";
$data['description'] = $fileType['type'];
// Count files and dirs
if ($file->isDirectory()) {
    // Get filtered files
    $fileFilter =& new BasicFileFilter();
    $fileFilter->setIncludeDirectoryPattern($config['filesystem.include_directory_pattern']);
    $fileFilter->setExcludeDirectoryPattern($config['filesystem.exclude_directory_pattern']);
    $fileFilter->setIncludeFilePattern($config['filesystem.include_file_pattern']);
    $fileFilter->setExcludeFilePattern($config['filesystem.exclude_file_pattern']);
    $files = $file->listFilesFiltered($fileFilter);
    //$files = $file->listFiles();
    $fileCount = 0;
    $dirCount = 0;
    $sizeSum = 0;
예제 #10
0
                $zippedfile['status_message'] = "Excluded by filters.";
                $zippedfile['status'] = "Denied";
                $excludedFileArray[] = $zippedfile['filename'];
            }
        }
        $contentOut[] = $zippedfile;
    }
    $zipList[$i]['name'] = $file->getName();
    $zipList[$i]['absolutepath'] = $file->getAbsolutePath();
    $zipList[$i]['shortname'] = substr($file->getName(), 0, strrpos($file->getName(), "."));
    $zipList[$i]['contents'] = $contentOut;
    $contentOut = array();
    $i++;
}
// Take the array we just made, and unzip it.
if ($action == "unzip" && $data['demo'] != "true" && $targetFile->canWrite() && checkBool($config["filesystem.writable"])) {
    $checks = array();
    if (isset($_REQUEST['checks'])) {
        $checks = $_REQUEST['checks'];
    }
    $parentExists = false;
    $unziplist = array();
    $resultList = array();
    $unzipfolder = "";
    $exists = false;
    $itemsresult = array();
    $i = 0;
    foreach ($zipList as $zipfile) {
        $zip = new PclZip($zipfile['absolutepath']);
        $unziplist = isset($checks[$zipfile['name']]) ? $checks[$zipfile['name']] : array();
        $overwrite = getRequestParam("overwrite_" . $i, "");
예제 #11
0
파일: ajax.php 프로젝트: stormlab/Stormlab
         $selectedFiles[] =& $fileFactory->getFile($value);
     }
 }
 // No access, tool disabled
 if (!in_array("delete", explode(',', $config['thumbnail.image_tools']))) {
     displayErrorXML("", $mcLanguage['error_delete_failed']);
 }
 if (checkBool($config['general.demo'])) {
     displayErrorXML("", $config['general.demo_msg']);
 }
 $canread = false;
 $canwrite = false;
 $th_deleted = false;
 foreach ($selectedFiles as $file) {
     $canread = $file->canRead() && checkBool($config["filesystem.readable"]) ? true : false;
     $canwrite = $file->canWrite() && checkBool($config["filesystem.writable"]) ? true : false;
     if ($canwrite) {
         // Check for Thumbnail
         if ($config['thumbnail.gd.delete'] == true) {
             $th_folder = "/" . $config['thumbnail.gd.folder'];
             $th_folder = dirname($file->getAbsolutePath()) . $th_folder;
             $thFolder = $fileFactory->getFile($th_folder);
             if ($thFolder->exists()) {
                 $th_path = $thFolder->getAbsolutePath() . "/" . $config['thumbnail.gd.prefix'] . basename($file->getAbsolutePath());
                 $th = $fileFactory->getFile($th_path);
                 if ($th->exists()) {
                     $th->delete();
                 }
                 $th_deleted = true;
             }
         }
예제 #12
0
                $fileItem['isCut'] = true;
                break;
            }
        }
    }
    // File info
    $fileType = getFileType($file->getAbsolutePath());
    $fileItem['icon'] = $fileType['icon'];
    $fileItem['type'] = $fileType['type'];
    $even = !$even;
    $fileList[] = $fileItem;
}
$data['files'] = $fileList;
$data['path'] = $path;
$data['hasReadAccess'] = $targetFile->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false";
$data['hasWriteAccess'] = $targetFile->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false";
$data['hasPasteData'] = isset($_SESSION['MCFileManager_clipboardAction']) ? "true" : "false";
$toolsCommands = explode(',', $config['general.tools']);
$newTools = array();
foreach ($toolsCommands as $command) {
    foreach ($tools as $tool) {
        if ($tool['command'] == $command) {
            $newTools[] = $tool;
        }
    }
}
$data['disabled_tools'] = $config['general.disabled_tools'];
$data['tools'] = $newTools;
$data['short_path'] = getUserFriendlyPath($path);
$data['full_path'] = getUserFriendlyPath($path);
$data['errorMsg'] = $errorMsg;
예제 #13
0
// Invalid path, use root path
if (!$fileFactory->verifyPath($path)) {
    $path = $rootPath;
}
// Get file and config
$targetFile =& $fileFactory->getFile($path);
$config = $targetFile->getConfig();
addFileEventListeners($fileFactory);
$previewpath = $path;
// Get parent dir if path points to a file
$fileFactory =& new FileFactory($mcFileManagerConfig, $rootPath);
$file =& $fileFactory->getFile($path);
if ($file->exists()) {
    if ($file->isFile()) {
        $path = $file->getParent();
    }
    $previewpath = $file->getAbsolutePath();
} else {
    $path = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path'));
    $previewpath = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path'));
}
$data['path'] = $path;
$data['previewpath'] = $previewpath;
$data['previewfilename'] = basename($previewpath);
$data['rootpath'] = $rootPath;
$data['showpreview'] = checkBool($mcFileManagerConfig['preview']);
$data['formname'] = getRequestParam("formname", "");
$data['elementnames'] = getRequestParam("elementnames", "");
$data['js'] = getRequestParam("js", "");
// Render output
renderPage("frameset.tpl.php", $data);
 /**
  * Returns true/false if the user is logged in or not.
  *
  * @return bool true/false if the user is logged in or not.
  */
 function isLoggedin()
 {
     return isset($_SESSION[$this->_loggedInKey]) && checkBool($_SESSION[$this->_loggedInKey]);
 }
예제 #15
0
    $prefix = " KB";
}
// Is MB
if (strpos(strtolower($config["upload.maxsize"]), "m") > 0) {
    $maxSizeBytes *= 1024 * 1024;
    $prefix = " MB";
}
$data['max_file_size'] = getSizeStr($maxSizeBytes);
// Always create a local file instance
for ($i = 0; isset($_FILES['file' . $i]['tmp_name']); $i++) {
    // Do nothing in demo mode
    if (checkBool($config['general.demo'])) {
        trigger_error($config['general.demo_msg'], ERROR);
    }
    // No access, tool disabled
    if (in_array("upload", explode(',', $config['general.disabled_tools'])) || !$targetFile->canWrite() || !checkBool($config["filesystem.writable"])) {
        trigger_error("You don't have access to perform the requested action.", ERROR);
    }
    $filename = getRequestParam("filename" . $i, false);
    $data['filename' . $i] = $filename;
    // Get the god damned extension
    $ext = "";
    if (strpos(basename($_FILES['file' . $i]['name']), ".") > 0) {
        $ar = explode('.', basename($_FILES['file' . $i]['name']));
        $ext = array_pop($ar);
    }
    $file =& new LocalFileImpl($fileFactory, $path, $filename . "." . $ext);
    if (is_uploaded_file($_FILES['file' . $i]['tmp_name'])) {
        // Exists?
        if ($file->exists()) {
            @unlink($_FILES['file' . $i]['tmp_name']);
예제 #16
0
 function _saveContent(&$man, &$input)
 {
     $file = $man->getFile($input["path"]);
     $config = $file->getConfig();
     if (!$man->isToolEnabled("edit", $config)) {
         trigger_error("{#error.no_access}", FATAL);
         die;
     }
     if (checkBool($config['general.demo'])) {
         trigger_error("{#error.demo}", FATAL);
         die;
     }
     if (!checkBool($config["filesystem.writable"])) {
         trigger_error("{#error.no_write_access}", FATAL);
         die;
     }
     if ($man->verifyFile($file, "edit") < 0) {
         trigger_error($man->getInvalidFileMsg(), FATAL);
         die;
     }
     if (!$file->canWrite()) {
         trigger_error("{#error.no_write_access}", FATAL);
         die;
     }
     $writer = $file->open('w');
     if ($writer) {
         $writer->write($input["content"]);
         $writer->close();
     } else {
         trigger_error("{#error.no_write_access}", FATAL);
         die;
     }
     return array("status" => "OK");
 }
예제 #17
0
$fileFactory =& new FileFactory($mcFileManagerConfig, $rootpath);
$targetFile =& $fileFactory->getFile($path);
$config = $targetFile->getConfig();
addFileEventListeners($fileFactory);
$filename = getRequestParam("filename", false);
$submitted = getRequestParam("submitted", false);
$data['path'] = $path;
$data['submitted'] = $submitted;
$data['short_path'] = getUserFriendlyPath($path, 30);
$data['full_path'] = getUserFriendlyPath($path);
$data['errorMsg'] = "";
$data['filename'] = "";
$data['demo'] = checkBool($config['general.demo']) ? "true" : "false";
$data['demo_msg'] = $config['general.demo_msg'];
// Create zip
if ($submitted && $targetFile->canWrite() && checkBool($config["filesystem.writable"])) {
    $targetFile =& $fileFactory->getFile($path, $filename . ".zip", MC_IS_FILE);
    $config = $targetFile->getConfig();
    // Setup first filter
    $fileFilterA =& new BasicFileFilter();
    $fileFilterA->setIncludeFilePattern($config['filesystem.include_file_pattern']);
    $fileFilterA->setExcludeFilePattern($config['filesystem.exclude_file_pattern']);
    if (!$fileFilterA->accept($targetFile)) {
        $data['errorMsg'] = $config['filesystem.invalid_file_name_msg'];
        renderPage("zip.tpl.php", $data);
    }
    /*
    // Setup second filter
    $fileFilterB =& new BasicFileFilter();
    $fileFilterB->setIncludeFilePattern($config['zip.include_file_pattern']);
    $fileFilterB->setExcludeFilePattern($config['zip.exclude_file_pattern']);
예제 #18
0
$action = getRequestParam("action");
$path = getRequestParam("path");
$orgpath = getRequestParam("orgpath", "");
$filename = getRequestParam("filename", "");
$msg = "";
if ($orgpath == "") {
    $orgpath = $path;
}
$temp_image = "mcic_" . session_id() . "";
verifyAccess($mcImageManagerConfig);
$rootpath = removeTrailingSlash(getRequestParam("rootpath", toUnixPath(getRealPath($mcImageManagerConfig, 'filesystem.rootpath'))));
$fileFactory =& new FileFactory($mcImageManagerConfig, $rootPath);
addFileEventListeners($fileFactory);
$file =& $fileFactory->getFile($path);
$config = $file->getConfig();
$demo = checkBool($config['general.demo']) ? "true" : "false";
$imageutils = new $config['thumbnail']();
$tools = explode(',', $config['thumbnail.image_tools']);
if (!in_array("edit", $tools)) {
    trigger_error("The thumbnail.image_tools needs to include edit.", WARNING);
}
// File info
$fileInfo = getFileType($file->getAbsolutePath());
$file_icon = $fileInfo['icon'];
$file_type = $fileInfo['type'];
$file_ext = $fileInfo['ext'];
$tempFile =& $fileFactory->getFile(dirname($file->getAbsolutePath()) . "/" . $temp_image . "." . $file_ext);
$tempFile->setTriggerEvents(false);
switch ($action) {
    case "resize":
        $status = $imageutils->resizeImage($file->getAbsolutePath(), $tempFile->getAbsolutePath(), $newWidth, $newHeight, $file_ext);
예제 #19
0
파일: index.php 프로젝트: laiello/vinhloi
$package = getRequestParam("package", "", true);
$type = getRequestParam("type", "", true);
// Include Base and Core and Config.
$man = new Moxiecode_ManagerEngine($type);
require_once $basepath . "CorePlugin.php";
require_once "../config.php";
$man->dispatchEvent("onPreInit", array($type));
$config = $man->getConfig();
$compressor = new Moxiecode_CSSCompressor(array('expires_offset' => 3600 * 24 * 10, 'disk_cache' => true, 'cache_dir' => '_cache', 'gzip_compress' => true, 'remove_whitespace' => false, 'charset' => 'UTF-8', 'name' => $theme . "_" . $package, 'convert_urls' => true));
$resources = new Moxiecode_ClientResources();
// Load theme resources
$resources->load('../pages/' . $theme . '/resources.xml');
// Load plugin resources
$plugins = explode(',', $config["general.plugins"]);
foreach ($plugins as $plugin) {
    $resources->load('../plugins/' . $plugin . '/resources.xml');
}
$files = $resources->getFiles($package);
if ($resources->isDebugEnabled() || checkBool($config["general.debug"])) {
    header('Content-type: text/css');
    $pagePath = dirname($_SERVER['SCRIPT_NAME']);
    echo "/* Debug enabled, css files will be loaded without compression */\n";
    foreach ($files as $file) {
        echo '@import url("' . $pagePath . '/' . $file->getPath() . '");' . "\n";
    }
} else {
    foreach ($files as $file) {
        $compressor->addFile($file->getPath(), $file->isRemoveWhiteSpaceEnabled());
    }
    $compressor->compress($package);
}
예제 #20
0
<?php

require_once 'configuration.php';
$arr = array();
if (!checkBool()) {
    $arr['type'] = 'error';
    $arr['msg'] = 'Keine Berechtigung';
} else {
    if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
        $arr['type'] = 'error';
        $arr['msg'] = 'Keine ID angegeben.';
    } else {
        $id = (int) $_POST['id'];
        $db->query("DELETE FROM `redirs` WHERE `id` = {$id} LIMIT 1;");
        if ($db->error) {
            $arr['type'] = 'error';
            $arr['msg'] = 'Beim Schreiben in die Datenbank ist ein Fehler aufgetreten, bitte versuche es später noch einmal.';
        } else {
            $arr['type'] = 'success';
            $arr['id'] = $id;
        }
    }
}
header("Content-type: application/json");
echo json_encode($arr);
exit;
예제 #21
0
 function handleError($errno, $errstr, $errfile, $errline, $errcontext)
 {
     global $man, $config;
     $error = array();
     $log = false;
     $error['title'] = "";
     $error['break'] = false;
     $error['errstr'] = $errstr;
     //$error['errcontext'] = $errcontext;
     $error['errcontext'] = "";
     $error['errfile'] = "";
     $error['errline'] = "";
     // Add file and line only in debug mode
     if (isset($man)) {
         $config = $man->getConfig();
         $log = $man->getLogger();
         if (checkBool($config['general.debug'])) {
             $error['errfile'] = $errfile;
             $error['errline'] = $errline;
         }
     }
     switch ($errno) {
         case E_USER_ERROR:
             $error['title'] = "Fatal Error";
             $error['break'] = true;
             break;
         case E_USER_NOTICE:
             $error['title'] = "Notice";
             $error['break'] = false;
             break;
         case E_USER_WARNING:
             $error['title'] = "Warning";
             $error['break'] = true;
             break;
         case E_PARSE:
             $error['title'] = "PHP Parse Error";
             $error['break'] = true;
             if ($log) {
                 $log->fatal($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_ERROR:
             $error['title'] = "PHP Error";
             $error['break'] = true;
             if ($log) {
                 $log->error($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_WARNING:
             $error['title'] = "PHP Warning";
             $error['break'] = false;
             if ($log) {
                 $log->warn($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_CORE_ERROR:
             $error['title'] = "PHP Error : Core Error";
             $error['break'] = true;
             if ($log) {
                 $log->error($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_CORE_WARNING:
             $error['title'] = "PHP Error : Core Warning";
             $error['break'] = true;
             if ($log) {
                 $log->warn($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_COMPILE_ERROR:
             $error['title'] = "PHP Error : Compile Error";
             $error['break'] = true;
             if ($log) {
                 $log->error($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_COMPILE_WARNING:
             $error['title'] = "PHP Error : Compile Warning";
             $error['break'] = true;
             if ($log) {
                 $log->warn($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_NOTICE:
             $error['title'] = "PHP Notice";
             $error['break'] = false;
             if ($log) {
                 $log->info($error['title'] . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
         case E_STRICT:
             $error['title'] = "PHP Strict";
             $error['break'] = false;
             if ($log) {
                 $log->info($error['title'] . " (" . $errno . ")" . ", Msg: " . $error['errstr'] . " in " . $error['errfile'] . "(" . $error['errline'] . ")");
             }
             break;
     }
     // Add error number
     $error['title'] = $error['title'] . " (" . $errno . ")";
     return $error;
 }
예제 #22
0
 function _createDocs(&$man, &$input)
 {
     $result = new Moxiecode_ResultSet("status,fromfile,tofile,message");
     $config = $man->getConfig();
     if (!$man->isToolEnabled("createdoc", $config)) {
         trigger_error("{#error.no_access}", FATAL);
         die;
     }
     for ($i = 0; isset($input["frompath" . $i]) && isset($input["toname" . $i]); $i++) {
         $fromFile =& $man->getFile($input["frompath" . $i]);
         $ext = getFileExt($fromFile->getName());
         $toFile =& $man->getFile($input["topath" . $i], $input["toname" . $i] . '.' . $ext);
         $toConfig = $toFile->getConfig();
         if (checkBool($toConfig['general.demo'])) {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.demo}");
             continue;
         }
         if ($man->verifyFile($toFile, "createdoc") < 0) {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());
             continue;
         }
         if (!$toFile->canWrite()) {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");
             continue;
         }
         if (!checkBool($toConfig["filesystem.writable"])) {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");
             continue;
         }
         if (!$fromFile->exists()) {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.template_missing}");
             continue;
         }
         if ($fromFile->copyTo($toFile)) {
             // Replace title
             $fields = $input["fields"];
             // Replace all fields
             if ($fields) {
                 // Read all data
                 $stream = $toFile->open('r');
                 $fileData = $stream->readToEnd();
                 $stream->close();
                 // Replace fields
                 foreach ($fields as $name => $value) {
                     $fileData = str_replace('${' . $name . '}', htmlentities($value), $fileData);
                 }
                 // Write file data
                 $stream = $toFile->open('w');
                 $stream->write($fileData);
                 $stream->close();
             }
             $result->add("OK", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#message.createdoc_success}");
         } else {
             $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.createdoc_failed}");
         }
     }
     return $result->toArray();
 }