示例#1
0
    public function __CreatePage()
    {
        header("Content-Type: text/xml; charset=" . G::$Engine->Site['charset']);
        echo '<?xml version="1.0" encoding="' . G::$Engine->Site['charset'] . '"?>';
        echo <<<EOH
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

EOH;
        $query = "SELECT `page_path`, `page_id` \n\t\t\t\tFROM `{$this->DB->Prefix}pages`";
        foreach ($this->DB->FetchRows($query, "slave") as $row) {
            $query = "SELECT `permission_view`\n\t\t\t\t\tFROM `" . $this->DB->Prefix . "page_permissions` \n\t\t\t\t\tWHERE `page_id` = " . $row['page_id'] . " \n\t\t\t\t\tAND `group_id` = " . $this->User->Group['id'] . " \n\t\t\t\t\tLIMIT 1";
            $row2 = $this->DB->FetchRow($query, "slave");
            if ($row2['permission_view'] === "1") {
                $loc = $this->Site->URL . fix_path("/" . $row['page_path']);
                echo <<<EOH
\t<url>
\t  <loc>{$loc}</loc>
\t  <priority>0.5</priority>
\t  <changefreq>daily</changefreq>
\t</url>

EOH;
            }
        }
        echo <<<EOH

</urlset>\t\t
EOH;
    }
示例#2
0
文件: RSS.php 项目: ericmuyser/web2f
    public function __CreatePage($__page)
    {
        $this->Page->Header['Content-Type'] = "text/xml; charset=UTF-8";
        $__filename = $this->Site->Path . "/cache/" . md5($__page) . ".tpl";
        // if this file doesn't exist, or this cache is older than 6 hours
        if (!file_exists($__filename) || file_exists($__filename) && filemtime($__filename) < time() - $this->Page['cache_time']) {
            $__page = $this->GrabPage($__page);
            // set page url and remove extra slashes
            $this->Page->URL = fix_path($this->Site->URL . '/' . $__page);
            // combine all titles
            $this->Page->Title = implode(" | ", $this->Page->Title);
            // create the page theme - may default back to site theme
            $this->Page->Theme = new Theme($this->Page['theme_name']);
            $this->Page->Theme->URL = $this->Site['url'] . "/themes/" . $this->Page['theme_name'];
            $this->SaveFile($__filename, $this->TemplateEngine->Process($this->Page->Content));
            $this->Page->Content = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
            $this->Page->Content .= <<<EOH
\t\t\t\t
<rss version="2.0">
<channel>
\t<title>{$this->Site->Title}</title>
\t<link>{$this->Site->URL}</link>
\t<description>{$this->Site->Description}</description>
\t<generator>{$this->Name} {$this->Version}</generator>
\t

\t<item>
\t\t<title>{$this->Page->Title}</title>
\t\t<link>{$this->Page->URL}</link>
\t\t<description>
\t\t<![CDATA[
\t\t\t\t
EOH;
            // include the cache file that sets up the new content
            $this->Page->Content .= stripslashes($this->LoadFile($__filename, SAVE_BUFFER));
            $this->Page->Content .= <<<EOH

\t\t]]>
\t\t</description>
\t</item>

</channel>
</rss>
\t\t
EOH;
            $this->Page->Input($this->Page->Content);
            // write the php content to the file
            $this->SaveFile($__filename, $this->Page);
        } else {
            $this->Page->Input(file_get_contents($__filename));
        }
        $this->Page->GZip();
        return $this->Page;
    }
示例#3
0
function is_child($parent, $child)
{
    if (false !== ($parent = realpath($parent))) {
        $parent = fix_path($parent);
        if (false !== ($child = realpath($child))) {
            $child = fix_path($child);
            if (substr($child, 0, strlen($parent)) == $parent) {
                return true;
            }
        }
    }
    return false;
}
示例#4
0
 public function Create($page)
 {
     $this->Buffer = '';
     $page = fix_path($page);
     if (!($data = G::$Engine->DB->FetchRow("SELECT * FROM `" . G::$Engine->DB->Prefix . "pages` WHERE `page_path` = '{$page}' OR `page_path` = '/{$page}' OR `page_path` = '{$page}/' OR `page_path` = '/{$page}/' LIMIT 1", "slave"))) {
         return false;
     }
     // if the page is disabled, load the disabled page
     if ($data['state'] === "private") {
         $data = G::$Engine->DB->FetchRow("SELECT * FROM `" . G::$Engine->DB->Prefix . "pages` WHERE `page_path` = 'disabled' OR `page_path` = '/disabled'  OR `page_path` = 'disabled/' OR `page_path` = '/disabled/' LIMIT 1", "slave");
     }
     //--------------------------------
     // Lets make this easier to manage
     //--------------------------------
     $data = preg_replace_array("/^page_/i", '', $data);
     // add to our title history
     $data['title'] = isset($data['name']) && $data['name'] != '' ? array($data['name']) : isset($data['title']) && $data['title'] != '' ? array_merge($this['title'], array($data['title'])) : $this['title'];
     $this->Merge($data);
     // set mime-type header
     $this->Headers['Content-Type'] = $this['mime_type'];
     return true;
 }
