本文整理汇总了PHP中gcms::writeDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP gcms::writeDebug方法的具体用法?PHP gcms::writeDebug怎么用?PHP gcms::writeDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcms
的用法示例。
在下文中一共展示了gcms::writeDebug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Inint database driver
*
* @param string DNS string driver://username:password@hostname/database
*/
function &sql($params)
{
if (($dns = @parse_url($params)) === FALSE) {
$msg = 'Invalid DB Connection String';
if (class_exists('gcms')) {
gcms::writeDebug($msg);
} else {
echo $msg;
}
} else {
$params = array('dbdriver' => strtolower($dns['scheme']), 'hostname' => isset($dns['host']) ? rawurldecode($dns['host']) : '', 'username' => isset($dns['user']) ? rawurldecode($dns['user']) : '', 'password' => isset($dns['pass']) ? rawurldecode($dns['pass']) : '', 'dbname' => isset($dns['path']) ? rawurldecode(substr($dns['path'], 1)) : '');
// inint database class
require_once ROOT_PATH . 'bin/drivers/class.db.driver.php';
// driver class
if (is_file(ROOT_PATH . 'bin/drivers/class.' . $params['dbdriver'] . '_driver.php')) {
// โหลดจาก driver ที่กำหนด
require_once ROOT_PATH . 'bin/drivers/class.' . $params['dbdriver'] . '_driver.php';
} else {
// ไม่พบ driver ใช้ pdo
require_once ROOT_PATH . 'bin/drivers/class.pdo_driver.php';
}
// driver string
$driver = strtoupper($params['dbdriver']) . '_DB_driver';
// parse query string
if (isset($dns['query'])) {
parse_str($dns['query'], $extra);
foreach ($extra as $key => $val) {
// booleans
if (strtoupper($val) == "TRUE") {
$params[$key] = TRUE;
} elseif (strtoupper($val) == "FALSE") {
$params[$key] = FALSE;
} else {
$params[$key] = $val;
}
}
}
// inint class
$db = new $driver($params);
// return class
return $db;
}
}
示例2: debug
/**
* ฟังก์ชั่น แสดงผล error
*
* @param string $source
* @param string $message
*/
function debug($source, $message = '')
{
$msg = "Error in <em>{$source}</em> Message : {$message}";
if (class_exists('gcms')) {
gcms::writeDebug($msg);
} else {
echo $msg;
}
return $message;
}
示例3: customMail
/**
* ฟังก์ชั่นส่งเมล์แบบกำหนดรายละเอียดเอง
*
* @global array $config ตัวแปรเก็บการตั้งค่าของ GCMS
* @param string $mailto ที่อยู่อีเมล์ผู้รับ คั่นแต่ละรายชื่อด้วย ,
* @param string $replyto ที่อยู่อีเมล์สำหรับการตอบกลับจดหมาย ถ้าระบุเป็นค่าว่างจะใช้ที่อยู่อีเมล์จาก noreply_email
* @param string $subject หัวข้อจดหมาย
* @param string $msg รายละเอียดของจดหมาย (รองรับ HTML)
* @return string สำเร็จคืนค่าว่าง ไม่สำเร็จ คืนค่าข้อความผิดพลาด
*/
public static function customMail($mailto, $replyto, $subject, $msg)
{
global $config;
$charset = empty($config['email_charset']) ? 'utf-8' : $config['email_charset'];
if ($replyto == '') {
$replyto = array($config['noreply_email'], strip_tags($config['web_title']));
} elseif (preg_match('/^(.*)<(.*?)>$/', $replyto, $match)) {
$replyto = array($match[1], empty($match[2]) ? $match[1] : $match[2]);
} else {
$replyto = array($replyto, $replyto);
}
if (strtolower($charset) !== 'utf-8') {
$subject = iconv('utf-8', $config['email_charset'], $subject);
$msg = iconv('utf-8', $config['email_charset'], $msg);
$replyto[1] = iconv('utf-8', $config['email_charset'], $replyto[1]);
}
if (isset($config['email_use_phpMailer']) && $config['email_use_phpMailer'] !== 1) {
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset={$charset}\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
$headers .= "To: {$mailto}\r\n";
$headers .= "From: {$replyto['1']}\r\n";
$headers .= "Reply-to: {$replyto['0']}\r\n";
$headers .= "X-Mailer: PHP mailer\r\n";
if (function_exists('imap_8bit')) {
$subject = "=?{$charset}?Q?" . imap_8bit($subject) . "?=";
$msg = imap_8bit($msg);
}
if (@mail($mailto, $subject, $msg, $headers)) {
return '';
} else {
return 'Send Mail Error.';
}
} else {
include_once str_replace('class.gcms.php', 'class.phpmailer.php', __FILE__);
$mail = new PHPMailer(true);
// use SMTP
$mail->IsSMTP();
$mail->Encoding = "quoted-printable";
// charset
$mail->CharSet = $charset;
// use html
$mail->IsHTML();
if ($config['email_SMTPAuth'] == 1) {
$mail->SMTPAuth = true;
$mail->Username = $config['email_Username'];
$mail->Password = $config['email_Password'];
$mail->SMTPSecure = $config['email_SMTPSecure'];
} else {
$mail->SMTPAuth = false;
}
if (!empty($config['email_Host'])) {
$mail->Host = $config['email_Host'];
}
if (!empty($config['email_Port'])) {
$mail->Port = $config['email_Port'];
}
try {
$mail->AddReplyTo($replyto[0], $replyto[1]);
foreach (explode(',', $mailto) as $email) {
if (preg_match('/^(.*)<(.*)>$/', $email, $match)) {
if ($mail->ValidateAddress($match[1])) {
$mail->AddAddress($match[1], $match[2]);
}
} else {
if ($mail->ValidateAddress($email)) {
$mail->AddAddress($email, $email);
}
}
}
$mail->SetFrom($config['noreply_email'], $replyto[1]);
$mail->Subject = $subject;
$mail->MsgHTML(preg_replace('/(<br([\\s\\/]{0,})>)/', "\$1\r\n", stripslashes($msg)));
$mail->Send();
return '';
} catch (phpmailerException $e) {
// Pretty error messages from PHPMailer
$message = $e->errorMessage();
gcms::writeDebug($message);
return strip_tags($message);
} catch (exception $e) {
// Boring error messages from anything else!
$message = $e->getMessage();
gcms::writeDebug($message);
return strip_tags($message);
}
}
}