Esempio n. 1
0
 public function socketServer($input)
 {
     //system_log($_SERVER);
     if ($input['key'] !== API_KEY) {
         return array('error' => 401);
     }
     $command = strtolower(trim($input['command']));
     $available_commands = array('start', 'stop');
     if (!in_array($command, $available_commands)) {
         return array('error' => 400);
     }
     $null = NULL;
     //null var
     switch ($command) {
         case 'start':
             //Create TCP/IP sream socket
             $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
             //reuseable port
             socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR, 1);
             //bind socket to specified host
             socket_bind($this->socket, 0, $this->port);
             //listen to port
             socket_listen($this->socket);
             $this->client = array($this->socket);
             $count = 0;
             $file = fopen($this->flag_file, 'w');
             fwrite($file, '');
             fclose($file);
             while (true) {
                 $count++;
                 sleep(1);
                 if (file_exists($this->flag_file) && file_get_contents($this->flag_file)) {
                     system_log('socket close');
                     die('Server Closed');
                 }
                 $changed = $this->client;
                 socket_select($changed, $null, $null, 0, 10);
                 if (in_array($this->socket, $changed)) {
                 }
             }
             // Infinite While Over
             socket_close($this->socket);
             return array('socketStatus' => 'running');
             break;
         case 'stop':
             $file = fopen($this->flag_file, 'w');
             fwrite($file, '1');
             sleep(2);
             fwrite($file, '');
             fclose($file);
             return array('socketStatus' => 'stoped');
             break;
     }
 }
Esempio n. 2
0
 public function editSubjectAction()
 {
     $mj_id = (int) I('post.id');
     $su_id = (int) I('post.subject');
     $sub_id = (int) I('post.sub');
     if (!$mj_id || !$su_id || !$sub_id) {
         $this->error('参数错误,请重试~');
     }
     $sql1 = 'update app_university_major set su_id = "' . $su_id . '", sub_id ="' . $sub_id . '" where id = "' . $mj_id . '";';
     $sql2 = 'update app_university_majorlang set su_id = "' . $su_id . '", sub_id ="' . $sub_id . '" where fid = "' . $mj_id . '";';
     $sql3 = 'update app_university_major_course set su_id = "' . $su_id . '", sub_id ="' . $sub_id . '" where mj_id = "' . $mj_id . '";';
     $sql4 = 'update app_university_major_courselang set su_id = "' . $su_id . '", sub_id ="' . $sub_id . '" where mj_id = "' . $mj_id . '";';
     $data = ['mj_id' => $mj_id, 'su_id' => $su_id, 'sub_id' => $sub_id];
     $mModel = M('university_major');
     $old_data = $mModel->field('id as mj_id, su_id, sub_id')->where(['id' => $mj_id])->find();
     $model = M();
     $model->startTrans();
     $res1 = $model->execute($sql1);
     $res2 = $model->execute($sql2);
     $res3 = $model->execute($sql3);
     $res4 = $model->execute($sql4);
     if ($res1 === false || $res2 === false || $res3 === false || $res4 === false) {
         $model->rollback();
         $this->error('修改失败,请重试');
     } else {
         $model->commit();
         $mark = session('adminUser') . '在 ' . date('Y-m-d H:i:s') . ', 修改了专业分类, 专业ID为:' . $mj_id;
         system_log($mark, $mModel->getTablename(), $mj_id, 'e', $data, $old_data, 0);
         $this->success('修改成功', U('AlyAdmin/Major/editSubject'));
     }
 }
Esempio n. 3
0
/**
 * System log listener.
 * This function listens to all events in the system and logs anything appropriate.
 *
 * @param String $event
 * @param String $object_type
 * @param mixed $object
 */
function system_log_listener($event, $object_type, $object)
{
    system_log($object, $event);
    return true;
}
Esempio n. 4
0
 public function active()
 {
     if ($_GET) {
         $data = self::getParam($_GET);
         $userModel = M('user');
         $is_active = $userModel->field('username,is_active')->where("id={$data['uid']}")->find();
         if ($is_active['is_active'] == '0') {
             $flag = $userModel->where("id={$data['uid']}")->save(array('is_active' => 2));
             if ($flag !== false) {
                 system_log(session('username') . "在" . date('Y-m-d H:i:s') . "激活了中介" . $is_active['username'], 'app_user', $data['uid'], 'e', array('is_active' => 0), array('is_active' => 2), 1);
                 echo json_encode(array('msg' => 'This sub-account has been activated', 'active' => 2));
             }
         } else {
             $flag = $userModel->where("id={$data['uid']}")->save(array('is_active' => 0));
             if ($flag !== false) {
                 system_log(session('username') . "在" . date('Y-m-d H:i:s') . "取消激活中介" . $is_active['username'], 'app_user', $data['uid'], 'e', array('is_active' => 2), array('is_active' => 0), 1);
                 echo json_encode(array('msg' => 'This sub-account has been deactivated', 'active' => 0));
             }
         }
     }
 }
Esempio n. 5
0
 public function delPic()
 {
     if ($_GET) {
         $id = $_GET['id'];
         $picModel = M('university_pic');
         $originData = $picModel->alias('a')->field('*')->where("id={$id}")->find();
         $picModel->startTrans();
         $flag = $picModel->where("id={$id}")->delete();
         $picInfoModel = M('university_piclang');
         $flag1 = $picInfoModel->where("fid={$id}")->delete();
         if ($flag !== false && $flag1 !== false) {
             $picModel->commit();
             system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "删除了学校图片信息", $picModel->getTableName(), $id, 'a', $_POST, $originData, 0);
             $this->success('删除成功');
         } else {
             $picModel->rollback();
             $this->success('删除失败');
         }
     }
 }
Esempio n. 6
0
 /**
  * 添加学生 第 4 步提交处理.
  * 
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function addStep4Action()
 {
     // 校验一级中介是否有权限添加学生
     if (!AgentAuth::checkTopAgentOfStu()) {
         $this->error('No permission');
     }
     // 当前操作, 参见第 1 步中说明.
     $operFlag = intval(I('post.oper', 1));
     $studentId = intval(I('post.currStudent', 0));
     // 学生 id
     if (empty($studentId)) {
         $this->error('Invalid parameters');
     }
     // 实例化模型
     $model = new MemberStuModel();
     $stuInfo = $model->fetchStuInfo($studentId);
     if (empty($stuInfo)) {
         $this->error('Invalid parameters');
     }
     // 对学生做权限验证
     $res = AgentAuth::checkStu($studentId, [AgentAuth::WRITE]);
     if (9 !== $res['status']) {
         $this->error('No permission');
     }
     // 验证成功规则能过, 验证是否有添加学生的权限
     // 校验一级中介是否有权限添加学生
     if (!AgentAuth::checkTopAgentOfStu($stuInfo['uid'])) {
         $this->error('No permission');
     }
     $post = I('post.');
     $files = $_FILES;
     // js 上传无效时, PHP做上传兼容处理, 仅在为空时才处理
     /*
     foreach($post as $k => & $v) {
         if(empty($v)) {
             $_f = isset($files[$k]) ? $files[$k] : [];
             if(empty($_f)) { // 没有上传文件
                 $v = '';
             } else {
                 $info = $this->procStuAttaUploadFile([$_f]);
                 if(0 === $info['status']) { // 上传失败
                     $v = '';
                 } else { // 上传成功
                     $v = $info['data']['src'];
                 }
             }
         }
     }
     unset($v);
     */
     // 设置并补齐默认数据
     if (empty($post['id'])) {
         $post['create_time'] = time();
     }
     $uid = $stuInfo['uid'];
     $ano = '';
     $post['uid'] = $uid;
     $post['fuid'] = $stuInfo['fuid'];
     $post['partid'] = $stuInfo['partid'];
     $post['s_id'] = $studentId;
     $post['a_no'] = $ano;
     // 执行验证
     // 若有上传学位证, 必须有毕业证附近
     $attDegreeCert = $post['degree_certificate'];
     if (!empty($attDegreeCert)) {
         $attDiploma = $post['diploma'];
         if (empty($attDiploma)) {
             $this->error('Please upload graduation certificate');
         }
     }
     // 必填项验证
     $res = $model->validate($model->uploadInfoRules)->create($post);
     if (!$res) {
         $this->error($model->getError());
     }
     // 验证通过
     $res = $model->procUploadInfo($post, $uid, $studentId, $ano);
     // 处理成功跳转到 lists 列表页面
     if ($res) {
         // 写入完整标志
         $res1 = $model->switchCompleteStatus($studentId, 1);
         if ($res1) {
             // 更新区域 id
             $model->updateStuArea($studentId);
             // 写入系统日志
             $_mark = session('username') . '在' . date('Y-m-d H:i:s') . ', 添加了一个学生, 学生姓名: ' . $stuInfo['first_name'] . $stuInfo['family_name'];
             if (1 === $operFlag) {
                 // 写入新增日志
                 system_log($_mark, $model->getTableName(), $studentId, 'a', $stuInfo, NULL, 1);
             }
             //$this->success('Successful!', U('noApplyStudentlist'));
             $this->success('Successful!', U('studentDetail', ['id' => $studentId]));
         } else {
             $this->error('Action failed');
         }
     } else {
         $this->error('Action failed');
     }
 }
Esempio n. 7
0
$port = 5352;
// create Socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
// Bind Socket
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n");
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
//while(true){
// Read Input form Client message
$input = socket_read($spawn, 2048) or die("Could not read input\n");
if ($input == "1") {
    $input = "Socket Closed";
    system_log($input);
    socket_close($spawn);
    socket_close($socket);
    return true;
}
$output = strrev($input) . "\n";
// Send Message to client
socket_write($spawn, $output, strlen($output)) or die("Could not write output\n");
system_log($input);
//}
var_dump($socket);
var_dump($result);
var_dump($spawn);
socket_close($spawn);
socket_close($socket);
?>
</body>
</html>
Esempio n. 8
0
 /**
  * @保存上传的文件地址
  * @Editer:段涛
  * @Function Name:saveUpfiles
  */
 public function saveUpfiles()
 {
     if (IS_AJAX) {
         $data = I('post.');
         $find = M('member_upload')->where(array('s_id' => $data['sid'], 'a_no' => ''))->getField('id');
         $result['status'] = false;
         //初始状态
         if ($find) {
             $success = M('member_upload')->where(array('id' => $find))->save($data);
             if ($success !== false) {
                 $result['status'] = true;
                 system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "修改学生个人基本上传文件,学生ID" . $data['sid'], 'member_upload', 's_id', 'e', $data, $find, 0);
             }
         } else {
             $result['error'] = "Can't find user information";
         }
         $result['status'] = true;
         $this->ajaxReturn($result, 'json');
     }
 }
Esempio n. 9
0
 public function startServices()
 {
     //echo 'Enter '.__FUNCTION__.'=========================== '.time().' <br>'.PHP_EOL;
     $this->socket = socket_create(AF_INET, SOCK_STREAM, 0) or $this->handle_error("Could not create socket");
     $result = socket_bind($this->socket, $this->host, $this->port) or $this->handle_error("Could not bind to socket");
     $count = 0;
     system_log('=================================================================');
     system_log('Start => ' . $this->phone . ' => ' . date('Y-m-d H:i:s'));
     while (true) {
         $input = false;
         $result = socket_listen($this->socket, 3) or $this->handle_error("Could not set up socket listener");
         $spawn = socket_accept($this->socket) or $this->handle_error("Could not accept incoming connection");
         $input = socket_read($spawn, 100000) or $this->handle_error("Could not read input");
         $response = array('status' => 201);
         if (!($input && !empty($input) && is_array(json_decode($input, true)))) {
         }
         $input = json_decode($input, true);
         system_log($input);
         $count++;
         if (!(isset($input['command']) && !empty($input['command']))) {
             $input['command'] = false;
         }
         $valid_flag = false;
         $command = trim(strtolower($input['command']));
         $log = $this->name . ' => ' . $this->port . ' => ' . $count . ' => ' . $input['command'];
         system_log($log);
         //echo $command.PHP_EOL;
         switch ($command) {
             case 'login':
                 $payload = $this->login();
                 $valid_flag = true;
                 break;
             case 'logout':
                 $payload = $this->logout();
                 if ($payload) {
                     $valid_flag = true;
                 }
                 break;
             case 'die':
                 $payload = $this->logout();
                 die('Die');
                 break;
             case 'type':
                 $payload = self::$whatsapp->sendMessageComposing($input['to']);
                 $valid_flag = true;
                 break;
             case 'pause':
                 $payload = self::$whatsapp->sendMessagePaused($input['to']);
                 $valid_flag = true;
                 break;
             case 'send':
                 $payload = $this->sendMessage($input['to'], $input['message'], $input['messagetype']);
                 $valid_flag = true;
                 break;
             case 'sync':
                 $contacts = $input['contacts'];
                 $contacts = array_unique($contacts);
                 $payload = $this->sendSync($contacts);
                 $valid_flag = true;
                 break;
             case 'poll':
                 while (self::$whatsapp->pollMessage()) {
                 }
                 $payload = true;
                 $valid_flag = true;
                 break;
             case 'ping':
             default:
                 $payload = self::$whatsapp->sendPing();
                 $valid_flag = true;
                 break;
         }
         if ($valid_flag) {
             $response['status'] = 200;
             $response['message'] = 'ok';
             $response['payload'] = isset($payload) ? $payload : true;
             system_log($response);
             //$response = isset($payload)?$payload:true;
             if (isset($payload)) {
                 if (!(is_array($payload) || is_object($payload))) {
                     $payload = mysql_real_escape_string($payload);
                 }
                 $response = $payload;
             } else {
                 $response = true;
             }
             $output = json_encode($response);
             socket_write($spawn, $output, strlen($output)) or $this->handle_error("Could not write output");
             if ($command == 'logout') {
                 sleep(1);
                 break;
             }
         }
         socket_close($spawn);
         $valid_flag = false;
     }
     // while close
     system_log('Stop => ' . $this->phone . ' => ' . date('Y-m-d H:i:s'));
     system_log('=================================================================');
     socket_close($this->socket);
     //echo 'OUT '.__FUNCTION__.'=========================== '.time().' <br>'.PHP_EOL;
     return true;
 }
Esempio n. 10
0
function test_log($log)
{
    system_log($log);
}
Esempio n. 11
0
 public function ajaxChgEmail()
 {
     $sid = I('get.sid');
     $email = I('get.email');
     $pwd = I('get.pwd');
     $res = '';
     if (empty($email) || empty($pwd)) {
         $res = false;
         $this->ajaxReturn($res, "json");
     }
     $model = M('member_stu');
     $data = ['ao_email' => $email, 'ao_email_pwd' => $pwd];
     $old_data = $model->where(['id' => $sid])->find();
     $result = $model->where(['id' => $sid])->save($data);
     if ($result !== false) {
         //写入日志系统
         $mark = session('adminUser') . '在 ' . date('Y-m-d H:i:s') . ',批量给学生id为' . $sid . '的学生,修改邮箱:' . $data['ao_email'] . ', 密码为:' . $data['ao_email_pwd'];
         system_log($mark, $model->getTableName(), $sid, 'e', $data, $old_data, 0);
         $res = true;
     } else {
         $res = false;
     }
     $this->ajaxReturn($res, "json");
 }
Esempio n. 12
0
function pleio_api_handle_push_queue()
{
    $site_guid = get_config("site_id");
    if ($site_guid == 1) {
        // pleio.nl only, handles all subsites
        $max_messages = 300;
        set_time_limit(59);
        elgg_set_ignore_access(1);
        $messages = elgg_get_entities(array('types' => 'object', 'subtypes' => 'push_message_queue', 'site_guid' => ELGG_ENTITIES_ANY_VALUE, 'order_by' => 'e.time_created asc', 'limit' => $max_messages));
        $apnsMessages = array();
        $gcmMessages = array();
        if ($messages) {
            foreach ($messages as $message) {
                if ($message->river_id) {
                    list($apnsMessages, $gcmMessages) = pleio_api_push_handle_river_id($message->river_id, $apnsMessages, $gcmMessages);
                } else {
                    list($apnsMessages, $gcmMessages) = pleio_api_push_handle_message_to($message, $apnsMessages, $gcmMessages);
                }
                system_log($message, 'handled apns:' . sizeof($apnsMessages) . ' gcm:' . sizeof($gcmMessages));
                $message->delete();
            }
        }
        if (sizeof($apnsMessages)) {
            pleio_api_push_apns_messages($apnsMessages);
        }
        if (sizeof($gcmMessages)) {
            pleio_api_push_gcm_messages($gcmMessages);
        }
        elgg_set_ignore_access(0);
        return sizeof($apnsMessages) + sizeof($gcmMessages);
    }
}
Esempio n. 13
0
 *	Company Url : 
 *	Description: index file of application
 *
 *
 *
 *
 *
 */
require_once 'config/config.php';
require_once 'config/route.php';
// Create Upload Directory if Not Exist
if (!is_dir(UPLOAD_DIR)) {
    mkdir(UPLOAD_DIR, 0777);
}
if (php_sapi_name() == 'cli') {
    system_log('cli execute');
    $ControllerFile = DIR_CONTROLLER . DS . 'socket.php';
    require_once $ControllerFile;
    $Controller = new Socket();
    $input = array();
    $input['key'] = 'app_secreat_key';
    $input['command'] = $argv[1];
    $response = $Controller->socketServer($input);
    die(json_encode($response));
}
$GET = array();
$GET[0] = $Url->getUrlSegment(0);
//$GET = explode('/',$GET);
$isApiRequest = isset($GET[0]) && strtolower($GET[0]) == 'api' ? true : false;
//$isAdmin = isset($GET[0])&&strtolower($GET[0])=='admin'?true:false;
if ($isApiRequest) {
Esempio n. 14
0
 /**
  * 添加学院提交处理
  *
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function addCollegeAction()
 {
     // 主表 university_college 数据
     $us_id = intval(I('post.us_id'));
     $data = array();
     $data['us_id'] = $us_id;
     $data['post_code'] = I('post.post_code');
     $data['link'] = I('post.link');
     $data['is_del'] = 0;
     // 返回给客户端的结果, 1: 成功, 0: 失败, 仅限 ajax
     $result = 1;
     $model = M('UniversityCollege');
     // 开启事务
     $model->startTrans();
     if (FALSE !== $model->add($data)) {
         $lastId = $model->getLastInsID();
         // 从表 university_collegelang 数据
         $detailData = array();
         $postMultiLang = I('post.multi');
         // 组装从表数据
         foreach ($postMultiLang as $lang => $postRow) {
             $row['fid'] = $lastId;
             $row['us_id'] = $us_id;
             $row['lang'] = $lang;
             $row['col_name'] = $postRow['col_name'];
             $row['addr'] = $postRow['addr'];
             $row['introduction'] = $postRow['introduction'];
             $row['is_del'] = 0;
             $detailData[] = $row;
         }
         // 写入从表成功, 提交事务
         $detailModel = M('UniversityCollegelang');
         if (FALSE !== $detailModel->addAll($detailData)) {
             $model->commit();
             // 写入系统日志
             $_mark = session('adminUser') . '在' . date('Y-m-d H:i:s') . ', 添加了学院 : 学校 id : ' . $us_id;
             system_log($_mark, $model->getTableName(), $lastId, 'a', $detailData, NULL, 0);
         } else {
             $model->rollback();
             $result = 0;
         }
     } else {
         $model->rollback();
         $result = 0;
     }
     if (IS_AJAX) {
         $this->ajaxReturn(array('status' => $result));
     } elseif ($result) {
         $this->success("添加学院成功", U('index'));
     } else {
         $this->error('添加学院失败');
     }
 }
Esempio n. 15
0
 if (file_exists($flag_file) && file_get_contents($flag_file)) {
     die('Server Closed');
 }
 $changed = $clients;
 //print_r(PHP_EOL);
 socket_select($changed, $null, $null, 0, 10);
 //print_r(PHP_EOL);
 //print_r($changed);
 if (in_array($socket, $changed)) {
     $socket_new = socket_accept($socket);
     // accpet new socket
     $clients[] = $socket_new;
     // add socket to client array
     $header = socket_read($socket_new, 2048);
     //read data sent by the socket
     system_log($header);
     perform_handshaking($header, $socket_new, $host, $port);
     //perform websocket handshake
     socket_getpeername($socket_new, $ip);
     //get ip address of connected socket
     $response = array('type' => 'system', 'message' => $ip . ' connected');
     $response = mask(json_encode($response));
     //prepare json data
     //print_r($socket_new); // new connection of client
     send_message($response);
     //notify all users about new connection
     //make room for new socket
     $found_socket = array_search($socket, $changed);
     //print_r(PHP_EOL);
     //print_r($found_socket);
     unset($changed[$found_socket]);
Esempio n. 16
0
 public function saveCAS()
 {
     if ($_POST) {
         $data = self::getParam($_POST);
         $casModel = M('apply_cas');
         $casModel->startTrans();
         $fileAddr = $casModel->where("a_no='{$data['a_no']}'")->getField('cas_file');
         $flag = -1;
         if (empty($fileAddr)) {
             echo '<script>alert("您还未上传CAS");</script>';
             exit;
         } else {
             //                if($data['is_valid']=='on'){
             //                    $data['is_valid']=0;
             //                    $invalid=1;
             //                }else{
             //                    $data['is_valid']=1;
             //                    $invalid=0;
             //                }
             $flag = $casModel->where("a_no='{$data['a_no']}'")->save($data);
             //                $statusModel=M('apply_status');
             //                $flag1=$statusModel->where("a_no='{$data['a_no']}'")->setField('invalid',$invalid);
         }
         if ($flag !== false) {
             $casModel->commit();
             system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "更新了CAS" . $data['cas_expire'], $casModel->getTableName(), $data['a_no'], 'e', $data, $fileAddr, 0);
             self::log(array('uid' => $data['uid'], 'aid' => $data['a_no'], 'type' => 1, 'txt' => date('Y-m-d H:i:s') . "," . session('adminUser') . ",(更新)了CAS[{$data['casFileName']}]", 'admin_id' => session('adminID') == null ? 0 : session('adminID'), 'c_time' => strtotime(date('Y-m-d'))));
             echo '<script>window.parent.casSuccess();alert("保存成功");</script>';
         } else {
             $casModel->rollback();
             echo '<script>alert("保存失败");</script>';
         }
     }
 }
Esempio n. 17
0
$port = '9000';
//port
$null = NULL;
//null var
//Create TCP/IP sream socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
//reuseable port
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
//bind socket to specified host
socket_bind($socket, 0, $port);
//listen to port
socket_listen($socket);
//create & add listning socket to the list
$clients = array($socket);
//echo '<pre>'; print_r($_SERVER); echo '</pre>';
system_log($_SERVER);
//start endless loop, so that our script doesn't stop
while (true) {
    if (file_exists('flag.txt') && file_get_contents('flag.txt')) {
        die('Server Closed');
    }
    //manage multipal connections
    $changed = $clients;
    //returns the socket resources in $changed array
    socket_select($changed, $null, $null, 0, 10);
    //check for new socket
    if (in_array($socket, $changed)) {
        $socket_new = socket_accept($socket);
        // accpet new socket
        $clients[] = $socket_new;
        // add socket to client array
Esempio n. 18
0
 /**
  * @保存上传的文件地址
  * @Editer:段涛
  * @Function Name:saveUpfiles
  */
 public function saveUpfiles()
 {
     if (IS_AJAX) {
         $data = I('post.');
         $find = M('member_upload')->where(array('a_no' => $data['a_no']))->find();
         $result['status'] = false;
         //初始状态
         if ($find) {
             $success = M('member_upload')->where(array('id' => $find['id']))->save($data);
             if ($success !== false) {
                 $result['status'] = true;
                 system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "修改学生个人申请信息上传资料,申请编号" . I('post.a_no'), 'app_member_upload', 'a_no', 'e', $data, $find, 0);
             }
         } else {
             $result['error'] = "Can't find user information";
         }
         $result['status'] = true;
         $this->ajaxReturn($result, 'json');
     }
 }
Esempio n. 19
0
 public function editSystemUser()
 {
     if ($_POST) {
         $data = self::getParam($_POST);
         if (empty($data['gid'])) {
             exit;
         }
         $userModel = M('user');
         $has = $userModel->where("(username='******'username']}' or email='{$data['email']}')and id<>{$data['id']}")->count();
         //            var_dump($userModel->getLastSql());exit;
         if ($has > 0) {
             echo json_encode(array('success' => -1));
             exit;
         }
         if ($data['passwd']) {
             $salt = self::getRandSalt();
             $data['salt'] = $salt;
             $data['passwd'] = md5($data['passwd'] . $salt);
         }
         //            $data['telephone'] = $data['telephone'];
         $data['region'] = $data['interNum'];
         $originData = $userModel->alias('a')->field('*')->where("id={$data['id']}")->find();
         $flag = $userModel->where("id={$data['id']}")->save($data);
         if ($flag !== false) {
             system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "修改了系统用户" . $data['username'], 'app_user', $data['id'], 'e', $data, $originData, 0);
             echo json_encode(array('success' => 1));
         } else {
             echo json_encode(array('success' => 0));
         }
     }
 }
Esempio n. 20
0
 public function addSys()
 {
     if ($_POST) {
         $data = $_POST['sys'];
         $userModel = M('user');
         $has = $userModel->where("username='******'username']}' or email='{$data['email']}'")->count();
         //var_dump($userModel->getLastSql());exit;
         if ($has > 0) {
             echo json_encode(array('success' => -1));
             exit;
         }
         if (empty($_POST['sys']['gid'])) {
             exit;
         }
         $salt = self::getRandSalt();
         $data['salt'] = $salt;
         $data['passwd'] = md5($data['passwd'] . $salt);
         $data['regdate'] = strtotime(date('Y-m-d H:i:s'));
         $data['regip'] = get_client_ip();
         //            $data['telephone']=$data['interNum'].$data['telephone'];
         $data['region'] = $data['interNum'];
         $data['user_type'] = 9;
         $data['is_active'] = 2;
         $flag = $userModel->add($data);
         if ($flag) {
             system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "新增了系统用户" . $data['username'], 'app_user', $userModel->getLastInsID(), 'a', $data, null, 0);
             echo json_encode(array('success' => 1));
             exit;
         } else {
             echo json_encode(array('success' => 0));
             exit;
         }
     }
 }
Esempio n. 21
0
/**
 * Create a new annotation.
 *
 * @param int $entity_guid
 * @param string $name
 * @param string $value
 * @param string $value_type
 * @param int $owner_guid
 * @param int $access_id
 */
function create_annotation($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE)
{
    global $CONFIG;
    $result = false;
    $entity_guid = (int) $entity_guid;
    //$name = sanitise_string(trim($name));
    //$value = sanitise_string(trim($value));
    $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
    $owner_guid = (int) $owner_guid;
    if ($owner_guid == 0) {
        $owner_guid = get_loggedin_userid();
    }
    $access_id = (int) $access_id;
    $time = time();
    // Add the metastring
    $value = add_metastring($value);
    if (!$value) {
        return false;
    }
    $name = add_metastring($name);
    if (!$name) {
        return false;
    }
    $entity = get_entity($entity_guid);
    if (trigger_elgg_event('annotate', $entity->type, $entity)) {
        system_log($entity, 'annotate');
        // If ok then add it
        $result = insert_data("INSERT into {$CONFIG->dbprefix}annotations (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ({$entity_guid},'{$name}',{$value},'{$value_type}', {$owner_guid}, {$time}, {$access_id})");
        if ($result !== false) {
            $obj = get_annotation($result);
            if (trigger_elgg_event('create', 'annotation', $obj)) {
                return true;
            } else {
                delete_annotation($result);
            }
        }
    }
    return $result;
}
Esempio n. 22
0
 /**
  * 编辑职位操作
  * @return POST;
  * @author liuxiaolin <*****@*****.**>
  */
 public function editAction()
 {
     $data = I('post.');
     if (empty($data['role_name'])) {
         $this->error('请输入职位名!');
     }
     if ($data['is_ao'] == 1) {
         if ($data['area_id'] == 0) {
             $this->error('请选择负责区域!');
         }
         //预制Ao的基本权限--根据产品设定
         $data['rule'][] = 10;
         $data['rule'][] = 8;
     } else {
         $data['is_ao'] = 0;
         $data['area_id'] = 0;
         $data['is_glob'] = 0;
     }
     $rules = array_unique($data['rule']);
     //如是不是Ao,则不能拥有“重新委派AO(本区)”的权限
     if ($data['is_ao'] != 1) {
         $key = array_search('7', $rules);
         if ($key !== false) {
             unset($rules[$key]);
         }
     }
     $rule = '';
     $rule .= implode(',', $rules);
     $data['group_name'] = $data['role_name'];
     unset($data['role_name']);
     unset($data['rule']);
     $data['rules'] = $rule;
     //存入数据库
     $model = M('user_group');
     $old_data = $model->where(['id' => $data['id']])->find();
     $res = $model->data($data)->save();
     if ($res) {
         $mark = session('adminUser') . '在:' . date('Y-m-d H:i:s') . ', 编辑了一个职位:' . $data['group_name'];
         system_log($mark, $model->getTableName(), $res, 'e', $data, $old_data);
         $this->success('编辑职位成功');
     } else {
         $this->error('编辑失败,请重试!');
     }
 }
Esempio n. 23
0
/**
 * Default system log handler, allows plugins to override, extend or disable logging.
 *
 * @param string   $event       Event name
 * @param string   $object_type Object type
 * @param Loggable $object      Object to log
 *
 * @return true
 */
function system_log_default_logger($event, $object_type, $object)
{
    system_log($object['object'], $object['event']);
    return true;
}
Esempio n. 24
0
 public function editAction()
 {
     if ($_POST) {
         $data = self::getParam($_POST);
         $userModel = M('user');
         if ($data['id']) {
             $has = $userModel->field('username')->where("(username='******'username']}' or email='{$data['email']}') and id<>{$data['id']}")->count();
             if ($has > 0) {
                 $this->success('操作失败,用户名或邮箱已存在!');
                 exit;
             }
             if ($data['passwd']) {
                 $salt = self::getRandSalt();
                 $data['salt'] = $salt;
                 $data['passwd'] = md5($data['passwd'] . $salt);
             } else {
                 unset($data['passwd']);
             }
             $originData = $userModel->field('*')->where("id={$data['id']}")->find();
             $flag = $userModel->where("id={$data['id']}")->save($data);
             if ($flag !== false) {
                 system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "修改了DIY用户{$data['username']}", $userModel->getTableName(), $data['a_no'], 'e', $data, $originData, 0);
                 $this->success('操作成功!');
                 exit;
             } else {
                 $this->success('操作失败!');
                 exit;
             }
         } else {
             $has = $userModel->field('username')->where("username='******'username']}' or email='{$data['email']}'")->count();
             if ($has > 0) {
                 $this->success('操作失败,用户名或邮箱已存在!');
                 exit;
             }
             $salt = self::getRandSalt();
             $data['salt'] = $salt;
             $data['passwd'] = md5($data['passwd'] . $salt);
             $data['regdate'] = strtotime(date('Y-m-d H:i:s'));
             $data['regip'] = get_client_ip();
             $flag = $userModel->add($data);
             if ($flag) {
                 $this->success('操作成功!');
                 exit;
             } else {
                 $this->success('操作失败!');
                 exit;
             }
         }
     }
 }