Ejemplo n.º 1
0
 /**
  * @param string $key
  * @throws Exception
  */
 static function save_md_data($key)
 {
     if (!isset(self::$_action_list[$key])) {
         self::_error_and_redirect('不存在此页', '/');
     }
     $actions = self::$_action_list[$key];
     $content = Lib_Request::post_var('content');
     if (trim($content) == '') {
         Lib_Request::flash('error', '提交内容为空');
         Module_HttpRequest_Router::redirect_to($actions[self::URL]);
     }
     $keyword = $actions[self::KEYWORD];
     $model_option = new Model_Option();
     $content = str_replace("\r", '', $content);
     $content = str_replace("\n", '\\n', $content);
     //$content = htmlentities($content);
     $result = $model_option->update_option_by_keyword($keyword, $content);
     if ($result['errno'] != Const_Err_Base::ERR_OK) {
         self::_error_and_redirect(Lib_Helper::format_err_struct($result), $actions[self::URL]);
     } else {
         $help2opcode = ['help_index' => Module_OperationRecord_Main::OPCODE_HELP_INFO, 'help_dev' => Module_OperationRecord_Main::OPCODE_HELP_DEVELOP, 'help_todo' => Module_OperationRecord_Main::OPCODE_HELP_TODO, 'internal_api' => Module_OperationRecord_Main::OPCODE_HELP_INTERNAL, 'open_api' => Module_OperationRecord_Main::OPCODE_HELP_OPEN];
         $opcode = isset($help2opcode[$keyword]) ? $help2opcode[$keyword] : Module_OperationRecord_Main::OPCODE_HELP_INFO;
         Module_OperationRecord_Main::add_record($opcode);
         Lib_Request::flash('保存成功');
         Module_HttpRequest_Router::redirect_to($actions[self::URL]);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param array
  * @return array
  */
 static function process_result($result)
 {
     if ($result['errno'] !== 0) {
         Lib_Log::error("Redis: get result failed! result: %s", json_encode($result));
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_GET_CARD, 'get card failed! result:' . json_encode($result));
     }
     return Lib_Helper::get_return_struct($result['data']);
 }
Ejemplo n.º 3
0
 /**
  * @param string $mail_to
  * @param string $title
  * @param string $msg
  */
 static function send_mail($mail_to, $title, $msg)
 {
     $headers = 'MIME-Version: 1.0' . "\n";
     $headers .= 'Content-type: text/html; charset=uft-8' . "\r\n";
     $headers .= "Content-Transfer-Encoding: 8bit";
     $msg = '<div style="padding:1em;border-left:3px solid #1982d1;">' . $msg . '</div>';
     $msg .= self::_common_footer();
     Lib_Helper::send_mail($mail_to, $msg, Lib_Helper::encodeMIMEString('UTF8', $title), $headers);
 }
Ejemplo n.º 4
0
 /**
  * @param string $val
  * @param array $perm
  * @param array $property
  * @return string
  */
 static function button($val, $perm = [], $property = [])
 {
     $btn = '';
     if (empty($perm) || Module_Account_User::has_perms($perm)) {
         $btn .= '<button type="button"';
         is_array($property) && ($btn .= ' ' . Lib_Helper::join_and_wrap_array_key_and_val($property, ' ', '=', '', '"'));
         $btn .= '>' . $val . '</a>';
     }
     return $btn;
 }
Ejemplo n.º 5
0
 /**
  * @return array
  * @throws Exception
  */
 function get_nav()
 {
     if ($this->_nav === null) {
         $mo = new Model_Option();
         $nav = $mo->get_one_by_keyword(Module_Page_Manager::SAVE_KEY_NAV);
         if ($nav[Const_DataAccess::MREK_ERRNO] != Const_Err_Base::ERR_OK) {
             throw new Exception(Lib_Helper::format_err_struct($nav), $nav[Const_DataAccess::MREK_ERRNO]);
         }
         $this->_nav = $nav[Const_DataAccess::MREK_DATA]['value'];
     }
     return $this->_nav;
 }
Ejemplo n.º 6
0
 /**
  * @return array
  */
 static function module_info()
 {
     $modules_info = new Model_ModulesInfo();
     $module_info = $modules_info->get_module_by_indentify(self::indentify());
     if ($module_info['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(__METHOD__ . ' faild! cause: ' . json_encode($module_info['data']));
         self::$module_id = self::MODULE_UNREG_ID;
         return Lib_Helper::get_err_struct(Const_Err_Db::ERR_GET_DATA_FAIL, '获取模块失败', __FILE__, __LINE__);
     }
     $module_info = $module_info['data'];
     if (empty($module_info)) {
         self::$module_id = self::MODULE_UNREG_ID;
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_MODULE_UNREG, '模块未注册', __FILE__, __LINE__);
     }
     self::$module_id = $module_info['_id'];
     return ['errno' => Const_Err_Base::ERR_OK, 'data' => $module_info];
 }
Ejemplo n.º 7
0
 /**
  * @param int $task_id
  * @param int $module_id
  * @param array $data
  * @param array $options
  * @return array
  */
 function run_module($task_id, $module_id, $data, $options)
 {
     $class = $this->get_module_class($module_id);
     Lib_Log::debug("%s begin run module [%d]\ttask_id:[%d]\toptions:%s", [__METHOD__, $module_id, $task_id, json_encode($options)]);
     $class->set_options($options);
     $this->run_hooks(self::get_run_module_hook_type(self::HOOK_TYPE_BEFORE_RUN_MODULE_PREFIX, $module_id), [$task_id, $module_id, $class, $data]);
     $this->run_hooks(self::HOOK_TYPE_BEFORE_RUN, [$task_id, $module_id, $class, $data]);
     try {
         $result = $class->run($task_id, $data);
     } catch (Exception $ex) {
         $code = $ex->getCode();
         $msg = $ex->getMessage();
         Lib_Log::error("Got a Exception, code [%d], message [%s]", [$code, $msg]);
         $result = Lib_Helper::get_err_struct($code, $msg);
     }
     $this->run_hooks(self::get_run_module_hook_type(self::HOOK_TYPE_AFTER_RUN_MODULE_PREFIX, $module_id), [$task_id, $module_id, $class, $result]);
     $this->run_hooks(self::HOOK_TYPE_AFTER_RUN, [$task_id, $module_id, $class, $result]);
     return $result;
 }
Ejemplo n.º 8
0
 static function task_list_action()
 {
     $task_id = Lib_Request::get_int('task_id');
     $ap_name = Lib_Request::get_var('ap_name');
     $ap_name = trim($ap_name);
     $src_id = Lib_Request::get_var('sub_src');
     $src_id = trim($src_id);
     $status = Lib_Request::get_int('status');
     $time_begin = Lib_Request::get_var('time_begin');
     $time_begin = trim($time_begin);
     $time_end = Lib_Request::get_var('time_end');
     $time_end = trim($time_end);
     $cond = [];
     $search_vars = [];
     $ap_cond = [];
     if (!empty($task_id)) {
         $cond = ['_id' => $task_id];
         $search_vars = ['task_id' => $task_id];
     } else {
         if (strpos($src_id, ',')) {
             $src_ids = explode(',', $src_id);
             $int_src_ids = [];
             foreach ($src_ids as $k => $v) {
                 $int_src_ids[] = intval($v);
             }
             $cond['src_id'] = ['$in' => array_merge($src_ids, $int_src_ids)];
         } elseif (!empty($src_id)) {
             $cond['src_id'] = ['$in' => [$src_id, intval($src_id)]];
         }
         if (!empty($status)) {
             $cond['status'] = $status;
             $search_vars['status'] = $status;
         }
         if (!empty($time_begin) || !empty($time_end)) {
             $time_cond = [];
             if (!empty($time_begin)) {
                 $time_begin = strtotime($time_begin);
                 $time_cond['$gt'] = $time_begin;
             }
             if (!empty($time_end)) {
                 $time_end = strtotime($time_end);
                 $time_cond['$lte'] = $time_end;
             }
             if ($time_begin >= $time_end) {
                 unset($time_cond['$lte']);
             }
             if (!empty($time_cond)) {
                 $cond['create_time'] = $time_cond;
             }
         }
     }
     if (!Module_Account_User::has_perms([Module_Account_Perm::PERM_AP_ADMIN])) {
         $ap_cond['interface_people'] = new MongoRegex("/" . Module_Account_User::get_current_user() . "/");
     }
     if (!empty($ap_name)) {
         $ap_cond = ['ap_name' => new MongoRegex("/" . $ap_name . "/")];
     }
     if (!empty($ap_cond)) {
         $search_vars['ap_name'] = $ap_name;
         $ap_ids = [];
         $int_ap_ids = [];
         $model = new Model_AccessPoint();
         $ap_infos = $model->get_all($ap_cond);
         if ($ap_infos['errno'] == Const_Err_Base::ERR_OK) {
             foreach ($ap_infos['data'] as $k => $ap) {
                 $ap_ids[] = $ap['ap_id'];
                 $int_ap_ids[] = intval($ap['ap_id']);
             }
         }
         $cond['ap_id'] = ['$in' => array_merge($ap_ids, $int_ap_ids)];
     }
     $model_task = new Model_Task();
     $total_num = $model_task->get_tasks_count($cond);
     $current_page = Lib_Request::get_int('page');
     //当前页码,必须
     $total_size = isset($total_num['data']) ? intval($total_num['data']) : 0;
     //总记录数,必须
     $page_size = 15;
     //每页条数,必须
     $skip = ($current_page - 1) * $page_size;
     //跳过记录,必须
     $skip = $skip < 0 ? 0 : $skip;
     $mode = 2;
     //页码模式,决定页码个数,默认1
     $tasks = $model_task->get_all($cond, $page_size, $skip);
     if ($tasks['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($tasks));
         $tasks = [];
         Lib_Request::flash('未获取到任务信息');
     }
     $tasks = $tasks['data'];
     $ap_infos = [];
     $ap_model = new Model_AccessPoint();
     foreach ($tasks as $_k => $_t) {
         $ap_info = $ap_model->get_ap_by_id($_t['ap_id']);
         $ap_info['ap_id'] = $_t['ap_id'];
         if ($ap_info['errno'] !== Const_Err_Base::ERR_OK) {
             Lib_Log::error(Lib_Helper::format_err_struct($ap_info));
             Lib_Request::flash('获取接入点信息失败');
             Module_HttpRequest_Router::redirect_to('/');
         }
         $ap_info = $ap_info[Const_DataAccess::MREK_DATA];
         $ap_infos[$_t['ap_id']] = $ap_info;
     }
     $source_model = new Model_Source();
     $all_sources = $source_model->get_all();
     $sources = $all_sources[Const_DataAccess::MREK_DATA];
     $all_src_type = [];
     foreach ($all_sources['data'] as $k => $v) {
         if (!in_array($v['src_type'], $all_src_type)) {
             $all_src_type[] = $v['src_type'];
         }
     }
     asort($all_src_type);
     $task_status_list = Module_ControlCentre_Main::$task_status_list;
     $pages = Module_View_Template::get_pages_html($current_page, $total_size, $page_size, $mode);
     Module_Page_Main::render('control_centre/task_list', ['ap_info' => $ap_infos, 'tasks' => $tasks, 'sources' => $sources, 'pages' => $pages, 'all_src_type' => $all_src_type, 'status_list' => $task_status_list, 'search_vars' => $search_vars]);
 }
Ejemplo n.º 9
0
 /**
  * @param $dataSave
  * @return array|bool|null
  * @throws Exception
  */
 public function Save($dataSave)
 {
     if (empty($dataSave)) {
         throw new Exception(__METHOD__ . 'empty param ! Data:' . json_encode($dataSave), self::ERRNO_EMPTY_PARAMS);
     }
     Lib_Helper::ConvVal2Int($this->_arrIntDbFields, $dataSave);
     $dataSave = $this->Compress($dataSave);
     $callback = function ($collection) use($dataSave) {
         $ret = $collection->save($dataSave);
         return $ret;
     };
     try {
         $ret = $this->_doAction($callback);
         if (is_null($ret['err'])) {
             return true;
         } else {
             $msg = '';
             if (isset($ret['code']) && isset($ret['errmsg'])) {
                 $msg = 'code: ' . $ret['code'] . ' msg: ' . $ret['errmsg'];
             } else {
                 $msg = json_encode($ret);
             }
             throw new Exception(__METHOD__ . ' Insert fail! code: ' . $msg, self::ERRNO_SAVE_FAIL);
         }
     } catch (Exception $e) {
         throw new Exception(__METHOD__ . ' Insert fail! Exception code: ' . $e->getCode() . ' msg: ' . $e->getMessage(), self::ERRNO_SAVE_FAIL);
     }
     return $ret;
 }
Ejemplo n.º 10
0
 static function index_action()
 {
     $model_task = new Model_Task();
     $tasks = $model_task->get_all(['status' => 2], 10);
     if ($tasks['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($tasks));
         $tasks = [];
     }
     $tasks = $tasks['data'];
     $ap_ids = [];
     $src_ids = [];
     foreach ($tasks as $_k => $_t) {
         $ap_ids[$_k] = isset($_t['ap_id']) ? $_t['ap_id'] : '';
         $src_ids[$_k] = isset($_t['src_id']) ? $_t['src_id'] : '';
     }
     $ap_model = new Model_AccessPoint();
     $aps = $ap_model->get_ap_by_ids($ap_ids);
     if ($aps['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($aps));
         $aps = [];
     }
     $aps = $aps['data'];
     $source_model = new Model_Source();
     $sources = $source_model->get_sources_by_ids($src_ids);
     if ($sources['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($sources));
         $sources = [];
     }
     $sources = $sources['data'];
     $gt_time = strtotime('-1 month');
     $source_model->set_table_name('t_src_statistics');
     $cond = ['update_time' => ['$gte' => $gt_time]];
     $source_statistics = $source_model->get_table()->get_all($cond, [], 0, 0, null, true);
     if ($source_statistics['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($source_statistics));
         $source_statistics = [];
     }
     $source_statistics = $source_statistics['data'];
     $statistics = [];
     foreach ($source_statistics as $v) {
         $day = date('m-d', $v['update_time']);
         $statistics[$day] = isset($statistics[$day]) ? $statistics[$day] : [];
         $statistics[$day]['total'] = isset($statistics[$day]['total']) ? $statistics[$day]['total'] : 0;
         $statistics[$day]['status_1'] = isset($statistics[$day]['status_1']) ? $statistics[$day]['status_1'] : 0;
         $statistics[$day]['status_other'] = isset($statistics[$day]['status_other']) ? $statistics[$day]['status_other'] : 0;
         $statistics[$day]['total'] += intval($v['total']);
         $statistics[$day]['status_1'] += intval($v['status_1']);
         $statistics[$day]['status_other'] = $statistics[$day]['total'] - $statistics[$day]['status_1'];
     }
     foreach ($statistics as $day => $v) {
         $source_statistics_min = isset($source_statistics_min) && $source_statistics_min < $v['status_1'] ? $source_statistics_min : $v['status_1'];
     }
     $_access = Module_Statistics_Action::get_index_month_charts();
     $access_date = $_access['access_date'];
     $receive_data = $_access['receive_data'];
     $send_data = $_access['send_data'];
     self::render('common/index', ['tasks' => $tasks, 'aps' => $aps, 'sources' => $sources, 'source_statistics' => $statistics, 'source_statistics_min' => $source_statistics_min, 'access_date' => $access_date, 'send_data' => $send_data, 'receive_data' => $receive_data]);
 }
Ejemplo n.º 11
0
 /**
  * @param int $module_id
  * @return array
  */
 static function functional_module_class_name($module_id)
 {
     $module = self::get_instance()->get_module_info_by_id($module_id);
     if (empty($module)) {
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_MODULE_NOT_EXISTS, '模块[' . $module_id . ']不存在');
     }
     if (!isset($module[Const_Module::META_TYPE])) {
         Lib_Log::error('errno:' . Const_Err_DataAccess::ERR_MODULE_INCORRECT_INFO . ' module not has meta type, module_id: ' . $module_id);
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_MODULE_INCORRECT_INFO, ' module not has meta type, module_id: ' . $module_id);
     }
     if (strcmp($module[Const_Module::META_TYPE], Const_Module::TYPE_FUNCTIONAL) !== 0) {
         Lib_Log::error('errno:' . Const_Err_DataAccess::ERR_MODULE_WRONG_TYPE . ' module is not functional module, module_id: ' . $module_id);
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_MODULE_WRONG_TYPE, ' module not has meta type, module_id: ' . $module_id);
     }
     $class_name = $module[Model_ModulesInfo::FIELD_MODULE_CLASS];
     if (!class_exists($class_name)) {
         Lib_Log::error("errno: %d, err: module class %s not exists!", [Const_Err_DataAccess::ERR_MODULE_CLASS_NOT_EXISTS, $class_name]);
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_MODULE_CLASS_NOT_EXISTS, 'Module class ' . $class_name . ' not exists!');
     }
     return Lib_Helper::get_return_struct($class_name);
 }
Ejemplo n.º 12
0
#!/usr/bin/env php
<?php 
require_once dirname(dirname(dirname(__FILE__))) . '/app/init.php';
$options = getopt('a:t:m:');
if (!isset($options['a']) || !isset($options['t']) || !isset($options['m'])) {
    p('use as xxx -a ap_id -t task_id -m module_id');
    exit;
}
$ap_id = $options['a'];
//'16723523721449231476';
$task_id = $options['t'];
// 123
$module_id = $options['m'];
//'9691047284819742687'
$control_options = [Const_DataAccess::RUN_OPTION_FLOW_INFO => [Module_FlowManager_Main::RUN_MODE => Module_FlowManager_Main::RUN_MODE_SINGLE_MODULE, Module_FlowManager_Main::RUN_OPTION_SINGLE_MODULE_ID => $module_id]];
$ap_info = Module_AccessPoint_Ap::get_ap($ap_id);
if ($ap_info['errno'] !== Const_Err_Base::ERR_OK) {
    p('Get ap faild! Result:' . Lib_Helper::format_err_struct($ap_info));
    exit;
}
$ap_info = $ap_info['data'];
$flow_id = $ap_info[Module_FlowManager_Main::KEY_FLOW_ID];
unset($ap_info[Module_FlowManager_Main::KEY_FLOW_ID]);
$control_options[Const_DataAccess::RUN_OPTION_ACCESS_POINT_INFO] = $ap_info;
$data = Module_ControlCentre_Main::run($flow_id, $control_options, $task_id);
p($data);
exit;
Ejemplo n.º 13
0
 /**
  * @param int $ap_id
  * @param int $mode
  * @param array $options
  * @param string $php_script
  * @return array
  */
 static function exec_task_by_cli($ap_id, $mode = Module_FlowManager_Main::RUN_MODE_CALLBACK, $options = ['meta' => true], $php_script = 'tools/access_point.php')
 {
     $script = self::get_run_ap_script($ap_id, $mode, $options, $php_script);
     $result = 0;
     $output = null;
     exec($script, $output, $result);
     if ($result != 0) {
         Lib_Log::notice("run ap script failed. case: %s", $output);
         return Lib_Helper::get_err_struct($result, '执行失败');
     }
     return Lib_Helper::get_return_struct('运行成功');
 }
Ejemplo n.º 14
0
 /**
  * @param string
  * @param string
  * @return array
  */
 function get_by_ids_then_change_id_key($ids, $id_key)
 {
     $result = $this->get_table()->get_all(['_id' => ['$in' => $ids]]);
     if ($result['errno'] !== Const_Err_Base::ERR_OK) {
         return $result;
     }
     $result = $result['data'];
     foreach ($result as $_k => $_r) {
         $result[$_k][$id_key] = $_r['_id'];
         unset($result[$_k]['_id']);
     }
     return Lib_Helper::get_return_struct($result);
 }
Ejemplo n.º 15
0
 /**
  * @param int $flow_id
  * @return array
  */
 private static function _get_fields_by_flow_id($flow_id)
 {
     $flow = new Module_FlowManager_Flow();
     $flow->id = $flow_id;
     $flow_info = $flow->get();
     if (!$flow_info) {
         return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_FLOW_NOT_EXISTS, 'no this flow, flow_id: ' . $flow_id);
     }
     $fields = Module_ModuleManager_InterfaceGen::get_instance()->gen_fields($flow);
     return Lib_Helper::get_return_struct($fields);
 }
Ejemplo n.º 16
0
 /**
  * @param string $indent
  * @param string $name
  * @param array $content
  * @return array
  */
 private static function _format_field($indent, $name, $content)
 {
     $type = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_TYPE, Const_Interface::NODE_TYPE_UNKNOW);
     $label = $content[Const_Interface::FIELD_ATTR_NAME];
     $is_global = isset($content[Const_Interface::FIELD_ATTR_IS_GLOBAL]) && $content[Const_Interface::FIELD_ATTR_IS_GLOBAL] ? true : false;
     $desc = isset($content[Const_Interface::FIELD_ATTR_DESC]) ? $content[Const_Interface::FIELD_ATTR_DESC] : '';
     $weight = isset($content[Const_Interface::FIELD_ATTR_WEIGHT]) ? $content[Const_Interface::FIELD_ATTR_WEIGHT] : 100;
     $set = [Const_Interface::FIELD_ATTR_KEY => $name, Const_Interface::FIELD_ATTR_MODULE => $indent, Const_Interface::FIELD_ATTR_NAME => $label, Const_Interface::FIELD_ATTR_TYPE => $type, Const_Interface::FIELD_ATTR_IS_GLOBAL => $is_global, Const_Interface::FIELD_ATTR_DESC => $desc, Const_Interface::FIELD_ATTR_WEIGHT => $weight];
     switch ($type) {
         case Const_Interface::NODE_TYPE_INPUT:
             $set[Const_Interface::FIELD_ATTR_PLACEHOLDER] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_PLACEHOLDER, $label);
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, '');
             break;
         case Const_Interface::NODE_TYPE_SELECT:
         case Const_Interface::NODE_TYPE_RSELECT:
             $value = $content[Const_Interface::FIELD_ATTR_DATA];
             $set[Const_Interface::FIELD_ATTR_VALUE] = self::_format_field_value($indent, $value);
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, array_keys($value)[0]);
             break;
         case Const_Interface::NODE_TYPE_MINPUT:
             $set[Const_Interface::FIELD_ATTR_DEFAULT] = Lib_Helper::get_data_from_array($content, Const_Interface::FIELD_ATTR_DEFAULT, []);
             break;
         default:
             $set = [];
     }
     return $set;
 }
