예제 #1
0
파일: Rule.php 프로젝트: jasmun/Noco100
 /**
  * Retrieves the prepared notification body text
  *
  * @return string
  */
 public function getNotificationBody()
 {
     if ($this->_notificationBody === null) {
         // see: http://stackoverflow.com/questions/6275380/does-html-entity-decode-replaces-nbsp-also-if-not-how-to-replace-it
         if (IfwPsn_Wp_Proxy_Blog::getCharset() == 'UTF-8') {
             $body = str_replace(" ", ' ', html_entity_decode($this->get('notification_body'), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset()));
         } else {
             $body = str_replace(" ", ' ', html_entity_decode($this->get('notification_body'), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset()));
         }
         $body = IfwPsn_Wp_Proxy_Filter::apply('psn_rule_notification_body', $this->_replacer->replace($body), $this);
         $this->_notificationBody = $body;
     }
     return $this->_notificationBody;
 }
예제 #2
0
파일: Blog.php 프로젝트: jasmun/Noco100
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @return string
  */
 public static function getServerEnvironment(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($pm);
     $count_users = count_users();
     $mysql_server_info = @mysql_get_server_info();
     $mysql_client_info = @mysql_get_client_info();
     $phpAutoloadFunctions = array();
     foreach (IfwPsn_Wp_Autoloader::getAllRegisteredAutoloadFunctions() as $function) {
         try {
             if (is_string($function)) {
                 array_push($phpAutoloadFunctions, $function);
             } elseif (is_array($function) && count($function) == 2) {
                 $autoloadObject = $function[0];
                 if (is_object($autoloadObject)) {
                     $autoloadObject = get_class($autoloadObject);
                 }
                 $autoloadMethod = $function[1];
                 if (!is_scalar($autoloadMethod)) {
                     $autoloadMethod = var_export($autoloadMethod, true);
                 }
                 array_push($phpAutoloadFunctions, $autoloadObject . '::' . $autoloadMethod);
             } elseif (is_object($function)) {
                 array_push($phpAutoloadFunctions, get_class($function));
             }
         } catch (Exception $e) {
             // no action
         }
     }
     $context = array('plugin_name' => $pm->getEnv()->getName(), 'plugin_version' => $pm->getEnv()->getVersion(), 'plugin_build_number' => $pm->getEnv()->getBuildNumber(), 'plugin_modules' => $pm->getBootstrap()->getModuleManager()->getModules(), 'plugin_modules_initialized' => $pm->getBootstrap()->getModuleManager()->getInitializedModules(), 'plugin_modules_custom_dir' => $pm->getBootstrap()->getModuleManager()->getCustomModulesLocation(), 'OS' => PHP_OS, 'uname' => php_uname(), 'wp_version' => IfwPsn_Wp_Proxy_Blog::getVersion(), 'wp_charset' => IfwPsn_Wp_Proxy_Blog::getCharset(), 'wp_count_users' => $count_users['total_users'], 'wp_debug' => WP_DEBUG == true ? 'true' : 'false', 'wp_debug_log' => WP_DEBUG_LOG == true ? 'true' : 'false', 'wp_debug_display' => WP_DEBUG_DISPLAY == true ? 'true' : 'false', 'plugins' => IfwPsn_Wp_Proxy_Blog::getPlugins(), 'theme_name' => IfwPsn_Wp_Proxy_Blog::getThemeName(), 'theme_version' => IfwPsn_Wp_Proxy_Blog::getThemeVersion(), 'theme_author' => IfwPsn_Wp_Proxy_Blog::getThemeAuthor(), 'theme_uri' => IfwPsn_Wp_Proxy_Blog::getThemeURI(), 'php_version' => phpversion(), 'php_memory_limit' => ini_get('memory_limit'), 'php_extensions' => IfwPsn_Wp_Server_Php::getExtensions(), 'php_include_path' => get_include_path(), 'php_open_basedir' => ini_get('open_basedir'), 'php_autoload_functions' => $phpAutoloadFunctions, 'mysql_version' => !empty($mysql_server_info) ? $mysql_server_info : '', 'mysql_client' => !empty($mysql_client_info) ? $mysql_client_info : '', 'server_software' => $_SERVER['SERVER_SOFTWARE']);
     if (function_exists('apache_get_version')) {
         $context['apache_version'] = apache_get_version();
     }
     if (function_exists('apache_get_modules')) {
         $context['apache_modules'] = apache_get_modules();
     }
     return $tpl->render('server_env.html.twig', $context);
 }
예제 #3
0
 public function render($content)
 {
     $element = $this->getElement();
     $name = htmlentities($element->getFullyQualifiedName());
     $label = $element->getLabel();
     $id = htmlentities($element->getId());
     $value = $element->getValue();
     if (is_string($value)) {
         $value = htmlentities($element->getValue(), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset());
     }
     switch ($element->getType()) {
         case 'IfwPsn_Vendor_Zend_Form_Element_Textarea':
             $html_entity_decode = $element->getAttrib('html_entity_decode');
             if (!isset($html_entity_decode) || empty($html_entity_decode) || $html_entity_decode === true) {
                 $value = html_entity_decode($element->getValue(), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset());
             }
             if ($element->getAttrib('ace_editor') == true) {
                 $value = $element->getValue();
                 $format = $this->_formatAceEditor;
                 $markup = sprintf($format, $name, $label, $name, $value, $id);
             } else {
                 $format = $this->_formatTextarea;
                 $cols = $element->getAttrib('cols');
                 $rows = $element->getAttrib('rows');
                 $markup = sprintf($format, $name, $label, $id, $name, $cols, $rows, $value);
             }
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Select':
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<option value="%s"%s>%s</option>', $k, $k == $value ? ' selected="selected"' : '', $v);
             }
             $markup = sprintf($this->_formatSelect, $id, $label, $id, $name, $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Multiselect':
             $defaults = $element->getValue();
             if (!is_array($defaults)) {
                 if (empty($defaults)) {
                     $defaults = array();
                 } else {
                     $defaults = array($defaults);
                 }
             }
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<option value="%s"%s>%s</option>', $k, in_array($k, $defaults) ? ' selected="selected"' : '', $v);
             }
             $markup = sprintf($this->_formatMultiselect, $id, $label, $id, $name, $element->getAttrib('size'), $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_MultiCheckbox':
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<label><input type="checkbox" name="%s" value="%s">%s</label>', $name, $k, $v);
             }
             $markup = sprintf($this->_formatMulticheckbox, $label, $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Checkbox':
             $value = $element->getCheckedValue();
             $checked = $element->isChecked() ? 'checked="checked"' : '';
             $markup = sprintf($this->_formatCheckbox, $id, $label, $id, $name, $value, $checked);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Radio':
             $markup = '<label>' . $label . '</label>';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $optid = $id . '-' . $k;
                 $checked = $k == $value ? 'checked="checked"' : '';
                 $markup .= sprintf($this->_formatRadio, $optid, $optid, $name, $k, $checked, $v['label']);
             }
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Password':
             $additionalParams = '';
             if ($element->getAttrib('maxlength') != null) {
                 $additionalParams .= sprintf('maxlength="%s"', $element->getAttrib('maxlength'));
             }
             if ($element->getAttrib('class') != null) {
                 $additionalParams .= sprintf('class="%s"', htmlspecialchars($element->getAttrib('class')));
             }
             $markup = sprintf($this->_formatPassword, $id, $label, $id, $name, $value, $additionalParams);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Text':
         default:
             $additionalParams = '';
             if ($element->getAttrib('maxlength') != null) {
                 $additionalParams .= sprintf('maxlength="%s"', $element->getAttrib('maxlength'));
             }
             if ($element->getAttrib('placeholder') != null) {
                 $additionalParams .= sprintf('placeholder="%s"', htmlspecialchars($element->getAttrib('placeholder')));
             }
             if ($element->getAttrib('class') != null) {
                 $additionalParams .= sprintf('class="%s"', htmlspecialchars($element->getAttrib('class')));
             }
             $markup = sprintf($this->_formatText, $id, $label, $id, $name, $value, $additionalParams);
             break;
     }
     return $markup;
 }