Esempio n. 1
0
 /**
  * 获得一个 PHPMailer 对象,已经作了基本配置,
  * SMTP
  *
  * @return PHPMailer
  */
 public static function getPhpMailerWithDefaultConfig()
 {
     include_once Watt_Config::getLibPath() . 'Third/phpmailer/class.phpmailer.php';
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // 设置使用 SMTP	 与发件人相同
     $mail->Host = Watt_Config::getCfg("MAIL_SMTP_HOST");
     // 指定的 SMTP 服务器地址
     $mail->Username = Watt_Config::getCfg("MAIL_SMTP_USERNAME");
     // SMTP 发邮件人的用户名
     $mail->Password = Watt_Config::getCfg("MAIL_SMTP_PASSWORD");
     // SMTP 密码
     $mail->SMTPAuth = Watt_Config::getCfg("MAIL_SMTP_AUTH");
     // 设置为安全验证方式
     $mail->From = Watt_Config::getCfg("MAIL_SMTP_ADDR");
     // 发件人地址  //"*****@*****.**"	;
     return $mail;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }