本文整理汇总了PHP中Fn::sess方法的典型用法代码示例。如果您正苦于以下问题:PHP Fn::sess方法的具体用法?PHP Fn::sess怎么用?PHP Fn::sess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fn
的用法示例。
在下文中一共展示了Fn::sess方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* 添加管理员操作日志
*
* @param string $action 操作类型
* @param string $content 操作对象
* @param string $log_info 操作信息
*/
public static function add($action, $content, $log_info = '')
{
$CI =& get_instance();
$CI->lang->load('admin/admin_log');
$action = $action ? $CI->lang->line('log_' . $action) : '';
$content = $content ? $CI->lang->line('log_' . $content) : '';
$op = $action . $content;
if ($op) {
$log_info = $log_info ? $op . "({$log_info})" : $op;
}
$log = array('admin_id' => Fn::sess()->userdata('admin_id'), 'log_info' => $log_info, 'ip_address' => $CI->input->ip_address(), 'log_time' => time());
Fn::db()->insert('rd_admin_log', $log);
}
示例2: setExamRelateQuestion
/**
* 设置考试试题对应关系
* 若$param为array,则为map<string, variant>,参数如下:
* int erq_examid 测评考试id
* int erq_paperid 测评考试试卷id
* int er_zmoss_examid 阅卷考试id
* string erq_relate_data 试题对应关系
* @return bool true|false
*/
public static function setExamRelateQuestion($param)
{
$param = Func::param_copy($param, 'erq_examid', 'erq_paperid', 'erq_zmoss_examid', 'erq_relate_data');
if (!Validate::isInt($param['erq_examid']) || $param['erq_examid'] <= 0 || !Validate::isInt($param['erq_zmoss_examid']) || $param['erq_zmoss_examid'] <= 0) {
message('请确认考试学科对应关系!');
}
if (!Validate::isInt($param['erq_paperid']) || $param['erq_paperid'] <= 0) {
throw new Exception('测评考试学科试卷不可为空!');
}
if (!Validate::isNotEmpty($param['erq_relate_data'])) {
throw new Exception('试题对应关系不可为空!');
}
$param['erq_adminid'] = Fn::sess()->userdata('admin_id');
$param['erq_addtime'] = time();
return Fn::db()->replace('t_exam_relate_question', $param);
}
示例3: is_action_type_self
public static function is_action_type_self($segment, $item, $subject_id = 0)
{
//return $this->get_action_type_segment($segment, $item) == '1';
$action = Fn::sess()->userdata('action');
$is_action_type_self = false;
foreach ($action as $power) {
$action_type = @unserialize($power['action_type']);
if ($subject_id > 0) {
if ($power['subject_id'] == -1 || in_array($subject_id, explode(',', $power['subject_id']))) {
if (!empty($action_type[$segment][$item]) && $action_type[$segment][$item] == 1) {
$is_action_type_self = true;
break;
}
}
} else {
if (!empty($action_type[$segment][$item]) && $action_type[$segment][$item] == 1) {
$is_action_type_self = true;
break;
}
}
}
return $is_action_type_self;
}
示例4: import_titc_excel
//.........这里部分代码省略.........
$data['error'] = $col_char[15] . ($k + 2) . ' - "联系电话"太长了';
break;
}
$row['tc_ctcphone'] = $row[15];
if (!isset($ti_arr[$row[0]])) {
$ti_arr[$row[0]] = count($ti_list);
$ti_list[] = array('index' => $k + 2, 'ti_id' => 0, 'ti_name' => $row[0], 'ti_typeid' => $row['ti_typeid'], 'ti_provid' => $row['ti_provid'], 'ti_cityid' => $row['ti_cityid'], 'ti_areaid' => $row['ti_areaid'], 'ti_addr' => $row[5], 'ti_priid' => $row['ti_priid'], 'ti_stumax' => $row[7], 'ti_url' => $row[8]);
}
if (!isset($tc_arr[$row[0]])) {
$tc_arr[$row[0]] = array();
}
if (isset($tc_arr[$row[0]][$row[9]])) {
$data['error'] = $col_char[9] . ($k + 2) . ' - "校区名称"同一机构内有重复';
break;
}
$tc_arr[$row[0]][$row[9]] = count($tc_list);
$tc_list[] = array('index' => $k + 2, 'ti_name' => $row[0], 'tc_name' => $row[9], 'tc_provid' => $row['tc_provid'], 'tc_cityid' => $row['tc_cityid'], 'tc_areaid' => $row['tc_areaid'], 'tc_ctcaddr' => $row[13], 'tc_ctcperson' => $row[14], 'tc_ctcphone' => $row[15]);
}
if (isset($data['error'])) {
break;
}
unset($region_map);
unset($regionname_map);
unset($tit_map);
unset($tipt_map);
unset($rows);
// 这里开始导入
try {
$db = Fn::db();
if (!$db->beginTransaction()) {
throw new Exception('开始导入事务处理失败');
}
$time = time();
$adduid = Fn::sess()->userdata('admin_id');
// 导入机构
$sql1 = <<<EOT
SELECT ti_id FROM t_training_institution WHERE ti_name = ?
EOT;
$sql2 = <<<EOT
SELECT tc_id FROM t_training_campus WHERE tc_tiid = ? AND tc_name = ?
EOT;
$sql3 = <<<EOT
UPDATE t_training_institution SET ti_campusnum = ti_campusnum + 1
WHERE ti_id =
EOT;
$tc_update = 0;
$tc_insert = 0;
$ti_update = 0;
$ti_insert = 0;
foreach ($ti_list as $k => $row) {
$ti_id = $db->fetchOne($sql1, array($row['ti_name']));
if ($ti_id) {
$ti_list[$k]['ti_id'] = $ti_id;
// update
$row2 = array();
if ($param['same_tiname_update_ti_typeid']) {
$row2['ti_typeid'] = $row['ti_typeid'];
}
if ($param['same_tiname_update_ti_region'] && intval($row['ti_provid']) != 0) {
$row2['ti_provid'] = $row['ti_provid'];
$row2['ti_cityid'] = $row['ti_provid'];
$row2['ti_areaid'] = $row['ti_areaid'];
}
if ($param['same_tiname_update_ti_addr'] && $row['ti_addr'] != '') {
$row2['ti_addr'] = $row['ti_addr'];
}
示例5: addTrainingCampus
/**
* 新增培训校区
* @param array map<string, variant>类型的参数
* string tc_name
* int tc_tiid
* int tc_flag
* int tc_provid
* int tc_cityid
* int tc_areaid
* string tc_ctcaddr
* string tc_ctcphone
* string tc_ctcperson
* int tc_environ
* @return int 返回新增的培训校区ID,否则返回0
*/
public static function addTrainingCampus(array $param)
{
$param = Func::param_copy($param, 'tc_name', 'tc_tiid', 'tc_flag', 'tc_provid', 'tc_cityid', 'tc_areaid', 'tc_ctcaddr', 'tc_ctcphone', 'tc_ctcperson', 'tc_environ');
if (!Validate::isStringLength($param['tc_name'], 1, 60)) {
throw new Exception('培训校区名称不能为空且长度最多60个字符');
}
if (!Validate::isInt($param['tc_tiid'])) {
throw new Exception('培训校区所属机构ID必须为整数');
}
if (!Validate::isInt($param['tc_flag'])) {
throw new Exception('培训校区状态标志必须为整数');
}
if (!Validate::isInt($param['tc_provid']) || !Validate::isInt($param['tc_cityid']) || !Validate::isInt($param['tc_areaid'])) {
throw new Exception('培训校区所在地区ID必须为整数');
}
if (!Validate::isStringLength($param['tc_ctcaddr'], 1, 255)) {
throw new Exception('培训校区联系地址长度最多为255个字符');
}
if (isset($param['tc_ctcperson'])) {
if ($param['tc_ctcperson'] == '') {
$param['tc_ctcperson'] = NULL;
} else {
if (!Validate::isStringLength($param['tc_ctcperson'], 1, 60)) {
throw new Exception('培训校区联系人姓名最多60个字符');
}
}
}
if (!Validate::isStringLength($param['tc_ctcphone'], 1, 120)) {
throw new Exception('培训校区联系电话长度最多为255个字符');
}
if (isset($param['tc_environ']) && !Validate::isInt($param['tc_environ'])) {
throw new Exception('培训校区环境指数必须为整数');
}
$db = Fn::db();
$param['tc_addtime'] = date('Y-m-d H:i:s');
$param['tc_adduid'] = Fn::sess()->userdata('admin_id');
$tc_id = 0;
if ($db->beginTransaction()) {
if ($db->insert('t_training_campus', $param)) {
$tc_id = $db->lastInsertId('t_training_campus', 'tc_id');
$ti_id = $param['tc_tiid'];
$sql = <<<EOT
UPDATE t_training_institution SET ti_campusnum = ti_campusnum + 1
WHERE ti_id = {$ti_id}
EOT;
$db->exec($sql);
if (!$db->commit()) {
$tc_id = 0;
$db->rollBack();
}
} else {
$db->rollBack();
}
}
return $tc_id;
}
示例6: importteacher
//.........这里部分代码省略.........
if (isset($grade_map[$v])) {
$row['ctg_gradeid'][] = $grade_map[$v];
} else {
$data['error'] = $col_char[1] . ($k + 2) . ' - "年级"里有不正确的选项';
break;
}
}
if (isset($data['error'])) {
break;
}
if (empty($row['ctg_gradeid'])) {
$data['error'] = $col_char[1] . ($k + 2) . ' - "年级"不能为空';
break;
}
$row['ctg_gradeid'] = array_unique($row['ctg_gradeid']);
// 学科
if ($row[2] == '') {
$data['error'] = $col_char[2] . ($k + 2) . ' - "学科"不能为空';
break;
}
$row[2] = str_replace(array(',', ' ', ' ', '、', "\r\n", "\r", "\n"), ',', $row[2]);
$row['cts_subjectid'] = array();
$arr = explode(',', $row[2]);
foreach ($arr as $v) {
$v = trim($v);
if ($v == '') {
continue;
}
if (isset($subject_map[$v])) {
$row['cts_subjectid'][] = $subject_map[$v];
} else {
$data['error'] = $col_char[2] . ($k + 2) . ' - "学科"里有不正确的选项空';
break;
}
}
if (isset($data['error'])) {
break;
}
if (empty($row['cts_subjectid'])) {
$data['error'] = $col_char[2] . ($k + 2) . ' - "学科"不能为空';
break;
}
$row['cts_subjectid'] = array_unique($row['cts_subjectid']);
// 简介
if ($row[3] == '') {
$row[3] = NULL;
}
$ct_list[] = array('index' => $k + 2, 'ct_name' => $row[0], 'ct_memo' => $row[3], 'ctg_gradeid' => $row['ctg_gradeid'], 'cts_subjectid' => $row['cts_subjectid']);
}
if (isset($data['error'])) {
break;
}
unset($grade_map);
unset($subject_map);
unset($rows);
// 这里开始导入
$db = Fn::db();
try {
$time = time();
$adduid = Fn::sess()->userdata('admin_id');
if (!$db->beginTransaction()) {
throw new Exception('开始导入事务处理失败');
}
$ct_insert = 0;
// 导入教师
foreach ($ct_list as $k => $row) {
// insert
$db->insert('t_cteacher', array('ct_name' => $row['ct_name'], 'ct_memo' => $row['ct_memo'], 'ct_flag' => $param['ct_flag']));
$ct_id = $db->lastInsertId('t_cteacher', 'ct_id');
$bind = array('scht_schid' => $sch_id, 'scht_ctid' => $ct_id);
$db->insert('t_cteacher_school', $bind);
foreach ($row['ctg_gradeid'] as $v) {
$db->insert('t_cteacher_gradeid', array('ctg_ctid' => $ct_id, 'ctg_gradeid' => $v));
}
foreach ($row['cts_subjectid'] as $v) {
$db->insert('t_cteacher_subjectid', array('cts_ctid' => $ct_id, 'cts_subjectid' => $v));
}
$ct_insert++;
}
if ($db->commit()) {
$data['success'] = <<<EOT
导入Excel文件({$_FILES['file']['name']})成功,共插入{$ct_insert}条教师记录
EOT;
admin_log('add', 'cteacher', $data['success']);
} else {
$err = $db->errorInfo()[2];
$db->rollBack();
throw new Exception($err);
}
} catch (Exception $e) {
$data['error'] = $e->getMessage();
}
break;
}
if (!isset($_FILES['file'])) {
$param = array('ct_flag' => time());
}
$data['param'] = $param;
$this->load->view('school/importteacher', $data);
}
示例7: import_cors_excel
//.........这里部分代码省略.........
// 不存在
if ($param['non_exist_tcname_action'] == '0') {
$data['error'] = $col_char[10] . $row['index'] . ' - "上课校区"不存在';
break;
}
$cc_list[$k]['cc_tcid'] = 0;
}
}
}
if (isset($data['error'])) {
break;
}
/* 不需要验证一对一课程是否只能有一个校区了
foreach ($cors_arr as $key => $index)
{
if ($cors_list[$index]['cors_cmid'] == 1)
{
if (count($cc_arr[$key]) > 1)
{
$data['error'] = $col_char[10]
. $cc_list[$cc_arr[$key][1]]['index']
. ' - 该行为一对一课程,只能有一条课程校区';
break;
}
}
}
if (isset($data['error']))
{
break;
}
*/
try {
$time = time();
$adduid = Fn::sess()->userdata('admin_id');
if (!$db->beginTransaction()) {
throw new Exception('开始导入事务处理失败');
}
$cors_insert = 0;
$tc_insert = 0;
$cc_insert = 0;
$ct_insert = 0;
// 导入课程
foreach ($cors_list as $k => $row) {
// insert
$row2 = array();
$row2['cors_cmid'] = $row['cors_cmid'];
$row2['cors_name'] = $row['cors_name'];
$row2['cors_flag'] = $time;
$row2['cors_tiid'] = $row['cors_tiid'];
if ($row['cors_cmid'] == 1) {
$row2['cors_stunumtype'] = 1;
} else {
$row2['cors_stunumtype'] = 2;
}
$row2['cors_url'] = $row['cors_url'];
$row2['cors_memo'] = $row['cors_memo'];
$row2['cors_addtime'] = date('Y-m-d H:i:s', $time);
$row2['cors_adduid'] = $adduid;
$row2['cors_lastmodify'] = date('Y-m-d H:i:s', $time);
$db->insert('t_course', $row2);
$cors_list[$k]['cors_id'] = $cors_id = $db->lastInsertId('t_course', 'cors_id');
if (empty($row['cors_gradeid'])) {
$db->insert('t_course_gradeid', array('cg_corsid' => $cors_id, 'cg_gradeid' => 0));
} else {
foreach ($row['cors_gradeid'] as $v) {
$db->insert('t_course_gradeid', array('cg_corsid' => $cors_id, 'cg_gradeid' => $v));
示例8: check_subject_power
/**
* 检查当前用户是否有 查看/编辑某个学科的权限
*/
public static function check_subject_power($subject_id = 0, $power_type = 'w', $output = true)
{
$subject_id = intval($subject_id);
if (!$subject_id) {
return true;
}
//管理员 或者 有查看所有权限
$is_super_user = Fn::sess()->userdata('is_super');
if ($is_super_user || CpUserModel::is_action_type_all('question', $power_type)) {
return true;
}
//当前学科
$is_action = CpUserModel::is_action_type_subject('question', $power_type, $subject_id);
if ($output && !$is_action) {
message('您没权限!');
} else {
return $is_action;
}
}
示例9: insert
/**
* 插入信息
* @param array $rule_data
* @param array $knowledge_data
* @param array $method_tactic_data
* @param array $group_type_data
* @return boolean
*/
public static function insert($rule_data, $knowledge_data, $method_tactic_data = array(), $group_type_data = array())
{
$bOk = false;
$db = Fn::db();
if (!$db->beginTransaction()) {
return $bOk;
}
try {
$rule_data['admin_id'] = Fn::sess()->userdata('admin_id');
if ($db->insert('rd_evaluate_rule', $rule_data)) {
$inserted_id = $db->lastInsertId('rd_evaluate_rule', 'id');
//知识点
foreach ($knowledge_data as &$item) {
$item['er_id'] = $inserted_id;
$db->insert('rd_evaluate_knowledge', $item);
}
//方法策略
if (is_array($method_tactic_data) && count($method_tactic_data)) {
foreach ($method_tactic_data as &$item) {
$item['er_id'] = $inserted_id;
$db->insert('rd_evaluate_method_tactic', $item);
}
}
//信息提取方式
if (is_array($group_type_data) && count($group_type_data)) {
foreach ($group_type_data as &$item) {
$item['er_id'] = $inserted_id;
$db->insert('rd_evaluate_group_type', $item);
}
}
}
$bOk = $db->commit();
if (!$bOk) {
$db->rollBack();
}
} catch (Exception $e) {
}
return $bOk;
}
示例10: get_admins
public static function get_admins($act)
{
$admin_id = Fn::sess()->userdata('admin_id');
if ($act == 'add') {
$sql = <<<EOT
SELECT admin_id,admin_user FROM rd_admin
WHERE admin_id <> {$admin_id} AND is_delete = 0
EOT;
} else {
$sql = <<<EOT
SELECT admin_id, admin_user FROM rd_admin WHERE is_delete = 0
EOT;
}
$res = Fn::db()->fetchPairs($sql);
return $res;
}
示例11: studentLoginUInfo
public static function studentLoginUInfo()
{
$uinfo = Fn::sess()->userdata('uinfo');
if (empty($uinfo)) {
$uinfo = array('fullname' => '[游客]', 'uid' => '', 'avatar_url' => __IMG_ROOT_URL__ . 'zeming/exam/head.gif');
Fn::sess()->set_userdata(array('uid' => '', 'uinfo' => $uinfo));
}
return $uinfo;
}
示例12: addCourse
//.........这里部分代码省略.........
$param['cors_memo'] = NULL;
}
}
$classid_list = array();
if (isset($param['classid_list'])) {
if (!is_array($param['classid_list'])) {
throw new Exception('考试类型参数类型不正确');
}
$param['classid_list'] = array_values($param['classid_list']);
$param['classid_list'] = array_unique($param['classid_list']);
foreach ($param['classid_list'] as $v) {
if (!Validate::isInt($v)) {
throw new Exception('考试类型ID必须为整数');
}
}
$classid_list = $param['classid_list'];
unset($param['classid_list']);
}
$kid_knprocid_pairs = array();
if (isset($param['kid_knprocid_pairs'])) {
if (!is_array($param['kid_knprocid_pairs'])) {
throw new Exception('相关知识点参数类型不正确');
}
foreach ($param['kid_knprocid_pairs'] as $k => $v) {
if (!Validate::isInt($v) || !Validate::isInt($k)) {
throw new Exception('相关知识点ID或认知过程ID必须为整数');
}
}
$kid_knprocid_pairs = $param['kid_knprocid_pairs'];
unset($param['kid_knprocid_pairs']);
}
$gradeid_list = array();
if (isset($param['gradeid_list'])) {
if (!is_array($param['gradeid_list'])) {
throw new Exception('年级参数类型不正确');
}
$param['gradeid_list'] = array_values($param['gradeid_list']);
$param['gradeid_list'] = array_unique($param['gradeid_list']);
foreach ($param['gradeid_list'] as $v) {
if (!Validate::isInt($v)) {
throw new Exception('年级ID必须为整数');
}
}
$gradeid_list = $param['gradeid_list'];
unset($param['gradeid_list']);
}
if (empty($gradeid_list)) {
throw new Exception('年级ID必须填写');
}
if ($param['cors_stunumtype'] != 1 && count($gradeid_list) > 1) {
throw new Exception('年级ID只能填写一个');
}
$subjectid_list = array();
if (isset($param['subjectid_list'])) {
if (!is_array($param['subjectid_list'])) {
throw new Exception('学科参数类型不正确');
}
$param['subjectid_list'] = array_values($param['subjectid_list']);
$param['subjectid_list'] = array_unique($param['subjectid_list']);
foreach ($param['subjectid_list'] as $v) {
if (!Validate::isInt($v)) {
throw new Exception('学科ID必须为整数');
}
}
$subjectid_list = $param['subjectid_list'];
unset($param['subjectid_list']);
}
if (empty($subjectid_list)) {
throw new Exception('学科ID必须填写');
}
if ($param['cors_stunumtype'] != 1 && count($subjectid_list) > 1) {
throw new Exception('学科ID只能填写一个');
}
$db = Fn::db();
$param['cors_addtime'] = date('Y-m-d H:i:s');
$param['cors_adduid'] = Fn::sess()->userdata('admin_id');
$param['cors_lastmodify'] = $param['cors_addtime'];
$cors_id = 0;
if ($db->beginTransaction()) {
$db->insert('t_course', $param);
$cors_id = $db->lastInsertId('t_course', 'cors_id');
foreach ($classid_list as $v) {
$db->insert('t_course_classid', array('cci_corsid' => $cors_id, 'cci_classid' => $v));
}
foreach ($kid_knprocid_pairs as $k => $v) {
$db->insert('t_course_knowledge', array('ck_corsid' => $cors_id, 'ck_kid' => $k, 'ck_knprocid' => $v));
}
foreach ($gradeid_list as $v) {
$db->insert('t_course_gradeid', array('cg_corsid' => $cors_id, 'cg_gradeid' => $v));
}
foreach ($subjectid_list as $v) {
$db->insert('t_course_subjectid', array('cs_corsid' => $cors_id, 'cs_subjectid' => $v));
}
if (!$db->commit()) {
$db->rollBack();
$cors_id = 0;
}
}
return $cors_id;
}