示例#1
0
 /**
  * What is the maximum file size supported system-wide?
  *
  * Controlled by the system-level directive `upload_max_filesize`, but
  * also constrained by the system-level directive `post_max_size`. The
  * *lower* of the two values defines the *upper* limit of the maximum
  * file size.
  *
  * If the number of returned bytes equals `PHP_INT_MAX`, there is
  * effectively no limit.
  *
  * @return int Bytes
  * @api
  * @since 1.0.0
  */
 public static function systemMaxUploadBytes()
 {
     // get both limits as bytes
     $post_max = ini_size_to_bytes(ini_get('post_max_size'));
     $upload_max = ini_size_to_bytes(ini_get('upload_max_filesize'));
     return static::limit($post_max, $upload_max);
 }
示例#2
0
    private function __buildPage()
    {
        $start = precision_timer();
        if (!($page = $this->resolvePage())) {
            $page = $this->_Parent->Database->fetchRow(0, "\n\t\t\t\t\t\t\t\tSELECT `tbl_pages`.* \n\t\t\t\t\t\t\t\tFROM `tbl_pages`, `tbl_pages_types` \n\t\t\t\t\t\t\t\tWHERE `tbl_pages_types`.page_id = `tbl_pages`.id \n\t\t\t\t\t\t\t\tAND tbl_pages_types.`type` = '404' \n\t\t\t\t\t\t\t\tLIMIT 1");
            if (empty($page)) {
                $this->_Parent->customError(E_USER_ERROR, __('Page Not Found'), __('The page you requested does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found'));
            }
            $page['filelocation'] = $this->resolvePageFileLocation($page['path'], $page['handle']);
            $page['type'] = $this->__fetchPageTypes($page['id']);
        }
        ####
        # Delegate: FrontendPageResolved
        # Description: Just after having resolved the page, but prior to any commencement of output creation
        # Global: Yes
        $this->ExtensionManager->notifyMembers('FrontendPageResolved', '/frontend/', array('page' => &$this, 'page_data' => &$page));
        $this->_pageData = $page;
        $root_page = @array_shift(explode('/', $page['path']));
        $current_path = explode(dirname($_SERVER['SCRIPT_NAME']), $_SERVER['REQUEST_URI'], 2);
        $current_path = '/' . ltrim(end($current_path), '/');
        // Get max upload size from php and symphony config then choose the smallest
        $upload_size_php = ini_size_to_bytes(ini_get('upload_max_filesize'));
        $upload_size_sym = Frontend::instance()->Configuration->get('max_upload_size', 'admin');
        $this->_param = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'website-name' => $this->_Parent->Configuration->get('sitename', 'general'), 'page-title' => $page['title'], 'root' => URL, 'workspace' => URL . '/workspace', 'root-page' => $root_page ? $root_page : $page['handle'], 'current-page' => $page['handle'], 'current-page-id' => $page['id'], 'current-path' => $current_path, 'parent-path' => '/' . $page['path'], 'current-url' => URL . $current_path, 'upload-limit' => min($upload_size_php, $upload_size_sym), 'symphony-build' => $this->_Parent->Configuration->get('build', 'symphony'));
        if (is_array($this->_env['url'])) {
            foreach ($this->_env['url'] as $key => $val) {
                $this->_param[$key] = $val;
            }
        }
        if (is_array($_GET) && !empty($_GET)) {
            foreach ($_GET as $key => $val) {
                if (!in_array($key, array('symphony-page', 'debug', 'profile'))) {
                    $this->_param['url-' . $key] = $val;
                }
            }
        }
        if (is_array($_COOKIE[__SYM_COOKIE_PREFIX_]) && !empty($_COOKIE[__SYM_COOKIE_PREFIX_])) {
            foreach ($_COOKIE[__SYM_COOKIE_PREFIX_] as $key => $val) {
                $this->_param['cookie-' . $key] = $val;
            }
        }
        // Flatten parameters:
        General::flattenArray($this->_param);
        ####
        # Delegate: FrontendParamsResolve
        # Description: Just after having resolved the page params, but prior to any commencement of output creation
        # Global: Yes
        $this->ExtensionManager->notifyMembers('FrontendParamsResolve', '/frontend/', array('params' => &$this->_param));
        $xml_build_start = precision_timer();
        $xml = new XMLElement('data');
        $xml->setIncludeHeader(true);
        $events = new XMLElement('events');
        $this->__processEvents($page['events'], $events);
        $xml->appendChild($events);
        $this->_events_xml = clone $events;
        $this->__processDatasources($page['data_sources'], $xml);
        $this->_Parent->Profiler->seed($xml_build_start);
        $this->_Parent->Profiler->sample('XML Built', PROFILE_LAP);
        if (is_array($this->_env['pool']) && !empty($this->_env['pool'])) {
            foreach ($this->_env['pool'] as $handle => $p) {
                if (!is_array($p)) {
                    $p = array($p);
                }
                foreach ($p as $key => $value) {
                    if (is_array($value) && !empty($value)) {
                        foreach ($value as $kk => $vv) {
                            $this->_param[$handle] .= @implode(', ', $vv) . ',';
                        }
                    } else {
                        $this->_param[$handle] = @implode(', ', $p);
                    }
                }
                $this->_param[$handle] = trim($this->_param[$handle], ',');
            }
        }
        ####
        # Delegate: FrontendParamsPostResolve
        # Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
        # Global: Yes
        $this->ExtensionManager->notifyMembers('FrontendParamsPostResolve', '/frontend/', array('params' => $this->_param));
        ## TODO: Add delegate for adding/removing items in the params
        $xsl = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:import href="./workspace/pages/' . basename($page['filelocation']) . '"/>
</xsl:stylesheet>';
        $this->_Parent->Profiler->seed();
        $this->setXML($xml->generate(true, 0));
        $this->_Parent->Profiler->sample('XML Generation', PROFILE_LAP);
        $this->setXSL($xsl, false);
        $this->setRuntimeParam($this->_param);
        $this->_Parent->Profiler->seed($start);
        $this->_Parent->Profiler->sample('Page Built', PROFILE_LAP);
    }
示例#3
0
$phrasegroups = array('language');
$specialtemplates = array();
// ########################## REQUIRE BACK-END ############################
require_once './global.php';
require_once DIR . '/includes/adminfunctions_language.php';
// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminlanguages')) {
    print_cp_no_permission();
}
$vbulletin->input->clean_array_gpc('r', array('dolanguageid' => TYPE_INT));
// ############################# LOG ACTION ###############################
log_admin_action(iif(!empty($vbulletin->GPC['dolanguageid']), "Language ID = " . $vbulletin->GPC['dolanguageid']));
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
if (($current_memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < 128 * 1024 * 1024 and $current_memory_limit > 0) {
    @ini_set('memory_limit', 128 * 1024 * 1024);
}
if (empty($_REQUEST['do'])) {
    $_REQUEST['do'] = 'modify';
}
$langglobals = array('title' => TYPE_NOHTML, 'userselect' => TYPE_INT, 'options' => TYPE_ARRAY_BOOL, 'languagecode' => TYPE_STR, 'charset' => TYPE_STR, 'locale' => TYPE_STR, 'imagesoverride' => TYPE_STR, 'dateoverride' => TYPE_STR, 'timeoverride' => TYPE_STR, 'registereddateoverride' => TYPE_STR, 'calformat1override' => TYPE_STR, 'calformat2override' => TYPE_STR, 'logdateoverride' => TYPE_STR, 'decimalsep' => TYPE_STR, 'thousandsep' => TYPE_STR);
$default_skipped_groups = array('cphelptext');
// #############################################################################
if ($_POST['do'] == 'download') {
    $vbulletin->input->clean_array_gpc('p', array('filename' => TYPE_STR, 'just_phrases' => TYPE_BOOL, 'product' => TYPE_STR, 'custom' => TYPE_BOOL));
    if (empty($vbulletin->GPC['filename'])) {
        $vbulletin->GPC['filename'] = DEFAULT_FILENAME;
    }
    if (function_exists('set_time_limit') and !SAFEMODE) {
        @set_time_limit(1200);
示例#4
0
 /**
  * This function accepts a file via URL or from $_FILES, verifies it, and places it in a temporary location for processing
  *
  * @param	mixed	Valid options are: (a) a URL to a file to retrieve or (b) a pointer to a file in the $_FILES array
  */
 function accept_upload(&$upload)
 {
     $this->error = '';
     if (!is_array($upload) and strval($upload) != '') {
         $this->upload['extension'] = strtolower(file_extension($upload));
         // Check extension here so we can save grabbing a large file that we aren't going to use
         if (!$this->is_valid_extension($this->upload['extension'])) {
             $this->set_error('upload_invalid_file');
             return false;
         }
         // Admins can upload any size file
         if ($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) {
             $this->maxuploadsize = 0;
         } else {
             $this->maxuploadsize = $this->fetch_max_uploadsize($this->upload['extension']);
             if (!$this->maxuploadsize) {
                 $newmem = 20971520;
             }
         }
         if (!preg_match('#^((http|ftp)s?):\\/\\/#i', $upload)) {
             $upload = 'http://' . $upload;
         }
         if (ini_get('allow_url_fopen') == 0 and !function_exists('curl_init')) {
             $this->set_error('upload_fopen_disabled');
             return false;
         } else {
             if ($filesize = $this->fetch_remote_filesize($upload)) {
                 if ($this->maxuploadsize and $filesize > $this->maxuploadsize) {
                     $this->set_error('upload_remoteimage_toolarge');
                     return false;
                 } else {
                     if (function_exists('memory_get_usage') and $memory_limit = @ini_get('memory_limit') and $memory_limit != -1) {
                         // Make sure we have enough memory to process this file
                         $memorylimit = vb_number_format($memory_limit, 0, false, null, '');
                         $memoryusage = memory_get_usage();
                         $freemem = $memorylimit - $memoryusage;
                         $newmemlimit = !empty($newmem) ? $freemem + $newmem : $freemem + $filesize;
                         if (($current_memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < $newmemlimit and $current_memory_limit > 0) {
                             @ini_set('memory_limit', $newmemlimit);
                         }
                     }
                     require_once DIR . '/includes/class_vurl.php';
                     $vurl = new vB_vURL($this->registry);
                     $vurl->set_option(VURL_URL, $upload);
                     $vurl->set_option(VURL_HEADER, true);
                     $vurl->set_option(VURL_MAXSIZE, $this->maxuploadsize);
                     $vurl->set_option(VURL_RETURNTRANSFER, true);
                     if ($result = $vurl->exec2()) {
                     } else {
                         switch ($vurl->fetch_error()) {
                             case VURL_ERROR_MAXSIZE:
                                 $this->set_error('upload_remoteimage_toolarge');
                                 break;
                             case VURL_ERROR_NOLIB:
                                 // this condition isn't reachable
                                 $this->set_error('upload_fopen_disabled');
                                 break;
                             case VURL_ERROR_SSL:
                             case VURL_URL_URL:
                             default:
                                 $this->set_error('retrieval_of_remote_file_failed');
                         }
                         return false;
                     }
                     unset($vurl);
                 }
             } else {
                 $this->set_error('upload_invalid_url');
                 return false;
             }
         }
         // write file to temporary directory...
         if ($this->registry->options['safeupload']) {
             // ... in safe mode
             $this->upload['location'] = $this->registry->options['tmppath'] . '/vbupload' . $this->userinfo['userid'] . substr(TIMENOW, -4);
         } else {
             // ... in normal mode
             $this->upload['location'] = $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'] ? tempnam(ini_get('upload_tmp_dir'), 'vbupload') : @tempnam(ini_get('upload_tmp_dir'), 'vbupload');
         }
         $attachment_write_failed = true;
         if (!empty($result['body'])) {
             $fp = $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'] ? fopen($this->upload['location'], 'wb') : @fopen($this->upload['location'], 'wb');
             if ($fp and $this->upload['location']) {
                 @fwrite($fp, $result['body']);
                 @fclose($fp);
                 $attachment_write_failed = false;
             }
         } else {
             if (file_exists($result['body_file'])) {
                 if (rename($result['body_file'], $this->upload['location'])) {
                     $mask = 0777 & ~umask();
                     @chmod($this->upload['location'], $mask);
                     $attachment_write_failed = false;
                 }
             }
         }
         if ($attachment_write_failed) {
             $this->set_error('upload_writefile_failed');
             return false;
         }
         $this->upload['filesize'] = @filesize($this->upload['location']);
         $this->upload['filename'] = basename($upload);
         $this->upload['extension'] = strtolower(file_extension($this->upload['filename']));
         $this->upload['thumbnail'] = '';
         $this->upload['filestuff'] = '';
         $this->upload['url'] = true;
     } else {
         $this->upload['filename'] = trim($upload['name']);
         $this->upload['filesize'] = intval($upload['size']);
         $this->upload['location'] = trim($upload['tmp_name']);
         $this->upload['extension'] = strtolower(file_extension($this->upload['filename']));
         $this->upload['thumbnail'] = '';
         $this->upload['filestuff'] = '';
         if ($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'] and $this->upload['error']) {
             // Encountered PHP upload error
             if (!($maxupload = @ini_get('upload_max_filesize'))) {
                 $maxupload = 10485760;
             }
             $maxattachsize = vb_number_format($maxupload, 1, true);
             switch ($this->upload['error']) {
                 case '1':
                     // UPLOAD_ERR_INI_SIZE
                 // UPLOAD_ERR_INI_SIZE
                 case '2':
                     // UPLOAD_ERR_FORM_SIZE
                     $this->set_error('upload_file_exceeds_php_limit', $maxattachsize);
                     break;
                 case '3':
                     // UPLOAD_ERR_PARTIAL
                     $this->set_error('upload_file_partially_uploaded');
                     break;
                 case '4':
                     $this->set_error('upload_file_failed');
                     break;
                 case '6':
                     $this->set_error('missing_temporary_folder');
                     break;
                 case '7':
                     $this->set_error('upload_writefile_failed');
                     break;
                 case '8':
                     $this->set_error('upload_stopped_by_extension');
                     break;
                 default:
                     $this->set_error('upload_invalid_file');
             }
             return false;
         } else {
             if ($this->upload['error'] or $this->upload['location'] == 'none' or $this->upload['location'] == '' or $this->upload['filename'] == '' or !$this->upload['filesize'] or !is_uploaded_file($this->upload['location'])) {
                 if ($this->emptyfile or $this->upload['filename'] != '') {
                     $this->set_error('upload_file_failed');
                 }
                 return false;
             }
         }
         if ($this->registry->options['safeupload']) {
             $temppath = $this->registry->options['tmppath'] . '/' . $this->registry->session->fetch_sessionhash();
             $moveresult = $this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'] ? move_uploaded_file($this->upload['location'], $temppath) : @move_uploaded_file($this->upload['location'], $temppath);
             if (!$moveresult) {
                 $this->set_error('upload_unable_move');
                 return false;
             }
             $this->upload['location'] = $temppath;
         }
     }
     $return_value = true;
     ($hook = vBulletinHook::fetch_hook('upload_accept')) ? eval($hook) : false;
     return $return_value;
 }
示例#5
0
error_reporting(E_ALL & ~E_NOTICE);
// Attempt to load XML extension if we don't have the XML functions
// already loaded.
if (!function_exists('xml_set_element_handler')) {
    $extension_dir = ini_get('extension_dir');
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
        $extension_file = 'php_xml.dll';
    } else {
        $extension_file = 'xml.so';
    }
    if ($extension_dir and file_exists($extension_dir . '/' . $extension_file)) {
        ini_set('display_errors', true);
        dl($extension_file);
    }
}
if (!function_exists('ini_size_to_bytes') or ($current_memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < 128 * 1024 * 1024 and $current_memory_limit > 0) {
    @ini_set('memory_limit', 128 * 1024 * 1024);
}
/**
* vBulletin XML Parsing Object
*
* This class allows the parsing of an XML document to an array
*
* @package 		vBulletin
* @author		Scott MacVicar
* @version		$Revision: 59788 $
* @date 		$Date: 2012-02-29 16:39:09 -0800 (Wed, 29 Feb 2012) $
* @copyright 	http://www.vbulletin.com/license.html
*
*/
class vB_XML_Parser
    public function __formAction()
    {
        $fields = $_POST['fields'];
        $this->_errors = array();
        if (trim($fields['name']) == '') {
            $this->_errors['name'] = __('This is a required field');
        }
        if (trim($fields['source']) == '') {
            $this->_errors['source'] = __('This is a required field');
        }
        $filters = is_array($fields['filters']) ? $fields['filters'] : array();
        $classname = Lang::createHandle($fields['name'], NULL, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
        $rootelement = str_replace('_', '-', $classname);
        ##Check to make sure the classname is not empty after handlisation.
        if (empty($classname)) {
            $this->_errors['name'] = __('Please ensure name contains at least one Latin-based alphabet.', array($classname));
        }
        $file = EVENTS . '/event.' . $classname . '.php';
        $isDuplicate = false;
        $queueForDeletion = NULL;
        if ($this->_context[0] == 'new' && is_file($file)) {
            $isDuplicate = true;
        } elseif ($this->_context[0] == 'edit') {
            $existing_handle = $this->_context[1];
            if ($classname != $existing_handle && is_file($file)) {
                $isDuplicate = true;
            } elseif ($classname != $existing_handle) {
                $queueForDeletion = EVENTS . '/event.' . $existing_handle . '.php';
            }
        }
        ##Duplicate
        if ($isDuplicate) {
            $this->_errors['name'] = __('An Event with the name <code>%s</code> name already exists', array($classname));
        }
        if (empty($this->_errors)) {
            $multiple = in_array('expect-multiple', $filters);
            $eventShell = file_get_contents(TEMPLATE . '/event.tpl');
            $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Administration::instance()->Author->getFullName(), 'author website' => URL, 'author email' => Administration::instance()->Author->get('email'), 'trigger condition' => $rootelement);
            $source = $fields['source'];
            $filter = NULL;
            $elements = NULL;
            $this->__injectAboutInformation($eventShell, $about);
            $this->__injectFilters($eventShell, $filters);
            $documentation = NULL;
            $documentation_parts = array();
            $documentation_parts[] = new XMLElement('h3', __('Success and Failure XML Examples'));
            $documentation_parts[] = new XMLElement('p', __('When saved successfully, the following XML will be returned:'));
            if ($multiple) {
                $code = new XMLElement($rootelement);
                $entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'success', 'type' => 'create | edit'));
                $entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
                $code->appendChild($entry);
            } else {
                $code = new XMLElement($rootelement, NULL, array('result' => 'success', 'type' => 'create | edit'));
                $code->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
            }
            $documentation_parts[] = self::processDocumentationCode($code);
            ###
            $documentation_parts[] = new XMLElement('p', __('When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned') . ($multiple ? __(' (<b>Notice that it is possible to get mixtures of success and failure messages when using the "Allow Multiple" option</b>)') : NULL) . ':');
            if ($multiple) {
                $code = new XMLElement($rootelement);
                $entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'error'));
                $entry->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $entry->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
                $code->appendChild($entry);
                $entry = new XMLElement('entry', NULL, array('index' => '1', 'result' => 'success', 'type' => 'create | edit'));
                $entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
                $code->appendChild($entry);
            } else {
                $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $code->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
            }
            $code->setValue('...', false);
            $documentation_parts[] = self::processDocumentationCode($code);
            ###
            if (is_array($filters) && !empty($filters)) {
                $documentation_parts[] = new XMLElement('p', __('The following is an example of what is returned if any options return an error:'));
                $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $code->appendChild(new XMLElement('filter', NULL, array('name' => 'admin-only', 'status' => 'failed')));
                $code->appendChild(new XMLElement('filter', __('Recipient not found'), array('name' => 'send-email', 'status' => 'failed')));
                $code->setValue('...', false);
                $documentation_parts[] = self::processDocumentationCode($code);
            }
            ###
            $documentation_parts[] = new XMLElement('h3', __('Example Front-end Form Markup'));
            $documentation_parts[] = new XMLElement('p', __('This is an example of the form markup you can use on your frontend:'));
            $container = new XMLElement('form', NULL, array('method' => 'post', 'action' => '', 'enctype' => 'multipart/form-data'));
            $container->appendChild(Widget::Input('MAX_FILE_SIZE', min(ini_size_to_bytes(ini_get('upload_max_filesize')), Symphony::Configuration()->get('max_upload_size', 'admin')), 'hidden'));
            $sectionManager = new SectionManager($this->_Parent);
            $section = $sectionManager->fetch($fields['source']);
            $section_fields = $section->fetchFields();
            if (is_array($section_fields) && !empty($section_fields)) {
                foreach ($section_fields as $f) {
                    if ($f->getExampleFormMarkup() instanceof XMLElement) {
                        $container->appendChild($f->getExampleFormMarkup());
                    }
                }
            }
            $container->appendChild(Widget::Input('action[' . $rootelement . ']', __('Submit'), 'submit'));
            $code = $container->generate(true);
            $documentation_parts[] = self::processDocumentationCode($multiple ? str_replace('fields[', 'fields[0][', $code) : $code);
            $documentation_parts[] = new XMLElement('p', __('To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:'));
            $documentation_parts[] = self::processDocumentationCode(Widget::Input('id' . ($multiple ? '[0]' : NULL), 23, 'hidden'));
            $documentation_parts[] = new XMLElement('p', __('To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:'));
            $documentation_parts[] = self::processDocumentationCode(Widget::Input('redirect', URL . '/success/', 'hidden'));
            if (in_array('send-email', $filters)) {
                $documentation_parts[] = new XMLElement('h3', __('Send Notification Email'));
                $documentation_parts[] = new XMLElement('p', __('Upon the event successfully saving the entry, this option takes input from the form and send an email to the desired recipient. <b>It currently does not work with "Allow Multiple".</b> The following are the recognised fields:'));
                $documentation_parts[] = self::processDocumentationCode('send-email[sender-email] // ' . __('Optional') . self::CRLF . 'send-email[sender-name] // ' . __('Optional') . self::CRLF . 'send-email[reply-to-email] // ' . __('Optional') . self::CRLF . 'send-email[reply-to-name] // ' . __('Optional') . self::CRLF . 'send-email[subject]' . self::CRLF . 'send-email[body]' . self::CRLF . 'send-email[recipient] // ' . __('list of comma-separated author usernames.'));
                $documentation_parts[] = new XMLElement('p', __('All of these fields can be set dynamically using the exact field name of another field in the form as shown below in the example form:'));
                $documentation_parts[] = self::processDocumentationCode('<form action="" method="post">
	<fieldset>
		<label>' . __('Name') . ' <input type="text" name="fields[author]" value="" /></label>
		<label>' . __('Email') . ' <input type="text" name="fields[email]" value="" /></label>
		<label>' . __('Message') . ' <textarea name="fields[message]" rows="5" cols="21"></textarea></label>
		<input name="send-email[sender-email]" value="fields[email]" type="hidden" />
		<input name="send-email[sender-name]" value="fields[author]" type="hidden" />
		<input name="send-email[reply-to-email]" value="fields[email]" type="hidden" />
		<input name="send-email[reply-to-name]" value="fields[author]" type="hidden" />
		<input name="send-email[subject]" value="You are being contacted" type="hidden" />
		<input name="send-email[body]" value="fields[message]" type="hidden" />
		<input name="send-email[recipient]" value="fred" type="hidden" />
		<input id="submit" type="submit" name="action[save-contact-form]" value="Send" />
	</fieldset>
</form>');
            }
            /**
             * Allows adding documentation for new filters. A reference to the $documentation
             * array is provided, along with selected filters
             * @delegate AppendEventFilterDocumentation
             * @param string $context
             * '/blueprints/events/(edit|new|info)/'
             * @param array $selected
             *  An array of all the selected filters for this Event
             * @param array $documentation
             *  An array of all the documentation XMLElements, passed by reference
             */
            Symphony::ExtensionManager()->notifyMembers('AppendEventFilterDocumentation', '/blueprints/events/' . $this->_context[0] . '/', array('selected' => $filters, 'documentation' => &$documentation_parts));
            $documentation = join(self::CRLF, array_map(create_function('$x', 'return rtrim($x->generate(true, 4));'), $documentation_parts));
            $documentation = str_replace('\'', '\\\'', $documentation);
            $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
            $eventShell = str_replace('<!-- SOURCE -->', $source, $eventShell);
            $eventShell = str_replace('<!-- DOCUMENTATION -->', General::tabsToSpaces($documentation, 2), $eventShell);
            $eventShell = str_replace('<!-- ROOT ELEMENT -->', $rootelement, $eventShell);
            ## Remove left over placeholders
            $eventShell = preg_replace(array('/<!--[\\w ]++-->/'), '', $eventShell);
            if ($this->_context[0] == 'new') {
                /**
                 * Prior to creating an Event, the file path where it will be written to
                 * is provided and well as the contents of that file.
                 *
                 * @delegate EventsPreCreate
                 * @since Symphony 2.2
                 * @param string $context
                 * '/blueprints/events/'
                 * @param string $file
                 *  The path to the Event file
                 * @param string $contents
                 *  The contents for this Event as a string passed by reference
                 * @param array $filters
                 *  An array of the filters attached to this event
                 */
                Symphony::ExtensionManager()->notifyMembers('EventPreCreate', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
            } else {
                /**
                 * Prior to editing an Event, the file path where it will be written to
                 * is provided and well as the contents of that file.
                 *
                 * @delegate EventPreEdit
                 * @since Symphony 2.2
                 * @param string $context
                 * '/blueprints/events/'
                 * @param string $file
                 *  The path to the Event file
                 * @param string $contents
                 *  The contents for this Event as a string passed by reference
                 * @param array $filters
                 *  An array of the filters attached to this event
                 */
                Symphony::ExtensionManager()->notifyMembers('EventPreEdit', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
            }
            // Write the file
            if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $eventShell, Symphony::Configuration()->get('write_mode', 'file')))) {
                $this->pageAlert(__('Failed to write Event to <code>%s</code>. Please check permissions.', array(EVENTS)), Alert::ERROR);
            } else {
                if ($queueForDeletion) {
                    General::deleteFile($queueForDeletion);
                    $sql = "SELECT * FROM `tbl_pages` WHERE `events` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]' ";
                    $pages = Symphony::Database()->fetch($sql);
                    if (is_array($pages) && !empty($pages)) {
                        foreach ($pages as $page) {
                            $page['events'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['events']);
                            Symphony::Database()->update($page, 'tbl_pages', "`id` = '" . $page['id'] . "'");
                        }
                    }
                }
                if ($this->_context[0] == 'new') {
                    /**
                     * After creating the Event, the path to the Event file is provided
                     *
                     * @delegate EventPostCreate
                     * @since Symphony 2.2
                     * @param string $context
                     * '/blueprints/events/'
                     * @param string $file
                     *  The path to the Event file
                     */
                    Symphony::ExtensionManager()->notifyMembers('EventPostCreate', '/blueprints/events/', array('file' => $file));
                } else {
                    /**
                     * After editing the Event, the path to the Event file is provided
                     *
                     * @delegate EventPostEdit
                     * @since Symphony 2.2
                     * @param string $context
                     * '/blueprints/events/'
                     * @param string $file
                     *  The path to the Event file
                     */
                    Symphony::ExtensionManager()->notifyMembers('EventPostEdit', '/blueprints/events/', array('file' => $file));
                }
                redirect(SYMPHONY_URL . '/blueprints/events/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
            }
        }
    }
示例#7
0
文件: misc.php 项目: hungnv0789/vhtm
}


// ################## Start rebuilding sgicon thumbnails ################
if ($_REQUEST['do'] == 'rebuildsgicons')
{
	$vbulletin->input->clean_array_gpc('r', array(
		'quality'      => TYPE_UINT,
		'autoredirect' => TYPE_BOOL,
		'perpage'      => TYPE_UINT,
		'startat'      => TYPE_UINT
	));

	// Increase memlimit
	if (($memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < 128 * 1024 * 1024 AND $memory_limit > 0)
	{
		@ini_set('memory_limit', 128 * 1024 * 1024);
	}

	// Get dimension constants
	require_once(DIR . '/includes/functions_socialgroup.php');

	// Get image handler
	require_once(DIR . '/includes/class_image.php');
	$image = vB_Image::fetch_library($vbulletin);

	// Check if image manip is supported
	if ($vbulletin->options['imagetype'] != 'Magick' AND !function_exists('imagetypes'))
	{
		print_stop_message('your_version_no_image_support');
示例#8
0
 /**
  *
  * See function definition in vB_Image_Abstract
  *
  */
 function fetch_thumbnail($filename, $location, $maxwidth = 100, $maxheight = 100, $quality = 75, $labelimage = false, $drawborder = false, $jpegconvert = false, $sharpen = true, $owidth = null, $oheight = null, $ofilesize = null)
 {
     $thumbnail = array('filedata' => '', 'filesize' => 0, 'dateline' => 0, 'imageerror' => '');
     if ($validfile = $this->is_valid_thumbnail_extension(file_extension($filename)) and $imageinfo = $this->fetch_image_info($location)) {
         $new_width = $width = $imageinfo[0];
         $new_height = $height = $imageinfo[1];
         if ($this->fetch_imagetype_from_extension(file_extension($filename)) != $imageinfo[2]) {
             $thumbnail['imageerror'] = 'thumbnail_notcorrectimage';
         } else {
             if ($width > $maxwidth or $height > $maxheight) {
                 $memoryok = true;
                 if (function_exists('memory_get_usage') and $memory_limit = @ini_get('memory_limit') and $memory_limit != -1) {
                     $memorylimit = vb_number_format($memory_limit, 0, false, null, '');
                     $memoryusage = memory_get_usage();
                     $freemem = $memorylimit - $memoryusage;
                     $checkmem = true;
                     $tmemory = $width * $height * ($imageinfo[2] == 'JPEG' ? 5 : 2) + 7372.8 + sqrt(sqrt($width * $height));
                     $tmemory += 166000;
                     // fudge factor, object overhead, etc
                     if ($freemem > 0 and $tmemory > $freemem and $tmemory <= $memorylimit * 3) {
                         // attempt to increase memory within reason, no more than triple
                         if (($current_memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < $memorylimit + $tmemory and $current_memory_limit > 0) {
                             @ini_set('memory_limit', $memorylimit + $tmemory);
                         }
                         $memory_limit = @ini_get('memory_limit');
                         $memorylimit = vb_number_format($memory_limit, 0, false, null, '');
                         $memoryusage = memory_get_usage();
                         $freemem = $memorylimit - $memoryusage;
                     }
                 }
                 switch ($imageinfo[2]) {
                     case 'GIF':
                         if (function_exists('imagecreatefromgif')) {
                             if ($checkmem) {
                                 if ($freemem > 0 and $tmemory > $freemem) {
                                     $thumbnail['imageerror'] = 'thumbnail_notenoughmemory';
                                     $memoryok = false;
                                 }
                             }
                             if ($memoryok and !($image = @imagecreatefromgif($location))) {
                                 $thumbnail['imageerror'] = 'thumbnail_nocreateimage';
                             }
                         } else {
                             $thumbnail['imageerror'] = 'thumbnail_nosupport';
                         }
                         break;
                     case 'JPEG':
                         if (function_exists('imagecreatefromjpeg')) {
                             if ($checkmem) {
                                 if ($freemem > 0 and $tmemory > $freemem) {
                                     $thumbnail['imageerror'] = 'thumbnail_notenoughmemory';
                                     $memoryok = false;
                                 }
                             }
                             if ($memoryok and !($image = @imagecreatefromjpeg($location))) {
                                 $thumbnail['imageerror'] = 'thumbnail_nocreateimage';
                             }
                         } else {
                             $thumbnail['imageerror'] = 'thumbnail_nosupport';
                         }
                         break;
                     case 'PNG':
                         if (function_exists('imagecreatefrompng')) {
                             if ($checkmem) {
                                 if ($freemem > 0 and $tmemory > $freemem) {
                                     $thumbnail['imageerror'] = 'thumbnail_notenoughmemory';
                                     $memoryok = false;
                                 }
                             }
                             if ($memoryok and !($image = @imagecreatefrompng($location))) {
                                 $thumbnail['imagerror'] = 'thumbnail_nocreateimage';
                             }
                         } else {
                             $thumbnail['imageerror'] = 'thumbnail_nosupport';
                         }
                         break;
                 }
                 if ($image) {
                     $xratio = $maxwidth == 0 ? 1 : $width / $maxwidth;
                     $yratio = $maxheight == 0 ? 1 : $height / $maxheight;
                     if ($xratio > $yratio) {
                         $new_width = round($width / $xratio);
                         $new_height = round($height / $xratio);
                     } else {
                         $new_width = round($width / $yratio);
                         $new_height = round($height / $yratio);
                     }
                     if ($drawborder) {
                         $create_width = $new_width + 2;
                         $create_height = $new_height + 2;
                         $dest_x_start = 1;
                         $dest_y_start = 1;
                     } else {
                         $create_width = $new_width;
                         $create_height = $new_height;
                         $dest_x_start = 0;
                         $dest_y_start = 0;
                     }
                     if ($labelimage) {
                         $font = 2;
                         $labelboxheight = $drawborder ? 13 : 14;
                         if ($ofilesize) {
                             $filesize = $ofilesize;
                         } else {
                             $filesize = @filesize($location);
                         }
                         if ($filesize / 1024 < 1) {
                             $filesize = 1024;
                         }
                         if ($owidth) {
                             $dimensions = $owidth . 'x' . $oheight;
                         } else {
                             $dimensions = (!empty($width) and !empty($height)) ? "{$width}x{$height}" : '';
                         }
                         $sizestring = !empty($filesize) ? number_format($filesize / 1024, 0, '', '') . 'kb' : '';
                         if (($string_length = strlen($string = "{$dimensions} {$sizestring} {$imageinfo['2']}") * imagefontwidth($font)) < $new_width) {
                             $finalstring = $string;
                             $finalwidth = $string_length;
                         } else {
                             if (($string_length = strlen($string = "{$dimensions} {$sizestring}") * imagefontwidth($font)) < $new_width) {
                                 $finalstring = $string;
                                 $finalwidth = $string_length;
                             } else {
                                 if (($string_length = strlen($string = $dimensions) * imagefontwidth($font)) < $new_width) {
                                     $finalstring = $string;
                                     $finalwidth = $string_length;
                                 } else {
                                     if (($string_length = strlen($string = $sizestring) * imagefontwidth($font)) < $new_width) {
                                         $finalstring = $string;
                                         $finalwidth = $string_length;
                                     }
                                 }
                             }
                         }
                         if (!empty($finalstring)) {
                             $create_height += $labelboxheight;
                             if ($drawborder) {
                                 $label_x_start = ($new_width - $finalwidth) / 2 + 2;
                                 $label_y_start = ($labelboxheight - imagefontheight($font)) / 2 + $new_height + 1;
                             } else {
                                 $label_x_start = ($new_width - $finalwidth) / 2 + 1;
                                 $label_y_start = ($labelboxheight - imagefontheight($font)) / 2 + $new_height;
                             }
                         }
                     }
                     if (!($finalimage = @imagecreatetruecolor($create_width, $create_height))) {
                         $thumbnail['imageerror'] = 'thumbnail_nocreateimage';
                         imagedestroy($image);
                         return $thumbnail;
                     }
                     $bgcolor = imagecolorallocate($finalimage, 255, 255, 255);
                     imagefill($finalimage, 0, 0, $bgcolor);
                     @imagecopyresampled($finalimage, $image, $dest_x_start, $dest_y_start, 0, 0, $new_width, $new_height, $width, $height);
                     imagedestroy($image);
                     if ($sharpen and PHP_VERSION != '4.3.2') {
                         $this->unsharpmask($finalimage);
                     }
                     if ($labelimage and !empty($finalstring)) {
                         $bgcolor = imagecolorallocate($finalimage, $this->thumbcolor['r'], $this->thumbcolor['g'], $this->thumbcolor['b']);
                         $recstart = $drawborder ? $create_height - $labelboxheight - 1 : $create_height - $labelboxheight;
                         imagefilledrectangle($finalimage, 0, $recstart, $create_width, $create_height, $bgcolor);
                         $textcolor = imagecolorallocate($finalimage, 255, 255, 255);
                         imagestring($finalimage, $font, $label_x_start, $label_y_start, $finalstring, $textcolor);
                     }
                     if ($drawborder) {
                         $bordercolor = imagecolorallocate($finalimage, $this->thumbcolor['r'], $this->thumbcolor['g'], $this->thumbcolor['b']);
                         imageline($finalimage, 0, 0, $create_width, 0, $bordercolor);
                         imageline($finalimage, 0, 0, 0, $create_height, $bordercolor);
                         imageline($finalimage, $create_width - 1, 0, $create_width - 1, $create_height, $bordercolor);
                         imageline($finalimage, 0, $create_height - 1, $create_width, $create_height - 1, $bordercolor);
                     }
                     ob_start();
                     $new_extension = $this->print_image($finalimage, $jpegconvert ? 'JPEG' : $imageinfo[2], false, $quality);
                     $thumbnail['filedata'] = ob_get_contents();
                     ob_end_clean();
                     $thumbnail['width'] = $new_width;
                     $thumbnail['height'] = $new_height;
                     $extension = file_extension($filename);
                     if ($new_extension != $extension) {
                         $thumbnail['filename'] = preg_replace('#' . preg_quote($extension, '#') . '$#', $new_extension, $filename);
                     }
                 }
             } else {
                 if ($imageinfo[0] == 0 and $imageinfo[1] == 0) {
                     $thumbnail['filedata'] = '';
                     $thumbnail['imageerror'] = 'thumbnail_nogetimagesize';
                 } else {
                     $thumbnail['filedata'] = @file_get_contents($location);
                     $thumbnail['width'] = $imageinfo[0];
                     $thumbnail['height'] = $imageinfo[1];
                     $thumbnail['imageerror'] = 'thumbnailalready';
                 }
             }
         }
     } else {
         if (!$validfile) {
             $thumbnail['filedata'] = '';
             $thumbnail['imageerror'] = 'thumbnail_nosupport';
         }
     }
     if (!empty($thumbnail['filedata'])) {
         $thumbnail['filesize'] = strlen($thumbnail['filedata']);
         $thumbnail['dateline'] = TIMENOW;
     }
     return $thumbnail;
 }
    /**
     * This function sets the page's parameters, processes the Datasources and
     * Events and sets the `$xml` and `$xsl` variables. This functions resolves the `$page`
     * by calling the `resolvePage()` function. If a page is not found, it attempts
     * to locate the Symphony 404 page set in the backend otherwise it throws
     * the default Symphony 404 page. If the page is found, the page's XSL utility
     * is found, and the system parameters are set, including any URL parameters,
     * params from the Symphony cookies. Events and Datasources are executed and
     * any parameters  generated by them are appended to the existing parameters
     * before setting the Page's XML and XSL variables are set to the be the
     * generated XML (from the Datasources and Events) and the XSLT (from the
     * file attached to this Page)
     *
     * @uses FrontendPageResolved
     * @uses FrontendParamsResolve
     * @uses FrontendParamsPostResolve
     * @see resolvePage()
     */
    private function __buildPage()
    {
        $start = precision_timer();
        if (!($page = $this->resolvePage())) {
            throw new FrontendPageNotFoundException();
        }
        /**
         * Just after having resolved the page, but prior to any commencement of output creation
         * @delegate FrontendPageResolved
         * @param string $context
         * '/frontend/'
         * @param FrontendPage $page
         *  An instance of this class, passed by reference
         * @param array $page_data
         *  An associative array of page data, which is a combination from `tbl_pages` and
         *  the path of the page on the filesystem. Passed by reference
         */
        Symphony::ExtensionManager()->notifyMembers('FrontendPageResolved', '/frontend/', array('page' => &$this, 'page_data' => &$page));
        $this->_pageData = $page;
        $path = explode('/', $page['path']);
        $root_page = is_array($path) ? array_shift($path) : $path;
        $current_path = explode(dirname($_SERVER['SCRIPT_NAME']), $_SERVER['REQUEST_URI'], 2);
        $current_path = '/' . ltrim(end($current_path), '/');
        $split_path = explode('?', $current_path, 3);
        $current_path = rtrim(current($split_path), '/');
        $querystring = '?' . next($split_path);
        // Get max upload size from php and symphony config then choose the smallest
        $upload_size_php = ini_size_to_bytes(ini_get('upload_max_filesize'));
        $upload_size_sym = Symphony::Configuration()->get('max_upload_size', 'admin');
        $this->_param = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'website-name' => Symphony::Configuration()->get('sitename', 'general'), 'page-title' => $page['title'], 'root' => URL, 'workspace' => URL . '/workspace', 'root-page' => $root_page ? $root_page : $page['handle'], 'current-page' => $page['handle'], 'current-page-id' => $page['id'], 'current-path' => $current_path, 'parent-path' => '/' . $page['path'], 'current-query-string' => XMLElement::stripInvalidXMLCharacters(utf8_encode(urldecode($querystring))), 'current-url' => URL . $current_path, 'upload-limit' => min($upload_size_php, $upload_size_sym), 'symphony-version' => Symphony::Configuration()->get('version', 'symphony'));
        if (is_array($this->_env['url'])) {
            foreach ($this->_env['url'] as $key => $val) {
                $this->_param[$key] = $val;
            }
        }
        if (is_array($_GET) && !empty($_GET)) {
            foreach ($_GET as $key => $val) {
                if (in_array($key, array('symphony-page', 'debug', 'profile'))) {
                    continue;
                }
                // If the browser sends encoded entities for &, ie. a=1&amp;b=2
                // this causes the $_GET to output they key as amp;b, which results in
                // $url-amp;b. This pattern will remove amp; allow the correct param
                // to be used, $url-b
                $key = preg_replace('/(^amp;|\\/)/', null, $key);
                // If the key gets replaced out then it will break the XML so prevent
                // the parameter being set.
                if (!General::createHandle($key)) {
                    continue;
                }
                $this->_param['url-' . $key] = XMLElement::stripInvalidXMLCharacters(utf8_encode(urldecode($val)));
            }
        }
        if (is_array($_COOKIE[__SYM_COOKIE_PREFIX_]) && !empty($_COOKIE[__SYM_COOKIE_PREFIX_])) {
            foreach ($_COOKIE[__SYM_COOKIE_PREFIX_] as $key => $val) {
                $this->_param['cookie-' . $key] = $val;
            }
        }
        // Flatten parameters:
        General::flattenArray($this->_param);
        /**
         * Just after having resolved the page params, but prior to any commencement of output creation
         * @delegate FrontendParamsResolve
         * @param string $context
         * '/frontend/'
         * @param array $params
         *  An associative array of this page's parameters
         */
        Symphony::ExtensionManager()->notifyMembers('FrontendParamsResolve', '/frontend/', array('params' => &$this->_param));
        $xml_build_start = precision_timer();
        $xml = new XMLElement('data');
        $xml->setIncludeHeader(true);
        $events = new XMLElement('events');
        $this->processEvents($page['events'], $events);
        $xml->appendChild($events);
        $this->_events_xml = clone $events;
        $this->processDatasources($page['data_sources'], $xml);
        Symphony::Profiler()->seed($xml_build_start);
        Symphony::Profiler()->sample('XML Built', PROFILE_LAP);
        if (is_array($this->_env['pool']) && !empty($this->_env['pool'])) {
            foreach ($this->_env['pool'] as $handle => $p) {
                if (!is_array($p)) {
                    $p = array($p);
                }
                foreach ($p as $key => $value) {
                    if (is_array($value) && !empty($value)) {
                        foreach ($value as $kk => $vv) {
                            $this->_param[$handle] .= @implode(', ', $vv) . ',';
                        }
                    } else {
                        $this->_param[$handle] = @implode(', ', $p);
                    }
                }
                $this->_param[$handle] = trim($this->_param[$handle], ',');
            }
        }
        /**
         * Access to the resolved param pool, including additional parameters provided by Data Source outputs
         * @delegate FrontendParamsPostResolve
         * @param string $context
         * '/frontend/'
         * @param array $params
         *  An associative array of this page's parameters
         */
        Symphony::ExtensionManager()->notifyMembers('FrontendParamsPostResolve', '/frontend/', array('params' => &$this->_param));
        $params = new XMLElement('params');
        foreach ($this->_param as $key => $value) {
            // To support multiple parameters using the 'datasource.field'
            // we will pop off the field handle prior to sanitizing the
            // key. This is because of a limitation where General::createHandle
            // will strip '.' as it's technically punctuation.
            if (strpos($key, '.') !== false) {
                $parts = explode('.', $key);
                $field_handle = '.' . array_pop($parts);
                $key = implode('', $parts);
            } else {
                $field_handle = '';
            }
            $key = Lang::createHandle($key) . $field_handle;
            $param = new XMLElement($key);
            // DS output params get flattened to a string, so get the original pre-flattened array
            if (isset($this->_env['pool'][$key])) {
                $value = $this->_env['pool'][$key];
            }
            if (is_array($value) && !(count($value) == 1 && empty($value[0]))) {
                foreach ($value as $key => $value) {
                    $item = new XMLElement('item', General::sanitize($value));
                    $item->setAttribute('handle', Lang::createHandle($value));
                    $param->appendChild($item);
                }
            } else {
                if (is_array($value)) {
                    $param->setValue(General::sanitize($value[0]));
                } else {
                    $param->setValue(General::sanitize($value));
                }
            }
            $params->appendChild($param);
        }
        $xml->prependChild($params);
        Symphony::Profiler()->seed();
        $this->setXML($xml->generate(true, 0));
        Symphony::Profiler()->sample('XML Generation', PROFILE_LAP);
        $xsl = '<?xml version="1.0" encoding="UTF-8"?>
			<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<xsl:import href="./workspace/pages/' . basename($page['filelocation']) . '"/>
			</xsl:stylesheet>';
        $this->setXSL($xsl, false);
        $this->setRuntimeParam($this->_param);
        Symphony::Profiler()->seed($start);
        Symphony::Profiler()->sample('Page Built', PROFILE_LAP);
    }
 public function addFrontendMarkupDoc(array &$doc_parts, $rootelement, $section, $filters)
 {
     $multiple = $this->hasMultipleFilter($filters);
     $doc_parts[] = new XMLElement('h3', __('Example Front-end Form Markup'));
     $doc_parts[] = new XMLElement('p', __('This is an example of the form markup you can use on your frontend:'));
     $container = new XMLElement('form', null, array('method' => 'post', 'action' => '{$current-url}/', 'enctype' => 'multipart/form-data'));
     $container->appendChild(Widget::Input('MAX_FILE_SIZE', (string) min(ini_size_to_bytes(ini_get('upload_max_filesize')), Symphony::Configuration()->get('max_upload_size', 'admin')), 'hidden'));
     if (is_numeric($section)) {
         $section = SectionManager::fetch($section);
         if ($section instanceof Section) {
             $section_fields = $section->fetchFields();
             if (is_array($section_fields) && !empty($section_fields)) {
                 foreach ($section_fields as $f) {
                     if ($f->getExampleFormMarkup() instanceof XMLElement) {
                         $container->appendChild($f->getExampleFormMarkup());
                     }
                 }
             }
         }
     }
     $container->appendChild(Widget::Input('action[' . $rootelement . ']', __('Submit'), 'submit'));
     $code = $container->generate(true);
     $doc_parts[] = self::processDocumentationCode($multiple ? str_replace('fields[', 'fields[0][', $code) : $code);
     $doc_parts[] = new XMLElement('p', __('To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:'));
     $doc_parts[] = self::processDocumentationCode(Widget::Input('id' . ($multiple ? '[0]' : null), '23', 'hidden'));
     $doc_parts[] = new XMLElement('p', __('To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:'));
     $doc_parts[] = self::processDocumentationCode(Widget::Input('redirect', URL . '/success/', 'hidden'));
 }
示例#11
0
 public function display($url = NULL)
 {
     self::$Parameters = new Register();
     // Default headers. Can be overwritten later
     //self::$Headers->append('HTTP/1.0 200 OK');
     self::$Headers->append('Content-Type', 'text/html;charset=utf-8');
     self::$Headers->append('Expires', 'Mon, 12 Dec 1982 06:14:00 GMT');
     self::$Headers->append('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
     self::$Headers->append('Cache-Control', 'no-cache, must-revalidate, max-age=0');
     self::$Headers->append('Pragma', 'no-cache');
     ####
     # Delegate: FrontendPreInitialise
     # Description: TODO
     # Global: Yes
     Extension::notify('FrontendPreInitialise', '/frontend/', array('view' => &self::$view, 'url' => &$url));
     if (!self::$view instanceof View) {
         $this->resolve($url);
     }
     ####
     # Delegate: FrontendPostInitialise
     Extension::notify('FrontendPostInitialise', '/frontend/', array('view' => &self::$view));
     // SETTING UP PARAMETERS --------------------------
     $root_page = array_shift(explode('/', self::$view->parent()->path));
     $current_path = explode(dirname($_SERVER['SCRIPT_NAME']), $_SERVER['REQUEST_URI'], 2);
     $current_path = '/' . ltrim(end($current_path), '/');
     self::$Parameters->register(array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => date_default_timezone_get(), 'website-name' => Symphony::Configuration()->core()->symphony->sitename, 'symphony-version' => Symphony::Configuration()->core()->symphony->version, 'upload-limit' => min(ini_size_to_bytes(ini_get('upload_max_filesize')), Symphony::Configuration()->core()->symphony->{'maximum-upload-size'}), 'root' => URL, 'workspace' => URL . '/workspace', 'page-title' => self::$view->title, 'root-page' => !is_null($root_page) ? $root_page : self::$view->handle, 'current-page' => self::$view->handle, 'current-path' => $current_path, 'parent-path' => '/' . self::$view->path, 'current-url' => URL . $current_path));
     if (isset(self::$view->{'url-parameters'}) && is_array(self::$view->{'url-parameters'})) {
         foreach (self::$view->{'url-parameters'} as $p) {
             self::$Parameters->{$p} = NULL;
         }
         foreach (self::$view->parameters() as $p => $v) {
             self::$Parameters->{$p} = str_replace(' ', '+', $v);
         }
     }
     if (is_array($_GET) && !empty($_GET)) {
         foreach ($_GET as $key => $val) {
             if (in_array($key, array('symphony-page', 'debug', 'profile'))) {
                 continue;
             }
             // self::$Parameters->{"url-{$key}"} = $val; "url" is not prepended by $_GET params
             self::$Parameters->{$key} = $val;
         }
     }
     if (is_array($_COOKIE[__SYM_COOKIE_PREFIX__]) && !empty($_COOKIE[__SYM_COOKIE_PREFIX__])) {
         foreach ($_COOKIE[__SYM_COOKIE_PREFIX__] as $key => $val) {
             self::$Parameters->{"cookie-{$key}"} = $val;
         }
     }
     // RENDER THE VIEW --------------------------
     // Can ask the view to operate on an existing
     // Document. Useful if we pass it around beyond
     // the scope of View::render()
     ####
     # Delegate: FrontendPreRender
     # Description: TODO
     # Global: Yes
     Extension::notify('FrontendPreRender', '/frontend/', array('view' => &self::$view, 'parameters' => &self::$Parameters, 'document' => &self::$Document, 'headers' => &self::$Headers));
     $output = self::$view->render(self::$Parameters, self::$Document, self::$Headers);
     ####
     # Delegate: FrontendPostRender
     # Description: TODO
     # Global: Yes
     Extension::notify('FrontendPostRender', '/frontend/', array('output' => &$output, 'headers' => &self::$Headers));
     self::Headers()->render();
     return $output;
 }
 public function getViewContext()
 {
     $this->context->register(array('view' => array('title' => $this->title, 'handle' => $this->handle, 'path' => $this->path, 'current-url' => URL . '/' . $this->path, 'root-view' => !is_null($root_page) ? $root_page : $this->handle, 'parent-path' => '/' . $this->path, 'upload-limit' => min(ini_size_to_bytes(ini_get('upload_max_filesize')), Symphony::Configuration()->core()->symphony->{'maximum-upload-size'}))));
 }