示例#5
0
文件: cssjs.php 项目: phpsa/CoreCMS
             fpassthru($fp);
             fclose($fp);
             exit;
         }
     }
 }
 // Get contents of the files
 $contents = '';
 reset($elements);
 if ($type == 'css') {
     $pattern = '(url ?\\((.*?)\\))';
     $pattern2 = "@import url\\((.*?)\\);";
     while (list(, $element) = each($elements)) {
         $path = realpath($base . '/' . $element);
         $contents .= preg_replace_callback('/' . $pattern . '/', function ($input) use($element) {
             return fix_path($input, $element);
         }, file_get_contents($path)) . "\n";
         // $contents .= "\n\n" . file_get_contents($path);
     }
     if ($compress) {
         $contents = str_replace('; ', ';', str_replace(' }', '}', str_replace('{ ', '{', str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), "", preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $contents)))));
     }
 } else {
     while (list(, $element) = each($elements)) {
         $path = realpath($base . '/' . $element);
         $contents .= file_get_contents($path) . "\n";
     }
     if ($compress) {
         $contents = str_replace('; ', ';', str_replace(' }', '}', str_replace('{ ', '{', str_replace(array("\t", '  ', '    ', '    '), "", $contents))));
     }
 }
示例#6
0
define('PATH_ABS_CORE', fix_path(dirname(__FILE__) . DIRECTORY_SEPARATOR));
define('PATH_ABS_ROOT', fix_path(realpath(PATH_ABS_CORE . '..') . DIRECTORY_SEPARATOR));
define('PATH_ABS_SELF', fix_path(realpath($_SERVER['PHP_SELF'])));
$coreDiff = fix_path(preg_replace('/^' . preg_quote(PATH_ABS_ROOT, '/') . '/', '', PATH_ABS_CORE), '/');
$called = get_included_files();
$called = $called[0];
$diff = preg_replace('/^' . preg_quote(PATH_ABS_ROOT, '/') . '/', '', $called);
$relroot = preg_replace('/' . preg_quote(fix_path($diff, '/'), '/') . '$/', '', $_SERVER['SCRIPT_NAME']);
define('PATH_REL_ROOT', $relroot);
define('PATH_REL_CORE', fix_path(PATH_REL_ROOT . $coreDiff, '/'));
define('PATH_REL_SELF', fix_path(PATH_REL_ROOT . basename(PATH_ABS_SELF), '/'));
define('DEFAULT_FILE', PATH_REL_CORE . 'index.php');
define('PATH_ABS_CONFIG', fix_path(PATH_ABS_ROOT . 'uConfig.php'));
define('PATH_ABS_MODULES', fix_path(PATH_ABS_ROOT . 'uModules') . '/');
define('PATH_ABS_TEMPLATES', fix_path(PATH_ABS_ROOT . 'uTemplates') . '/');
define('PATH_ABS_THEMES', fix_path(PATH_ABS_ROOT . 'uThemes') . '/');
define('PATH_FULL_ROOT', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . PATH_REL_ROOT);
define('PATH_FULL_CORE', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . PATH_REL_CORE);
define('MAX_ORDER', 99999999);
/**
 * Initialise session
 */
ini_set('session.cookie_path', PATH_REL_ROOT);
session_cache_limiter(false);
session_name('ucore');
session_start();
$timeout = 3600;
if (isset($_SESSION['SESSION_LIFETIME'])) {
    $timeout = $_SESSION['SESSION_LIFETIME'];
}
if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > $timeout) {
示例#7
0
 public static function GetTemplates($includeDefault = false, $includeCore = true)
 {
     $userTemplates = array_merge(array_filter((array) glob(PATH_ABS_TEMPLATES . '*')), array_filter((array) glob(PATH_ABS_THEMES . '*')));
     // find all user templates
     $adminTemplates = glob(PATH_ABS_CORE . 'themes/*');
     // find all admin templates
     $nTemplates = array();
     if ($includeDefault) {
         $nTemplates[''] = 'Default Template';
     }
     if (is_array($adminTemplates)) {
         foreach ($adminTemplates as $k => $v) {
             if ($v == '.' || $v == '..' || !is_dir($v)) {
                 continue;
             }
             $v = str_replace(PATH_ABS_ROOT, '/', $v);
             $v = fix_path($v, '/');
             $nTemplates[$v] = $v;
         }
     }
     if (is_array($userTemplates)) {
         foreach ($userTemplates as $k => $v) {
             if ($v == '.' || $v == '..' || !is_dir($v)) {
                 continue;
             }
             $v = str_replace(PATH_ABS_ROOT, '/', $v);
             $v = fix_path($v, '/');
             $nTemplates[$v] = $v;
         }
     }
     foreach ($nTemplates as $template => $v) {
         if (file_exists(PATH_ABS_ROOT . $template . '/template.ini')) {
             $inifile = parse_ini_file(PATH_ABS_ROOT . $template . '/template.ini');
             if (isset($inifile['hidden'])) {
                 unset($nTemplates[$template]);
             }
         }
     }
     return $nTemplates;
 }
示例#8
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path), fix_path($path_thumb));
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name)) {
                 die(lang_Rename_existing_folder);
             }
             rename_folder($path_thumb, $name);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
示例#9
0
文件: CMS.php 项目: ericmuyser/web2f
 public function __CreatePage($__page, $__path = null)
 {
     $__filename = $this->Site->Path . "/cache/" . md5($this->Page->RequestURL) . ".tpl";
     $__page = $this->GrabPage($__page);
     $this->Page->Headers['Content-Type'] = $this->Page['mime_type'] . "; charset=" . $this->Page['charset'];
     // if this file doesn't exist, or this cache is older than 6 hours
     if (!file_exists($__filename) || file_exists($__filename) && filemtime($__filename) < time() - $this->Page['cache_time']) {
         // set page url and remove extra slashes
         $this->Page->URL = fix_path($this->Site->URL . '/' . $__page);
         // combine all titles
         $this->Page->Title = implode(" | ", $this->Page->Title);
         if (get_class($this->Page->Theme) !== "Theme") {
             // create the page theme - may default back to site theme
             $this->Page->Theme = new Theme($this->Page['theme_name']);
         }
         if ($this->User->IsSpider()) {
             $this->Page->ChangeTheme("robots");
         }
         $this->Page->Theme->URL = $this->Site['url'] . "/themes/" . $this->Page['theme_name'];
         if ($__path === null) {
             $this->SaveFile($__filename, $this->TemplateEngine->Process($this->Page->Content));
             // include the cache file that sets up the new content
             $this->Page->Content = $this->LoadFile($__filename, SAVE_BUFFER);
         } else {
             $this->Page->Content = $this->LoadFile($__path, SAVE_BUFFER);
         }
         // input the entire page content into the buffer
         $this->Page->Input($this->LoadFile($this->Site->Path . "/themes/" . $this->Page->Theme->Path . "/templates/page.tpl", SAVE_BUFFER));
         // write the php content to the file
         $this->SaveFile($__filename, $this->Page);
     } else {
         $this->Page->Input(file_get_contents($__filename));
     }
     return $this->Page;
 }
示例#10
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path, $transliteration, $convert_spaces), fix_path($path_thumb, $transliteration, $convert_spaces));
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name, $transliteration, $convert_spaces);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name, $transliteration, $convert_spaces)) {
                 die(lang_Rename_existing_folder);
             }
             rename_folder($path_thumb, $name, $transliteration, $convert_spaces);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
示例#11
0
            list($shadow_opac, $shadow_sig, $shadow_ol, $shadow_ot, $shadow_color) = explode(',', $FStyle['qe_Shadow'], 4);
            $shadow_opac = is_number($shadow_opac) && $shadow_opac <= 100 ? $shadow_opac : 75;
            $shadow_sig = is_number($shadow_sig) ? $shadow_sig : 2;
            $shadow_ol = preg_match('#^[+-][0-9]{1,4}$#', $shadow_ol) ? $shadow_ol : '+2';
            $shadow_ot = preg_match('#^[+-][0-9]{1,4}$#', $shadow_ot) ? $shadow_ot : '+2';
            $shadow_color = is_hexcolor($shadow_color) ? strtoupper($shadow_color) : 'FF0000';
            $shadow = array('opacity' => $shadow_opac, 'sigma' => $shadow_sig, 'left' => $shadow_ol, 'top' => $shadow_ot, 'color' => $shadow_color);
            break;
    }
    $shadow = (IS_WINDOWS ? '' : '\\') . '( +clone -background ' . escapeshellarg('#' . $shadow['color']) . '  -shadow ' . $shadow['opacity'] . 'x' . $shadow['sigma'] . $shadow['left'] . $shadow['top'] . ' ' . (IS_WINDOWS ? '' : '\\') . ' ) +swap -background none -mosaic -matte ';
    $left = substr($shadow['offset-left'], 1);
    $top = substr($shadow['offset-top'], 1);
    if ($left > 0) {
        add_girth($left * 2);
    }
    if ($top > 0) {
        add_girth($top * 2, true);
    }
}
$out_width += $add_width;
$out_height += $add_height;
$cmd = CONVERT . ' -size ' . $out_width . 'x' . $out_height . ' xc:' . $bkg_hex . ' ' . '-font ' . escapeshellarg(fix_path($FLIR['font'])) . ' -density ' . $FLIR['dpi'] . ' -pointsize ' . $FLIR['size_pts'] . ' -gravity North ' . $extrude . ' ' . $stroke . ' ' . $fill . ' ' . ' -annotate 0 ' . $cmdtext . ' ' . $shadow . ' ' . ' ' . $fulltrim . ' ' . escapeshellarg(FULL_CACHE_PATH);
//die($cmd);
exec($cmd);
if ($FStyle['realFontHeight'] == 'true') {
    // trim sides
    $info = shell_exec(CONVERT . ' ' . escapeshellarg(FULL_CACHE_PATH) . ' -trim info:');
    if (preg_match('#(PNG|GIF|JPEG) ([0-9]+)x([0-9]+) ([0-9]+)x([0-9]+)([+-][0-9]+)([+-][0-9]+)#', $info, $m)) {
        exec(CONVERT . ' ' . escapeshellarg(FULL_CACHE_PATH) . ' -crop ' . $m[2] . 'x' . $m[5] . $m[6] . '+0 +repage ' . escapeshellarg(FULL_CACHE_PATH));
    }
}
示例#12
0
/**
 *@name  pdftk
 *@brief Validate with xmlint (external tool) an xml file using the schema (XML|DTD|XSD|RNG|SCH)
 *@access public 
 *@note 	This function will call pdftk/pdftk.exe like this:
 *	pdftk form.pdf fill_form data.fdf output out.pdf flatten
 *	(pdftk form.filled.pdf output out.pdf flatten is not supported)
 *
 *	 If  the  input  FDF file includes Rich Text formatted data in
 *	 addition to plain text, then the Rich	Text  data  is	packed
 *	 into  the  form fields as well as the plain text.  Pdftk also
 *	 sets a flag that cues Acrobat/Reader to  generate  new  field
 *	 appearances  based on the Rich Text data.  That way, when the
 *	 user opens the PDF, the viewer  will  create  the  Rich  Text
 *	 fields  on  the spot.	If the user's PDF viewer does not sup-
 *	 port Rich Text, then the user will see the  plain  text  data
 *	 instead.   If	you  flatten  this  form  before Acrobat has a
 *	 chance to create (and save) new field appearances,  then  the
 *	 plain text field data is what you'll see.
 *	 
 *@internal Wrapper to call pdftk, a shell command, in background.
 *@param String pdf_file absolute pathname to a pdf form file
 *@param String fdf_file absolute pathname to a pdf data file
 *@param String settings 
 *
 *	Output modes 'compress', 'uncompress', 'flatten' ..(see pdftk --help)
 *@return Array an associative array with two keys: 
 *	Boolean success a flag , if positive meaning the process is a success
 *	String return the path to the pdf generated or the error message 
 **/
function pdftk($pdf_file, $fdf_file, $settings)
{
    //------------------------------------------
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $output_modes = $settings['output_modes'];
    $security = $settings['security'];
    $cwd = '/tmp';
    $env = array('misc_options' => 'aeiou');
    $err = '';
    $success = 0;
    if (is_windows()) {
        $cmd = "pdftk.exe";
        //For windows
    } else {
        $cmd = "pdftk";
        //For linux and mac
    }
    $dircmd = fix_path(dirname(__FILE__));
    if (file_exists("{$dircmd}/{$cmd}")) {
        $pdf_out = FPDM_CACHE . "pdf_flatten.pdf";
        $cmdline = "{$dircmd}/{$cmd} \"{$pdf_file}\" fill_form \"{$fdf_file}\" output \"{$pdf_out}\" {$output_modes} {$security}";
        //direct to ouptut
        //echo htmlentities("$cmdline , $descriptorspec, $cwd, $env");
        if (PHP5_ENGINE) {
            // Php5
            $process = proc_open($cmdline, $descriptorspec, $pipes, $cwd, $env);
        } else {
            //Php4
            $process = proc_open($cmdline, $descriptorspec, $pipes);
        }
        if (is_resource($process)) {
            if (PHP5_ENGINE) {
                $err = stream_get_contents($pipes[2]);
            } else {
                //Php4
                $err = "";
                while ($str = fgets($pipes[2], 4096)) {
                    $err .= "{$str}\n";
                }
            }
            fclose($pipes[2]);
            //Its important to close the pipes before proc_close call to avoid  dead locks
            $return_value = proc_close($process);
        } else {
            $err = "No more resource to execute the command";
        }
    } else {
        $err = "Sorry but pdftk binary is not provided / Cette fonctionnalite requiere pdftk non fourni ici<ol>";
        $err .= "<li>download it from / telecharger ce dernier a partir de <br><blockquote><a href=\"http://www.pdflabs.com/docs/install-pdftk/\">pdflabs</a></blockquote>";
        $err .= "<li>copy the executable in this directory / Copier l'executable dans<br><blockquote><b>{$dircmd}</b></blockquote>";
        $err .= "<li>set \$cmd to match binary name in / configurer \$cmd pour  qu'il corresponde dans le fichier<br><blockquote><b>" . __FILE__ . "</b></blockquote></ol>";
    }
    if ($err) {
        $ret = array("success" => false, "return" => $err);
    } else {
        $ret = array("success" => true, "return" => $pdf_out);
    }
    return $ret;
}
示例#13
0
 /**
  * Sets the initial variables, checks if we need to process the css
  * and then sends whichever file to the browser.
  *
  * @return void
  * @author Anthony Short
  **/
 public static function run($get, $config = array(), $path = array())
 {
     static $run;
     # This function can only be run once
     if ($run === TRUE) {
         return;
     }
     # If we want to debug (turn on errors and FirePHP)
     if ($config['debug']) {
         # Set the error reporting level.
         error_reporting(E_ALL & ~E_STRICT);
         # Set error handler
         set_error_handler(array('CSScaffold', 'exception_handler'));
         # Set exception handler
         set_exception_handler(array('CSScaffold', 'exception_handler'));
         # Turn on FirePHP
         FB::setEnabled(true);
     } else {
         # Turn off errors
         error_reporting(0);
         FB::setEnabled(false);
     }
     # The default options
     $default_config = array('debug' => false, 'in_production' => false, 'force_recache' => false, 'show_header' => true, 'auto_include_mixins' => true, 'override_import' => false, 'absolute_urls' => false, 'use_css_constants' => false, 'minify_css' => true, 'constants' => array(), 'disabled_plugins' => array());
     # Merge them with our set options
     $config = array_merge($default_config, $config);
     # The default paths
     $default_paths = array('document_root' => $_SERVER['DOCUMENT_ROOT'], 'css' => '../', 'system' => 'system', 'cache' => 'cache');
     # Merge them with our set options
     $path = array_merge($default_paths, $path);
     # Set the options and paths in the config
     self::config_set('core', $config);
     # Set the paths in the config
     self::config_set('core.path.docroot', fix_path($path['document_root']));
     self::config_set('core.path.system', fix_path($path['system']));
     self::config_set('core.path.cache', fix_path($path['cache']));
     self::config_set('core.path.css', fix_path($path['css']));
     self::config_set('core.url.css', str_replace(self::config('core.path.docroot'), '/', self::config('core.path.css')));
     self::config_set('core.url.system', str_replace(self::config('core.path.docroot'), '/', SYSPATH));
     # Load the include paths
     self::include_paths(TRUE);
     # Change into the system directory
     chdir(SYSPATH);
     # Set the output
     if (isset($get['output'])) {
         self::config_set('core.output', $get['output']);
     }
     # Parse the $_GET['request'] and set it in the config
     self::config_set('core.request', self::parse_request($get['request']));
     # Get the modified time of the CSS file
     self::config_set('core.request.mod_time', filemtime(self::config('core.request.path')));
     # Tell CSScaffold where to cache and tell if we want to recache
     self::cache_set(self::config('core.path.cache'));
     # Set it back to false if it's locked
     if ($config['in_production'] and file_exists(self::$cached_file)) {
         $recache = false;
     } elseif ($config['force_recache'] or isset($get['recache']) or self::config('core.cache.mod_time') <= self::config('core.request.mod_time')) {
         $recache = true;
         self::cache_clear();
     }
     # Load the modules
     self::load_modules($config['disabled_plugins']);
     # Work in the same directory as the requested CSS file
     chdir(dirname(self::config('core.request.path')));
     # Create a new CSS object
     CSS::load(self::config('core.request.path'));
     # Parse it
     if ($recache) {
         self::parse_css();
     }
     # Log to Firebug
     FB::group('CSScaffold Settings');
     FB::log(self::config('core'));
     FB::groupEnd();
     # Output it
     self::output(CSS::$css);
     # Setup is complete, prevent it from being run again
     $run = TRUE;
 }
