예제 #1
0
파일: File.php 프로젝트: uwitec/outbuying
 function __construct($logFileName = "", $logPath = "")
 {
     if ($logFileName != "") {
         $this->_logFileName = $logFileName . '_' . date("ymd") . ".log";
     } else {
         /**
          * 因访问量增大,改为按小时记录
          * @author terry
          * @version 0.1.0
          * Mon Jul 07 14:59:05 CST 2008
          */
         $this->_logFileName = date("Ymd_H") . ".log";
     }
     $this->_logPath = $logPath == "" ? Watt_Config::getLogPath() : $logPath;
     if (!file_exists($this->_logPath)) {
         mkdir($this->_logPath, 0777, true);
         @chmod($this->_logPath, 0777);
     }
     $this->_hLogFile = fopen($this->_logPath . $this->_logFileName, "a");
     @chmod($this->_logPath . $this->_logFileName, 0766);
     //$this->_startTime = $this->_microtime_float();
     if (defined('APP_START_TIME')) {
         $this->_startTime = (int) (APP_START_TIME * 1000);
     } else {
         $this->_startTime = $this->_microtime_float();
     }
     $this->_lastLogTime = $this->_startTime;
     $this->logerSn = $this->_startTime;
 }
예제 #2
0
 /**
  * 调用配置文件的方法
  *
  * @return array
  */
 private function _getConfig()
 {
     if (!self::$_config) {
         self::$_config = Watt_Config::getCfgFromFile('sync/sync.conf.php');
     }
     return self::$_config;
 }
예제 #3
0
파일: Ext.php 프로젝트: uwitec/outbuying
    /**
     * 使用yui-ext建立TableGrid
     * 
     * <code>
     * $grid->showMe( array('gridId'=>'sql_grid') );
     * Watt_View_Helper_Ext::buildTableGrid( 'sql_grid' );
     * </code>
     *
     * @param string $gridId grid的ID
     */
    public static function buildTableGrid($gridId)
    {
        if (!self::$_loadedTableGridLib) {
            ?>
<script src="<?php 
            echo Watt_Config::getSiteRoot();
            ?>
js/ext-1.0/tpm/TableGrid.js"></script>
<?php 
            self::$_loadedTableGridLib = true;
        }
        ?>
<script>
/*
 * Ext JS Library 1.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */
Ext.onReady(function() {
	// create the grid
    var grid = new Ext.grid.TableGrid('<?php 
        echo $gridId;
        ?>
');
    grid.render();
});
</script>
<?php 
    }
예제 #4
0
 public function build($name, $value = null, $attribs = null, $disable = false)
 {
     //$info = $this->_getInfo($name, $value, $attribs);
     //extract($info); // name, value, attribs, options, listsep, disable
     // build the element
     if ($disable) {
         // disabled
         $xhtml = $this->_hidden($name, $value) . htmlspecialchars($value);
     } else {
         // enabled
         $id = "dingdan_selector_" . $name;
         $attribs["id"] = $id;
         $sitePath = Watt_Config::getSiteRoot();
         $xhtml = $this->_getCommonHtml();
         $xhtml .= Watt_View_Helper::buildElmentByVartype("C", $name, $value, $attribs);
         //echo "<script>alert('aa');</script>";
         /*
                     $xhtml = '<input type="text"'
                            . ' name="' . htmlspecialchars($name) . '"'
                            . ' value="' . htmlspecialchars($value) . '"'
                            . $this->_htmlAttribs($attribs)
                            . ' />';*/
         $xhtml .= '<a href="#" class="btn" type="button" id="btnSelectCr" onclick="ddSelTool.show(  \'' . $attribs["id"] . '\', this,\'\',\'s0=\'+document.all.' . $name . '.value+\'\' );return false;">' . i18ntrans('#选') . '</a>';
     }
     return $xhtml;
 }
예제 #5
0
 public function build($name, $value = null, $attribs = null, $disable = false)
 {
     //$info = $this->_getInfo($name, $value, $attribs);
     //extract($info); // name, value, attribs, options, listsep, disable
     // build the element
     if ($disable) {
         // disabled
         $xhtml = $this->_hidden($name, $value) . htmlspecialchars($value);
     } else {
         // enabled
         if (!isset($attribs["id"])) {
             $id = "person_selector_" . $name;
             $attribs["id"] = $id;
         }
         if (!isset($attribs["onclick"])) {
             $attribs["onclick"] = 'userSelTool.show( null, \'' . $attribs["id"] . '\', this, \'' . @$attribs["param"] . '\' );return false;';
             if (!isset($attribs["style"])) {
                 $attribs["style"] = 'cursor:pointer;';
             }
         }
         $sitePath = Watt_Config::getSiteRoot();
         $xhtml = $this->_getCommonHtml();
         $xhtml .= Watt_View_Helper::buildElmentByVartype("C", $name, $value, $attribs);
         /*
                     $xhtml = '<input type="text"'
                            . ' name="' . htmlspecialchars($name) . '"'
                            . ' value="' . htmlspecialchars($value) . '"'
                            . $this->_htmlAttribs($attribs)
                            . ' />';*/
         $xhtml .= '<a href="#" class="btn" type="button" id="btnSelectCr" onclick="userSelTool.show( null, \'' . $attribs["id"] . '\', this, \'' . @$attribs["param"] . '\' );return false;">' . i18ntrans('#选') . '</a>';
     }
     return $xhtml;
 }
예제 #6
0
    public function build($name, $value = null, $attribs = null, $disable = false)
    {
        //$info = $this->_getInfo($name, $value, $attribs);
        //extract($info); // name, value, attribs, options, listsep, disable
        // build the element
        if ($disable) {
            // disabled
            $xhtml = $this->_hidden($name, $value) . htmlspecialchars($value);
        } else {
            // enabled
            if (!isset($attribs['id'])) {
                $id = "date" . mt_rand(1000, 9999);
                $attribs["id"] = $id;
            } else {
                $id = $attribs["id"];
            }
            $sitePath = Watt_Config::getSiteRoot();
            $xhtml = Watt_View_Helper::buildElmentByVartype("C", $name, $value, $attribs);
            $xhtml .= $this->_getCommonHtml();
            /*
                        $xhtml = '<input type="text"'
                               . ' name="' . htmlspecialchars($name) . '"'
                               . ' value="' . htmlspecialchars($value) . '"'
                               . $this->_htmlAttribs($attribs)
                               . ' />';*/
            $xhtml .= <<<EOT
<img id="dateButton_{$id}" src="{$sitePath}js/john/jscalendar/calendar.gif" border="0" align="absmiddle" style="cursor:pointer" />
<!--<input   name="start_date[{\$i}]" type="text" class="Input1" id="start_date[{\$i}]" value="{\$start_mren}" size="14" readonly/>-->
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "{$id}",
EOT;
            if ($this->_showTimes) {
                $xhtml .= '
        ifFormat       :    "%Y-%m-%d %H:%M",
        showsTime      :    true,';
            } else {
                if ($this->_showTimeSecs) {
                    $xhtml .= '
        ifFormat       :    "%Y-%m-%d %H:%M:%S",
        showsTime      :    true,';
                } else {
                    $xhtml .= '
        ifFormat       :    "%Y-%m-%d",';
                }
            }
            $xhtml .= <<<EOT
        button         :    "dateButton_{$id}",
        singleClick    :    true,
        step           :    1
    });
</script>
EOT;
            /* $xhtml .= <<<EOT
                    <img id="dateButton_{$id}" src="{$sitePath}js/john/jscalendar/calendar.gif" border="0" align="absmiddle" style="cursor:pointer" onClick="Calendar.setDayHM(document.getElementById({$id}),0,'');"/>       
            EOT;*/
        }
        return $xhtml;
    }
