public static function getInstance($adapter = 'Email', $config = null) { if (empty($config)) { $config = SConfig::getField($adapter, "Main"); } $className = __NAMESPACE__ . "\\Adaptor\\{$adapter}"; return SFactory::getInstance($className, $config); }
/** * 发送邮件 * @see RegShutdownEvent::add('Home\controller\index::taskEmail','*****@*****.**','xhh','test','body'); * @author xiaohuihui <*****@*****.**> * @param $toEmail * @param $toUser * @param $title * @param $body */ public static function sendEmail($toEmail, $toUser, $title, $content, $callback = null) { if (!$toEmail || !$title) { return; } $result = EmailFactory::getInstance()->send_mail($toEmail, $toUser, $title, $content); $callbackData = array('email' => $toEmail, 'status' => (int) $result, 'time' => time(), 'content' => $content, 'type' => SConfig::getField('Email', 'Main')['EmailType']); if (is_callable($callback)) { call_user_func_array($callback, array("data" => $callbackData)); } }
function jstoken() { $accessKey = Config::getField("Qiniu", "AK"); $secretKey = Config::getField("Qiniu", "SK"); $auth = new Auth($accessKey, $secretKey); // 空间名 http://developer.qiniu.com/docs/v6/api/overview/concepts.html#bucket $bucket = Config::getField("Qiniu", "bucket"); // 生成上传Token $token = $auth->uploadToken($bucket, $key = null, 3600, array()); $t = array("uptoken" => $token, "domain" => Config::getField("Qiniu", "domain")); Response::apiJsonResult($t, 1); }
public static function sendTextMessage($toPhone, $Content = "", $callback = null) { //短信URL $SMS_SEND_ONE_URL = SConfig::getField('SMS', 'SMS_SEND_ONE_URL', "http://mb345.com:999/ws/batchSend.aspx?CorpID={\$SMS_ACCOUNT}&Pwd={\$SMS_PWD}&Mobile={\$toPhone}&Cell=&SendTime=&Content={\$Content}"); //短信帐号 $SMS_ACCOUNT = SConfig::getField('SMS', 'SMS_ACCOUNT'); //短信密码 $SMS_PWD = SConfig::getField('SMS', 'SMS_PWD'); $SMS_CHARSET = SConfig::getField('SMS', 'SMS_CHARSET', "GBK"); $SMS_SEND_ONE_URL = preg_replace(array('/\\{\\$SMS_ACCOUNT\\}/', '/\\{\\$SMS_PWD\\}/', '/\\{\\$toPhone\\}/', '/\\{\\$Content\\}/'), array($SMS_ACCOUNT, $SMS_PWD, $toPhone, iconv('UTF-8', $SMS_CHARSET, $Content)), $SMS_SEND_ONE_URL); if (SConfig::getField('SMS', 'SMS_IS_DEVELOP', false) === false) { $result = file_get_contents($SMS_SEND_ONE_URL); $result = $result >= 0 ? 1 : 0; } else { $result = 1; //开发模式,始终成功 } $callbackData = array('phone' => $toPhone, 'status' => $result, 'time' => time(), 'content' => $Content, 'type' => SConfig::getField('SMS', 'SMS_TYPE', 1)); if (is_callable($callback)) { call_user_func_array($callback, array("data" => $callbackData)); } return; }
public function __call($name, $arguments) { $name = strtolower($name); if (in_array($name, self::$read_array)) { self::getInstance('Mysql', $config = SConfig::getField("Mysql", "Slave")); } elseif (in_array($name, self::$write_array)) { self::getInstance('Mysql', $config = SConfig::getField("Mysql", "Main")); } if (self::$page !== null && is_numeric(self::$page)) { self::$_instance->setPage(self::$page); } if (self::$pagesize !== null && is_numeric(self::$pagesize)) { self::$_instance->setLimit(self::$pagesize); } if (self::$count !== null) { self::$_instance->setCount(self::$count); } if (self::$startTransaction !== null) { self::$_instance->execute('SET AUTOCOMMIT=0'); self::$_instance->execute('BEGIN'); } if (self::$commit !== null) { self::$_instance->execute('COMMIT'); self::$_instance->execute('SET AUTOCOMMIT=1'); } if (self::$rollBack !== null) { self::$_instance->execute('ROLLBACK'); self::$_instance->execute('SET AUTOCOMMIT=1'); } $count = count($arguments); $table = self::$prefix . self::$table; switch ($count) { case 0: $res = self::$_instance->{$name}($table); break; case 1: $res = self::$_instance->{$name}($table, $arguments[0]); break; case 2: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1]); break; case 3: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1], $arguments[2]); break; case 4: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1], $arguments[2], $arguments[3]); break; case 5: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]); break; case 6: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5]); break; case 7: $res = self::$_instance->{$name}($table, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]); break; } return $res; }
if (is_file(__DIR__ . '/../../../../vendor/autoload.php')) { $rootpath = __DIR__ . '/../../../../'; require $rootpath . 'vendor/autoload.php'; } elseif ($autoload = realpath(__DIR__ . "/../vendor/autoload.php")) { require $autoload; } if (!class_exists('\\SsdPHP\\SsdPHP')) { require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "SsdPHP" . DIRECTORY_SEPARATOR . "SsdPHP.php"; } use SsdPHP\Core\RegShutdownEvent, SsdPHP\Core\Route, SsdPHP\Core\Error, SsdPHP\Core\Config, SsdPHP\Core\Language, SsdPHP\SsdPHP; use SsdPHP\Pulgins\Session\Factory as Session; SsdPHP::setRootPath($rootpath); if (($r = SsdPHP::Bootstrap(function () { date_default_timezone_set('PRC'); RegShutdownEvent::register(); SsdPHP::setAppDir("App"); SsdPHP::setDebug(true); Error::$CONSOLE = SsdPHP::isDebug(); Config::load(SsdPHP::getRootPath() . DIRECTORY_SEPARATOR . 'config'); Route::set(Config::getField('ROUTE', 'home', array())); Language::load(); Session::Start($config = Config::get('SessionApiUser')); })->Run()) === false) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); echo "404 error"; } else { echo $r; } $end = microtime(true); echo SsdPHP::isDebug() ? "<!--" . "SsdPHP" . "Framwork runtime=" . ($end - $start) . "秒" . "-->" : "";