Ejemplo n.º 17
0
 /**
  * @param string $path
  * @return bool
  */
 static function is_current_url_path($path = '/')
 {
     if (is_null($path)) {
         return false;
     }
     $url = self::current_url_path();
     if (is_array($path)) {
         foreach ($path as $_p) {
             $_p = rtrim($_p, '/');
             if (Lib_Helper::str_equal($_p, $url)) {
                 return true;
             }
         }
         return false;
     }
     Lib_Helper::str_equal($path, '/') || ($path = rtrim($path, '/'));
     return Lib_Helper::str_equal($path, $url);
 }
Ejemplo n.º 18
0
 /**
  * @param array $cond
  * @return array
  */
 public function get_tables($cond = [])
 {
     switch ($this->_driver) {
         case self::DB_DRIVER_MONGO:
         default:
             Lib_Log::debug(__METHOD__ . ': Use mongo driver, cond: %s', [json_encode($cond)]);
             try {
                 $result = $this->_db->GetTables($cond);
                 if (is_null($result)) {
                     $result = Lib_Helper::get_err_struct(Const_Err_Db::ERR_MONGO_COLLECTIONS_FAIL, '获取数据集失败', __FILE__, __LINE__);
                 } else {
                     $result = Lib_Helper::get_return_struct($result);
                 }
             } catch (Exception $ex) {
                 Lib_Log::error(__METHOD__ . " get faild! cond: %s, code: %d, messsage: %s", [json_encode($cond), $ex->getCode(), $ex->getMessage()]);
                 $result = Lib_Helper::get_err_struct(Const_Err_Db::ERR_MONGO_COLLECTIONS_FAIL, '获取数据集失败', __FILE__, __LINE__);
             }
     }
     return $result;
 }
Ejemplo n.º 19
0
 /**
  * @param bool $all_people
  * @return array
  */
 static function interface_people($all_people = true)
 {
     $ap = self::current_ap();
     $people = Lib_Helper::check_and_explode_array_val(';', $ap, Module_ScheduledTask_Main::FIELD_CALL_MAN, [], " \t;");
     if ($all_people) {
         $interface_people = Lib_Helper::check_and_explode_array_val(';', $ap, Module_AccessPoint_Main::FIELD_INTERFACE_PEOPLE, [], " \t;");
         $people = array_merge($people, $interface_people);
     }
     $admins = Da\Sys_Config::config('account/users');
     $_p = [];
     empty($admins) || ($_p = array_keys($admins));
     $people = array_merge($people, $_p);
     $people = array_unique($people);
     return $people;
 }
Ejemplo n.º 20
0
 /**
  * @param int $task_id
  * @param int $mid
  * @return array|mixed
  */
 static function read_meta($task_id, $mid)
 {
     $mtrmr = new Model_TaskRunModuleRecord();
     $pre_result = $mtrmr->get_nearest_record_by_task_and_module($task_id, $mid, null, ['result']);
     if ($pre_result[Const_DataAccess::MREK_ERRNO] != Const_Err_Base::ERR_OK) {
         return $pre_result;
     }
     $pre_result = $pre_result[Const_DataAccess::MREK_DATA];
     if (!isset($pre_result['result']) || !isset($pre_result['result'][Const_DataAccess::MREK_ERRNO])) {
         return Lib_Helper::get_err_struct(Const_Err_Base::ERR_UNEXPECT_RETURN, 'there is no result to use: ' . json_encode($pre_result));
     }
     $meta = null;
     if ($pre_result['result'][Const_DataAccess::MREK_ERRNO] == Const_Err_Base::ERR_OK && isset($pre_result['result'][Const_DataAccess::MREK_DATA])) {
         $meta = $pre_result['result'][Const_DataAccess::MREK_DATA];
     } elseif (isset($pre_result['result'][Const_DataAccess::MREK_META])) {
         $meta = $pre_result['result'][Const_DataAccess::MREK_META];
     } else {
         return Lib_Helper::get_err_struct(Const_Err_Base::ERR_UNEXPECT_RETURN, 'there is no result to use: ' . json_encode($pre_result));
     }
     return Lib_Helper::get_return_struct($meta);
 }
Ejemplo n.º 21
0
 /**
  * @return array
  */
 private function _del_all_counts()
 {
     $this->_pool = [];
     $del = [];
     foreach ($this->_current_keys as $_k => $_hash_key) {
         $del[$_k] = xcache_unset($_hash_key);
     }
     return Lib_Helper::get_return_struct($del);
 }