コード例 #1
0
 public function writeFile($type, $f, $content)
 {
     $files = $this->getFilesFromType($type);
     if (!isset($files[$f])) {
         throw new Exception(__('File does not exist.'));
     }
     try {
         $dest = $this->getDestinationFile($type, $f);
         if ($dest == false) {
             throw new Exception();
         }
         if ($type == 'tpl' && !is_dir(dirname($dest))) {
             files::makeDir(dirname($dest));
         }
         $fp = @fopen($dest, 'wb');
         if (!$fp) {
             throw new Exception('tocatch');
         }
         $content = preg_replace('/(\\r?\\n)/m', "\n", $content);
         $content = preg_replace('/\\r/m', "\n", $content);
         fwrite($fp, $content);
         fclose($fp);
         # Updating inner files list
         $this->updateFileInList($type, $f, $dest);
     } catch (Exception $e) {
         throw new Exception(sprintf(__('Unable to write file %s. Please check your theme files and folders permissions.'), $f));
     }
 }
コード例 #2
0
 /**
  * Ecrit un fichier avec les données envoyées en POST.
  *
  * @param string $sFilename
  * @return void
  */
 public function writeFileFromPost($sFilename)
 {
     if (!is_dir(dirname($sFilename))) {
         files::makeDir(dirname($sFilename), true);
     }
     $aValues = array_merge($this->getDefaultValues(), $this->getPostValues());
     $sFileContent = $this->getFileContent($aValues);
     file_put_contents($sFilename, $sFileContent);
 }
コード例 #3
0
 /**
  * Constructor.
  *
  * @param string $sLogDir
  */
 public function __construct($sLogDir = null)
 {
     if (is_null($sLogDir)) {
         $sLogDir = OKT_LOG_PATH;
     }
     $this->sLogDir = $sLogDir;
     if (!is_dir($this->sLogDir)) {
         files::makeDir($this->sLogDir, true);
     }
 }
コード例 #4
0
 /**
  * Make basis directories
  *
  */
 protected function makeDirs()
 {
     if (file_exists($this->dir)) {
         throw new Exception(sprintf(__('m_development_bootstrap_module_allready_exists'), $this->id));
     }
     files::makeDir($this->dir);
     files::makeDir($this->dir . '/_install', true);
     files::makeDir($this->dir . '/_install/tpl', true);
     files::makeDir($this->dir . '/inc', true);
     files::makeDir($this->dir . '/inc/admin', true);
     files::makeDir($this->dir . '/locales', true);
     files::makeDir($this->dir . '/locales/fr', true);
     files::makeDir($this->dir . '/locales/en', true);
 }