예제 #7
0
파일: Cache.php 프로젝트: uwitec/outbuying
 function __construct($cacheLimitTime)
 {
     $this->cacheRoot = Watt_Config::getRootPath() . 'cache/cachefiles/';
     if (intval($cacheLimitTime)) {
         $this->cacheLimitTime = $cacheLimitTime;
     }
     $this->cacheFileName = $this->getCacheFileName();
     ob_start();
 }
예제 #8
0
파일: Utils.php 프로젝트: uwitec/outbuying
 /**
  * 获得 经过 组ID 偏移后的 RealEpollId 
  *
  * @param int $idOffset
  * @return int
  */
 public static function getRealEpollId($idOffset = 0)
 {
     if (defined('TQ_33')) {
         if (Watt_Config::getEpollGroupId()) {
             $epo = Watt_Config::getEpollGroupId() * 65536 * 256 + $idOffset;
         } else {
             $epo = 65536 * 256 + $idOffset;
         }
     } else {
         $epo = $idOffset;
     }
     return $epo;
 }
예제 #9
0
파일: Mail.php 프로젝트: uwitec/outbuying
 /**
  * 邮件模板函数
  *
  * @param unknown_type $model      模板名称
  * @param unknown_type $varname    替换数据
  */
 public static function formatMailBody($model, $searchname, $replcename)
 {
     $_searchname = array();
     $path = Watt_Config::getConfigPath() . "public/emailtemplates/" . $model;
     $str = file_get_contents($path);
     if (count($searchname) > 0) {
         foreach ($searchname as $val) {
             $_searchname[] = "<?\$" . $val . "?>";
         }
     }
     //return $str;
     $search = str_replace($_searchname, $replcename, $str);
     return $search;
 }
예제 #10
0
 /**
  * 集成工具
  * 将个人目录中的
  * app/
  * lib/
  * view/
  *
  * 目录中的文件复制到集成目录
  *
  * @author terry
  * @version v1.0
  */
 function indexAction()
 {
     return false;
     /**
      * 禁止提交;
      */
     //error_reporting(E_ALL);
     //include '/home/terry/integration.php';
     //$fromModelDir = dirname( __FILE__ );
     $fromModelDir = Watt_Config::getRootPath();
     $toModelDir = Watt_Config::getRootPath(1);
     //$toModelDir   = "/site/includes/tpm/";
     if ($toModelDir == "") {
         echo "Target dir is blank!";
         exit;
     }
     echo "<pre>";
     echo "1) copying app files...\n\n";
     $fromFolder = $fromModelDir . 'app/';
     $toFolder = $toModelDir . 'app/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "2) copying lib files...\n\n";
     $fromFolder = $fromModelDir . 'lib/';
     $toFolder = $toModelDir . 'lib/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "3) copying view files...\n\n";
     $fromFolder = $fromModelDir . 'view/';
     $toFolder = $toModelDir . 'view/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "4) copying language files...\n\n";
     $fromFolder = $fromModelDir . 'language/';
     $toFolder = $toModelDir . 'language/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "5) copying js files...\n\n";
     $fromFolder = $fromModelDir . 'htdocs/js/';
     $toFolder = $toModelDir . 'htdocs/js/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "6) copying css files...\n\n";
     $fromFolder = $fromModelDir . 'htdocs/css/';
     $toFolder = $toModelDir . 'htdocs/css/';
     folderFilesCopy($fromFolder, $toFolder, true);
     echo "</pre>";
 }
예제 #11
0
파일: Dbx.php 프로젝트: uwitec/outbuying
 public static function getAdodb($con_name = "propel")
 {
     /**
      * 数据库连结类:ADODB
      */
     $configuration = (include Watt_Config::getConfigPath() . "propel.conf.php");
     if (!isset($configuration['datasources'][$con_name])) {
         $con_name = $configuration['datasources']["default"];
     }
     $cfg = $configuration['datasources'][$con_name]['connection'];
     include_once Watt_Config::getLibPath(1) . "adodb/adodb.inc.php";
     $db_a = ADONewConnection("mysql");
     $ADODB_CACHE_DIR = Watt_Config::getRootPath() . "cache/adodb";
     $db_a->Connect($cfg["hostspec"] . ($cfg["port"] ? ":" . $cfg["port"] : ""), $cfg["username"], $cfg["password"], $cfg["database"]);
     $db_a->Execute("set names 'utf8'");
     //数据库字符编码设置
     $db_a->SetFetchMode(ADODB_FETCH_ASSOC);
     // 设置缓存有效时间为5分钟
     $db_a->cacheSecs = 300;
     return $db_a;
 }
예제 #12
0
 /**
  * 过滤
  *
  * @param array $data
  * @return $data
  */
 public function filter($data)
 {
     //调用配置
     $config = Watt_Config::getCfgFromFile('sync/TpmOutToIn.filter.conf.php');
     //var_dump($config);
     //白名单过滤,删除白名单里不存在的
     /*if(isset($data['cols']) && is_array($data['cols']) && count($data['cols']))
     		{
     			foreach ($data['cols'] as $col => $val){
     				$is_del = true;
     				if (isset($config['whiteList'][$data['tableName']]) && count($config['whiteList'][$data['tableName']]))
     				{
     					foreach ($config['whiteList'][$data['tableName']] as $col_){
     						if ($col == strtoupper($col_)){
     							$is_del = false;
     						}
     					}
     				}
     				if ($is_del)
     				{
     					//echo "white:".$col."<br>";
     					//删除
     					unset($data['cols'][$col]);
     				}
     			}
     		}*/
     //黑名单过滤,删除黑名单里存在的
     if (isset($config['blackList'][$data['tableName']]) && count($config['blackList'][$data['tableName']])) {
         foreach ($config['blackList'][$data['tableName']] as $col_) {
             if (isset($data['cols'][strtoupper($col_)])) {
                 //echo "black:".strtoupper($col_)."<br>";
                 //删除
                 unset($data['cols'][strtoupper($col_)]);
             }
         }
     }
     return $data;
 }
예제 #13
0
파일: Menu.php 프로젝트: uwitec/outbuying
 function __construct()
 {
     $this->_menu_lib_path = Watt_Config::getSiteRoot(1) . 'js/jsmenu/';
 }
예제 #14
0
파일: Sms.php 프로젝트: uwitec/outbuying
 /**
  * 初始化
  */
 private static function _init()
 {
     if (!self::$_site_code) {
         self::$_site_code = sprintf("%02d", Watt_Config::getEpollGroupId());
     }
 }
