public function __construct(&$controler)
 {
     parent::__construct($controler);
     if (!XC_CLASS_EXISTS('Legacy_TextareaEditor')) {
         $this->Legacy_TextareaEditor_delete = true;
     }
 }
Example #2
0
 function _parseType()
 {
     //
     // FIXME
     //
     foreach ($this->_mService->_mTypes as $className) {
         if (XC_CLASS_EXISTS($className)) {
             if (call_user_func(array($className, 'isArray')) == true) {
                 $targetClassName = call_user_func(array($className, 'getClassName'));
                 if (XCube_ServiceUtils::isXSD($targetClassName)) {
                     $targetClassName = 'xsd:' . $targetClassName;
                 } else {
                     $targetClassName = 'tns:' . $targetClassName;
                 }
                 $this->_mServer->wsdl->addComplexType($className, 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => $targetClassName . '[]')), $targetClassName);
             } else {
                 $t_fieldArr = call_user_func(array($className, 'getPropertyDefinition'));
                 $t_arr = array();
                 foreach ($t_fieldArr as $t_field) {
                     $name = $t_field['name'];
                     $type = $t_field['type'];
                     if (XCube_ServiceUtils::isXSD($t_field['type'])) {
                         $type = 'xsd:' . $type;
                     } else {
                         $type = 'tns:' . $type;
                     }
                     $t_arr[$name] = array('name' => $name, 'type' => $type);
                 }
                 $this->_mServer->wsdl->addComplexType($className, 'complexType', 'struct', 'all', '', $t_arr);
             }
         }
     }
 }
Example #3
0
	function _createAction(&$actionFrame)
	{
		if (is_object($this->mAction)) {
			return;
		}
		
		//
		// Create action object by mActionName
		//
		$className = "User_" . ucfirst($actionFrame->mActionName) . "Action";
		$fileName = ucfirst($actionFrame->mActionName) . "Action";
		if ($actionFrame->mAdminFlag) {
			$fileName = XOOPS_MODULE_PATH . "/user/admin/actions/${fileName}.class.php";
		}
		else {
			$fileName = XOOPS_MODULE_PATH . "/user/actions/${fileName}.class.php";
		}
	
		if (!file_exists($fileName)) {
			die();
		}
	
		require_once $fileName;
	
		if (XC_CLASS_EXISTS($className)) {
			$actionFrame->mAction =new $className($actionFrame->mAdminFlag);
		}
	}
Example #4
0
function smarty_function_hyp_emoji_pad($params, &$smarty)
{
    if (!function_exists('XC_CLASS_EXISTS') || !XC_CLASS_EXISTS('HypCommonFunc')) {
        return 'Class "HypCommonFunc" not exists.';
    }
    if (empty($params['id'])) {
        return 'Parameter "id" is not set.';
    }
    $id = $params['id'];
    $checkmsg = empty($params['msg']) ? '' : $params['msg'];
    $clearDisplayId = empty($params['showDomId']) ? '' : $params['showDomId'];
    $emojiurl = empty($params['emojiUrl']) ? '' : $params['emojiUrl'];
    $writeJS = empty($params['outputWithJS']) ? TRUE : (bool) $params['outputWithJS'];
    $emj_list = empty($params['emojiList']) ? NULL : $params['emojiList'];
    if (strtolower($emj_list) === 'all') {
        $emj_list = 'all';
    } else {
        if (!empty($emj_list)) {
            $emj_list = explode(',', $emj_list);
            $emj_list = array_map('trim', $emj_list);
            $emj_list = array_map('intval', $emj_list);
        }
    }
    return HypCommonFunc::make_emoji_pad($id, $checkmsg, $clearDisplayId, $emojiurl, $writeJS, $emj_list);
}
Example #5
0
 function execute(&$controller)
 {
     if (!preg_match("/^\\w+\$/", $this->mActionName)) {
         die;
     }
     //
     // Create action object by mActionName
     //
     $className = "Pm_" . ucfirst($this->mActionName) . "Action";
     $fileName = ucfirst($this->mActionName) . "Action";
     if ($this->mAdminFlag) {
         $fileName = XOOPS_MODULE_PATH . "/pm/admin/actions/{$fileName}.class.php";
     } else {
         $fileName = XOOPS_MODULE_PATH . "/pm/actions/{$fileName}.class.php";
     }
     if (!file_exists($fileName)) {
         die;
     }
     require_once $fileName;
     if (XC_CLASS_EXISTS($className)) {
         $this->mAction =& new $className();
     }
     if (!is_object($this->mAction)) {
         $this->doActionNotFoundError($controller);
         return;
     }
     $handler =& xoops_gethandler('config');
     $moduleConfig =& $handler->getConfigsByDirname('pm');
     $this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser, $moduleConfig);
     if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser, $moduleConfig)) {
         $this->doPermissionError($controller);
         return;
     }
     if (xoops_getenv("REQUEST_METHOD") == "POST") {
         $viewStatus = $this->mAction->execute($controller, $controller->mRoot->mContext->mXoopsUser);
     } else {
         $viewStatus = $this->mAction->getDefaultView($controller, $controller->mRoot->mContext->mXoopsUser);
     }
     switch ($viewStatus) {
         case PM_FRAME_VIEW_SUCCESS:
             $this->mAction->executeViewSuccess($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case PM_FRAME_VIEW_ERROR:
             $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case PM_FRAME_VIEW_INDEX:
             $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case PM_FRAME_VIEW_INPUT:
             $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case PM_FRAME_VIEW_PREVIEW:
             $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
         case PM_FRAME_VIEW_CANCEL:
             $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget());
             break;
     }
 }
Example #6
0
    function _buildXML()
    {
        if ($this->encording) {
            if (!extension_loaded('mbstring') && !XC_CLASS_EXISTS('HypMBString')) {
                require_once dirname(dirname(__FILE__)) . '/mbemulator/mb-emulator.php';
            }
            $this->name = htmlspecialchars(mb_convert_encoding($this->name, 'UTF-8', $this->encording), ENT_COMPAT, 'UTF-8');
            $this->tag = htmlspecialchars(mb_convert_encoding($this->tag, 'UTF-8', $this->encording), ENT_COMPAT, 'UTF-8');
        }
        $tag = $changesurl = '';
        if ($this->changesurl) {
            $changesurl = <<<EOD
<param>
<value>{$this->changesurl}</value>
</param>
EOD;
        }
        if ($this->tag) {
            $tag = <<<EOD
<param>
<value>{$this->tag}</value>
</param>
EOD;
        }
        $this->xml_normal = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value>{$this->name}</value>
</param>
<param>
<value>{$this->url}</value>
</param>{$changesurl}{$tag}
</params>
</methodCall>
EOD;
        $this->xml_extended = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param>
<value>{$this->name}</value>
</param>
<param>
<value>{$this->url}</value>
</param>
{$changesurl}
<param>
<value>{$this->rssurl}</value>
</param>
{$tag}
</params>
</methodCall>
EOD;
    }
Example #7
0
 /**
  * create
  * 
  * @param   bool $isNew
  * 
  * @return  XoopsSimpleObject  $obj
  **/
 public function &create($isNew = true)
 {
     $obj = null;
     if (XC_CLASS_EXISTS($this->mClass)) {
         $obj = new $this->mClass($this->getDirname());
         if ($isNew) {
             $obj->setNew();
         }
     }
     return $obj;
 }
 /**
  *  @public
  */
 public static function renderNone(&$html, $params)
 {
     if (!XC_CLASS_EXISTS('xoopsformelement')) {
         require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     }
     $form = new XoopsFormTextArea($params['name'], $params['name'], $params['value'], $params['rows'], $params['cols']);
     $form->setId($params['id']);
     if ($params['class'] != null) {
         $form->setClass($params['class']);
     }
     $html = $form->render();
 }
function smarty_function_xoops_dhtmltarea($params, &$smarty)
{
	if (!XC_CLASS_EXISTS('xoopsformelement')) {
		require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
	}
	$form = null;

	$root =& XCube_Root::getSingleton();
	$textFilter =& $root->getTextFilter();
	if (isset($params['name'])) {
		//
		// Fetch major elements from $params.
		//
		$params['name'] = trim($params['name']);
		$params['class'] = isset($params['class']) ? trim($params['class']) : null;
		$params['cols'] = isset($params['cols']) ? intval($params['cols']) : XOOPS_DHTMLTAREA_DEFAULT_COLS;
		$params['rows'] = isset($params['rows']) ? intval($params['rows']) : XOOPS_DHTMLTAREA_DEFAULT_ROWS;
		$params['value'] = isset($params['value']) ? $textFilter->toEdit($params['value']) : null;
		$params['id'] = isset($params['id']) ? trim($params['id']) : XOOPS_DHTMLTAREA_DEFID_PREFIX . $params['name'];
	
		//
		// Build the object for output.
		//
		$html = "";
		switch($params['editor']){
		case 'html':
			XCube_DelegateUtils::call("Site.TextareaEditor.HTML.Show", new XCube_Ref($html), $params);
			break;
		
		case 'none':
			XCube_DelegateUtils::call("Site.TextareaEditor.None.Show", new XCube_Ref($html), $params);
			break;
		case 'bbcode':
		default:
			XCube_DelegateUtils::call("Site.TextareaEditor.BBCode.Show", new XCube_Ref($html), $params);
			break;
		}
		print $html;
	
		/*
		$form =new XoopsFormDhtmlTextArea($name, $name, $value, $rows, $cols);
		$form->setId($id);
		if ($class != null) {
			$form->setClass($class);
		}
		
		print $form->render();
		*/
	}
}
Example #10
0
 function output($file, $mime, $size, $mtime)
 {
     $this->check_304($mtime);
     header('Content-Length: ' . $size);
     header('Content-Type: ' . $mime);
     header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $mtime) . " GMT");
     header('Etag: ' . $mtime);
     header('Cache-Control: private, max-age=' . XELFINDER_CACHE_TTL);
     header('Expires: ' . gmdate("D, d M Y H:i:s", XELFINDER_UNIX_TIME + XELFINDER_CACHE_TTL) . ' GMT');
     header('Pragma:');
     if (function_exists('XC_CLASS_EXISTS') && XC_CLASS_EXISTS('HypCommonFunc')) {
         HypCommonFunc::readfile($file);
     } else {
         readfile($file);
     }
 }
Example #11
0
 protected function getMailer()
 {
     $classname = 'XoopsMailer';
     if (_USE_XOOPSMAILER == true) {
         require_once XOOPS_ROOT_PATH . '/class/xoopsmailer.php';
         if (is_file(XOOPS_ROOT_PATH . '/language/' . $this->root->mLanguageManager->mLanguageName . '/xoopsmailerlocal.php')) {
             require_once XOOPS_ROOT_PATH . '/language/' . $this->root->mLanguageManager->mLanguageName . '/xoopsmailerlocal.php';
             if (XC_CLASS_EXISTS('XoopsMailerLocal')) {
                 $classname = 'XoopsMailerLocal';
             }
         }
     } else {
         require_once XOOPS_ROOT_PATH . '/class/mail/phpmailer/class.phpmailer.php';
         require_once _MY_MODULE_PATH . 'class/MyMailer.class.php';
         $classname = 'My_Mailer';
     }
     return new $classname();
 }
 /**
  * タイプに合わせて、専用のクラスオブジェクトを生成
  *
  * 例.
  * <code>
  * require_once("MobilePictogramConverter.php");
  *
  * $mpc =& MobilePictogramConverter::factory($str, MPC_FROM_FOMA, MPC_FROM_CHARSET_SJIS);
  * if (is_object($mpc) == false) {
  *     die($mpc);
  * }
  * </code>
  *
  * @param string  $str     変換前文字列
  * @param string  $carrier $strの絵文字キャリア (MPC_FROM_FOMA, MPC_FROM_EZWEB, MPC_FROM_SOFTBANK)
  * @param string  $charset 文字コード         (MPC_FROM_CHARSET_SJIS, MPC_FROM_CHARSET_UTF8)
  * @param string  $type    $strの絵文字タイプ  (MPC_FROM_OPTION_RAW, MPC_FROM_OPTION_WEB, MPC_FROM_OPTION_IMG)
  * @return mixed
  */
 public static function &factory($str, $carrier, $charset, $type = MPC_FROM_OPTION_RAW)
 {
     $filepath = dirname(__FILE__) . '/Carrier/' . strtolower($carrier) . '.php';
     if (file_exists($filepath) == false) {
         $error = 'The file doesn\'t exist.';
         return $error;
     }
     require_once $filepath;
     $classname = 'MPC_' . $carrier;
     if (XC_CLASS_EXISTS($classname) == false) {
         $error = 'The class doesn\'t exist.';
         return $error;
     }
     $mpc = new $classname();
     $mpc->setFromCharset($charset);
     $mpc->setString($str);
     $mpc->setFrom(strtoupper($carrier));
     $mpc->setStringType($type);
     return $mpc;
 }
Example #13
0
function smarty_modifier_hyp_emoji_pad($id = '', $checkmsg = '', $clearDisplayId = '', $emojiurl = '', $writeJS = TRUE, $emj_list = NULL)
{
    if (!function_exists('XC_CLASS_EXISTS') || !XC_CLASS_EXISTS('HypCommonFunc')) {
        return 'Class "HypCommonFunc" not exists.';
    }
    if (empty($id)) {
        return 'Parameter "id" is not set.';
    }
    $writeJS = (bool) $writeJS;
    $emj_list = empty($params['emojiList']) ? NULL : $params['emojiList'];
    if (is_string($emj_list)) {
        if (strtolower($emj_list) === 'all') {
            $emj_list = 'all';
        } else {
            if (!empty($emj_list)) {
                $emj_list = explode(',', $emj_list);
                $emj_list = array_map('trim', $emj_list);
                $emj_list = array_map('intval', $emj_list);
            }
        }
    }
    return HypCommonFunc::make_emoji_pad($id, $checkmsg, $clearDisplayId, $emojiurl, $writeJS, $emj_list);
}
Example #14
0
function xpwiki_pagecss_filter(&$css, $chrctor)
{
    if (!extension_loaded('mbstring')) {
        if (!function_exists('XC_CLASS_EXISTS')) {
            include XOOPS_TRUST_PATH . '/class/hyp_common/XC_CLASS_EXISTS.inc.php';
        }
        if (!XC_CLASS_EXISTS('HypMBString')) {
            include XOOPS_TRUST_PATH . '/class/hyp_common/mbemulator/mb-emulator.php';
        }
    }
    $css = mb_convert_kana($css, 'asKV', mb_detect_encoding($css));
    $css = preg_replace('/(expression|javascript|vbscript|@import|cookie|eval|behavior|behaviour|binding|include-source|@i|[\\x00-\\x08\\x0e-\\x1f\\x7f]+|\\\\(?![\'"{};:()#A*]))/i', '', $css);
    $css = str_replace(array('*/', '<', '>', '&#'), array('*/  ', '&lt;', '&gt;', ''), $css);
}
Example #15
0
 function invoke_method()
 {
     $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
     if ($this->wsdl) {
         if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
             $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
             $this->appendDebug('opData=' . $this->varDump($this->opData));
         } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
             // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
             $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
             $this->appendDebug('opData=' . $this->varDump($this->opData));
             $this->methodname = $this->opData['name'];
         } else {
             $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
             $this->fault('Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
             return;
         }
     } else {
         $this->debug('in invoke_method, no WSDL to validate method');
     }
     // if a . is present in $this->methodname, we see if there is a class in scope,
     // which could be referred to. We will also distinguish between two deliminators,
     // to allow methods to be called a the class or an instance
     $class = '';
     $method = '';
     if (strpos($this->methodname, '..') > 0) {
         $delim = '..';
     } else {
         if (strpos($this->methodname, '.') > 0) {
             $delim = '.';
         } else {
             $delim = '';
         }
     }
     if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 && XC_CLASS_EXISTS(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
         // get the class and method name
         $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
         $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
         $this->debug("in invoke_method, class={$class} method={$method} delim={$delim}");
     }
     // does method exist?
     if ($class == '') {
         if (!function_exists($this->methodname)) {
             $this->debug("in invoke_method, function '{$this->methodname}' not found!");
             $this->result = 'fault: method not found';
             $this->fault('Client', "method '{$this->methodname}' not defined in service");
             return;
         }
     } else {
         $method_to_compare = substr(phpversion(), 0, 2) == '4.' ? strtolower($method) : $method;
         if (!in_array($method_to_compare, get_class_methods($class))) {
             $this->debug("in invoke_method, method '{$this->methodname}' not found in class '{$class}'!");
             $this->result = 'fault: method not found';
             $this->fault('Client', "method '{$this->methodname}' not defined in service");
             return;
         }
     }
     // evaluate message, getting back parameters
     // verify that request parameters match the method's signature
     if (!$this->verify_method($this->methodname, $this->methodparams)) {
         // debug
         $this->debug('ERROR: request not verified against method signature');
         $this->result = 'fault: request failed validation against method signature';
         // return fault
         $this->fault('Client', "Operation '{$this->methodname}' not defined in service.");
         return;
     }
     // if there are parameters to pass
     $this->debug('in invoke_method, params:');
     $this->appendDebug($this->varDump($this->methodparams));
     $this->debug("in invoke_method, calling '{$this->methodname}'");
     if ($class == '') {
         $this->debug('in invoke_method, calling function using call_user_func_array()');
         $call_arg = "{$this->methodname}";
         // straight assignment changes $this->methodname to lower case after call_user_func_array()
     } elseif ($delim == '..') {
         $this->debug('in invoke_method, calling class method using call_user_func_array()');
         $call_arg = array($class, $method);
     } else {
         $this->debug('in invoke_method, calling instance method using call_user_func_array()');
         $instance = new $class();
         $call_arg = array(&$instance, $method);
     }
     //
     // Insert CUBE CODE
     //
     $root =& XCube_Root::getSingleton();
     // $root->mContext->mUser->setService(true);
     $retValue = call_user_func_array($call_arg, array($root->mContext->mUser, $this->methodparams));
     if (is_array($retValue)) {
         $retValue = $this->_encodeUTF8($retValue, $root->mLanguageManager);
     } else {
         $retValue = $root->mLanguageManager->encodeUTF8($retValue);
     }
     $this->methodreturn = $retValue;
     $this->debug('in invoke_method, methodreturn:');
     $this->appendDebug($this->varDump($this->methodreturn));
     $this->debug("in invoke_method, called method {$this->methodname}, received {$this->methodreturn} of type " . gettype($this->methodreturn));
 }
Example #16
0
<?php

// $Id: hyp_get_engine.php,v 1.19 2012/01/04 14:11:20 nao-pon Exp $
// HypGetQueryWord Class by nao-pon http://hypweb.net
////////////////////////////////////////////////
if (!XC_CLASS_EXISTS('HypCommonFunc')) {
    include dirname(__FILE__) . '/hyp_common_func.php';
}
if (!XC_CLASS_EXISTS('HypGetQueryWord')) {
    class HypGetQueryWord
    {
        function set_constants($qw = 'HYP_QUERY_WORD', $qw2 = 'HYP_QUERY_WORD2', $en = 'HYP_SEARCH_ENGINE_NAME', $tmpdir = '', $enc = 'EUC-JP')
        {
            $use_kakasi = $qw2;
            $enc = strtoupper($enc);
            list($getengine_name, $getengine_query, $getengine_query2) = HypGetQueryWord::se_getengine($tmpdir, $enc, $use_kakasi);
            define($qw, $getengine_query);
            if ($use_kakasi) {
                define($qw2, $getengine_query2);
            }
            define($en, $getengine_name);
        }
        function se_getengine($tmpdir, $enc, $use_kakasi)
        {
            $_query = array_merge($_POST, $_GET);
            $_query = HypCommonFunc::stripslashes_gpc($_query);
            $query = isset($_query['query']) ? $_query['query'] : '';
            if ($query) {
                $query = preg_replace('/^("|\')(.+)\\1$/', '$2', $query);
            }
            if (!$query) {
Example #17
0
 function plugin_moblog_action()
 {
     error_reporting(0);
     $this->debug = array();
     $this->admin = $this->root->userinfo['admin'];
     $this->chk_fp = NULL;
     $this->output_mode = isset($this->root->vars['om']) && $this->root->vars['om'] === 'rss' ? 'rss' : 'img';
     $host = $user = $pass = $port = '';
     $execution_time = intval(ini_get('max_execution_time'));
     //設定ファイル読み込み
     if (isset($this->config['host'])) {
         $host = (string) $this->config['host'];
     }
     if (isset($this->config['mail'])) {
         $mail = (string) $this->config['mail'];
     }
     if (isset($this->config['user'])) {
         $user = (string) $this->config['user'];
     }
     if (isset($this->config['pass'])) {
         $pass = (string) $this->config['pass'];
     }
     if (isset($this->config['port'])) {
         $port = (int) $this->config['port'];
     }
     foreach (array('mail', 'host', 'port', 'user', 'pass') as $key) {
         $_key = 'moblog_pop_' . $key;
         if (!empty($this->root->{$_key})) {
             ${$key} = $this->root->{$_key};
         }
     }
     if (!$host || !$user || !$pass || !$port) {
         $this->plugin_moblog_output();
     }
     $ref_option = (string) $this->config['ref'];
     $maxbyte = (int) $this->config['maxbyte'];
     $body_limit = (int) $this->config['body_limit'];
     $refresh_min = (int) $this->config['refresh_min'];
     $nosubject = (string) $this->config['nosubject'];
     $deny = (array) $this->config['deny'];
     $deny_mailer = (string) $this->config['deny_mailer'];
     $deny_title = (string) $this->config['deny_title'];
     $deny_lang = (string) $this->config['deny_lang'];
     $subtype = (string) $this->config['subtype'];
     $viri = (string) $this->config['viri'];
     $del_ereg = (string) $this->config['del_ereg'];
     $word = (array) $this->config['word'];
     $imgonly = (int) $this->config['imgonly'];
     $chk_file = $this->cont['CACHE_DIR'] . "moblog.chk";
     if (!is_file($chk_file)) {
         touch($chk_file);
     } else {
         if ($refresh_min * 60 > $this->cont['UTC'] - filemtime($chk_file) && empty($this->root->vars['now'])) {
             $this->plugin_moblog_output();
         } else {
             $this->func->pkwk_touch_file($chk_file);
         }
     }
     if ($this->config['check_interval']) {
         $interval = max($this->config['check_interval'], $this->config['refresh_min']);
         $data = array('action' => 'plugin_func', 'plugin' => 'moblog', 'func' => 'plugin_moblog_action');
         $this->func->regist_jobstack($data, 0, $interval * 60);
     }
     $this->chk_fp = fopen($chk_file, 'wb');
     if (!flock($this->chk_fp, LOCK_EX)) {
         $this->plugin_moblog_output();
     }
     // user_pref 読み込み
     $adr2page = (array) $this->config['adr2page'];
     $user_pref_all = $this->func->get_user_pref();
     if ($user_pref_all) {
         foreach ($user_pref_all as $_uid => $_dat) {
             $_dat = unserialize($_dat);
             if (!empty($_dat['moblog_base_page'])) {
                 if (!empty($_dat['moblog_mail_address'])) {
                     $adr2page[strtolower($_dat['moblog_mail_address'])] = array($_dat['moblog_base_page'], $_uid);
                 } else {
                     if (!empty($_dat['moblog_user_mail'])) {
                         $adr2page[strtolower($_dat['moblog_user_mail'])] = array($_dat['moblog_base_page'], $_uid);
                     }
                 }
             }
         }
     }
     // SMS(MMS) 経由のデーター読み込み
     if ($smsdata = $this->func->cache_get_db(null, 'moblog')) {
         foreach ($smsdata as $_data) {
             $_data = unserialize($_data);
             $adr2page = array_merge($adr2page, $_data);
         }
     }
     // attach プラグイン読み込み
     $attach = $this->func->get_plugin_instance('attach');
     // wait 指定
     $wait = empty($this->root->vars['wait']) ? 0 : (int) $this->root->vars['wait'];
     sleep(min(5, $wait));
     // 接続開始
     $err = "";
     $num = $size = $errno = 0;
     $this->sock = fsockopen($host, $port, $err, $errno, 10) or $this->plugin_moblog_error_output('Could not connect to ' . $host . ':' . $port);
     $buf = fgets($this->sock, 512);
     if (substr($buf, 0, 3) != '+OK') {
         $this->plugin_moblog_error_output($buf);
     }
     $buf = $this->plugin_moblog_sendcmd("USER {$user}");
     if (substr($buf, 0, 3) != '+OK') {
         $this->plugin_moblog_error_output($buf);
     }
     $buf = $this->plugin_moblog_sendcmd("PASS {$pass}");
     if (substr($buf, 0, 3) != '+OK') {
         $this->plugin_moblog_error_output($buf);
     }
     $data = $this->plugin_moblog_sendcmd("STAT");
     //STAT -件数とサイズ取得 +OK 8 1234
     sscanf($data, '+OK %d %d', $num, $size);
     if ($num == "0") {
         $buf = $this->plugin_moblog_sendcmd("QUIT");
         //バイバイ
         fclose($this->sock);
         $this->debug[] = 'No mail.';
         $this->plugin_moblog_output();
     }
     $this->debug[] = $num . ' message(s) found.';
     $tmpfiles = array();
     // 件数分
     for ($i = 1; $i <= $num; $i++) {
         $line = $this->plugin_moblog_sendcmd("RETR {$i}");
         //RETR n -n番目のメッセージ取得(ヘッダ含
         $dat = '';
         while (!preg_match("/^\\.\r\n/", $line) && $line !== false) {
             //EOFの.まで読む
             $line = fgets($this->sock, 4096);
             $dat .= $line;
         }
         $data = $this->plugin_moblog_sendcmd("DELE {$i}");
         //DELE n n番目のメッセージ削除
         $tmpfname = tempnam($this->cont['CACHE_DIR'], 'moblog');
         file_put_contents($tmpfname, $dat);
         $tmpfiles[] = $tmpfname;
     }
     $buf = $this->plugin_moblog_sendcmd("QUIT");
     //バイバイ
     fclose($this->sock);
     foreach ($tmpfiles as $tmpfname) {
         if ($execution_time) {
             @set_time_limit($execution_time);
         }
         $write = true;
         $subject = $from = $text = $atta = $part = $filename = $charset = '';
         $this->user_pref = array();
         $this->post_options = array();
         $this->is_newpage = 0;
         $filenames = array();
         $body_text = array();
         $rotate = 0;
         $page = '';
         $exifgeo = array();
         $attach_only = false;
         $this->root->vars['refid'] = '';
         unset($this->root->rtf['esummary'], $this->root->rtf['twitter_update']);
         $dat = file_get_contents($tmpfname);
         unlink($tmpfname);
         list($head, $body) = $this->plugin_moblog_mime_split($dat);
         // To:ヘッダ確認
         $treg = array();
         $to_ok = FALSE;
         if (preg_match("/^To:[ \t]*([^\r\n]+)/im", $head, $treg)) {
             $treg[1] = $this->plugin_moblog_addr_search($treg[1]);
             $mail_reg = preg_quote($mail, '/');
             $mail_reg = '/' . str_replace('\\*', '[^@]*?', $mail_reg) . '/i';
             //if ($mail === $treg[1]) {
             if (preg_match($mail_reg, $treg[1])) {
                 $to = $treg[1];
                 $to_ok = TRUE;
             } else {
                 if (preg_match("/^X-Forwarded-To:[ \t]*([^\r\n]+)/im", $head, $treg)) {
                     //if ($mail === $treg[1]) {
                     $treg[1] = $this->plugin_moblog_addr_search($treg[1]);
                     if (preg_match($mail_reg, $treg[1])) {
                         $to = $treg[1];
                         $to_ok = TRUE;
                     }
                 }
             }
         }
         if (!$to_ok) {
             $write = false;
             $this->debug[] = 'Bad To: ' . $to;
         }
         $to = strtolower($to);
         // Received-SPF: のチェック
         if ($this->config['allow_spf']) {
             if (preg_match('/^Received-SPF:\\s*([a-z]+)/im', $head, $match)) {
                 if (!preg_match($this->config['allow_spf'], $match[1])) {
                     $write = false;
                     $this->debug[] = 'Bad SPF.';
                 }
             }
         }
         // メーラーのチェック
         $mreg = array();
         if ($write && preg_match("#^(X-Mailer|X-Mail-Agent):[ \t]*([^\r\n]+)#im", $head, $mreg)) {
             if ($deny_mailer) {
                 if (preg_match($deny_mailer, $mreg[2])) {
                     $write = false;
                     $this->debug[] = 'Bad mailer.';
                 }
             }
         }
         // キャラクターセットのチェック
         if ($write && preg_match('/charset\\s*=\\s*"?([^"\\r\\n]+)/i', $head, $mreg)) {
             $charset = $mreg[1];
             if ($deny_lang) {
                 if (preg_match($deny_lang, $charset)) {
                     $write = false;
                     $this->debug[] = 'Bad charset.';
                 }
             }
         }
         // 日付の抽出
         $datereg = array();
         preg_match("#^Date:[ \t]*([^\r\n]+)#im", $head, $datereg);
         $now = strtotime($datereg[1]);
         if ($now == -1) {
             $now = $this->cont['UTC'];
         }
         // 送信者アドレスの抽出
         $freg = array();
         if (preg_match("#^From:[ \t]*([^\r\n]+)#im", $head, $freg)) {
             $from = $this->plugin_moblog_addr_search($freg[1]);
         } elseif (preg_match("#^Reply-To:[ \t]*([^\r\n]+)#im", $head, $freg)) {
             $from = $this->plugin_moblog_addr_search($freg[1]);
         } elseif (preg_match("#^Return-Path:[ \t]*([^\r\n]+)#im", $head, $freg)) {
             $from = $this->plugin_moblog_addr_search($freg[1]);
         }
         $from = strtolower($from);
         // サブジェクトの抽出
         $subreg = array();
         if (preg_match("#^Subject:[ \t]*([^\r\n]+)#im", $head, $subreg)) {
             if (HypCommonFunc::get_version() >= '20081215') {
                 if (!XC_CLASS_EXISTS('MobilePictogramConverter')) {
                     HypCommonFunc::loadClass('MobilePictogramConverter');
                 }
                 $mpc =& MobilePictogramConverter::factory_common();
             } else {
                 $mpc = null;
             }
             // 改行文字削除
             $subject = str_replace(array("\r", "\n"), "", $subreg[1]);
             $subject = $this->mime_decode($subject, $mpc, $from);
             // ^\*\d+ 認証キー抽出
             $_reg = '/^\\*(\\d+)/i';
             if (preg_match($_reg, $subject, $match)) {
                 $this->post_options['auth_code'] = $match[1];
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             // ページ指定コマンド検出
             $_reg = '/@&([^&]+)&/';
             if (preg_match($_reg, $subject, $match)) {
                 $page = $match[1];
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             // ダイレクトページ指定コマンド検出
             $_reg = '/@&([^\\$]+)\\$/';
             if (preg_match($_reg, $subject, $match)) {
                 $page = $match[1];
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
                 $this->post_options['directpage'] = 1;
             }
             // 回転指定コマンド検出
             $_reg = '/@(r|l)\\b/i';
             if (preg_match($_reg, $subject, $match)) {
                 $rotate = strtolower($match[1]) == "r" ? 1 : 3;
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             $_reg = '/\\b(r|l)@/i';
             // compat for old type
             if (preg_match($_reg, $subject, $match)) {
                 $rotate = strtolower($match[1]) == "r" ? 1 : 3;
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             // @new 新規ページ指定コマンド検出
             $_reg = '/@new\\b/i';
             if (preg_match($_reg, $subject)) {
                 $this->post_options['new'] = true;
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             // @p\d+ 対象ページ指定(過去へxページ)コマンド検出
             $_reg = '/@p(\\d+)/i';
             if (preg_match($_reg, $subject, $match)) {
                 $this->post_options['page_past'] = $match[1];
                 $subject = trim(preg_replace($_reg, '', $subject));
             }
             // マップ作成コマンド検出
             $_reg = '/@map\\b/i';
             if (preg_match($_reg, $subject, $match)) {
                 $this->post_options['makemap'] = true;
                 $subject = trim(preg_replace($_reg, '', $subject));
             }
             // タグの抽出
             $_reg = '/#([^#]*)/';
             if (preg_match($_reg, $subject, $match)) {
                 $_tag = trim($match[1]);
                 if ($_tag) {
                     $this->post_options['tag'] = $_tag;
                 }
                 $subject = trim(preg_replace($_reg, '', $subject, 1));
             }
             // 未承諾広告カット
             if ($write && $deny_title) {
                 if (preg_match($deny_title, $subject)) {
                     $write = false;
                     $this->debug[] = 'Bad title.';
                 }
             }
         }
         $today = getdate($now);
         $date = sprintf("/%04d-%02d-%02d-0", $today['year'], $today['mon'], $today['mday']);
         // 拒否アドレス
         if ($write) {
             for ($f = 0; $f < count($deny); $f++) {
                 if (strpos($from, $deny[$f]) !== false) {
                     $write = false;
                     $this->debug[] = 'Bad from addr.';
                 }
             }
         }
         // 登録対象ページを設定
         if ($write) {
             $uid = 0;
             if (!empty($adr2page[$to])) {
                 if (!$page) {
                     $page = is_array($adr2page[$to]) ? $adr2page[$to][0] : $adr2page[$to];
                 }
                 if (is_array($adr2page[$to])) {
                     $uid = $adr2page[$to][1];
                     if (!empty($adr2page[$to][2])) {
                         $attach_only = true;
                         $this->post_options['directpage'] = 1;
                         if (!empty($adr2page[$to][3])) {
                             $this->root->vars['refid'] = $adr2page[$to][3];
                         }
                     }
                 }
             } else {
                 if (!empty($adr2page[$from])) {
                     if (!$page) {
                         $page = is_array($adr2page[$from]) ? $adr2page[$from][0] : $adr2page[$from];
                     }
                     if (is_array($adr2page[$from])) {
                         $uid = $adr2page[$from][1];
                     }
                 } else {
                     if (!$page) {
                         $page = is_array($adr2page['other']) ? $adr2page['other'][0] : $adr2page['other'];
                     }
                 }
             }
             $uid = intval($uid);
             // userinfo を設定
             $this->func->set_userinfo($uid);
             $this->root->userinfo['ucd'] = '';
             $this->root->cookie['name'] = '';
             // pginfo のキャッシュをクリア
             $this->func->get_pginfo($page, '', TRUE);
             if ($page) {
                 $page = $this->get_pagename($page, $uid, $today);
             }
             if ($page) {
                 if (!$this->func->is_pagename($page)) {
                     $write = false;
                     $this->debug[] = '"' . $page . '" is not the WikiName.';
                 } else {
                     if (!$attach_only) {
                         $this->user_pref = $this->func->get_user_pref($uid);
                         if (!empty($this->user_pref['moblog_auth_code'])) {
                             if ($this->user_pref['moblog_auth_code'] != $this->post_options['auth_code']) {
                                 $write = false;
                                 $this->debug[] = 'User auth key dose not mutch.';
                             }
                         }
                     }
                 }
             } else {
                 $write = false;
                 $this->debug[] = 'Allow page not found.' . $page;
             }
         }
         if ($write) {
             // マルチパートならばバウンダリに分割
             if (preg_match("#^Content-type:.*multipart/#im", $head)) {
                 $boureg = array();
                 preg_match('#boundary="([^"]+)"#i', $head, $boureg);
                 $body = str_replace($boureg[1], urlencode($boureg[1]), $body);
                 $part = split("\r\n--" . urlencode($boureg[1]) . "-?-?", $body);
                 $boureg2 = array();
                 if (preg_match('#boundary="([^"]+)"#i', $body, $boureg2)) {
                     //multipart/altanative
                     $body = str_replace($boureg2[1], urlencode($boureg2[1]), $body);
                     $body = preg_replace("#\r\n--" . urlencode($boureg[1]) . "-?-?\r\n#i", "", $body);
                     $part = split("\r\n--" . urlencode($boureg2[1]) . "-?-?", $body);
                 }
             } else {
                 $part[0] = $dat;
                 // 普通のテキストメール
             }
             foreach ($part as $multi) {
                 if (!$write) {
                     break;
                 }
                 @(list($m_head, $m_body) = $this->plugin_moblog_mime_split($multi));
                 if (!$m_body) {
                     continue;
                 }
                 $filename = '';
                 $m_body = preg_replace("/\r\n\\.\r\n\$/", "", $m_body);
                 if (!preg_match("#^Content-type:(.+)\$#im", $m_head, $match)) {
                     continue;
                 }
                 $match = trim($match[1]);
                 list($type, $charset) = array_pad(explode(';', $match), 2, '');
                 if ($charset) {
                     $charset = trim($charset);
                     if (preg_match('/^charset=(.+)$/i', $charset)) {
                         $charset = substr($charset, 8);
                     } else {
                         $charset = '';
                     }
                 }
                 list($main, $sub) = explode('/', trim($type));
                 $sub = strtolower($sub);
                 // 本文をデコード
                 if (strtolower($main) === 'text') {
                     if (!empty($body_text['plain']) && $sub === 'html') {
                         continue;
                     }
                     // キャラクターセットのチェック
                     if ($charset) {
                         if ($deny_lang) {
                             if (preg_match($deny_lang, $charset)) {
                                 $write = false;
                                 $this->debug[] = 'Bad charset.';
                                 break;
                             }
                         }
                     } else {
                         $charset = 'AUTO';
                     }
                     if (preg_match("#^Content-Transfer-Encoding:.*base64#im", $m_head)) {
                         $m_body = base64_decode($m_body);
                     }
                     if (preg_match("#^Content-Transfer-Encoding:.*quoted-printable#im", $m_head)) {
                         $m_body = quoted_printable_decode($m_body);
                     }
                     if (HypCommonFunc::get_version() >= '20081215') {
                         if (!isset($mpc)) {
                             if (!XC_CLASS_EXISTS('MobilePictogramConverter')) {
                                 HypCommonFunc::loadClass('MobilePictogramConverter');
                             }
                             $mpc =& MobilePictogramConverter::factory_common();
                         }
                         $m_body = $mpc->mail2ModKtai($m_body, $from, $charset);
                     }
                     $text = trim(mb_convert_encoding($m_body, $this->cont['SOURCE_ENCODING'], $charset));
                     // 改行文字統一
                     $text = str_replace(array("\r\n", "\r"), array("\n", "\n"), $text);
                     if ($sub === 'html') {
                         $text = str_replace("\n", '', $text);
                         $text = preg_replace('#<br([^>]+)?>#i', "\n", $text);
                         $text = preg_replace('#</?(?:p|tr|table|div)([^>]+)?>#i', "\n\n", $text);
                         $text = strip_tags($text);
                     }
                     // 改行3連続以上を #clear に置換
                     $text = preg_replace("/\n{3,}/", "\n#clear\n", $text);
                     if ($write) {
                         // 電話番号削除
                         //$text = preg_replace("#([[:digit:]]{11})|([[:digit:]\-]{13})#", "", $text);
                         // 下線削除
                         $text = preg_replace('#' . $del_ereg . '#', '', $text);
                         // mac削除
                         $text = preg_replace("#Content-type: multipart/appledouble;[[:space:]]boundary=(.*)#", "", $text);
                         // 広告等削除
                         if (is_array($word)) {
                             foreach ($word as $delstr) {
                                 $text = str_replace($delstr, "", $text);
                             }
                         }
                         if (strlen($text) > $body_limit) {
                             $text = substr($text, 0, $body_limit) . "...";
                         }
                     }
                     // ISBN, ASIN 変換
                     if (!empty($this->config['isbn'])) {
                         $isbn = $this->config['isbn'];
                         $text = preg_replace('/^([A-Za-z0-9]{10}|\\d{13})$/me', 'str_replace(\'__ISBN__\', \'$1\', \'' . $isbn . '\')', $text);
                     }
                     // キーワード@amazon 変換
                     if (!empty($this->config['amazon'])) {
                         $amazon = $this->config['amazon'];
                         $text = preg_replace('/^(.+)@amazon$/mei', 'str_replace(\'__KEYWORD__\', \'$1\', \'' . $amazon . '\')', $text);
                     }
                     $body_text[$sub][] = trim($text);
                 } else {
                     // ファイル名を抽出
                     $filereg = array();
                     if (preg_match("#name=\"?([^\"\n]+)\"?#i", $m_head, $filereg)) {
                         $filename = trim($filereg[1]);
                         $filename = $this->mime_decode($filename);
                     }
                     // 添付データをデコードして保存
                     if (preg_match("#^Content-Transfer-Encoding:.*base64#im", $m_head) && preg_match('#' . $subtype . '#i', $sub)) {
                         $tmp = base64_decode($m_body);
                         //$save_file = $this->cont['CACHE_DIR'].$this->func->encode($filename).".tmp";
                         if (strlen($tmp) < $maxbyte && $write && $attach) {
                             $save_file = tempnam(rtrim($this->cont['UPLOAD_DIR'], '/'), 'moblog');
                             chmod($save_file, 0606);
                             if (file_put_contents($save_file, $tmp, LOCK_EX)) {
                                 //Exif geo
                                 $exifgeo = $this->getExifGeo($save_file);
                                 list($usec) = explode(' ', microtime());
                                 if (!$filename) {
                                     $filename = $this->cont['UTC'] . '_' . $usec . '.' . $sub;
                                 }
                                 //回転指定
                                 if ($rotate) {
                                     HypCommonFunc::rotateImage($save_file, $rotate);
                                 }
                                 // ページが無ければ空ページを作成
                                 if (!$this->func->is_page($page)) {
                                     $this->func->make_empty_page($page, false);
                                 }
                                 //$attach = $this->func->get_plugin_instance('attach');
                                 $pass = null;
                                 if (!$uid) {
                                     list($pass) = explode('@', $from);
                                 }
                                 $res = $attach->do_upload($page, $filename, $save_file, false, $pass, true);
                                 if ($res['result']) {
                                     $filenames[] = array('name' => $res['name'], 'exifgeo' => $exifgeo);
                                 } else {
                                     $this->debug[] = $res['msg'];
                                 }
                             } else {
                                 $write = false;
                                 $this->debug[] = 'Can not make temp-file.';
                             }
                         } else {
                             $write = false;
                             $this->debug[] = 'Plugin attach was not found.';
                         }
                     }
                 }
             }
             if ($imgonly && !$filenames) {
                 $write = false;
                 $this->debug[] = 'Attach file was not found.';
             }
             $subject = trim($subject);
         }
         if (!empty($body_text['plain'])) {
             $text = join("\n\n", $body_text['plain']);
         } else {
             if (!empty($body_text['html'])) {
                 $text = join("\n\n", $body_text['html']);
             } else {
                 $text = '';
             }
         }
         // wikiページ書き込み
         if ($write && !$attach_only) {
             $this->plugin_moblog_page_write($page, $subject, $text, $filenames, $ref_option, $now);
         }
     }
     // imgタグ呼び出し
     $this->plugin_moblog_output();
 }
 /**
  * The generic factory for installers. This function is used by other
  * utility functions.
  * @param string $dirname
  * @param string $mode 'installer' 'updater' or 'uninstaller'
  * @param string $defaultClassName
  */
 function &_createInstaller($dirname, $mode, $defaultClassName)
 {
     $info = array();
     $filepath = XOOPS_MODULE_PATH . "/{$dirname}/xoops_version.php";
     if (file_exists($filepath)) {
         @(include $filepath);
         $info = $modversion;
     }
     if (isset($info['legacy_installer']) && is_array($info['legacy_installer']) && isset($info['legacy_installer'][$mode])) {
         $updateInfo = $info['legacy_installer'][$mode];
         $className = $updateInfo['class'];
         $filePath = isset($updateInfo['filepath']) ? $updateInfo['filepath'] : XOOPS_MODULE_PATH . "/{$dirname}/admin/class/{$className}.class.php";
         $namespace = isset($updateInfo['namespace']) ? $updateInfo['namespace'] : ucfirst($dirname);
         if ($namespace != null) {
             $className = "{$namespace}_{$className}";
         }
         if (!XC_CLASS_EXISTS($className) && file_exists($filePath)) {
             require_once $filePath;
         }
         if (XC_CLASS_EXISTS($className)) {
             $installer = new $className();
             return $installer;
         }
     }
     $installer = new $defaultClassName();
     return $installer;
 }
Example #19
0
    function plugin_edit_write()
    {
        $_uname = empty($this->root->vars['uname']) || !empty($this->root->vars['anonymous']) ? $this->root->siteinfo['anonymous'] : $this->root->vars['uname'];
        if ($_uname) {
            if (!empty($this->root->vars['anonymous'])) {
                $this->root->cookie['name'] = $_uname;
            } else {
                // save name to cookie
                $this->func->save_name2cookie($_uname);
            }
        }
        $page = isset($this->root->vars['page']) ? $this->root->vars['page'] : '';
        $add = isset($this->root->vars['add']) ? $this->root->vars['add'] : '';
        $digest = isset($this->root->vars['digest']) ? $this->root->vars['digest'] : '';
        $paraid = isset($this->root->vars['paraid']) ? $this->root->vars['paraid'] : '';
        $original = '';
        $this->root->vars['msg'] = preg_replace($this->cont['PLUGIN_EDIT_FREEZE_REGEX'], '', $this->root->vars['msg']);
        $this->root->vars['msg'] = $this->func->remove_pginfo($this->root->vars['msg']);
        $msg =& $this->root->vars['msg'];
        // Reference
        // Get original data from cache DB.
        if (!empty($this->root->vars['orgkey'])) {
            $original = (string) $this->func->cache_get_db($this->root->vars['orgkey'], 'edit', true);
            $original = $this->func->remove_pginfo($original);
        }
        // ParaEdit
        $hash = '';
        if ($paraid) {
            if (!$original) {
                $original = $this->func->remove_pginfo($this->func->get_source($page, TRUE, TRUE));
            }
            $source = preg_split('/([^\\n]*\\n)/', $original, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
            if ($this->plugin_edit_parts($paraid, $source, $msg) !== FALSE) {
                $fullmsg = join('', $source);
            } else {
                // $this->root->vars['msg']だけがページに書き込まれてしまうのを防ぐ。
                $fullmsg = rtrim($original) . "\n\n" . $msg;
            }
            $msg = $fullmsg;
            $hash = '#' . $paraid;
        }
        // 文末処理
        $msg = rtrim($msg) . "\n";
        // 改行・TAB・スペースのみだったら削除とみなす
        $msg = preg_replace('/^\\s+$/', '', $msg);
        // Page title
        if ($msg && !empty($this->root->post['pgtitle'])) {
            $msg = $this->root->title_setting_string . trim($this->root->post['pgtitle']) . "\n" . $msg;
        }
        $retvars = array();
        // Collision Detection
        $oldpagesrc = $this->func->get_source($page, TRUE, TRUE);
        $oldpagemd5 = $this->func->get_digests($oldpagesrc);
        if ($digest != $oldpagemd5) {
            $this->root->vars['digest'] = $oldpagemd5;
            // Reset
            unset($this->root->vars['paraid']);
            // 更新が衝突したら全文編集に切り替え
            $oldpagesrc = $this->func->remove_pginfo($oldpagesrc);
            list($postdata_input, $auto) = $this->func->do_update_diff($oldpagesrc, $msg, $original);
            $retvars['msg'] = $this->root->_title_collided;
            $retvars['body'] = ($auto ? $this->root->_msg_collided_auto : $this->root->_msg_collided) . "\n";
            $retvars['body'] .= $this->root->do_update_diff_table;
            $retvars['body'] .= $this->func->edit_form($page, $postdata_input, $oldpagemd5, FALSE);
            if (isset($this->root->vars['ajax'])) {
                $this->func->convert_finisher($retvars['body']);
                $body = <<<EOD
<xpwiki>
<content><![CDATA[{$retvars['body']}]]></content>
<mode>preview</mode>
</xpwiki>
EOD;
                $this->func->send_xml($body);
            }
            return $retvars;
        }
        // Action?
        if ($add) {
            // Add
            if (isset($this->root->vars['add_top']) && $this->root->vars['add_top']) {
                $postdata = $msg . "\n\n" . $this->func->get_source($page, TRUE, TRUE);
            } else {
                $postdata = $this->func->get_source($page, TRUE, TRUE) . "\n\n" . $msg;
            }
        } else {
            // Edit or Remove
            $postdata =& $msg;
            // Reference
        }
        // NULL POSTING, OR removing existing page
        if (!$postdata) {
            $this->func->page_write($page, '');
            if ($this->root->trackback) {
                $this->func->tb_delete($page);
            }
            if ($this->root->maxshow_deleted && $this->func->is_page($this->root->whatsdeleted)) {
                $url = $this->func->get_page_uri($this->root->whatsdeleted, true);
            } else {
                $url = $this->cont['HOME_URL'];
            }
            $title = str_replace('$1', $this->func->htmlspecialchars($page), $this->root->_title_deleted);
            if (isset($this->root->vars['ajax'])) {
                $url = $this->func->htmlspecialchars($url, ENT_QUOTES);
                $body = <<<EOD
<xpwiki>
<content><![CDATA[{$title}]]></content>
<mode>delete</mode>
<url>{$url}</url>
</xpwiki>
EOD;
                $this->func->send_xml($body);
            }
            $this->func->redirect_header($url, 1, $title);
        }
        // $notimeupdate: Checkbox 'Do not change timestamp'
        $notimestamp = isset($this->root->vars['notimestamp']) && $this->root->vars['notimestamp'] != '';
        if ($this->root->notimeupdate > 1 && !$this->root->userinfo['admin']) {
            $notimestamp = false;
        }
        $this->func->page_write($page, $postdata, $this->root->notimeupdate != 0 && $notimestamp);
        if (isset($this->root->vars['ajax'])) {
            if (!empty($this->root->vars['nonconvert'])) {
                $body = '';
            } else {
                $obj = new XpWiki($this->root->mydirname);
                $obj->init($page);
                $obj->root->userinfo['uname_s'] = $this->func->htmlspecialchars($this->root->cookie['name']);
                $obj->execute();
                if (isset($obj->root->rtf['useJavascriptInHead'])) {
                    $body = '<script src="" />';
                } else {
                    $body = $obj->body;
                    // set target
                    if (isset($this->root->vars['popup'])) {
                        $body = preg_replace('/(<a[^>]+)(href=(?:"|\')[^#])/isS', '$1target="' . (intval($this->root->vars['popup']) === 1 ? '_parent' : $this->func->htmlspecialchars(substr($this->root->vars['popup'], 0, 30))) . '" $2', $body);
                    }
                    $body = str_replace(array('<![CDATA[', ']]>'), '', $body);
                }
                if (preg_match('/\\(\\([eisv]:[0-9a-f]{4}\\)\\)|\\[emj:\\d{1,4}(?::(?:im|ez|sb))?\\]/S', $body)) {
                    if (!XC_CLASS_EXISTS('MobilePictogramConverter')) {
                        HypCommonFunc::loadClass('MobilePictogramConverter');
                    }
                    if (XC_CLASS_EXISTS('MobilePictogramConverter')) {
                        $mpc =& MobilePictogramConverter::factory_common();
                        $mpc->setImagePath($this->cont['ROOT_URL'] . 'images/emoji');
                        $mpc->setString($body, FALSE);
                        $body = $mpc->autoConvertModKtai();
                    }
                }
            }
            $body = <<<EOD
<xpwiki>
<content><![CDATA[{$body}]]></content>
<mode>write</mode>
</xpwiki>
EOD;
            $this->func->send_xml($body);
        }
        $this->func->send_location($page, $hash);
    }
Example #20
0
 function emojiFilter($str)
 {
     if ($str === '' || strpos($str, '<html') === FALSE) {
         return false;
     }
     if (preg_match('/\\(\\([eisv]:[0-9a-f]{4}\\)\\)|\\[emj:\\d{1,4}(?::(?:im|ez|sb))?\\]/S', $str)) {
         if (!XC_CLASS_EXISTS('MobilePictogramConverter')) {
             HypCommonFunc::loadClass('MobilePictogramConverter');
         }
         $mpc =& MobilePictogramConverter::factory_common();
         $mpc->setImagePath(XOOPS_URL . '/images/emoji');
         $mpc->setString($str, FALSE);
         $str = $mpc->autoConvertModKtai();
         if (!$str) {
             return false;
         }
     }
     $this->changeContentLength = true;
     return $str;
 }
Example #21
0
 function _setupFilterChain()
 {
     $primaryPreloads = $this->mController->mRoot->getSiteConfig('Legacy.PrimaryPreloads');
     foreach ($primaryPreloads as $className => $classPath) {
         if (file_exists(XOOPS_ROOT_PATH . $classPath)) {
             require_once XOOPS_ROOT_PATH . $classPath;
             if (XC_CLASS_EXISTS($className) && !isset($this->_mLoadedFilterNames[$className])) {
                 $this->_mLoadedFilterNames[$className] = true;
                 $filter = new $className($this->mController);
                 $this->mController->addActionFilter($filter);
                 unset($filter);
             }
         }
     }
     //
     // Auto pre-loading.
     //
     if ($this->mController->mRoot->getSiteConfig('Legacy', 'AutoPreload') == 1) {
         $this->mController->_processPreload(XOOPS_ROOT_PATH . "/preload");
     }
 }
Example #22
0
 /**
  * @private
  * @brief Create an instance.
  * 
  * Create the instance dynamic with the rule and the string parameters.
  * First, load the file from $classPath. The rule is XOOPS_ROOT_PATH + 
  * $classPath + $className + .class.php. Next, create the instance of the
  * class if the class is defined rightly. This member function is called by
  * other member functions of XCube_Root.
  * 
  * @param $className string - the name of class.
  * @param $classPath string - the path that $className is defined in.
  * @param $root      string - the root path instead of Cube.Root.
  * @return Object
  * 
  * @todo If the file doesn't exist, require_once() raises fatal errors.
  */
 function &_createInstance($className, $classPath = null, $root = null)
 {
     $ret = null;
     if ($classPath != null) {
         if ($root == null) {
             $root = $this->mSiteConfig['Cube']['Root'];
         }
         if (is_file($root . $classPath)) {
             // [secret trick] ... Normally, $classPath has to point a directory.
             require_once $root . $classPath;
         } else {
             require_once $root . $classPath . '/' . $className . '.class.php';
         }
     }
     if (XC_CLASS_EXISTS($className)) {
         $ret = new $className();
     }
     return $ret;
 }
Example #23
0
 function plugin_tracker_get_fields($base, $refer, &$config)
 {
     $fields = array();
     foreach ($config->get('fields') as $field) {
         // $field[0]: Field name
         // $field[1]: Field name (for display)
         // $field[2]: Field type
         // $field[3]: Option
         // $field[3]: Option ("size", "cols", "rows", etc)
         // $field[4]: Default value
         $class = 'XpWikiTracker_field_' . $field[2];
         if (!XC_CLASS_EXISTS($class)) {
             // Default
             $field[2] = 'text';
             $class = 'XpWikiTracker_field_' . $field[2];
             $field[3] = '20';
         }
         $fieldname = $field[0];
         $fields[$fieldname] =& new $class($this->xpwiki, $field, $base, $refer, $config);
     }
     foreach (array('_date' => 'text', '_update' => 'date', '_past' => 'past', '_page' => 'page', '_name' => 'text', '_real' => 'real', '_refer' => 'page', '_base' => 'page', '_submit' => 'submit') as $fieldname => $type) {
         if (isset($fields[$fieldname])) {
             continue;
         }
         $field = array($fieldname, xpwiki_plugin_tracker::plugin_tracker_message('btn' . $fieldname), '', '20', '');
         $class = 'XpWikiTracker_field_' . $type;
         $fields[$fieldname] =& new $class($this->xpwiki, $field, $base, $refer, $config);
     }
     return $fields;
 }
Example #24
0
 /**
  * Write a module to the database
  *
  * @remark This method unsets cache of the module, and re-contruct the cache.
  *		   But this mechanism may break the reference to the previous cache....
  *		   Maybe that's no problem. But, we should notice it. 
  * @param	object	&$module reference to a {@link XoopsModule}
  * @return	bool
  **/
 function insert(&$module)
 {
     if (strtolower(get_class($module)) != 'xoopsmodule') {
         return false;
     }
     if (!$module->isDirty()) {
         return true;
     }
     if (!$module->cleanVars()) {
         return false;
     }
     foreach ($module->cleanVars as $k => $v) {
         ${$k} = $v;
     }
     if ($module->isNew()) {
         if (empty($mid)) {
             //Memo: if system module, mid might be set to 1
             $mid = $this->db->genId('modules_mid_seq');
         }
         $sql = sprintf("INSERT INTO %s (mid, name, version, last_update, weight, isactive, dirname, trust_dirname, role, hasmain, hasadmin, hassearch, hasconfig, hascomments, hasnotification) VALUES (%u, %s, %u, %u, %u, %u, %s, %s, %s, %u, %u, %u, %u, %u, %u)", $this->db->prefix('modules'), $mid, $this->db->quoteString($name), $version, time(), $weight, 1, $this->db->quoteString($dirname), $this->db->quoteString($trust_dirname), $this->db->quoteString($role), $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification);
     } else {
         $sql = sprintf("UPDATE %s SET name = %s, dirname = %s, trust_dirname = %s, role = %s, version = %u, last_update = %u, weight = %u, isactive = %u, hasmain = %u, hasadmin = %u, hassearch = %u, hasconfig = %u, hascomments = %u, hasnotification = %u WHERE mid = %u", $this->db->prefix('modules'), $this->db->quoteString($name), $this->db->quoteString($dirname), $this->db->quoteString($trust_dirname), $this->db->quoteString($role), $version, time(), $weight, $isactive, $hasmain, $hasadmin, $hassearch, $hasconfig, $hascomments, $hasnotification, $mid);
     }
     if (!($result = $this->db->query($sql))) {
         return false;
     }
     $module->unsetNew();
     if (empty($mid)) {
         $mid = $this->db->getInsertId();
     }
     $module->assignVar('mid', $mid);
     if (!empty($this->_cachedModule_dirname[$dirname])) {
         unset($this->_cachedModule_dirname[$dirname]);
     }
     if (!empty($this->_cachedModule_mid[$mid])) {
         unset($this->_cachedModule_mid[$mid]);
     }
     $this->_cachedModule_dirname[$dirname] =& $module;
     $this->_cachedModule_mid[$mid] =& $module;
     if (XC_CLASS_EXISTS('Legacy_AdminSideMenu')) {
         Legacy_AdminSideMenu::clearCache();
     }
     return true;
 }
Example #25
0
 function &createBlockProcedure(&$block)
 {
     //
     // IMPORTANT CONVENTION
     //
     $retBlock = null;
     //
     // TODO need cache here?
     //
     XCube_DelegateUtils::call('Legacy_Utils.CreateBlockProcedure', new XCube_Ref($retBlock), $block);
     if (is_object($retBlock) && is_a($retBlock, 'Legacy_AbstractBlockProcedure')) {
         return $retBlock;
     }
     $func = $block->get('show_func');
     if (substr($func, 0, 4) == 'cl::') {
         $className = ucfirst($block->get('dirname')) . '_' . substr($func, 4);
         if (!XC_CLASS_EXISTS($className)) {
             $filePath = XOOPS_ROOT_PATH . '/modules/' . $block->get('dirname') . '/blocks/' . $block->get('func_file');
             if (!file_exists($filePath)) {
                 $retBlock = new Legacy_BlockProcedureAdapter($block);
                 return $retBlock;
             }
             require_once $filePath;
             if (!XC_CLASS_EXISTS($className)) {
                 $retBlock = new Legacy_BlockProcedureAdapter($block);
                 return $retBlock;
             }
         }
         $retBlock = new $className($block);
     } else {
         $retBlock = new Legacy_BlockProcedureAdapter($block);
     }
     return $retBlock;
 }
Example #26
0
<?php

/* mbstring emulator Class HypMBString
 * by nao-pon at hypweb.net
 * based on "mbstring emulator for Japanese by Andy"
 * 
 * license based on GPL(GNU General Public License)
 *
 * $Id: mb-emulator.php,v 1.13 2009/03/01 23:42:25 nao-pon Exp $
 */
if (!function_exists('XC_CLASS_EXISTS')) {
    require dirname(dirname(__FILE__)) . '/XC_CLASS_EXISTS.inc.php';
}
if (!XC_CLASS_EXISTS('HypMBString')) {
    if (!defined('MB_CASE_UPPER')) {
        define('MB_CASE_UPPER', 0);
    }
    if (!defined('MB_CASE_LOWER')) {
        define('MB_CASE_LOWER', 1);
    }
    if (!defined('MB_CASE_TITLE')) {
        define('MB_CASE_TITLE', 2);
    }
    if (!function_exists('mb_detect_order')) {
        function mb_detect_order($encoding_list = '')
        {
            $mb =& HypMBString::getInstance();
            return $mb->mb_detect_order($encoding_list);
        }
    }
    if (!function_exists('mb_language')) {
Example #27
0
 function &_getMobilePictogramConverter()
 {
     if (!XC_CLASS_EXISTS('MobilePictogramConverter')) {
         HypCommonFunc::loadClass('MobilePictogramConverter');
     }
     $mpc =& MobilePictogramConverter::factory_common();
     $mpc->setImagePath($this->Config_emojiDir);
     $mpc->setFromCharset(strtoupper($this->outputEncode) === 'UTF-8' ? MPC_FROM_CHARSET_UTF8 : MPC_FROM_CHARSET_SJIS);
     $mpc->userAgent = $this->vars['ua']['agent'];
     return $mpc;
 }
Example #28
0
 function load_extensions($exts)
 {
     $base = $this->root->mytrustdirpath . "/class/extension";
     if (!is_array($exts)) {
         $exts = array($exts);
     }
     foreach ($exts as $name) {
         if (preg_match("/^[_0-9a-zA-Z-]+\$/", $name)) {
             include_once $base . "/" . $name . ".php";
             $class = "XPWikiExtension_" . $name;
             if (XC_CLASS_EXISTS($class)) {
                 $this->extension->{$name} = new $class($this);
             }
         }
     }
 }
 /**
  * This is utility member function for the sub-class controller. Load files
  * with the rule from $path, and add the instance of the sub-class to the
  * chain.
  *
  * @access protected
  * @param $path string Absolute path.
  */
 function _processPreload($path)
 {
     $path = $path . "/";
     if (is_dir($path)) {
         foreach (glob($path . '/*.class.php') as $file) {
             require_once $file;
             $className = basename($file, '.class.php');
             if (XC_CLASS_EXISTS($className) && !isset($this->_mLoadedFilterNames[$className])) {
                 $this->_mLoadedFilterNames[$className] = true;
                 $instance = new $className($this);
                 $this->addActionFilter($instance);
                 unset($instance);
             }
         }
     }
 }
Example #30
0
 /**
  * @public
  * @internal
  * @brief [static] Gets a XCube_Validator object by the rule name (depend name).
  * @param $dependName string
  * @return XCube_Validator
  * @attention
  *     Only 'XCube_ActionForm' class should use this class.
  */
 function &factoryClass($dependName)
 {
     static $_cache;
     if (!is_array($_cache)) {
         $_cache = array();
     }
     if (!isset($_cache[$dependName])) {
         // or switch?
         $class_name = "XCube_" . ucfirst($dependName) . "Validator";
         if (XC_CLASS_EXISTS($class_name)) {
             $_cache[$dependName] = new $class_name();
         } else {
             // FIXME:: use delegate?
             die("This is an error message of Alpha or Beta series. {$dependName} Validator is not found.");
         }
     }
     return $_cache[$dependName];
 }