示例#14
0
function process_upload()
{
    /*
    	Process the upload file
    */
    global $CFG;
    $ret = array();
    // Select the upload dir
    $upl_dir = $CFG->imgUploadDir;
    if (isset($_POST['dir']) && $_POST['dir'] !== '') {
        $upl_dir = realpath($CFG->imgUploadDir . $_POST['dir']);
        if ((file_exists($upl_dir) && is_dir($upl_dir) && is_subdir($CFG->imgUploadDir, $upl_dir) === true) === false) {
            $upl_dir = $CFG->imgUploadDir;
        }
    }
    $upl_dir = fix_path($upl_dir);
    // Create the list of uploaded files, support the one and couple files inputs as array (name like "file[1]")
    if (!is_array($_FILES['file']['name'])) {
        $upl_files[1] = $_FILES['file'];
    } else {
        $arr_len = count($_FILES['file']['name']);
        foreach ($_FILES['file'] as $key => $val) {
            $i = 1;
            foreach ($val as $v) {
                $upl_files[$i][$key] = $v;
                $i++;
            }
        }
    }
    // Process upload for all uploaded files
    foreach ($upl_files as $key => $upl_file) {
        // Allow process upload for new file in list
        $upload = true;
        // Fix the upload file name
        $upload_file = fix_name(strtolower(basename($upl_file['name'])));
        $file_ext = pathinfo($upload_file, PATHINFO_EXTENSION);
        // Get file name without the ext
        $name_wo_ext = empty($file_ext) ? $upload_file : substr($upload_file, 0, -(strlen($file_ext) + 1));
        // Get the target upload file path
        if (!empty($CFG->uploadNameFormat)) {
            $upload_file_path = $upl_dir . str_replace('n', $name_wo_ext, date($CFG->uploadNameFormat)) . '.' . $file_ext;
        } else {
            $upload_file_path = $upl_dir . $upload_file;
        }
        // Check if tagret file exist and create owerwrite is disabled - then grenerate the new file name
        if (!$CFG->overwriteFile && file_exists($upload_file_path)) {
            $upload_file_path = get_free_file_name($upload_file_path);
            // If can't get free file name - stop upload
            if ($upload_file_path === false) {
                $upload = false;
            }
        }
        // Check file extension
        if (!in_array($file_ext, $CFG->uploadExt)) {
            $upload = false;
        }
        // Get max upload file size
        $phpmaxsize = trim(ini_get('upload_max_filesize'));
        $last = strtolower($phpmaxsize[strlen($phpmaxsize) - 1]);
        switch ($last) {
            case 'g':
                $phpmaxsize *= 1024;
            case 'm':
                $phpmaxsize *= 1024;
            case 'k':
                $phpmaxsize *= 1024;
        }
        $cfgmaxsize = trim($CFG->maxUploadFileSize);
        $last = strtolower($cfgmaxsize[strlen($cfgmaxsize) - 1]);
        switch ($last) {
            case 'g':
                $cfgmaxsize *= 1024;
            case 'm':
                $cfgmaxsize *= 1024;
            case 'k':
                $cfgmaxsize *= 1024;
        }
        $cfgmaxsize = (int) $cfgmaxsize;
        // Check upload file size
        if ($cfgmaxsize > 0 && $upl_file['size'] > $cfgmaxsize || $upl_file['size'] > $phpmaxsize) {
            $upload = false;
        }
        // Check upload dir is writable
        if (!is_writable($upl_dir)) {
            $upload = false;
        }
        // If all OK then move upload file
        if ($upload) {
            move_uploaded_file($upl_file['tmp_name'], $upload_file_path);
            $ret[] = $upload_file_path;
            // Resize section
            if (isset($_POST['resize'][$key]) && $_POST['resize'][$key] !== '') {
                $newsize = $_POST['resize'][$key];
                settype($newsize, 'integer');
                $newsize = $newsize < 0 ? $newsize * -1 : $newsize;
                if ($newsize > $CFG->maxImgResize) {
                    $newsize = $CFG->maxImgResize;
                }
                if ($newsize > 0) {
                    if (!function_exists('resize_img')) {
                        require_once 'img_function.php';
                    }
                    if (function_exists('resize_img')) {
                        resize_img($upload_file_path, $upload_file_path, $newsize);
                    }
                }
            }
        } else {
        }
    }
    return $ret;
}
示例#15
0
文件: fpdm.php 项目: rohmad-st/fpdf
 /**
  *Output PDF to some destination
  *
  *@access public
  *@note reproduces the fpdf's behavior
  *@param string name the filename
  *@string dest the destination
  *	by default it's a file ('F')
  *   if 'D'  , download
  *	and 'I' , Send to standard output
  *
  **/
 function Output($name = '', $dest = '')
 {
     //-----------------------------------
     $pdf_file = '';
     if ($this->support == "pdftk") {
         //As PDFTK can only merge FDF files not data directly,
         require_once "lib/url.php";
         //we will need a url support because relative urls for pdf inside fdf files are not supported by PDFTK...
         require_once "export/fdf/fdf.php";
         //...conjointly with my patched/bridged forge_fdf that provides fdf file generation support from array data.
         require_once "export/pdf/pdftk.php";
         //Of course don't forget to bridge to PDFTK!
         $tmp_file = false;
         $pdf_file = resolve_path(fix_path(dirname(__FILE__) . '/' . $this->pdf_source));
         //string: full pathname to the input pdf , a form file
         if ($this->fdf_source) {
             //FDF file provided
             $fdf_file = resolve_path(fix_path(dirname(__FILE__) . '/' . $this->fdf_source));
         } else {
             $pdf_url = getUrlfromDir($pdf_file);
             //Normaly http scheme not local file
             if ($this->fdf_parse_needed) {
                 //fdf source was provided
                 $pdf_data = $this->parseFDFContent();
             } else {
                 //fields data was provided as an array, we have to generate the fdf file
                 $pdf_data = $this->fields;
             }
             $fdf_file = fix_path(FPDM_CACHE) . "fields" . rnunid() . ".fdf";
             $tmp_file = true;
             $ret = output_fdf($pdf_url, $pdf_data, $fdf_file);
             if (!$ret["success"]) {
                 $this->Error("Output failed as something goes wrong (Pdf was {$pdf_url}) <br> during internal FDF generation of file {$fdf_file}, <br>Reason is given by {$ret['return']}");
             }
         }
         //Serializes security options (not deeply tested)
         $security = '';
         if (!is_null($this->security["password"]["owner"])) {
             $security .= ' owner_pw "' . substr($this->security["password"]["owner"], 0, FPDM_PASSWORD_MAX_LEN) . '"';
         }
         if (!is_null($this->security["password"]["user"])) {
             $security .= ' user_pw "' . substr($this->security["password"]["user"], 0, FPDM_PASSWORD_MAX_LEN) . '"';
         }
         if ($this->security["encrypt"] != 0) {
             $security .= ' encrypt_' . $this->security["encrypt"] . 'bit';
         }
         if (count($this->security["allow"]) > 0) {
             $permissions = $this->security["allow"];
             $security .= ' allow ';
             foreach ($permissions as $permission) {
                 $security .= ' ' . $permission;
             }
         }
         //Serialize output modes
         $output_modes = '';
         if ($this->flatten_mode) {
             $output_modes .= ' flatten';
         }
         if ($this->compress_mode) {
             $output_modes .= ' compress';
         }
         if ($this->uncompress_mode) {
             $output_modes .= ' uncompress';
         }
         $ret = pdftk($pdf_file, $fdf_file, array("security" => $security, "output_modes" => $output_modes));
         if ($tmp_file) {
             @unlink($fdf_file);
         }
         //Clear cache
         if ($ret["success"]) {
             $pdf_file = $ret["return"];
         } else {
             $this->Error($ret["return"]);
         }
     }
     $this->buffer = $this->get_buffer($pdf_file);
     $dest = strtoupper($dest);
     if ($dest == '') {
         if ($name == '') {
             $name = 'doc.pdf';
             $dest = 'I';
         } else {
             $dest = 'F';
         }
     }
     //Abort to avoid to polluate output
     if ($this->verbose && ($dest == 'I' || $dest == 'D')) {
         $this->Close($dest);
     }
     switch ($dest) {
         case 'I':
             //Send to standard output
             if (ob_get_length()) {
                 $this->Error('Some data has already been output, can\'t send PDF file');
             }
             if (php_sapi_name() != 'cli') {
                 //We send to a browser
                 header('Content-Type: application/pdf');
                 if (headers_sent()) {
                     $this->Error('Some data has already been output, can\'t send PDF file');
                 }
                 header('Content-Length: ' . strlen($this->buffer));
                 header('Content-Disposition: inline; filename="' . $name . '"');
                 header('Cache-Control: private, max-age=0, must-revalidate');
                 header('Pragma: public');
                 ini_set('zlib.output_compression', '0');
             }
             echo $this->buffer;
             break;
         case 'D':
             //Download file
             if (ob_get_length()) {
                 $this->Error('Some data has already been output, can\'t send PDF file');
             }
             header('Content-Type: application/x-download');
             if (headers_sent()) {
                 $this->Error('Some data has already been output, can\'t send PDF file');
             }
             header('Content-Length: ' . strlen($this->buffer));
             header('Content-Disposition: attachment; filename="' . $name . '"');
             header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
             // Date in the past
             header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
             // always modified
             header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
             // HTTP/1.1
             header("Cache-Control: post-check=0, pre-check=0", false);
             //header("Pragma: "); // HTTP/1.0
             header('Cache-Control: private, max-age=0, must-revalidate');
             header('Pragma: public,no-cache');
             ini_set('zlib.output_compression', '0');
             echo $this->buffer;
             break;
         case 'F':
             //Save to local file
             if ($this->verbose) {
                 $this->dumpContent("Write file {$name}", "Output");
             }
             $f = fopen($name, 'wb');
             if (!$f) {
                 $this->Error('Unable to create output file: ' . $name . ' (currently opened under Acrobat Reader?)');
             }
             fwrite($f, $this->buffer, strlen($this->buffer));
             fclose($f);
             break;
         case 'S':
             //Return as a string
             return $this->buffer;
         default:
             $this->Error('Incorrect output destination: ' . $dest);
     }
     return '';
 }