예제 #15
0
 /**
  * 处理 do
  * 有可能会返回 goToDo
  * 
  * 只有一个单词的do,对应的action是 index
  * 
  *
  * @param string $do
  * @return string $goToDo
  */
 protected function processDo($do, $defaultView = "Html")
 {
     if ($do == "") {
         $e = new Watt_Exception(Watt_I18n::trans("ERR_DISPATCH_NODO"));
         throw $e;
     }
     $goToDo = "";
     $arrCtrlAndAction = $this->_analyzeDoToControllerAndAction($do);
     $controller = $arrCtrlAndAction[0];
     $action = $arrCtrlAndAction[1];
     $doFile = $arrCtrlAndAction[2];
     $doAction = $arrCtrlAndAction[3];
     //exit( $doFile . "|" . $doAction );
     //使用 ob_start 是为了Controller里的 redirect 可以正常使用
     if (defined('ENABLE_CTRL_BUFFER') && ENABLE_CTRL_BUFFER) {
         /**
          * 为了不让服务器过长等待时间,改为不启用Ctrl Buffer
          * @author terry
          * @version 0.1.0
          * Mon Jan 14 14:41:39 CST 2008
          */
         ob_start();
     }
     /**
      * 增加了对页面缓存的支持
      */
     $cache = null;
     Watt_Debug::addInfoToDefault('Begin create action [' . $controller . '] [' . $action . ']');
     $theCtrl = Watt_Controller_Action::factory($controller, $action);
     Watt_Debug::addInfoToDefault('After create action');
     $viewMenu = isset($_REQUEST["view_menu"]) ? trim($_REQUEST["view_menu"]) == '0' ? false : true : true;
     $theCtrl->setNeedMenu($viewMenu);
     $actionCacheTime = $theCtrl->getActionCacheTime($action);
     if ($actionCacheTime > 0) {
         $cache = new Watt_Cache($actionCacheTime);
         if ($cache->cacheCheck()) {
             //如果符合缓存条件,则会读取缓存文件,并 exit.
             /**
              * 改为退出处理,为了记录页面执行时间。
              * 这里一定不能 return true.
              * @author terry
              * @version 0.1.0
              * Mon Jan 14 14:30:43 CST 2008
              */
             return '';
         }
     }
     /**
      * 检查 会话的权限。 
      * 如果没有权限,抛出一个异常
      * 此处别扭
      */
     $rbac = new Watt_Rbac();
     //$rbac->checkSession(Watt_Session::getSession(), $do);
     $privilege = $rbac->checkActionPrivilege(Watt_Session::getSession(), $theCtrl, $action);
     if (is_object($privilege) && $privilege instanceof TpmYonghuzhaoquanxian) {
         if (!$theCtrl->getTitle()) {
             $theCtrl->setTitle(Watt_I18n::trans($privilege->getQxMingcheng()));
         }
     }
     Watt_Debug::addInfoToDefault('', 'Pre do action..');
     if (method_exists($theCtrl, $doAction)) {
         //执行controller中的action
         $theCtrl->{$doAction}();
     } else {
         throw new Exception(Watt_I18n::trans("ERR_APP_LOST_ACTION"));
     }
     Watt_Debug::addInfoToDefault('', 'After do action..');
     $goToDo = $theCtrl->getGoToDo();
     $data = $theCtrl->getData();
     /**
      * 改为对 Ctrl 不进行 Buffer 的处理
      * @author terry
      * @version 0.1.0
      * Mon Jan 14 15:05:28 CST 2008
      */
     if (defined('ENABLE_CTRL_BUFFER') && ENABLE_CTRL_BUFFER) {
         if (defined("DEBUG") && DEBUG) {
             //调试阶段才显示Controller里输出的信息
             echo ob_get_clean();
         } else {
             //用户使用阶段不允许 action 里输出显示数据
             ob_clean();
         }
     }
     if ($theCtrl->isNeedView()) {
         Watt_Debug::addInfoToDefault('', 'Pre load view..');
         if ($theCtrl->getViewType()) {
             $defaultView = $theCtrl->getViewType();
         }
         /**
          * 创建一个View。将来可以用不同的View代替此View
          */
         //$view = Watt_View::factory( "Html", Watt_Config::getViewPath() );
         $view = Watt_View::factory($defaultView, Watt_Config::getViewPath());
         $view->setHeader($theCtrl->getHeader());
         Watt_Debug::addInfoToDefault('', 'After view factory..');
         /**
          * 读取菜单应该由View来判断
          * @author terry
          * Thu Jul 22 10:46:07 CST 2010
          */
         if ($theCtrl->isNeedMenu() && strtolower($defaultView) == 'html') {
             //$theCtrl->isNeedCaidan();
             /**
              * 如果用户已登录,读取菜单信息
              * @todo 未登录可能也可以有菜单
              */
             if ($user_id = Watt_Session::getSession()->getUserId()) {
                 $tpmCaidans = TpmCaidanPeer::getJueseCaidan(Watt_Session::getSession()->getRoleId());
                 if (count($tpmCaidans)) {
                     $view->setHeader($tpmCaidans, "menu");
                 }
             }
             //读取菜单完
         }
         //$view->renderModel($theCtrl);
         $view->renderView($data, $this->_getDefaultViewFileOfAction($controller, $action), true);
     }
     /**
      * 与开始的Cache对应
      */
     if ($actionCacheTime > 0 && $cache instanceof Watt_Cache) {
         $cache->caching();
     }
     return $goToDo;
 }
예제 #16
0
 public static function test()
 {
     set_time_limit(10);
     $url = Watt_Util_Net::isLANIp($_SERVER['SERVER_ADDR']);
     $epollServer = Watt_Config::getEpollServer();
     /*
     		$epoll_url = Watt_Config::getEpollServer();
     		
     		if($url)//判断是否内网IP
     		{
     			if(preg_match("/\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/",$epoll_url))//判断是否IP
     			{
     				$epollUpdateUrl = $epoll_url;
     			}
     			else //是否域名
     			{
     				$epollUpdateUrl = "in".$epoll_url;
     			}
     		}
     		else 
     		{
     			$epollUpdateUrl = $epoll_url;
     		}
     		$epollServer = $epollUpdateUrl;
     */
     $port = Watt_Config::getEpollServerPort();
     $epollClient = new Watt_Net_EpollClient($epollServer, $port);
     $fromId = 4040;
     $epollClient->login($fromId);
     $epollClient->sendTpmMsg($fromId, 151017933, 1, 'Title', 'Link', 'test消息', 'msn', 'qq18076495', 'extmsg', 1);
     //		$list = $epollClient->getOnlineList( $fromId );
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 19:46:17 CST 2008] :\n ";
     //		var_dump( $list );
     //		echo "</pre>";
     //exit();
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Thu Jun 26 20:28:09 CST 2008] :\n ";
     //		var_dump( strToHex( iconv('ISO-8859-1','UTF-8','消息' ) ) );
     //		var_dump( ( urlencode('消息') ) );
     //		var_dump( pack( "H*","886D6F60" ) );
     //		echo "</pre>";
     //exit();
     Watt_Debug::getDefaultDebug()->addInfo('After login');
     //		$docHeader = pack( 'H*', 'D0CF11E0A1B11AE1' );
     //		$docHeader = pack( 'H*', 'FFFE' );
     //		$total = pack('H*','00910001000003EA');
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n ";
     //		var_dump( strToHex($total) );
     //		echo "</pre>";
     //
     //		$total = pack('nnN',0x0091,0x0001,0x000003EA);
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n ";
     //		var_dump( strToHex($total) );
     //		echo "</pre>";
     //
     //		$rev = unpack('nlen/ncmd/Nepollid/', $total);
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 14:24:03 CST 2008] :\n ";
     //		var_dump( $rev );
     //		echo "</pre>";
     //		//exit();
     //
     //		$total = pack( 'H*', '00910001000003EA50F1120058DBEEBFAAC1040880DBEEBF50DBEEBF68DBEEBFD8C1040884DBEEBFC8DCEE00000012F12800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' );
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n ";
     //		var_dump( strToHex($total) );
     //		echo "</pre>";
     //
     //		$rev = unpack( "nlen/ncmd/Nepollid/a".self::MAX_USER_NAME_EX."user/a".self::MAX_PASSWD_LEN_EX."pwd/Nip/Naction/a*memo/",$total );
     //		echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 14:24:03 CST 2008] :\n ";
     //		var_dump( $rev );
     //		echo "</pre>";
     //		exit();
     /*
     0091
     0001
     000003EA
     50F1120058DBEEBFAAC1040880DBEEBF50DBEEBF68DBEEBFD8C1040884DBEEBF
     C8DCEE00000012F1280000000000000000000000000000000000000000000000
     00000000
     00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
     */
 }
예제 #17
0
 /**
  * 过滤
  *
  * @param array $data
  * @return $data
  */
 public function filter($data)
 {
     //调用配置
     $config = Watt_Config::getCfgFromFile('sync/TpmInToOut.filter.conf.php');
     //var_dump($config);
     //白名单过滤,删除白名单里不存在的
     if (!isset($config['whiteList']) || isset($config['whiteList']) && !count($config['whiteList'])) {
         //不存在白名单或白名单为空,将不进行白名单过滤
     } else {
         if (isset($config['whiteList'][$data['tableName']]) && is_array($config['whiteList'][$data['tableName']]) && !count($config['whiteList'][$data['tableName']])) {
             //白名单中设置该表的值是空数组,表示该表的所有数据都允许,白名单过滤不执行任何操作
         } else {
             if (isset($config['whiteList']) && count($config['whiteList']) && !isset($config['whiteList'][$data['tableName']])) {
                 //白名单里不存在该表名
                 return array();
             } else {
                 if (isset($config['whiteList'][$data['tableName']]) && count($config['whiteList'][$data['tableName']])) {
                     if (isset($data['cols']) && is_array($data['cols']) && count($data['cols'])) {
                         foreach ($data['cols'] as $col => $val) {
                             $is_del = true;
                             foreach ($config['whiteList'][$data['tableName']] as $col_) {
                                 if ($col == strtoupper($col_)) {
                                     $is_del = false;
                                 }
                             }
                             if ($is_del) {
                                 //echo "white:".$col."<br>";
                                 //删除
                                 unset($data['cols'][$col]);
                             }
                         }
                     }
                 }
             }
         }
     }
     /*if(isset($data['cols']) && is_array($data['cols']) && count($data['cols']))
     		{
     			foreach ($data['cols'] as $col => $val){
     				$is_del = true;
     				if (isset($config['whiteList'][$data['tableName']]) && count($config['whiteList'][$data['tableName']]))
     				{
     					foreach ($config['whiteList'][$data['tableName']] as $col_){
     						if ($col == strtoupper($col_)){
     							$is_del = false;
     						}
     					}
     				}
     				if ($is_del)
     				{
     					//echo "white:".$col."<br>";
     					//删除
     					unset($data['cols'][$col]);
     				}
     			}
     		}*/
     //黑名单过滤,删除黑名单里存在的
     if (isset($config['blackList'][$data['tableName']]) && !count($config['blackList'][$data['tableName']])) {
         //如果黑名单中存在该表,并且该表的设为空数组
         return array();
     } else {
         if (isset($config['blackList'][$data['tableName']]) && count($config['blackList'][$data['tableName']])) {
             foreach ($config['blackList'][$data['tableName']] as $col_) {
                 if (isset($data['cols'][strtoupper($col_)])) {
                     //echo "black:".strtoupper($col_)."<br>";
                     //删除
                     unset($data['cols'][strtoupper($col_)]);
                 }
             }
         }
     }
     return $data;
 }
예제 #18
0
파일: Config.php 프로젝트: uwitec/outbuying
 /**
  * 设置次要config
  *
  * @param array $config
  */
 public static function setSecondaryConfig($config)
 {
     self::$_secCfg = $config;
 }
예제 #19
0
 /**
  * 是否是外部用户
  * @return boolean
  * @author terry
  * Tue Feb 17 14:07:05 CST 2009
  */
 public function isOutterUser()
 {
     if (Watt_Config::isFlowMode()) {
         $crSessionRoleId = array('6b32ff50-df19-4e07-d50c-45b6b62bc171' => 'CR', '4ade1c61-fac6-8f11-4200-466fa0a2c627' => 'CR', '8fdee018-5bd1-1a17-61c4-491a8b139cf9' => 'CRCPM', '2798de2b-30bf-9dcb-22cd-45b6b68b315e' => 'TR', '61c705eb-0cde-4867-3211-45b6b6753d4d' => 'PR', '84f3fb25-f8f2-0f43-e33f-4b8c751b7280' => 'EDIT');
         //说明这个是客户的角色ID
         $crSessionRoleShortName = array('CR' => 'CR', 'TR' => 'TR', 'PR' => 'PR', 'EDIT' => 'EDIT');
     } else {
         $crSessionRoleId = array('6b32ff50-df19-4e07-d50c-45b6b62bc171' => 'CR', '2798de2b-30bf-9dcb-22cd-45b6b68b315e' => 'TR', '61c705eb-0cde-4867-3211-45b6b6753d4d' => 'PR', '4ade1c61-fac6-8f11-4200-466fa0a2c627' => 'CR', '8fdee018-5bd1-1a17-61c4-491a8b139cf9' => 'CRCPM', '84f3fb25-f8f2-0f43-e33f-4b8c751b7280' => 'EDIT');
         //说明这个是客户的角色ID
         $crSessionRoleShortName = array('CR' => 'CR', 'TR' => 'TR', 'PR' => 'PR', 'EDIT' => 'EDIT');
     }
     $sessionRoleId = Watt_Session::getSession() ? Watt_Session::getSession()->getRoleId() : '';
     $sessionRoleShortName = Watt_Session::getSession() ? Watt_Session::getSession()->getRoleShortName() : '';
     return key_exists($sessionRoleId, $crSessionRoleId) || key_exists($sessionRoleShortName, $crSessionRoleShortName);
 }
예제 #20
0
 public function __construct()
 {
     $this->_recerverlists = Watt_Config::getCfgFromFile('sync/alertMonitor.conf.php');
 }