コード例 #5
0
ファイル: class.oktMedia.php プロジェクト: jewelhuq/okatea
 /**
  * Object constructor.
  *
  * @param object $core oktCore instance
  * @param string $type Media type filter
  * @return void
  */
 public function __construct($okt, $type = '')
 {
     $this->okt = $okt;
     $this->db = $okt->db;
     $this->config = $okt->media_manager->config;
     $this->t_media = $this->db->prefix . 'mod_media';
     $this->t_users = $this->db->prefix . 'core_users';
     $this->icon_img = OKT_PUBLIC_URL . '/img/media/%s.png';
     $root = OKT_UPLOAD_PATH . '/media_manager/';
     if (!is_dir($root)) {
         files::makeDir($root, true);
     }
     if (preg_match('#^http(s)?://#', OKT_UPLOAD_URL . '/media_manager/')) {
         $root_url = rawurldecode(OKT_UPLOAD_URL . '/media_manager/');
     } else {
         $root_url = rawurldecode($this->okt->config->app_host . path::clean(OKT_UPLOAD_URL . '/media_manager/'));
     }
     if (!is_dir($root)) {
         throw new Exception(sprintf(__('Directory %s does not exist.'), $root));
     }
     $this->type = $type;
     parent::__construct($root, $root_url);
     $this->chdir('');
     $this->path = OKT_UPLOAD_URL . '/media_manager/';
     //		$this->addExclusion(DC_RC_PATH);
     //		$this->addExclusion(__DIR__.'/../');
     $this->exclude_pattern = $this->config->media_exclusion;
     # Event handlers
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/gif', 'create', array($this, 'imageThumbCreate'));
     $this->addFileHandler('image/png', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/jpeg', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/gif', 'update', array($this, 'imageThumbUpdate'));
     $this->addFileHandler('image/png', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/gif', 'remove', array($this, 'imageThumbRemove'));
     $this->addFileHandler('image/jpeg', 'create', array($this, 'imageMetaCreate'));
     # Thumbnails sizes
     $this->thumb_sizes['m'][0] = abs($this->config->media_img_m_size);
     $this->thumb_sizes['s'][0] = abs($this->config->media_img_s_size);
     $this->thumb_sizes['t'][0] = abs($this->config->media_img_t_size);
 }
コード例 #6
0
ファイル: module_handler.php プロジェクト: jewelhuq/okatea
 /**
  * Récupération des informations de version sur le dépot distant.
  *
  */
 protected function getVersionInfo($sVersionType)
 {
     $this->resetVersionInfos();
     $sVersionType = $sVersionType == 'dev' ? 'dev' : 'stable';
     $this->sCacheFile = OKT_CACHE_PATH . '/releases/okatea-' . $sVersionType;
     # Check cached file
     if (is_readable($this->sCacheFile) && filemtime($this->sCacheFile) > strtotime($this->sCacheTtl)) {
         $c = @file_get_contents($this->sCacheFile);
         $c = @unserialize($c);
         if (is_array($c)) {
             $this->aVersionInfo = $c;
             return $this->aVersionInfo;
         }
     }
     $sCacheDir = dirname($this->sCacheFile);
     $bCanWrite = !is_dir($sCacheDir) && is_writable(dirname($sCacheDir)) || !file_exists($this->sCacheFile) && is_writable($sCacheDir) || is_writable($this->sCacheFile);
     # If we can't write file, don't bug host with queries
     if (!$bCanWrite) {
         return $this->aVersionInfo;
     }
     if (!is_dir($sCacheDir)) {
         try {
             files::makeDir($sCacheDir);
         } catch (Exception $e) {
             return $this->aVersionInfo;
         }
     }
     # Try to get latest version number
     try {
         $sFilename = $this->sRepositoryPath . '/packages/versions.xml';
         if (!file_exists($sFilename)) {
             throw new Exception('File version.xml not found.');
         }
         $this->readVersion(file_get_contents($this->sRepositoryPath . '/packages/versions.xml'), $sVersionType);
     } catch (Exception $e) {
         return $this->aVersionInfo;
     }
     # Create cache
     file_put_contents($this->sCacheFile, serialize($this->aVersionInfo));
     return $this->aVersionInfo;
 }
コード例 #7
0
ファイル: class.oktUpdate.php プロジェクト: jewelhuq/okatea
 /**
  * Récupération des informations de version sur le dépot distant.
  *
  */
 public function getVersionInfo()
 {
     # Check cached file
     if (is_readable($this->sCacheFile) && filemtime($this->sCacheFile) > strtotime($this->sCacheTtl)) {
         $c = @file_get_contents($this->sCacheFile);
         $c = @unserialize($c);
         if (is_array($c)) {
             $this->aVersionInfo = $c;
             return;
         }
     }
     $sCacheDir = dirname($this->sCacheFile);
     $bCanWrite = !is_dir($sCacheDir) && is_writable(dirname($sCacheDir)) || !file_exists($this->sCacheFile) && is_writable($sCacheDir) || is_writable($this->sCacheFile);
     # If we can't write file, don't bug host with queries
     if (!$bCanWrite) {
         return;
     }
     if (!is_dir($sCacheDir)) {
         try {
             files::makeDir($sCacheDir);
         } catch (Exception $e) {
             return;
         }
     }
     # Try to get latest version number
     try {
         $sPath = '';
         $oClient = netHttp::initClient($this->sUrl, $sPath);
         if ($oClient !== false) {
             $oClient->setTimeout(4);
             $oClient->setUserAgent($_SERVER['HTTP_USER_AGENT']);
             $oClient->get($sPath);
             $this->readVersion($oClient->getContent());
         }
     } catch (Exception $e) {
     }
     # Create cache
     file_put_contents($this->sCacheFile, serialize($this->aVersionInfo));
 }
コード例 #8
0
 /**
  * New directory
  *
  * Creates a new directory <var>$d</var> relative to working directory.
  *
  * @param string	$d			Directory name
  */
 public function makeDir($d)
 {
     files::makeDir($this->pwd . '/' . path::clean($d));
 }
コード例 #9
0
ファイル: wizard.php プロジェクト: nikrou/dotclear
}
if (!is_writable(dirname(DC_RC_PATH))) {
    $err = '<p>' . sprintf(__('Path <strong>%s</strong> is not writable.'), path::real(dirname(DC_RC_PATH))) . '</p>' . '<p>' . __('Dotclear installation wizard could not create configuration file for you. ' . 'You must change folder right or create the <strong>config.php</strong> ' . 'file manually, please refer to ' . '<a href="http://dotclear.org/documentation/2.0/admin/install">' . 'the documentation</a> to learn how to do this.') . '</p>';
}
$DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : (function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
$DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : '';
$DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : '';
$DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : '';
$DBPASSWORD = !empty($_POST['DBPASSWORD']) ? $_POST['DBPASSWORD'] : '';
$DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'dc_';
if (!empty($_POST)) {
    try {
        if ($DBDRIVER == 'sqlite') {
            if (strpos($DBNAME, '/') === false) {
                $sqlite_db_directory = dirname(DC_RC_PATH) . '/../db/';
                files::makeDir($sqlite_db_directory, true);
                # Can we write sqlite_db_directory ?
                if (!is_writable($sqlite_db_directory)) {
                    throw new Exception(sprintf(__('Cannot write "%s" directory.'), path::real($sqlite_db_directory, false)));
                }
                $DBNAME = $sqlite_db_directory . $DBNAME;
            }
        }
        # Tries to connect to database
        try {
            $con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, $DBPASSWORD);
        } catch (Exception $e) {
            throw new Exception('<p>' . __($e->getMessage()) . '</p>');
        }
        # Checks system capabilites
        require dirname(__FILE__) . '/check.php';
コード例 #10
0
 public static function canWriteImages($create = false)
 {
     global $core;
     $public = path::real($core->blog->public_path);
     $imgs = self::imagesPath();
     if (!function_exists('imagecreatetruecolor') || !function_exists('imagepng') || !function_exists('imagecreatefrompng')) {
         return false;
     }
     if (!is_dir($public)) {
         return false;
     }
     if (!is_dir($imgs)) {
         if (!is_writable($public)) {
             return false;
         }
         if ($create) {
             files::makeDir($imgs);
         }
         return true;
     }
     if (!is_writable($imgs)) {
         return false;
     }
     return true;
 }
コード例 #11
0
ファイル: index.php プロジェクト: nikrou/dcCKEditorAddons
         $core->blog->settings->dcCKEditorAddons->put('active', $dcckeditor_addons_active, 'boolean');
         // change other settings only if they were in html page
         if ($dcckeditor_addons_was_actived) {
             $dcckeditor_addons_check_validity = empty($_POST['dcckeditor_addons_check_validity']) ? false : true;
             $core->blog->settings->dcCKEditorAddons->put('check_validity', $dcckeditor_addons_check_validity, 'boolean');
             if (empty($_POST['dcckeditor_addons_repository_path']) || trim($_POST['dcckeditor_addons_repository_path']) == '') {
                 $tmp_repository = $core->blog->public_path . '/dcckeditor_addons';
             } else {
                 $tmp_repository = trim($_POST['dcckeditor_addons_repository_path']);
             }
             if (is_dir($tmp_repository) && is_writable($tmp_repository)) {
                 $core->blog->settings->related->put('repository_path', $tmp_repository);
                 $repository = $tmp_repository;
             } else {
                 try {
                     files::makeDir($tmp_repository);
                     $core->blog->settings->dcCKEditorAddons->put('repository_path', $tmp_repository);
                     $repository = $tmp_repository;
                 } catch (Exception $e) {
                     throw new Exception(sprintf(__('Directory "%s" for dcCKEditorAddons plugins repository needs to allow read and write access.'), $tmp_repository));
                 }
             }
         }
         dcPage::addSuccessNotice(__('The configuration has been updated.'));
         http::redirect($p_url);
     } catch (Exception $e) {
         $core->error->add($e->getMessage());
     }
 } elseif (!empty($_POST['upload_plugin']) && !empty($_FILES['plugin_file']) || !empty($_POST['fetch_plugin']) && !empty($_POST['plugin_url'])) {
     if (empty($_POST['your_pwd']) || !$core->auth->checkPassword($core->auth->crypt($_POST['your_pwd']))) {
         dcPage::addErrorNotice(__('Password verification failed'));
コード例 #12
0
ファイル: class.dc.modules.php プロジェクト: nikrou/dotclear
 public static function installPackage($zip_file, dcModules &$modules)
 {
     $zip = new fileUnzip($zip_file);
     $zip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.hg|\\.git|\\.DS_Store|\\.directory|Thumbs\\.db)(/|$)#');
     $zip_root_dir = $zip->getRootDir();
     $define = '';
     if ($zip_root_dir != false) {
         $target = dirname($zip_file);
         $destination = $target . '/' . $zip_root_dir;
         $define = $zip_root_dir . '/_define.php';
         $has_define = $zip->hasFile($define);
     } else {
         $target = dirname($zip_file) . '/' . preg_replace('/\\.([^.]+)$/', '', basename($zip_file));
         $destination = $target;
         $define = '_define.php';
         $has_define = $zip->hasFile($define);
     }
     if ($zip->isEmpty()) {
         $zip->close();
         unlink($zip_file);
         throw new Exception(__('Empty module zip file.'));
     }
     if (!$has_define) {
         $zip->close();
         unlink($zip_file);
         throw new Exception(__('The zip file does not appear to be a valid Dotclear module.'));
     }
     $ret_code = 1;
     if (!is_dir($destination)) {
         try {
             files::makeDir($destination, true);
             $sandbox = clone $modules;
             $zip->unzip($define, $target . '/_define.php');
             $sandbox->resetModulesList();
             $sandbox->requireDefine($target, basename($destination));
             unlink($target . '/_define.php');
             $new_errors = $sandbox->getErrors();
             if (!empty($new_errors)) {
                 $new_errors = is_array($new_errors) ? implode(" \n", $new_errors) : $new_errors;
                 throw new Exception($new_errors);
             }
             files::deltree($destination);
         } catch (Exception $e) {
             $zip->close();
             unlink($zip_file);
             files::deltree($destination);
             throw new Exception($e->getMessage());
         }
     } else {
         # test for update
         $sandbox = clone $modules;
         $zip->unzip($define, $target . '/_define.php');
         $sandbox->resetModulesList();
         $sandbox->requireDefine($target, basename($destination));
         unlink($target . '/_define.php');
         $new_modules = $sandbox->getModules();
         if (!empty($new_modules)) {
             $tmp = array_keys($new_modules);
             $id = $tmp[0];
             $cur_module = $modules->getModules($id);
             if (!empty($cur_module) && (defined('DC_DEV') && DC_DEV === true || dcUtils::versionsCompare($new_modules[$id]['version'], $cur_module['version'], '>', true))) {
                 # delete old module
                 if (!files::deltree($destination)) {
                     throw new Exception(__('An error occurred during module deletion.'));
                 }
                 $ret_code = 2;
             } else {
                 $zip->close();
                 unlink($zip_file);
                 throw new Exception(sprintf(__('Unable to upgrade "%s". (older or same version)'), basename($destination)));
             }
         } else {
             $zip->close();
             unlink($zip_file);
             throw new Exception(sprintf(__('Unable to read new _define.php file')));
         }
     }
     $zip->unzipAll($target);
     $zip->close();
     unlink($zip_file);
     return $ret_code;
 }
コード例 #13
0
ファイル: index.php プロジェクト: jewelhuq/okatea
	var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
	window.addEventListener("keydown", function(e){
		kkeys.push(e.keyCode);
		if (kkeys.toString().indexOf( konami ) >= 0) {
			window.location = "http://jquery.com/";
		}
	}, true);
}
');
# News feed reader
if ($okt->config->news_feed['enabled'] && !empty($okt->config->news_feed['url'][$okt->user->language])) {
    require_once OKT_VENDOR_PATH . '/simplepie/autoloader.php';
    // We'll process this feed with all of the default options.
    $feed = new SimplePie();
    if (!is_dir(OKT_CACHE_PATH . '/feeds/')) {
        files::makeDir(OKT_CACHE_PATH . '/feeds/', true);
    }
    $feed->set_cache_location(OKT_CACHE_PATH . '/feeds/');
    // Set which feed to process.
    $feed->set_feed_url($okt->config->news_feed['url'][$okt->user->language]);
    // Run SimplePie.
    $feed_success = $feed->init();
    // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
    $feed->handle_content_type();
    $okt->page->css->addCss('
		#news_feed_list {
			height: 13em;
			width: 28%;
			overflow-y: scroll;
			overflow-x: hidden;
			padding-right: 0.8em;
コード例 #14
0
ファイル: class.filemanager.php プロジェクト: jewelhuq/okatea
 function newDir($name)
 {
     $name = str_replace('/', '', $name);
     return files::makeDir($this->root . $this->base_path . '/' . $name);
 }
コード例 #15
0
ファイル: class.unzip.php プロジェクト: jewelhuq/okatea
 protected function testTargetDir($dir)
 {
     if (is_dir($dir) && !is_writable($dir)) {
         throw new Exception(__('Unable to write in target directory, permission denied.'));
     }
     if (!is_dir($dir)) {
         files::makeDir($dir, true);
     }
 }
コード例 #16
0
 public function install()
 {
     global $core;
     $zip = new fileUnzip($this->zip_file);
     if ($zip->isEmpty()) {
         $zip->close();
         unlink($this->zip_file);
         throw new Exception(__('Empty plugin zip file.'));
     }
     $zip_root_dir = $zip->getRootDir();
     if (!$zip_root_dir) {
         // try to find a root anyway if all dirs start with same pattern
         $dirs = $zip->getDirsList();
         $n = 0;
         $zip_root_dir = substr($dirs[0], 0, strpos($dirs[0], '/'));
         foreach ($dirs as $dir) {
             if ($zip_root_dir != substr($dirs[0], 0, strpos($dirs[0], '/'))) {
                 $n++;
             }
         }
         if ($n > 0) {
             $zip_root_dir = false;
         }
     }
     if ($zip_root_dir != false) {
         $target = dirname($this->zip_file);
         $destination = $target . '/' . $zip_root_dir;
         $plugin_js = $zip_root_dir . '/plugin.js';
         $has_plugin_js = $zip->hasFile($plugin_js);
     } else {
         $target = dirname($this->zip_file) . '/' . preg_replace('/\\.([^.]+)$/', '', basename($this->zip_file));
         $destination = $target;
         $plugin_js = 'plugin.js';
         $has_plugin_js = $zip->hasFile($plugin_js);
     }
     if ($core->blog->settings->dcCKEditorAddons->check_validity) {
         if (!$has_plugin_js) {
             $zip->close();
             unlink($this->zip_file);
             throw new Exception(__('The zip file does not appear to be a valid CKEditor addon.'));
         }
     }
     if (!is_dir($destination)) {
         files::makeDir($destination, true);
     }
     $zip->unzipAll($target);
     $zip->close();
     unlink($this->zip_file);
 }
コード例 #17
0
 /**
  * Modification des fichiers
  *
  * @return array
  */
 public function updFiles($iItemId, $aCurrentFiles = array())
 {
     $aNewFiles = array();
     $j = 1;
     for ($i = 1; $i <= $this->config['number']; $i++) {
         if (!isset($_FILES[sprintf($this->config['files_patern'], $i)]) || empty($_FILES[sprintf($this->config['files_patern'], $i)]['tmp_name'])) {
             if (isset($aCurrentFiles[$i])) {
                 $aNewFiles[$j] = array('filename' => $aCurrentFiles[$i]['filename'], 'title' => !empty($_REQUEST[sprintf($this->config['files_title_patern'], $i)]) ? $_REQUEST[sprintf($this->config['files_title_patern'], $i)] : $aCurrentFiles[$i]['title']);
                 $j++;
             }
             continue;
         }
         $sUploadedFile = $_FILES[sprintf($this->config['files_patern'], $i)];
         try {
             $sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
             # des erreurs d'upload ?
             util::uploadStatus($sUploadedFile);
             # vérification de l'extension
             $this->checkFile($sExtension);
             # vérification du type
             //				$aAllowedTypes = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
             //				if (!in_array($sUploadedFile['type'], $aAllowedTypes)) {
             //					throw new Exception('Type de fichier non-autorisé.');
             //				}
             # création du répertoire s'il existe pas
             if (!file_exists($this->upload_dir)) {
                 files::makeDir($this->upload_dir, true);
             }
             # suppression de l'éventuel ancien fichier
             if (isset($aCurrentFiles[$i]) && files::isDeletable($this->upload_dir . $aCurrentFiles[$i])) {
                 unlink($this->upload_dir . $aCurrentFiles[$i]);
             }
             $sDestination = $this->upload_dir . $iItemId . '-' . $j . '.' . $sExtension;
             if (!move_uploaded_file($sUploadedFile['tmp_name'], $sDestination)) {
                 throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
             }
             $aNewFiles[$j] = array('filename' => basename($sDestination), 'title' => !empty($_REQUEST[sprintf($this->config['files_title_patern'], $i)]) ? $_REQUEST[sprintf($this->config['files_title_patern'], $i)] : $j);
             $j++;
         } catch (Exception $e) {
             $this->okt->error->set('Problème avec le fichier ' . $i . ' : ' . $e->getMessage());
         }
     }
     return array_filter($aNewFiles);
 }
コード例 #18
0
 /**
  * Get repository modules list using cache.
  *
  * @param	string	$url		XML feed URL
  * @return	array	Feed content or False on fail
  */
 protected function withCache($url)
 {
     $url_md5 = md5($url);
     $cached_file = sprintf('%s/%s/%s/%s/%s.ser', $this->cache_dir, $this->cache_file_prefix, substr($url_md5, 0, 2), substr($url_md5, 2, 2), $url_md5);
     $may_use_cached = false;
     # Use cache file ?
     if (@file_exists($cached_file) && !$this->force) {
         $may_use_cached = true;
         $ts = @filemtime($cached_file);
         if ($ts > strtotime($this->cache_ttl)) {
             # Direct cache
             return unserialize(file_get_contents($cached_file));
         }
         $this->setValidator('IfModifiedSince', $ts);
     }
     # Query repository
     if (!$this->getModulesXML($url)) {
         if ($may_use_cached) {
             # Touch cache TTL even if query failed ?
             if ($this->cache_touch_on_fail) {
                 @files::touch($cached_file);
             }
             # Connection failed - fetched from cache
             return unserialize(file_get_contents($cached_file));
         }
         return false;
     }
     # Parse response
     switch ($this->getStatus()) {
         # Not modified, use cache
         case '304':
             @files::touch($cached_file);
             return unserialize(file_get_contents($cached_file));
             # Ok, parse feed
         # Ok, parse feed
         case '200':
             if ($modules = new dcStoreParser($this->getContent())) {
                 try {
                     files::makeDir(dirname($cached_file), true);
                 } catch (Exception $e) {
                     return $modules;
                 }
                 if ($fp = @fopen($cached_file, 'wb')) {
                     fwrite($fp, serialize($modules));
                     fclose($fp);
                     files::inheritChmod($cached_file);
                 }
                 return $modules;
             }
     }
     return false;
 }
コード例 #19
0
ファイル: config.php プロジェクト: jewelhuq/okatea
$css_admin = $oktConfig->minify_css_admin;
$js_admin = $oktConfig->minify_js_admin;
$css_public = $oktConfig->minify_css_public;
$js_public = $oktConfig->minify_js_public;
function oktReplaceMinifyURLStrings(&$str)
{
    $aReplacements = util::getMinifyReplacements($GLOBALS['oktConfig']);
    $str = '/' . str_replace($aReplacements['aSearch'], $aReplacements['aReplace'], $str);
}
array_walk($css_admin, 'oktReplaceMinifyURLStrings');
array_walk($js_admin, 'oktReplaceMinifyURLStrings');
array_walk($css_public, 'oktReplaceMinifyURLStrings');
array_walk($js_public, 'oktReplaceMinifyURLStrings');
$oktMinifyConfig = array('js_admin' => $js_admin, 'css_admin' => $css_admin, 'js_public' => $js_public, 'css_public' => $css_public);
if (!is_dir(OKT_CACHE_PATH . '/minify')) {
    files::makeDir(OKT_CACHE_PATH . '/minify');
}
$min_enableBuilder = false;
$min_cachePath = OKT_CACHE_PATH . '/minify';
$min_serveOptions['maxAge'] = 3600 * 12;
// 12 hours
$min_serveOptions['minApp']['groupsOnly'] = true;
/**
 * END OKATEA CONFIG
 */
/**
 * Allow use of the Minify URI Builder app. Only set this to true while you need it.
 */
//$min_enableBuilder = false;
/**
 * If non-empty, the Builder will be protected with HTTP Digest auth.
コード例 #20
0
ファイル: display.php プロジェクト: jewelhuq/okatea
 $sTempDir = OKT_ROOT_PATH . '/temp/';
 $sZipFilename = $sTempDir . $sUploadedFile['name'];
 try {
     # on supprime l'éventuel répertoire temporaire s'il existe déjà
     if (is_dir($sTempDir)) {
         files::deltree($sTempDir);
     }
     $sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
     # des erreurs d'upload ?
     util::uploadStatus($sUploadedFile);
     # vérification de l'extension
     if ($sExtension != 'zip') {
         throw new Exception(__('c_a_config_display_not_zip_file'));
     }
     # création répertoire temporaire
     files::makeDir($sTempDir);
     if (!move_uploaded_file($sUploadedFile['tmp_name'], $sZipFilename)) {
         throw new Exception(__('c_a_config_display_unable_move_file'));
     }
     $oZip = new fileUnzip($sZipFilename);
     $oZip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|Thumbs\\.db|development-bundle|js)(/|$)#');
     $zip_root_dir = $oZip->getRootDir();
     if ($zip_root_dir !== false) {
         $sTargetDir = dirname($sZipFilename);
         $sDestinationDir = $sTargetDir . '/' . $zip_root_dir;
         $sCssFilename = $zip_root_dir . '/css/custom-theme/' . basename($sTargetDir) . '.css';
         $hasCssFile = $oZip->hasFile($sCssFilename);
     } else {
         $zip_root_dir = preg_replace('/\\.([^.]+)$/', '', basename($sZipFilename));
         $sTargetDir = dirname($sZipFilename) . '/' . $zip_root_dir;
         $sDestinationDir = $sTargetDir;
コード例 #21
0
 /**
  * Réalise l'upload d'une simple image et retourne son chemin.
  *
  * Par exemple utilisé pour l'upload des filigrane.
  *
  * Il n'y a PAS de création de miniature.
  *
  * @param $form_input_name 		Le nom du champs du formulaire
  * @param $sCurrentImageDir 	Le chemin du répertoire destination
  * @param $sFilename 			Le nom du fichier destination sans l'extension
  * @return string 				Le nom de l'image
  */
 public static function getSingleUploadedFile($form_input_name = 'p_file', $sCurrentImageDir, $sFilename)
 {
     global $okt;
     $return = '';
     if (isset($_FILES[$form_input_name]) && !empty($_FILES[$form_input_name]['tmp_name'])) {
         $sUploadedFile = $_FILES[$form_input_name];
         try {
             # extension du fichier
             $sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
             # des erreurs d'upload ?
             util::uploadStatus($sUploadedFile);
             # vérification de l'extension
             self::checkExtension($sExtension);
             # vérification du type
             self::checkType($sUploadedFile['type']);
             # création du répertoire s'il existe pas
             if (!file_exists($sCurrentImageDir)) {
                 files::makeDir($sCurrentImageDir, true);
             }
             # nom du fichier
             $sOutput = $sFilename . '.' . $sExtension;
             # suppression de l'éventuel ancien fichier
             if (file_exists($sCurrentImageDir . $sOutput) && files::isDeletable($sCurrentImageDir . $sOutput)) {
                 unlink($sCurrentImageDir . $sOutput);
             }
             if (!move_uploaded_file($sUploadedFile['tmp_name'], $sCurrentImageDir . $sOutput)) {
                 throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
             }
             $return = $sOutput;
         } catch (Exception $e) {
             $okt->error->set('Problème avec l’image : ' . $e->getMessage());
         }
     }
     return $return;
 }
コード例 #22
0
ファイル: module_handler.php プロジェクト: jewelhuq/okatea
 /**
  * Modification des fichiers
  *
  * @return void
  */
 protected function editFiles()
 {
     $aCurrentFiles = $this->getQuestion($this->params['id'])->getFilesInfo();
     $aNewFiles = array();
     foreach ($this->okt->languages->list as $aLanguage) {
         $aNewFiles[$aLanguage['code']] = array();
         $j = 1;
         for ($i = 0; $i <= $this->config->files['number']; $i++) {
             if (!isset($_FILES['p_files_' . $aLanguage['code'] . '_' . $i]) || empty($_FILES['p_files_' . $aLanguage['code'] . '_' . $i]['tmp_name'])) {
                 if (!empty($aCurrentFiles[$aLanguage['code']][$i])) {
                     $aNewFiles[$aLanguage['code']][$i] = $aCurrentFiles[$aLanguage['code']][$i]['filename'];
                     $j++;
                 }
                 continue;
             }
             $sUploadedFile = $_FILES['p_files_' . $aLanguage['code'] . '_' . $i];
             try {
                 # des erreurs d'upload ?
                 util::uploadStatus($sUploadedFile);
                 # vérification de l'extension
                 $sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
                 if (!in_array($sExtension, explode(',', $this->config->files['allowed_exts']))) {
                     throw new Exception('Type de fichier non-autorisé.');
                 }
                 if (!file_exists($this->upload_dir)) {
                     files::makeDir($this->upload_dir, true);
                 }
                 if (!empty($aCurrentFiles[$aLanguage['code']][$i]) && files::isDeletable($this->upload_dir . $aCurrentFiles[$aLanguage['code']][$i]['filename'])) {
                     unlink($this->upload_dir . $aCurrentFiles[$aLanguage['code']][$i]['filename']);
                 }
                 $sDestination = $this->upload_dir . util::strToLowerURL($this->params['title'][$aLanguage['code']], false) . '-' . $aLanguage['code'] . '-' . $j . '.' . $sExtension;
                 if (!move_uploaded_file($sUploadedFile['tmp_name'], $sDestination)) {
                     throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
                 }
                 $aNewFiles[$aLanguage['code']][] = basename($sDestination);
                 $j++;
             } catch (Exception $e) {
                 $this->okt->error->set('Pour le fichier ' . $i . ' dans la langue ' . $aLanguage['code'] . ' : ' . $e->getMessage());
             }
         }
     }
     $this->params['files'] = $aNewFiles;
 }
コード例 #23
0
 public function getFile($file)
 {
     $tpl_file = $this->getFilePath($file);
     if (!$tpl_file) {
         throw new Exception('No template found for ' . $file);
         return false;
     }
     $file_md5 = md5($tpl_file);
     $dest_file = sprintf('%s/%s/%s/%s/%s.php', $this->cache_dir, 'cbtpl', substr($file_md5, 0, 2), substr($file_md5, 2, 2), $file_md5);
     clearstatcache();
     $stat_f = $stat_d = false;
     if (file_exists($dest_file)) {
         $stat_f = stat($tpl_file);
         $stat_d = stat($dest_file);
     }
     # We create template if:
     # - dest_file doest not exists
     # - we don't want cache
     # - dest_file size == 0
     # - tpl_file is more recent thant dest_file
     if (!$stat_d || !$this->use_cache || $stat_d['size'] == 0 || $stat_f['mtime'] > $stat_d['mtime']) {
         files::makeDir(dirname($dest_file), true);
         if (($fp = @fopen($dest_file, 'wb')) === false) {
             throw new Exception('Unable to create cache file');
         }
         $fc = $this->compileFile($tpl_file);
         fwrite($fp, $fc);
         fclose($fp);
         files::inheritChmod($dest_file);
     }
     return $dest_file;
 }
コード例 #24
0
 /**
  * Force le remplacement des fichiers de façon récursive dans les fichiers
  *
  */
 protected function forceReplaceFiles($sSourceDir, $sDestDir, $aLockedFiles = array())
 {
     if (!is_dir($sSourceDir)) {
         return false;
     }
     $aSources = files::getDirList($sSourceDir);
     $aDests = array();
     foreach ($aSources['files'] as $file) {
         $aDests[] = str_replace($sSourceDir, '', $file);
     }
     if (!is_dir($sDestDir)) {
         files::makeDir($sDestDir, true);
     }
     foreach ($aDests as $file) {
         $parent_dir = dirname($sDestDir . $file);
         if (!is_dir($parent_dir)) {
             files::makeDir($parent_dir, true);
         }
         if (in_array($sDestDir . $file, $aLockedFiles)) {
             continue;
         }
         if (file_exists($sDestDir . $file)) {
             if (file_exists($sDestDir . $file . '.bak')) {
                 unlink($sDestDir . $file . '.bak');
             }
             rename($sDestDir . $file, $sDestDir . $file . '.bak');
         }
         copy($sSourceDir . $file, $sDestDir . $file);
     }
     return true;
 }
コード例 #25
0
ファイル: class.oktThemes.php プロジェクト: jewelhuq/okatea
 /**
  * Permet de créer un thème vierge.
  *
  * @param string $sId
  */
 public function bootstrapTheme($sName, $sId = null)
 {
     if (empty($sId)) {
         $sId = util::strToLowerURL($sName, false);
     }
     $this->getThemesList();
     if (isset($this->aThemes[$sId])) {
         return $sId;
     }
     $sThemePath = $this->sPath . '/' . $sId;
     $aSearch = array('{{theme_id}}', '{{theme_name}}');
     $aReplace = array($sId, html::escapeHTML($sName));
     try {
         # required files
         files::makeDir($sThemePath);
         file_put_contents($sThemePath . '/_define.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/_define.tpl')));
         file_put_contents($sThemePath . '/index.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/index.tpl')));
         file_put_contents($sThemePath . '/oktTheme.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/oktTheme.tpl')));
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/locked_files.txt', $sThemePath . '/locked_files.txt');
         # css files
         files::makeDir($sThemePath . '/css');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/definitions.less.tpl', $sThemePath . '/css/definitions.less');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/css/index.html');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/overload.less.tpl', $sThemePath . '/css/overload.less');
         # images files
         files::makeDir($sThemePath . '/images');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/images/index.html');
         # js
         files::makeDir($sThemePath . '/js');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/js/index.html');
         # locales files
         files::makeDir($sThemePath . '/locales');
         files::makeDir($sThemePath . '/locales/fr');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/locales/fr/index.html');
         # modules files
         files::makeDir($sThemePath . '/modules');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/modules/index.html');
         # templates files
         files::makeDir($sThemePath . '/templates');
         copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/templates/index.html');
         copy(OKT_THEMES_PATH . '/default/templates/layout.php', $sThemePath . '/templates/layout.php');
         return $sId;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
