예제 #1
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;
 }
예제 #2
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;
 }
예제 #3
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));
 }
예제 #4
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.");
         }
     }
 }