예제 #21
0
 /**
  * 根据一个 WSDL,获得一个 SoapClient 对象
  *
  * Uses:
  * <code>
  * $client = Watt_Service_Servicer::getSoapClient( "demo.wsdl", array('trace' => false
  *                                                            ,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP
  *                                                            ));
  * </code>
  * 
  * @param mixed $wsdl
  * @param array $options
  * @return SoapClient
  */
 public static function getSoapClient($wsdl, array $options = array())
 {
     return new SoapClient(Watt_Config::getConfigPath() . "wsdl/" . $wsdl, array('trace' => false, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
 }
예제 #22
0
 function __construct()
 {
     $this->_selector_lib_path = Watt_Config::getSiteRoot() . 'js/tpm/';
 }
예제 #23
0
파일: File.php 프로젝트: uwitec/outbuying
 /**
  *  检查ftp方式上传下载是否正常函数
  * 下载使用的是http方式
  * @return unknown
  * jute
  * 20080115
  */
 function checkftpfile()
 {
     $testuploadfiledir = Watt_Config::getRootPath() . 'htdocs/upload/';
     $testuploadfilepath = $testuploadfiledir . 'testupload.txt';
     if (!file_exists($testuploadfilepath)) {
         //上传测试文件不存在则创建
         $fp = fopen($testuploadfilepath, 'wb');
         fwrite($fp, 'aa');
         fclose($fp);
     }
     $file = Watt_Util_File::ftpuploadfile($testuploadfilepath);
     if ($file) {
         //上传文件成功
         //下载文件
         $rev = Watt_Util_File::httpdownloadfile($file);
         if (!strcmp($rev, file_get_contents($testuploadfilepath))) {
             //返回结果相同
             return true;
         } else {
             //
             return false;
         }
     }
     return false;
 }
예제 #24
0
파일: View.php 프로젝트: uwitec/outbuying
 /**
  * 获得 view 的文件名
  * 输入的参数是相对于 view 根目录的 PathFilename
  * 自动获得绝对ViewPathFilename
  * 
  * 单独写一个方法是为了对付外部设置view路径的时的情况。
  * 那时就在这里修改就好了。
  *
  * @param string $relFilename
  * @return string
  */
 protected function _getAbsViewPathFilename($relPathFilename)
 {
     return Watt_Config::getAbsPathFilename("PATH_VIEW", $relPathFilename);
 }
예제 #25
0
파일: Export.php 프로젝트: uwitec/outbuying
 private static function getXlsByModel($arr, $old_path, $new_path, $file_name, $expand_name, $is_output)
 {
     include Watt_Config::getLibPath() . 'Third/Excel/PHPExcel.php';
     include Watt_Config::getLibPath() . 'Third/Excel/PHPExcel/IOFactory.php';
     $objReader = PHPExcel_IOFactory::createReader('Excel5');
     $objPHPExcel = $objReader->load($old_path);
     if (!$objPHPExcel) {
         throw new Exception('Load Excel Path error.');
     }
     if (count($arr) > 0) {
         foreach ($arr as $key => $val) {
             $objPHPExcel->getActiveSheet()->setCellValue($key, $val);
         }
     }
     //$objPHPExcel->getActiveSheet()->setTitle($file_name);
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     if ($is_output) {
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
         header("Content-Type:application/force-download");
         header("Content-Type:application/vnd.ms-execl");
         header("Content-Type:application/octet-stream");
         header("Content-Type:application/download");
         header('Content-Disposition:attachment;filename="' . iconv("UTF-8", "GBK", $file_name) . "." . $expand_name . '"');
         header("Content-Transfer-Encoding:binary");
         $objWriter->save('php://output');
     } else {
         $objWriter->save($path);
     }
     //$objWriter->save($new_path);
     //return $new_path;
 }
예제 #26
0
파일: Log.php 프로젝트: uwitec/outbuying
 /**
  * 记录操作数据库日志
  *
  * @param string $sql
  */
 public static function logDbOprate($sql)
 {
     //如果禁用日志则不记录 by terry at Wed Aug 18 10:02:05 CST 2010
     if (self::$_disabledAddLog) {
         return true;
     }
     $sql = trim($sql);
     if (!$sql) {
         return false;
     }
     //生成消息序列 by jute
     $enableSync = Watt_Config::getCfgInFile('EnableSync', 'sync/sync.conf.php');
     if ($enableSync == '1') {
         Watt_Sync_MessageListManage::createDbMsgList($sql);
     }
     $tableName = '';
     $logName = '';
     $msg = '';
     //忽略列表优先于允许列表
     $ignoreTalbenameList = array('tpm_rizhi' => 'rz_id', 'tpm_xiangmu_rizhi' => 'rz_id', 'tpm_ziyuan_rizhi' => 'rz_id', 'tpm_rizhi_fangwen' => 'rz_id');
     $toLogTablenameList = array('tpm_dingdan' => 'dd_id', 'tpm_shengchandingdan' => 'sd_id', 'tpm_xiangmu' => 'xm_id', 'tpm_renwu' => 'rw_id', 'tpm_gaojian' => 'gj_id', 'tpm_yonghukuozhan' => 'yh_id', 'tpm_yonghu' => 'yh_id', 'tpm_kehu_yonghu' => 'yh_id');
     //因为之前已经trim了,所以 === 0
     if (stripos($sql, 'SELECT') === 0) {
         /**
          * debug模式同时记录select便于调试
          * @author terry
          * @version 0.1.0
          * Tue Oct 21 09:33:14 CST 2008
          */
         /*
         if( defined('DEBUG') && DEBUG ){
         	$logName   = self::DB_OPRATE_TYPE_SELECT;
         	$msg       = $sql;
         }else{
         */
         //不记录Select
         return false;
         //$sql = str_replace( array("\n","\r") , array(" ", "" ) , $sql );
         /*
         }
         */
     } elseif (stripos($sql, 'UPDATE') === 0) {
         /*
         			/update[\s]+(\w+)[\s]+set(.*)where[\s]+(.*)/
                      ^^table name ^^col         ^^cond
         */
         if (preg_match("/update[\\s]+(\\w+)[\\s]+set(.*)where[\\s]+(.*)/i", $sql, $matchs)) {
             $tableName = $matchs[1];
             $cols = $matchs[2];
             $cond = $matchs[3];
             $logName = self::DB_OPRATE_TYPE_PREFIX . '-' . $tableName . '-' . self::DB_OPRATE_TYPE_UPDATE;
             $msg = $cols . self::DB_OPRATE_MSG_SPLITER . $cond;
         }
     } elseif (stripos($sql, 'INSERT') === 0) {
         /*
         /insert into[\s]+(\w+)[\s]+\((.*)\)[\s]+values[\s]+\((.*)\)/
         */
         if (preg_match('/insert into[\\s]+(\\w+)[\\s]+\\((.*)\\)[\\s]+values[\\s]+\\((.*)\\)/i', $sql, $matchs)) {
             $tableName = $matchs[1];
             $cols = $matchs[2];
             $values = $matchs[3];
             $logName = self::DB_OPRATE_TYPE_PREFIX . '-' . $tableName . '-' . self::DB_OPRATE_TYPE_INSERT;
             $msg = $cols . self::DB_OPRATE_MSG_SPLITER . $values;
         }
     } elseif (stripos($sql, 'DELETE') === 0) {
         /*
         /insert into[\s]+(\w+)[\s]+\((.*)\)[\s]+values[\s]+\((.*)\)/
         */
         if (preg_match('/DELETE FROM[\\s]+(\\w+)[\\s]+WHERE(.*)/i', $sql, $matchs)) {
             $tableName = $matchs[1];
             $cond = $matchs[2];
             $logName = self::DB_OPRATE_TYPE_PREFIX . '-' . $tableName . '-' . self::DB_OPRATE_TYPE_DELETE;
             $msg = $cond;
         }
     } else {
         /**
          * 对未解析的SQL 也记录在案
          * @author terry
          * @version 0.1.0
          * Wed Sep 26 13:38:08 CST 2007
          */
         $logName = self::DB_OPRATE_TYPE_UNKNOWN;
         $msg = $sql;
     }
     //strtolower( $tableName ) != 'tpm_rizhi'
     if ($msg && $logName && !key_exists(strtolower($tableName), $ignoreTalbenameList) && key_exists(strtolower($tableName), $toLogTablenameList) && stripos($sql, 'UPDATE tpm_yonghu SET YH_ZAIXIANSHIJIAN') === false) {
         //self::addLog( "stripos".stripos( $sql, 'UPDATE tpm_yonghu SET YH_ZAIXIANSHIJIAN' ) );
         /**
          * 更新用户状态的不记录在数据库,因为频率太高,太常规了
          * @author terry
          * @version 0.1.0
          * Sat Sep 29 19:41:27 CST 2007
          */
         //			print"<pre>Terry :";var_dump( $logName );print"</pre>";
         //			print"<pre>Terry :";print ( $msg );print"</pre>";
         //			exit();
         self::addLog("Execute [ {$sql} ]" . self::DB_OPRATE_MSG_SPLITER . $msg, self::LEVEL_SYSTEM, $logName);
         return true;
     } else {
         /**
          * 忽略列表中的数据表操作亦将不被写入文件Log
          * @author terry
          * @version 0.1.0
          * Wed Sep 05 09:46:56 CST 2007
          */
         if (!key_exists(strtolower($tableName), $ignoreTalbenameList)) {
             self::addLog("Execute [ {$sql} ]", Watt_Log::LEVEL_DEBUG, $logName);
         }
         return false;
     }
 }
예제 #27
0
파일: Db.php 프로젝트: uwitec/outbuying
 /**
  * 重新连接一次数据库
  * 如果 $con_name 相同则不连接
  *
  * @param string|array $con_name
  * @param string $forceReconnect
  */
 public function reconnect($con_name, $forceReconnect = false)
 {
     if (is_array($con_name)) {
         $cfg = $con_name;
     } else {
         $cfg = null;
     }
     if ($forceReconnect || $con_name != $this->getConnName()) {
         if ($this->_debug) {
             Watt_Debug::addInfoToDefault("Watt", "Before connect use Watt_Db.");
         }
         if (class_exists('Propel')) {
             $this->_connection = Propel::getConnection($con_name);
             $this->_conn = $this->_connection->getResource();
             $this->_dsn = $this->_connection->getDSN();
         } else {
             if (!is_array($cfg)) {
                 $configuration = (include Watt_Config::getConfigPath() . "propel.conf.php");
                 $cfg = $configuration['datasources'][$con_name]['connection'];
             }
             $this->_conn = mysql_connect($cfg["hostspec"] . ($cfg["port"] ? ":" . $cfg["port"] : ""), $cfg["username"], $cfg["password"]);
             $this->_dsn = $cfg;
             mysql_select_db($cfg["database"], $this->_conn);
             $charset = @$cfg["charset"] ? $cfg["charset"] : 'utf8';
             mysql_query("set names '{$charset}'");
         }
         $this->setConnName($con_name);
         if ($this->_debug) {
             Watt_Debug::addInfoToDefault("Watt", "After connect [{$con_name}] use Watt_Db.");
         }
     }
 }
예제 #28
0
파일: Action.php 프로젝트: uwitec/outbuying
 /**
  * 获得一个Request的变量
  * 如果没有在request中定义,则返回一个null
  * 不推荐直接使用,尽量使用in
  *
  * @param string $varname
  * @return mix
  */
 protected function getRequestVar($varname)
 {
     if (isset($_REQUEST[$varname])) {
         /**
          * 容不得考虑仔细了,先满足了再说
          * 系统耦合度已经越来越高了..要坏掉了
          * @author terry
          * @version 0.1.0
          * Thu Feb 14 10:26:10 CST 2008
          */
         if (Watt_Session::getSession()->getUserId()) {
             return $_REQUEST[$varname];
         } else {
             //仅过滤未登录用户输入的信息
             $filterList = Tpm_Config::getUserConfig(Watt_Config::getDefaultZuId(), 'filter_words');
             return Watt_Util_String::filterString($_REQUEST[$varname], $filterList);
         }
         //return $_REQUEST[$varname];
     } else {
         return null;
     }
 }
예제 #29
0
파일: I18n.php 프로젝트: uwitec/outbuying
 private function _loadStrings()
 {
     $this->_connectMemcache();
     if ($this->_memcache) {
         if ($this->_memcache->get($this->_memcacheKeyPrefix . $this->_lang . '_LOADED')) {
             $this->isStringsLoaded = true;
             Watt_Debug::addInfoToDefault('After load language string from memcache.(cached)');
             return true;
         }
         Watt_Debug::addInfoToDefault('Before load language string from memcache.');
         $langPath = Watt_Config::getLangPath() . $this->_lang . DIRECTORY_SEPARATOR;
         if (!file_exists($langPath)) {
             $langPath = Watt_Config::getLangPath() . "default" . DIRECTORY_SEPARATOR;
         }
         $this->_loadLangFilesInDir($langPath);
         //载入备用目录的语言文件 //
         //$langPath = Watt_Config::getLangPath(1).$this->_lang.DIRECTORY_SEPARATOR;
         //$this->_loadLangFilesInDir( $langPath );
         $this->_memcache->set($this->_memcacheKeyPrefix . $this->_lang . '_LOADED', true);
         Watt_Debug::addInfoToDefault('After load language string from memcache.');
         return true;
     } else {
         return false;
     }
 }