コード例 #26
0
ファイル: add_zip.php プロジェクト: jewelhuq/okatea
     //	}
     $sTempDir = $okt->galleries->upload_dir . '/temp/';
     files::makeDir($sTempDir, true);
     $sZipFile = $sTempDir . $_FILES['p_zip_file']['name'];
     if (!move_uploaded_file($_FILES['p_zip_file']['tmp_name'], $sZipFile)) {
         throw new Exception(__('m_galleries_zip_error_unable_move_uploaded_file'));
     }
     $oZip = new fileUnzip($sZipFile);
     foreach ($oZip->getList() as $sFileName => $aFileInfos) {
         $sFileExtension = pathinfo($sFileName, PATHINFO_EXTENSION);
         if ($aFileInfos['is_dir'] || !in_array(strtolower($sFileExtension), array('jpg', 'gif', 'png'))) {
             continue;
         }
         $iItemId = $okt->galleries->items->addItem($okt->galleries->items->openItemCursor(array('gallery_id' => $iGalleryId, 'active' => 1)), $aItemLocalesData);
         $sDestination = $okt->galleries->upload_dir . '/img/items/' . $iItemId . '/1.' . $sFileExtension;
         files::makeDir(dirname($sDestination), true);
         $oZip->unzip($sFileName, $sDestination);
         $aNewImagesInfos = $okt->galleries->items->getImageUploadInstance()->buildImagesInfos($iItemId, array(1 => basename($sDestination)));
         if (isset($aNewImagesInfos[1])) {
             $aNewItemImages = $aNewImagesInfos[1];
             $aNewItemImages['original_name'] = utf8_encode(basename($sFileName));
         } else {
             $aNewItemImages = array();
         }
         $okt->galleries->items->updImages($iItemId, $aNewItemImages);
     }
     $oZip->close();
     files::deltree($sTempDir);
 } catch (Exception $e) {
     $okt->error->set($e->getMessage());
 }
コード例 #27
0
 /**
  * Cache content
  *
  * Returns feedParser object from cache if present or write it to cache and
  * returns result.
  *
  * @param string	$url			Feed URL
  * @return feedParser
  */
 protected function withCache($url)
 {
     $url_md5 = md5($url);
     $cached_file = sprintf('%s/%s/%s/%s/%s.php', $this->cache_dir, $this->cache_file_prefix, substr($url_md5, 0, 2), substr($url_md5, 2, 2), $url_md5);
     $may_use_cached = false;
     if (@file_exists($cached_file)) {
         $may_use_cached = true;
         $ts = @filemtime($cached_file);
         if ($ts > strtotime($this->cache_ttl)) {
             # Direct cache
             return unserialize(file_get_contents($cached_file));
         }
         $this->setValidator('IfModifiedSince', $ts);
     }
     if (!$this->getFeed($url)) {
         if ($may_use_cached) {
             # connection failed - fetched from cache
             return unserialize(file_get_contents($cached_file));
         }
         return false;
     }
     switch ($this->getStatus()) {
         case '304':
             @files::touch($cached_file);
             return unserialize(file_get_contents($cached_file));
         case '200':
             if ($feed = new feedParser($this->getContent())) {
                 try {
                     files::makeDir(dirname($cached_file), true);
                 } catch (Exception $e) {
                     return $feed;
                 }
                 if ($fp = @fopen($cached_file, 'wb')) {
                     fwrite($fp, serialize($feed));
                     fclose($fp);
                     files::inheritChmod($cached_file);
                 }
                 return $feed;
             }
     }
     return false;
 }
コード例 #28
0
$cursor->meta_keywords = html::clean($cursor->meta_keywords);

if (!$cursor->insert()) {
	die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "unable to create item"}, "id" : "id"}');
}

# récupération de l'ID
$iNewId = $okt->db->getLastID();

# création du slug
$okt->galleries->setItemSlug($iNewId);
*/
# define the target directory
$targetDir = $okt->galleries->upload_dir . 'img/items/' . $iNewId;
if (!file_exists($targetDir)) {
    files::makeDir($targetDir, true);
}
$fileName = '1.' . pathinfo($inputFileName, PATHINFO_EXTENSION);
# Remove old temp files
if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
    while (($file = readdir($dir)) !== false) {
        $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
        # Remove temp files if they are older than the max age
        if (preg_match('/\\.tmp$/', $file) && filemtime($filePath) < time() - $maxFileAge) {
            @unlink($filePath);
        }
    }
    closedir($dir);
} else {
    die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}
コード例 #29
0
ファイル: lib.themeconfig.php プロジェクト: nikrou/dotclear
 /**
  * Check if images folder exists and may be written
  *
  * @param  string  $folder images folder
  * @param  boolean $create create the folder if not exists
  *
  * @return boolean          true if folder exists and may be written
  */
 public static function canWriteImages($folder, $create = false)
 {
     global $core;
     $public = path::real($core->blog->public_path);
     $imgs = self::imagesPath($folder);
     if (!function_exists('imagecreatetruecolor') || !function_exists('imagepng') || !function_exists('imagecreatefrompng')) {
         $core->error->add(__('At least one of the following functions is not available: ' . 'imagecreatetruecolor, imagepng & imagecreatefrompng.'));
         return false;
     }
     if (!is_dir($public)) {
         $core->error->add(__('The \'public\' directory does not exist.'));
         return false;
     }
     if (!is_dir($imgs)) {
         if (!is_writable($public)) {
             $core->error->add(sprintf(__('The \'%s\' directory cannot be modified.'), 'public'));
             return false;
         }
         if ($create) {
             files::makeDir($imgs);
         }
         return true;
     }
     if (!is_writable($imgs)) {
         $core->error->add(sprintf(__('The \'%s\' directory cannot be modified.'), 'public/' . $folder));
         return false;
     }
     return true;
 }
コード例 #30
0
ファイル: class.oktCore.php プロジェクト: jewelhuq/okatea
 /**
  * Invoque le filtre HTML qui permet de supprimer
  * le code potentiellement malveillant, les mauvaises
  * balises et produire du XHTML valide.
  *
  * @param    string    str        Chaine à filtrer
  * @return    string Chaine filtrée
  */
 public function HTMLfilter($str)
 {
     if ($this->config->htmlpurifier_disabled) {
         return $str;
     }
     if ($this->htmlpurifier === null) {
         if (!file_exists(OKT_CACHE_PATH . '/HTMLPurifier')) {
             files::makeDir(OKT_CACHE_PATH . '/HTMLPurifier', true);
         }
         if (version_compare(PHP_VERSION, '5.2.11', '>=')) {
             require_once OKT_INC_PATH . '/vendor/htmlpurifier/library/HTMLPurifier.auto.php';
         } else {
             require_once OKT_INC_PATH . '/vendor/htmlpurifier/library/HTMLPurifier/Bootstrap.php';
             spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'));
         }
         $config = HTMLPurifier_Config::createDefault();
         $config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
         $config->set('Cache.SerializerPath', OKT_CACHE_PATH . '/HTMLPurifier');
         $config->set('HTML.SafeEmbed', true);
         $config->set('HTML.SafeObject', true);
         $config->set('Output.FlashCompat', true);
         $config->set('HTML.SafeIframe', true);
         $config->set('URI.SafeIframeRegexp', '%^http://(www.youtube.com/embed/|player.vimeo.com/video/)%');
         # autorise les ID
         # http://htmlpurifier.org/docs/enduser-id.html
         $config->set('Attr.EnableID', true);
         # modification de la définition
         # http://htmlpurifier.org/docs/enduser-customize.html
         $config->set('HTML.DefinitionID', 'okatea');
         $config->set('HTML.DefinitionRev', 1);
         if ($def = $config->maybeGetRawHTMLDefinition()) {
             # autorise l'attribut target sur les liens
             $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
             # autorise l'attribut usemap sur les images
             $def->addAttribute('img', 'usemap', 'CDATA');
             # autorise l'élément map
             $map = $def->addElement('map', 'Block', 'Flow', 'Common', array('name' => 'CDATA', 'id' => 'ID', 'title' => 'CDATA'));
             $map->excludes = array('map' => true);
             # autorise l'élément area
             $area = $def->addElement('area', 'Block', 'Empty', 'Common', array('name' => 'CDATA', 'id' => 'ID', 'alt' => 'Text', 'coords' => 'CDATA', 'accesskey' => 'Character', 'nohref' => new HTMLPurifier_AttrDef_Enum(array('nohref')), 'href' => 'URI', 'shape' => new HTMLPurifier_AttrDef_Enum(array('rect', 'circle', 'poly', 'default')), 'tabindex' => 'Number', 'target' => new HTMLPurifier_AttrDef_Enum(array('_blank', '_self', '_target', '_top'))));
             $area->excludes = array('area' => true);
         }
         # get it now !
         $this->htmlpurifier = new HTMLPurifier($config);
     }
     $str = $this->htmlpurifier->purify($str);
     return $str;
 }