示例#16
0
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path, $transliteration, $convert_spaces, $replace_with), fix_path($path_thumb, $transliteration, $convert_spaces, $replace_with));
         create_folder('', fix_path($path_thumb, $transliteration, $convert_spaces, $replace_with) . '/200');
         create_folder('', fix_path($path_thumb, $transliteration, $convert_spaces, $replace_with) . '/330');
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name, $transliteration, $convert_spaces)) {
                 response(trans('fm.Rename_existing_folder'), 403)->send();
                 exit;
             }
             rename_folder($path_thumb, $name, $transliteration, $convert_spaces);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
switch ($FStyle['cAlign']) {
    case 'center':
        $align = 'center';
        break;
    default:
        $align = 'west';
        break;
    case 'right':
        $align = 'east';
        break;
}
if ($FStyle['ff_Wrap'] == 'true') {
    $cmd = CONVERT . ' -background ' . $bkg_hex . ' ' . ' -font ' . escapeshellarg(fix_path($FLIR['font'])) . ' -fill ' . escapeshellarg('#' . $fore_hex . $opacity) . ' -density ' . $FLIR['dpi'] . ' -pointsize ' . $FLIR['size_pts'] . ' -gravity ' . $align . '  -size ' . $FLIR['maxwidth'] . 'x' . ' caption:' . escapeshellarg($FLIR['text']) . ' ' . escapeshellarg(FULL_CACHE_PATH);
} else {
    $xOffset = $bounds['xOffset'] >= 0 ? '+' . $bounds['xOffset'] : $bounds['xOffset'];
    $yOffset = $bounds['yOffset'] >= 0 ? '+' . $bounds['yOffset'] : $bounds['yOffset'];
    $cmd = CONVERT . ' -size ' . ($bounds['width'] + 300) . 'x' . $REAL_HEIGHT_BOUNDS['height'] . ' xc:' . $bkg_hex . ' ' . ' -font ' . escapeshellarg(fix_path($FLIR['font'])) . ' -fill ' . escapeshellarg('#' . $fore_hex . $opacity) . ' -density ' . $FLIR['dpi'] . ' -pointsize ' . $FLIR['size_pts'] . ' -annotate 0x0' . $xOffset . $yOffset . ' ' . escapeshellarg($FLIR['text']) . ' ' . $fulltrim . ' ' . escapeshellarg(FULL_CACHE_PATH);
}
//die($cmd);
exec($cmd);
if ($FStyle['ff_BlurEdges'] == 'true') {
    $cmd2 = CONVERT . ' ' . escapeshellarg(FULL_CACHE_PATH) . ' -matte -virtual-pixel transparent -channel A -blur 0x0.3  -level 0,90%  ' . escapeshellarg(FULL_CACHE_PATH);
    exec($cmd2);
}
if ($FStyle['ff_Wrap'] != 'true' && $FStyle['fixBaseline'] == 'true') {
    // trim sides
    $info = shell_exec(CONVERT . ' ' . escapeshellarg(FULL_CACHE_PATH) . ' -trim info:');
    if (preg_match('#(PNG|GIF|JPEG) ([0-9]+)x([0-9]+) ([0-9]+)x([0-9]+)([+-][0-9]+)([+-][0-9]+)#', $info, $m)) {
        exec(CONVERT . ' ' . escapeshellarg(FULL_CACHE_PATH) . ' -crop ' . $m[2] . 'x' . $m[5] . $m[6] . '+0 +repage ' . escapeshellarg(FULL_CACHE_PATH));
    }
}
示例#18
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path, $transliteration), fix_path($path_thumb, $transliteration));
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name, $transliteration);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name, $transliteration)) {
                 die(lang_Rename_existing_folder);
             }
             rename_folder($path_thumb, $name, $transliteration);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
示例#19
0
文件: Core.php 项目: ericmuyser/web2f
 public function __RewriteHandler($var)
 {
     foreach ($this->Rewrites as $row) {
         $rule = $row['rewrite_rule'];
         if (preg_match("@" . $rule . "@smU", $var, $matches)) {
             if ($row['rewrite_https'] === "1") {
                 $this->Site->EnableHTTPS();
             }
             if (isset($row['rewrite_password']) && $row['rewrite_password'] !== '') {
                 if (md5($this->Session['protected_password']) === $row['rewrite_password']) {
                     if (isset($row['rewrite_replacement']) && $row['rewrite_replacement'] !== '') {
                         $replacement = $row['rewrite_replacement'];
                         for ($i = 1, $l = count($matches) + 1; $i < $l; ++$i) {
                             $replacement = str_replace("\$" . $i, $matches[$i], $replacement);
                         }
                         if ($url = parse_url($replacement)) {
                             if ($query = $url['query']) {
                                 foreach (explode("&", $query) as $amps) {
                                     $pieces = explode("=", $amps);
                                     $this->Request[$pieces[0]] = $pieces[1];
                                 }
                             }
                         }
                         $var = preg_replace("@^(/)+@", '', fix_path(preg_replace("@\\?(.+)\$@", '', $replacement)));
                     }
                 } else {
                     $var = "authorize";
                 }
             } else {
                 $rule = $row['rewrite_rule'];
                 if (preg_match("@" . $rule . "@smU", $var, $matches)) {
                     if (isset($row['rewrite_replacement']) && $row['rewrite_replacement'] !== '') {
                         $replacement = $row['rewrite_replacement'];
                         for ($i = 1, $l = count($matches) + 1; $i < $l; ++$i) {
                             $replacement = str_replace("\$" . $i, $matches[$i], $replacement);
                         }
                         if ($url = parse_url($replacement)) {
                             if ($query = $url['query']) {
                                 foreach (explode("&", $query) as $amps) {
                                     $pieces = explode("=", $amps);
                                     $this->Request[$pieces[0]] = $pieces[1];
                                 }
                             }
                         }
                         $var = preg_replace("@^(/)+@", '', fix_path(preg_replace("@\\?(.+)\$@", '', $replacement)));
                     }
                 }
             }
         }
     }
     return $var;
 }
示例#20
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path, $transliteration, $convert_spaces, $replace_with), fix_path($path_thumb, $transliteration, $convert_spaces, $replace_with));
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name, $transliteration, $convert_spaces)) {
                 response(trans('Rename_existing_folder'), 403)->send();
                 exit;
             }
             rename_folder($path_thumb, $name, $transliteration, $convert_spaces);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
示例#21
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     if (is_dir($base_dir)) {
                         deleteDir($base_dir);
                     }
                 }
             }
         }
     }
     break;
 case 'create_folder':
     if ($create_folders) {
         create_folder(fix_path($path, $transliteration, true, $replace_with), fix_path($path_thumb, $transliteration, true, $replace_with));
     }
     break;
 case 'rename_folder':
     if ($rename_folders) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         $name = str_replace('.', '', $name);
         if (!empty($name)) {
             if (!rename_folder($path, $name, $transliteration, $convert_spaces)) {
                 response(trans('Rename_existing_folder'), 403)->send();
                 exit;
             }
             rename_folder($path_thumb, $name, $transliteration, $convert_spaces);
             if ($fixed_image_creation) {
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {