/** * 记录日志 */ public function saveLogs($description = '', $remark = 1, $parameters = array()) { $data = array(); $userinfo = Wave::app()->session->getState('userinfo'); if (!empty($userinfo)) { $data['username'] = $userinfo['username']; } $data['time'] = time(); $data['description'] = $description; $data['remark'] = $remark; if ($parameters) { $p = ''; foreach ($parameters as $key => $value) { $v = ''; if (is_array($value)) { $v = implode(',', $value); } else { $v = $value; } $p .= $key . '=' . $v . ' | '; } $data['parameters'] = $p; } $this->insert($data); }
public function init() { if (extension_loaded('redis') == false) { exit('extension redis not found!'); } $hosts = Wave::app()->config[$this->cache_name]; if (isset($hosts['slave'])) { $this->cacheArray[$this->cache_name] = new WaveRedisCluster(true); $ret1 = $this->cacheArray[$this->cache_name]->connect(array('host' => $hosts['master']['host'], 'port' => $hosts['master']['port']), true); // if (!$ret1) { // throw new Exception('redis server '.$this->hosts['master']['host'].':'.$this->hosts['master']['port'].' connection faild.'); // } if ($ret1) { foreach ($hosts['slave'] as $key => $value) { $ret = $this->cacheArray[$this->cache_name]->connect(array('host' => $value['host'], 'port' => $value['port']), false); if (!$ret) { // throw new Exception('redis server '.$value['host'].':'.$value['port'].' connection faild.'); $this->cacheArray = null; $this->cache_name = null; } } } else { $this->cacheArray = null; $this->cache_name = null; } } else { $this->cacheArray[$this->cache_name] = new WaveRedisCluster(false); $ret = $this->cacheArray[$this->cache_name]->connect(array('host' => $hosts['master']['host'], 'port' => $hosts['master']['port'])); if (!$ret) { // throw new Exception('redis server '.$value['host'].':'.$value['port'].' connection faild.'); $this->cacheArray = null; $this->cache_name = null; } } }
/** * 上传图片 */ public function actionUpload() { $fn = $_GET['CKEditorFuncNum']; $url = WaveCommon::getCompleteUrl(); $imgTypeArr = WaveCommon::getImageTypes(); if (!in_array($_FILES['upload']['type'], $imgTypeArr)) { echo '<script type="text/javascript"> window.parent.CKEDITOR.tools.callFunction("' . $fn . '","","图片格式错误!"); </script>'; } else { $projectPath = Wave::app()->projectPath; $uploadPath = $projectPath . 'data/uploadfile/substance'; if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777); } $ym = WaveCommon::getYearMonth(); $uploadPath .= '/' . $ym; if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777); } $imgType = strtolower(substr(strrchr($_FILES['upload']['name'], '.'), 1)); $imageName = time() . '_' . rand() . '.' . $imgType; $file_abso = $url . '/data/uploadfile/substance/' . $ym . '/' . $imageName; $SimpleImage = new SimpleImage(); $SimpleImage->load($_FILES['upload']['tmp_name']); $SimpleImage->resizeToWidth(800); $SimpleImage->save($uploadPath . '/' . $imageName); echo '<script type="text/javascript"> window.parent.CKEDITOR.tools.callFunction("' . $fn . '","' . $file_abso . '","上传成功"); </script>'; } }
/** * 获得对应多语言数组 * @param string $lang 语言类型 * @return array * */ public function getLanguage($lang) { $i18n = array(); $dir = Wave::app()->projectPath . 'data/caches/'; if (!is_dir($dir)) { mkdir($dir); } $filepath = $dir . 'language_' . $lang . '.php'; if (!is_file($filepath)) { $zhnew = array(); $zh = $this->where(array('lang_code' => 'zh-cn'))->getAll('lang_key,lang_value'); foreach ($zh as $key => $val) { $zhnew[$val['lang_key']] = $val['lang_value']; } $foreign = $this->where(array('lang_code' => $lang))->getAll('lang_key,lang_value'); foreach ($foreign as $key => $val) { $zhcn = $zhnew[$val['lang_key']]; $i18n[$zhcn] = $val['lang_value']; } $cache = var_export($i18n, true); $content = "<?php defined('Application')"; $content .= "or die('No direct script access.');\n"; $content .= "return {$cache} ?>"; Wave::writeCache($filepath, $content); } else { $i18n = (require $filepath); } return $i18n; }
public function __construct() { $this->path = Wave::app()->projectPath . '/data/files/'; if (!is_dir($this->path)) { mkdir($this->path); } }
public function isLogin() { $userinfo = Wave::app()->session->getState('userinfo'); if (!empty($userinfo)) { return true; } return false; }
public function getTheme($themeString) { $externalThemeBasePath = \Wave::getInstance()->getExtensionPath() . "themes/" . $themeString . ".rwtheme/"; if (file_exists($externalThemeBasePath)) { return new ExternalWaveTheme($externalThemeBasePath, $this); } else { die("Theme " . $themeString . " not found!"); } }
public function __construct() { parent::__construct(); $this->Log = new Log(); $this->userinfo = Wave::app()->session->getState('userinfo'); if (empty($this->userinfo)) { $this->redirect(Wave::app()->homeUrl . 'adminsite/login'); } }
public function __construct() { $option = Wave::app()->config['session']; $this->lifeTime = $option['timeout']; if (isset($option['redis'])) { $this->cache = new Cache_Redis($option['redis']); } else { $this->cache = Wave::app()->redis; } }
/** * 开始 */ public function run() { $this->loadMemcache(); $this->loadMemcached(); $this->loadRedis(); $this->loadSession(); self::$Route = new Route(); self::$Route->route(); $this->Base->clear(); }
public function __construct() { $option = Wave::app()->config['session']; $this->lifeTime = $option['timeout']; if (isset($option['memcache'])) { $this->cache = new Cache_Memcache($option['memcache']); } else { $this->cache = Wave::app()->memcache; } }
/** * 工厂方法 * * @param string $dbname 数据库名称 * * @return object $db * */ public static function factory($dbname = '') { $option = Wave::app()->config[$dbname]; $driver = isset($option['driver']) ? $option['driver'] : 'mysql'; if (isset(self::$db[$dbname]) && is_object(self::$db[$dbname])) { return self::$db[$dbname]; } $class = ucfirst($driver); self::$db[$dbname] = new $class($option); return self::$db[$dbname]; }
/** * 初始化 */ public function __construct() { $this->app = Wave::app(); if (isset($this->app->config['smarty'])) { if (isset($this->app->config['smarty']['is_on'])) { $this->isSmarty = $this->app->config['smarty']['is_on']; } } if ($this->isSmarty) { $this->view = $this->initView(); } }
/** * 添加、修改分类结果 */ public function actionModified() { $Category = new Category(); $data = WaveCommon::getFilter($_POST); $cid = (int) $data['cid']; unset($data['cid']); if ($cid == 0) { $Category->insert($data); } else { $Category->update($data, array('cid' => $cid)); } $this->jumpBox('成功!', Wave::app()->homeUrl . 'categories', 1); }
function response() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); //消息类型 $type = (string) $postObj->MsgType; error_log(json_encode($postObj), 3, "log.log"); /* * 若为语音消息,调用语音消息处理方法 */ if ($type == 'voice') { $weixin = new \Weixin\Api($postObj, APPID, APPSECRET); $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . date('Y-m-d', time()) . DIRECTORY_SEPARATOR . "openid_" . (string) $postObj->FromUserName . DIRECTORY_SEPARATOR; mkdir($dir, 0777, true); $file = date('YmdHis', time()); $path = $weixin->getMediaFile($dir . $file); $save = $path . ".wav"; $cmd = "D:/ffmpeg/bin/ffmpeg.exe -i {$path} {$save}"; error_log("\r\n{$cmd}\r\n", 3, "log.log"); error_log("\r\n" . json_encode(ini_get('safe_mode')) . "\r\n", 3, "log.log"); $tmp = `{$cmd}`; error_log("\r\n{$tmp}\r\n", 3, "log.log"); $wav = new \Wave($save); $dB = $wav->avg_db(); error_log("\r\ndB: {$dB}\r\n", 3, "log.log"); $reply = $weixin->replyText($dB); echo $reply; error_log("reply: {$reply}\r\n", 3, "log.log"); exit; } //关注公众号触发事件 if ($type == 'event' && (string) $postObj->Event == 'subscribe') { $weixin = new \Weixin\Api($postObj, APPID, APPSECRET); echo $weixin->replyText("欢迎"); exit; } } }
/** * 提交信息 */ public function actionModified() { $Links = new Links(); $data = $this->Common->getFilter($_POST); $id = (int) $data['lid']; unset($data['lid']); if ($id == 0) { $Links->insert($data); } else { $Links->update($data, array('lid' => $id)); } $this->jumpBox('成功!', Wave::app()->homeUrl . 'links', 1); }
/** * 提交信息 */ public function actionModified() { $data = WaveCommon::getFilter($_POST); $id = (int) $data['mid']; unset($data['mid']); $GhMenu = new GhMenu(); if ($id == 0) { $GhMenu->insert($data); } else { $GhMenu->update($data, array('mid' => $id)); } $this->jumpBox('成功!', Wave::app()->homeUrl . 'wxmenu', 1); }
public function __construct() { $config = Wave::app()->config; $this->lifeTime = $config['session']['timeout']; if (isset($config['session_memcache'])) { if (extension_loaded('memcached')) { $this->cache = new Cache_Memcached('session_memcached'); } else { $this->cache = new Cache_Memcache('session_memcache'); } } else { $this->cache = Wave::app()->memcache; } }
function open($savePath, $sessName) { $tables = $this->queryAll('show tables'); $tablesList = array(); $dbName = Wave::app()->config['database']['master']['dbname']; foreach ($tables as $key => $value) { $tablesList[] = $value['Tables_in_' . $dbName]; } if (!in_array($this->_tableName, $tablesList)) { $sql = "CREATE TABLE `" . $this->_tableName . "` (\n `session_id` varchar(255) CHARACTER \n SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',\n `session_expires` int(10) unsigned NOT NULL DEFAULT '0',\n `session_data` text,\n PRIMARY KEY (`session_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; $this->sqlQuery($sql); } return true; }
/** * 设置密码 */ public function actionSetpwd() { $Users = new Users(); $data = $this->Common->getFilter($_POST); if (empty($data['pwd']) || empty($data['newpwd']) || empty($data['confirmpwd'])) { $this->jumpBox('参数错误!', Wave::app()->homeUrl . 'member', 1); } if ($data['newpwd'] != $data['confirmpwd']) { $this->jumpBox('两次密码不一样!', Wave::app()->homeUrl . 'member', 1); } $updateData = array('password' => md5($data['newpwd'])); $Users->update($updateData, array('userid' => $this->userinfo['userid'])); $this->jumpBox('修改成功!', Wave::app()->homeUrl . 'member', 1); }
/** * 初始化 * * @param string $db 数据库名称 * */ public function minit($db = '') { // 表前缀 $this->dbname = 'database'; if (!empty($db)) { $this->dbname = $db; } if (empty($this->tablePrefixArray[$this->dbname])) { $configs = Wave::app()->config[$this->dbname]; $this->tablePrefixArray[$this->dbname] = $configs['master']['table_prefix']; } if (empty($this->dbArray[$this->dbname])) { $this->dbArray[$this->dbname] = Database::factory($this->dbname); } $this->init(); }
/** * 选数据库 */ public function init($tag) { if (isset($this->conn[$tag])) { $this->selectCharsetAndDb($tag); return true; } $this->conn[$tag] = $this->_connect($tag); if (!$this->conn[$tag]) { if (Wave::app()->config['crash_show_sql']) { die('Can not connect to MySQL server:' . $this->config[$tag]['dbhost']); } else { die('Can not connect to MySQL server'); } } $this->selectCharsetAndDb($tag); }
/** * 初始化 */ function __construct() { $app = Wave::app(); if (isset($app->config['smarty'])) { if (isset($app->config['smarty']['is_on'])) { $this->isSmarty = $app->config['smarty']['is_on']; } } if (isset($app->config['debuger'])) { $this->isDebuger = $app->config['debuger']; } $this->projectPath = $app->projectPath; $this->projectName = $app->projectName; $this->pathInfo = $app->request->pathInfo; $this->defaultControl = $app->defaultControl; }
/** * 自动加载函数 * * 例如 $User = new User(); * 会自动加载 项目路径/models/User.php 这个文件 * 例如 extends CommonController * 会自动加载 项目路径/controllers/CommonController.php 这个文件 * */ public static function loader($class) { $app = Wave::app(); $filename = $app->projectPath . $app->modelName . '/models/' . $class . '.php'; if (file_exists($filename)) { require $filename; if (!class_exists($class)) { exit('no ' . $class); } } if (!empty($app->import)) { $import = $app->import; foreach ($import as $key => $value) { $path = ''; $file_array = explode('.', $value); foreach ($file_array as $k => $v) { $path .= $v . '/'; } $filename = $app->projectPath . $app->projectName . '/' . str_replace('*/', '', $path) . $class . '.php'; if (file_exists($filename)) { require $filename; if (!class_exists($class)) { exit('no ' . $class); } break; } } } $dirArr = array('Cache', 'Core', 'Db', 'Language', 'Session', 'Web'); $filename = $app->frameworkPath . $class . '.php'; if (file_exists($filename)) { require $filename; if (!class_exists($class)) { exit('no ' . $class); } } foreach ($dirArr as $key => $dir) { $filename = $app->frameworkPath . $dir . '/' . $class . '.php'; if (file_exists($filename)) { require $filename; if (!class_exists($class)) { exit('no ' . $class); } break; } } }
/** * 提交信息 */ public function actionModified() { $data = $this->Common->getFilter($_POST); $id = (int) $data['gid']; unset($data['gid']); $md5 = md5($data['gh_id']); $data['gh_key'] = substr($md5, 16); $data['gh_token'] = substr($md5, 8, 8); $data['gh_enaeskey'] = $md5 . substr($md5, 21); $GhManage = new GhManage(); if ($id == 0) { $data['userid'] = $this->userinfo['userid']; $GhManage->insert('gh_manage', $data); } else { $GhManage->update($data, array('gid' => $id)); } $this->jumpBox('成功!', Wave::app()->homeUrl . 'wx', 1); }
public function init() { if (extension_loaded('memcached') == false) { exit('extension memcached not found!'); } $hosts = Wave::app()->config[$this->cache_name]; $this->cacheArray[$this->cache_name] = new Memcached(); $this->cacheArray[$this->cache_name]->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true); $i = 0; $servers = array(); foreach ($hosts as $key => $value) { $servers[$i] = array($value['host'], $value['port'], $i); $i++; } if (!$this->cacheArray[$this->cache_name]->addServers($servers)) { // throw new Exception('memcahced server '.json_encode($servers).' connection faild.'); $this->cacheArray = null; $this->cache_name = null; } }
public function init() { if (extension_loaded('memcache') == false) { exit('extension memcache not found!'); } $hosts = Wave::app()->config[$this->cache_name]; $this->cacheArray[$this->cache_name] = new Memcache(); $i = 1; foreach ($hosts as $key => $value) { if ($i == 1) { if (!@$this->cacheArray[$this->cache_name]->connect($value['host'], $value['port'])) { // throw new Exception('memcahce server '.$value['host'].':'.$value['port'].' connection faild.'); $this->cacheArray = null; $this->cache_name = null; } } else { $this->cacheArray[$this->cache_name]->addServer($value['host'], $value['port']); } $i++; } }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $portal = \lms_portal::get_instance(); $content = \Wave::getInstance()->loadTemplate("wave.template.html"); if (strtolower($this->calledNamespace) === "wave" && strtolower($this->calledCommand) === "index") { $sideId = $this->params[0]; $internalPath = $this->params; array_shift($internalPath); $sideUrl = $this->getExtension()->getExtensionUrl() . "Index/" . $sideId . "/"; } else { $sideObject = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), WAVE_PATH_INTERN); if ($sideObject instanceof \steam_object) { $sideId = $sideObject->get_id(); $internalPath = $this->params; $sideUrl = PATH_URL; } else { die("WAVE config broken (WAVE_PATH_INTERN: " . WAVE_PATH_INTERN . ")"); } } if (!isset($internalPath)) { $internalPath = array(); } $waveEngine = new \Wave\Model\WaveEngine($sideId, $internalPath, $sideUrl); $waveSide = $waveEngine->getSide(); $waveObject = $waveEngine->getCurrentObject(); if ($waveObject instanceof \Wave\Model\WavePage) { $content->setVariable("CONTENT", $waveObject->getHtml()); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; } else { if ($waveObject instanceof \Wave\Model\WaveDownload) { $waveObject->download(); die; } else { die("Not Wave-Object detected."); } } }
/** * 日志列表JSON */ public function actionJsonlist() { $start = (int) $_GET['iDisplayStart']; $pagesize = (int) $_GET['iDisplayLength']; $list = $this->Log->limit($start, $pagesize)->order('id', 'desc')->getAll(); $iTotal = $this->Log->getCount('*'); $output = array("sEcho" => $_GET['sEcho'], "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iTotal, "aaData" => array()); $homeUrl = Wave::app()->homeUrl . 'articles/modify/'; foreach ($list as $key => $value) { $list[$key]['parameters'] = '<textarea class="form-control" rows="1">'; $list[$key]['parameters'] .= $value['parameters'] . '</textarea>'; $list[$key]['time'] = date('Y-m-d H:i:s'); if ($value['remark']) { $list[$key]['remark'] = '<font color="green">成功</font>'; } else { $list[$key]['remark'] = '<font color="red">失败</font>'; } } $output['aaData'] = $list; echo json_encode($output); die; }
/** * 默认函数 */ public function actionIndex($cid) { $this->data = $this->Common->getFilter($_GET); $this->cid = (int) $cid; $where = array(); $this->category = array(); $Category = new Category(); if ($cid != 0) { $where['a.cid'] = $cid; $this->category = $Category->from('category a')->getOne('*', $where); } $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $pagesize = 15; $start = ($page - 1) * $pagesize; $Articles = new Articles(); $this->list = $Articles->select('a.aid,a.title,a.add_date,c.c_name')->from('articles a')->join('category c', 'a.cid=c.cid')->where($where)->limit($start, $pagesize)->order('a.aid', 'desc')->getAll(); $count = $Articles->from('articles a')->getCount('*', $where); $url = 'http://' . Wave::app()->request->hostInfo . $_SERVER['REQUEST_URI']; if (empty($data['page'])) { $url .= '?page=1'; } $this->pagebar = $this->Common->getPageBar($url, $count, $pagesize, $page); }