/**
  * 登陆,如果失败,返回失败原因(用户名或者密码不正确),如果成功,返回用户信息,
  * 附带返回系统服务器时间戳
  */
 public function login()
 {
     //查user表
     $User = M('User');
     check_error($User);
     $user = $User->field(array('id' => 'userId', 'username' => 'userName', 'name', 'role_id' => 'roleId', 'role'))->where(array('username' => safe_post_param('username'), '_string' => "`password`=MD5('" . safe_post_param('password') . "')"))->find();
     if (!empty($user)) {
         //根据权限查菜单
         $Menu = M('Menu');
         check_error($Menu);
         $menu = $Menu->join('`role_privilege` on `menu`.`id`=`role_privilege`.`menu_id`')->join('`user` on `user`.`role_id`=`role_privilege`.`role_id`')->field(array('`menu`.`id`', 'level', 'label', 'icon', 'widget', 'show', 'big_icon'))->where("`user`.`id`='" . $user['userId'] . "'")->order('`level` ASC')->select();
         check_error($Menu);
         //保存session
         session('logined', true);
         session('user', $user);
         session('menu', $menu);
         //设置返回数据
         $data = array();
         $data['serverTime'] = time();
         $data['user'] = $user;
         $data['menu'] = $menu;
         //保存日志
         R('Log/adduserlog', array('登录', '登录成功', '成功'));
         //返回结果:用户数据+服务器时间
         return_value_json(true, 'data', $data);
     } else {
         //保存日志
         R('Log/adduserlog', array('登录', '登录失败:用户名或者密码不正确', '失败:权限不够', '用户名:' . safe_post_param('username')));
         return_value_json(false, 'msg', '用户名或者密码不正确');
     }
 }
Esempio n. 2
0
function dao_open()
{
    global $db, $all_ops_stmt, $operation_stmt, $operation_id_stmt, $code_ref_stmt, $io_stmt, $object_stmt, $io_for_object_stmt, $io_for_parent_io_stmt, $operation_by_name_stmt, $io_for_object_parent_name_stmt;
    $db = new PDO("sqlite:test.sq3");
    # Get all ops
    $all_ops_stmt = $db->prepare("SELECT operation_id as id, name, parent_id, code_start_id, code_end_id, terminated_time FROM operation ORDER BY operation_id");
    # Get operation for a given id
    $operation_stmt = $db->prepare("SELECT operation_id as id, name, parent_id, code_start_id, code_end_id, terminated_time FROM operation WHERE operation_id = :id");
    # Operation id for parent operation
    $operation_id_stmt = $db->prepare('SELECT operation_id as id FROM operation WHERE parent_id = :id');
    # get a reference to code by reference id
    $code_ref_stmt = $db->prepare("SELECT code_id as id, file, line FROM code WHERE code_id = :id");
    # Get list of IOs for given operation (only the top-level ones)
    $io_stmt = $db->prepare('SELECT io_id as id, io_time, object_id, operation_id, name, value, readwrite, note, code_id FROM io WHERE operation_id = :id AND parent_id = -1 ORDER BY io_time ASC');
    # Get object of given id
    $object_stmt = $db->prepare('SELECT object_id as id, type, deallocated_time FROM object where object_id = :id');
    # All parent IOs for object
    $io_for_object_stmt = $db->prepare('SELECT io_id as id, io_time, object_id, operation_id, name, value, readwrite, note, code_id FROM io where object_id = :id ORDER BY io_time ASC');
    # All IOs for parent io
    $io_for_parent_io_stmt = $db->prepare('SELECT io_id as id, io_time, object_id, operation_id, name, value, readwrite, note, code_id, parent_id FROM io WHERE parent_id = :id ORDER BY io_id ASC');
    # Operation of a given name for parent operation
    $operation_by_name_stmt = $db->prepare('SELECT operation_id as id, name, parent_id, code_start_id, code_end_id, terminated_time FROM operation WHERE name = :name AND parent_id = :parent ORDER BY operation_id');
    # All IOs for given object, parent IO and name
    $io_for_object_parent_name_stmt = $db->prepare('SELECT io_id as id, io_time, object_id, operation_id, name, value, readwrite, note, code_id FROM io where operation_id = :operation_id AND parent_id = :parent_io AND name = :name AND note=:note ORDER BY io_time ASC');
    check_error();
}
 /**
  * add操作根据POST数据插入一个分组信息到数据库里,并返回操作结果
  */
 public function add()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $Department = M('Department');
     //数据检查
     $name = trim($this->_post('name'));
     if (empty($name)) {
         return_value_json(false, 'msg', '分组名称为空');
     }
     $seq = $this->_post('sequence') + 0;
     if (empty($seq)) {
         return_value_json(false, 'msg', '系统出错:提交的序号为0或者为空');
     }
     //先更新次序在插入者之后的分组的次序
     $condition['sequence'] = array('egt', $seq);
     $Department->where($condition)->setInc('sequence', 1);
     check_error($Department);
     //插入
     $Department->create();
     check_error($Department);
     $Department->id = null;
     if (false === $Department->add()) {
         //保存日志
         R('Log/adduserlog', array('添加分组', '添加分组失败:' . get_error($Department), '失败:系统错误', '分组名称:' . $name));
         return_value_json(false, 'msg', get_error($Department));
     } else {
         //保存日志
         R('Log/adduserlog', array('添加分组', '添加分组成功', '成功', '分组名称:' . $name));
         return_value_json(true);
     }
 }
Esempio n. 4
0
 public function getmanage()
 {
     $type = $_REQUEST['type'];
     $departmentId = $_REQUEST['departmentId'] + 0;
     if (!in_array($type, array('车辆', '人员', '集装箱', '班列', '设备'))) {
         return_json(true, null, 'targets', array());
     }
     $condition = '1';
     $condition .= empty($departmentId) ? '' : " AND `department_id`='{$departmentId}'";
     $DB = M();
     check_error($DB);
     if ($type == '车辆') {
         $targets = $DB->query("SELECT `id` AS `target_id`, '车辆' AS `target_type`, `number` AS `target_name`, " . "CONCAT('车辆^', `id`, '^', `number`) AS `type_id_name` FROM `vehicle` WHERE " . $condition . " ORDER BY `sequence` ASC");
     } else {
         if ($type == '人员') {
             $targets = $DB->query("SELECT `id` AS `target_id`, '人员' AS `target_type`, `name` AS `target_name`, " . "CONCAT('人员^', `id`, '^', `name`) AS `type_id_name` FROM `employee` WHERE " . $condition . " ORDER BY `sequence` ASC");
         } else {
             if ($type == '集装箱') {
                 $targets = $DB->query("SELECT `id` AS `target_id`, '集装箱' AS `target_type`, `number` AS `target_name`, " . "CONCAT('集装箱^', `id`, '^', `number`) AS `type_id_name` FROM `container` WHERE " . $condition . " ORDER BY `id` ASC");
             } else {
                 if ($type == '班列') {
                     $targets = $DB->query("SELECT `id` AS `target_id`, '班列' AS `target_type`, `number` AS `target_name`, " . "CONCAT('班列^', `id`, '^', `number`) AS `type_id_name` FROM `train` WHERE " . $condition . " ORDER BY `id` ASC");
                 } else {
                     if ($type == '设备') {
                         $targets = $DB->query("SELECT `id` AS `target_id`, '设备' AS `target_type`, `label` AS `target_name`, " . "CONCAT('设备^', `id`, '^', `label`) AS `type_id_name` FROM `device` WHERE " . $condition . " ORDER BY `id` ASC");
                     }
                 }
             }
         }
     }
     check_error($DB);
     //		Log::write("\n".M()->getLastSql(), Log::SQL);
     return_json(true, null, 'targets', $targets);
 }
Esempio n. 5
0
 public function log($data)
 {
     $Sms = M('Sms');
     check_error($Sms);
     $Sms->create($data);
     check_error($Sms);
     if (false === $Sms->add()) {
         return_value_json(false, 'msg', get_error($Sms));
     }
 }
Esempio n. 6
0
function get_kartukeluarga_id($nik)
{
    $sql = "select keluarga_id from penduduk where nik = '{$nik}'";
    $connection = MysqlManager::get_connection();
    $result = $connection->query($sql);
    check_error($connection);
    $row = $result->fetch_object();
    MysqlManager::close_connection($connection);
    return $row->keluarga_id;
}
Esempio n. 7
0
function generate_key_pair()
{
    $key_length = '64';
    $key_pair = new Crypt_RSA_KeyPair($key_length);
    check_error($key_pair);
    $public_key = $key_pair->getPublicKey();
    $private_key = $key_pair->getPrivateKey();
    $keys = array('public' => $public_key->toString(), 'private' => $private_key->toString());
    return $keys;
}
 public function check_orangtua($nik_ayah, $nik_ibu)
 {
     $connection = MysqlManager::get_connection();
     $id_ayah = $this->get_penduduk_id($nik_ayah);
     $id_ibu = $this->get_penduduk_id($nik_ibu);
     $sql = "select count(*) as count from orang_tua where bapak_id = {$id_ayah} and ibu_id = {$id_ibu}";
     $result = $connection->query($sql);
     check_error($connection);
     $row = $result->fetch_object();
     MysqlManager::close_connection($connection);
     return $row->count;
 }
Esempio n. 9
0
 /**
  * cell操作返回指定边界之内的基站
  */
 public function cell()
 {
     $nlat = $_GET['nelat'] + 0;
     $elng = $_GET['nelng'] + 0;
     $slat = $_GET['swlat'] + 0;
     $wlng = $_GET['swlng'] + 0;
     if (empty($nlat) || empty($elng) || empty($slat) || empty($wlng)) {
         return_value_json(false, msg, '边界坐标经度或(和)纬度为空');
     }
     $Cell = M('Cell');
     check_error($Cell);
     $cells = $Cell->field(array('id', 'mcc', 'mnc', 'lac', 'cellid', 'gps_lng', 'gps_lat', 'range', 'offset_lng', 'offset_lat', 'address', 'update_time'))->where("`gps_lng`<{$elng} AND `gps_lng`>{$wlng} AND `gps_lat`<{$nlat} AND `gps_lat`>{$slat}")->limit('250')->select();
     check_error($Cell);
     //		Log::write("\n".M()->getLastSql(), Log::SQL);
     return_json(true, null, 'cells', $cells);
 }
Esempio n. 10
0
function decrypt($encriptedMessage, $privateKey)
{
    ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . S3DB_SERVER_ROOT);
    require_once 'pearlib/RSACrypt/RSA.php';
    $enc_text = $encriptedMessage;
    $private_key = $privateKey;
    $key = Crypt_RSA_Key::fromString($private_key);
    check_error($key);
    $rsa_obj = new Crypt_RSA();
    check_error($rsa_obj);
    $rsa_obj->setParams(array('dec_key' => $key));
    check_error($rsa_obj);
    $plain_text = $rsa_obj->decrypt($enc_text);
    check_error($rsa_obj);
    return $plain_text;
}
Esempio n. 11
0
function pdo_mysql_errorinfo($db, $offset)
{
    try {
        /*
        If you create a PDOStatement object through PDO->prepare()
        or PDO->query() and invoke an error on the statement handle,
        PDO->errorCode() will not reflect that error. You must call
        PDOStatement->errorCode() to return the error code for an
        operation performed on a particular statement handle.
        */
        $code = $db->errorCode();
        check_error($offset + 2, $db);
        $stmt = $db->query('SELECT id, label FROM test');
        $stmt2 =& $stmt;
        check_error($offset + 3, $db);
        check_error($offset + 4, $stmt);
        $db->exec('DROP TABLE IF EXISTS test');
        @$stmt->execute();
        check_error($offset + 5, $db);
        check_error($offset + 6, $stmt, '42S02');
        check_error($offset + 7, $stmt2, '42S02');
        @($stmt = $db->query('SELECT id, label FROM unknown'));
        check_error($offset + 8, $db, '42S02');
        MySQLPDOTest::createTestTable($db);
        $stmt = $db->query('SELECT id, label FROM test');
        check_error($offset + 9, $db);
        check_error($offset + 10, $stmt);
        $db2 =& $db;
        $db->exec('DROP TABLE IF EXISTS unknown');
        @$db->query('SELECT id, label FROM unknown');
        check_error($offset + 11, $db, '42S02');
        check_error($offset + 12, $db2, '42S02');
        check_error($offset + 13, $stmt);
        check_error($offset + 14, $stmt2);
        // lets hope this is an invalid attribute code
        $invalid_attr = -1 * PHP_INT_MAX + 3;
        $tmp = @$db->getAttribute($invalid_attr);
        check_error($offset + 15, $db, 'IM001');
        check_error($offset + 16, $db2, 'IM001');
        check_error($offset + 17, $stmt);
        check_error($offset + 18, $stmt2);
    } catch (PDOException $e) {
        printf("[%03d] %s [%s] %s\n", $offset + 19, $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
    }
}
Esempio n. 12
0
 public function retrieve_data()
 {
     $conn = MysqlManager::get_connection();
     $sql = "select n.no_pernikahan as nomor_pernikahan, n.tanggal as tanggal,\n        n.wali as wali, p.nama as pria, p.wni as wni_pria, a.agama as agama_pria,\n        pp.nama as wanita, pp.wni as wni_wanita, aa.agama as agama_wanita from pernikahan n,\n        penduduk p, penduduk pp, agama a, agama aa where n.id = {$this->id} and\n        n.pria = p.id and n.wanita = pp.id and p.agama_id = a.id and pp.agama_id = aa.id";
     $result = $conn->query($sql);
     check_error($conn);
     $row = $result->fetch_object();
     $this->pria = $row->pria;
     $this->no_pernikahan = $row->nomor_pernikahan;
     $this->tanggal_menikah = $row->tanggal;
     $this->wali = $row->wali;
     $this->pria_agama = $row->agama_pria;
     $this->pria_wni = $row->wni_pria;
     $this->wanita = $row->wanita;
     $this->wanita_agama = $row->agama_wanita;
     $this->wanita_wni = $row->wni_wanita;
     MysqlManager::close_connection($conn);
 }
Esempio n. 13
0
 public function retrieve_data()
 {
     $conn = MysqlManager::get_connection();
     $sql = "select p.nik as nik, p.nama as nama, p.tmp_lahir as tempat_lahir, p.tgl_lahir as tgl_lahir, \r\n        p.jenis_kelamin as jenis_kelamin, p.wni as wni, \r\n        a.no_akta as no_akta, a.created_at as tanggal_pembuatan, pp.nama as ayah, ppp.nama as ibu \r\n        from penduduk p, penduduk pp, penduduk ppp, akta_kelahiran a, orang_tua o where p.id = " . $this->id . " and p.id = a.penduduk_id and p.orangtua_id = o.id and o.bapak_id = pp.id and o.ibu_id = ppp.id";
     $result = $conn->query($sql);
     check_error($conn);
     $row = $result->fetch_object();
     $this->nik = $row->nik;
     $this->nama = $row->nama;
     $this->tempat_lahir = $row->tempat_lahir;
     $this->tanggal_lahir = $row->tgl_lahir;
     $this->jenis_kelamin = $row->jenis_kelamin;
     $this->wni = $row->wni;
     $this->no_akta = $row->no_akta;
     $this->tanggal_pembuatan = $row->tanggal_pembuatan;
     $this->ayah = $row->ayah;
     $this->ibu = $row->ibu;
     MysqlManager::close_connection($conn);
 }
Esempio n. 14
0
function generate_key_pair()
{
    set_include_path(get_include_path() . PATH_SEPARATOR . S3DB_SERVER_ROOT . '/pearlib/phpseclib');
    if (is_file(S3DB_SERVER_ROOT . '/pearlib/phpseclib/Crypt/RSA.php')) {
        include S3DB_SERVER_ROOT . '/pearlib/phpseclib/Crypt/RSA.php';
        define('CRYPT_RSA_SMALLEST_PRIME', 1000);
        $rsa = new Crypt_RSA();
        $createKey = $rsa->createKey(10 * 64);
        $keys = array('public' => base64_encode($createKey['publickey']), 'private' => $createKey['privatekey']);
    } else {
        require_once S3DB_SERVER_ROOT . '/pearlib/RSACrypt/RSA.php';
        $key_length = '64';
        $key_pair = new Crypt_RSA_KeyPair($key_length);
        check_error($key_pair);
        $public_key = $key_pair->getPublicKey();
        $private_key = $key_pair->getPrivateKey();
        $keys = array('public' => $public_key->toString(), 'private' => $private_key->toString());
    }
    return $keys;
}
Esempio n. 15
0
 /**
  * add操作根据POST数据插入一个分组信息到数据库里,并返回操作结果
  */
 public function add()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $Driver = M('Driver');
     //数据检查
     $name = trim($this->_post('name'));
     if (empty($name)) {
         return_value_json(false, 'msg', '司机姓名为空');
     }
     $dpm_id = $this->_post('department_id') + 0;
     //先更新次序在插入者之后的同一分组的司机的次序
     $seq = $this->_post('sequence') + 0;
     if (!empty($seq)) {
         $condition['department_id'] = array('eq', $dpm_id);
         $condition['sequence'] = array('egt', $seq);
         $Driver->where($condition)->setInc('sequence', 1);
         check_error($Driver);
     } else {
         $condition['department_id'] = array('eq', $dpm_id);
         $seqs = $Driver->where($condition)->order('`sequence` DESC')->limit('1')->field('sequence')->select();
         $seq = empty($seqs) ? 1 : $seqs[0]['sequence'] + 1;
     }
     //插入
     $Driver->create();
     check_error($Driver);
     $Driver->sequence = $seq;
     $Driver->id = null;
     if (false === $Driver->add()) {
         //保存日志
         R('Log/adduserlog', array('添加司机资料', '添加司机资料:' . get_error($Driver), '失败:系统错误', '司机名称:' . $Driver->name . ',失败原因:' . get_error($Driver)));
         return_value_json(false, 'msg', get_error($Driver));
     }
     //保存日志
     R('Log/adduserlog', array('添加司机资料', '添加司机资料成功', '成功', '车牌号码:' . $Driver->name));
     return_value_json(true);
 }
Esempio n. 16
0
 public function logs()
 {
     $SealLog = M('EsealLog');
     check_error($SealLog);
     //根据过滤条件和查询涉及的各个表之间,决定哪些字段有可能会模糊不清,在这里做定义
     $ambiguous = array('eseal_id' => 'eseal_log`.`eseal_id', 'bar_id' => 'eseal_log`.`bar_id');
     $condition = '1';
     $filters = $_REQUEST['filter'];
     if (!empty($filters)) {
         $condition .= ' AND (' . $this->_getFiltersCondition($filters, $ambiguous) . ')';
     }
     $total = $SealLog->where($condition)->count();
     check_error($SealLog);
     $SealLog->join('`eseal` on `eseal_log`.`eseal_tb_id`=`eseal`.`id`')->join('`device` on `device`.`id`=`eseal`.`device_id`')->field(array('`eseal_log`.`id`', '`eseal_log`.`eseal_id`', '`eseal_log`.`bar_id`', '`eseal`.`device_id`', '`device`.`target_type`', '`device`.`target_id`', '`device`.`target_name`', '`eseal_log`.`local_time`', '`eseal_log`.`msg_data`', '`eseal_log`.`time`', '`eseal_log`.`power`', '`eseal_log`.`power_pct`', '`eseal_log`.`location`', '`eseal_log`.`latitude`', '`eseal_log`.`longitude`', '`eseal_log`.`speed_kn`', '`eseal_log`.`speed_km`', '`eseal_log`.`direction`', '`eseal_log`.`direction_text`', '`eseal_log`.`gmtime`', '`eseal_log`.`counter_hex`', '`eseal_log`.`counter`', '`eseal_log`.`msg`'))->order('`local_time` DESC')->where($condition);
     $page = $_REQUEST['page'] + 0;
     $limit = $_REQUEST['limit'] + 0;
     if ($page && $limit) {
         $SealLog->limit($limit)->page($page);
     }
     $logs = $SealLog->select();
     //		Log::write(M()->getLastSql(), Log::SQL);
     check_error($SealLog);
     return_json(true, $total, 'logs', $logs);
 }
Esempio n. 17
0
 function retrieve_data()
 {
     $connection = MysqlManager::get_connection();
     $result = $connection->query($this->sql);
     check_error($connection);
     $row = $result->fetch_object();
     $this->nik = $row->nik;
     $this->nama = $row->nama;
     $this->jenis_kelamin = $row->jenis_kelamin;
     $this->photo = $row->photo;
     $this->status_nikah = $row->status_nikah;
     $this->gol_darah = $row->gol_darah;
     $this->tempat_lahir = $row->tmp_lahir;
     $this->tgl_lahir = $row->tgl_lahir;
     $this->agama = $row->agama;
     $this->pendidikan = $row->pendidikan;
     $this->pekerjaan = $row->pekerjaan;
     $this->keluarga_id = $row->keluarga_id;
     $this->wni = $row->wni;
     // --
     $sql = "select alamat_id from keluarga where id = {$this->keluarga_id}";
     $result = $connection->query($sql);
     check_error($connection);
     $alamat_id = $result->fetch_object()->alamat_id;
     $sql = "select a.alamat as alamat, a.rukun_tetangga as rt, a.rukun_warga as rw,\r\r\n            kel.nama_kelurahan as kelurahan, kec.nama_kecamatan as kecamatan, kec.kodepos as kodepos \r\r\n            from alamat a, kelurahan kel, kecamatan kec where a.id = {$alamat_id} and a.kelurahan_id = kel.id and\r\r\n            kel.kecamatan_id = kec.id ";
     $result = $connection->query($sql);
     check_error($connection);
     $row = $result->fetch_object();
     $this->alamat = $row->alamat;
     $this->rt = $row->rt;
     $this->rw = $row->rw;
     $this->kelurahan = $row->kelurahan;
     $this->kecamatan = $row->kecamatan;
     $this->kodepos = $row->kodepos;
     MysqlManager::close_connection($connection);
 }
Esempio n. 18
0
 /**
  * delete操作根据post数据删除一个用户角色,一并删除相关的角色权限。
  */
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $roles = json_decode(file_get_contents("php://input"));
     if (!is_array($roles)) {
         $roles = array($roles);
     }
     $Role = M('Role');
     check_error($Role);
     $RolePrivilege = M('RolePrivilege');
     check_error($RolePrivilege);
     foreach ($roles as $role) {
         //删除角色
         if (false === $Role->where("`id`='" . $role->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除角色', '删除角色失败', '失败:系统错误', '删除角色[' . $role->name . ']时出错:' + get_error($Role)));
             return_value_json(false, 'msg', '删除角色[' . $role->name . ']时出错:' + get_error($Role));
         }
         //删除角色权限
         if (false === $RolePrivilege->where("`role_id`='" . $role->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除角色', '删除角色失败', '失败:系统错误', '删除角色[' . $role->name . ']的权限时出错:' + get_error($Role)));
             return_value_json(false, 'msg', '删除角色[' . $role->name . ']的权限时出错:' + get_error($Role));
         }
         //保存日志
         R('Log/adduserlog', array('删除角色', '删除角色成功', '成功', '角色名称:' . $role->name));
     }
     return_value_json(true);
 }
 public function savesetting()
 {
     $data = array();
     $username = $this->_post('username');
     $password = $this->_post('password');
     if (!empty($username) && !empty($password)) {
         $data['username'] = $username;
         $data['password'] = $password;
     }
     $refresh_frequency = $this->_post('refresh_frequency');
     if (!empty($refresh_frequency)) {
         $data['refresh_frequency'] = $refresh_frequency;
     }
     if (!empty($data)) {
         $DataImport = M('DataImport1');
         check_error($DataImport);
         $DataImport->where('1')->save($data);
         check_error($DataImport);
     }
     return_value_json(true);
 }
function create_new_network($_form)
{
    // function checks initial settings for network creation
    $can_network_be_created = Network::can_network_be_created();
    if ($can_network_be_created['error'] == TRUE) {
        $config_error = TRUE;
        $error = TRUE;
        $error_msg = $can_network_be_created['error_msg'];
    } else {
        if (!PA::$login_uid) {
            $config_error = TRUE;
        }
    }
    //form_data is array used for form fields
    // its initialized by $_form
    $temp_data['action'] = 'add';
    $vartoset = array('address', 'name', 'tagline', 'category', 'desc', 'header_image', 'header_image_option', 'action', 'type', 'network_group_title', 'network_content_moderation');
    for ($i = 0; $i < count($vartoset); $i += 1) {
        $var = $vartoset[$i];
        if (!empty($_form[$var])) {
            $temp_data[$var] = trim($_form[$var]);
        }
        if ($var == 'type') {
            if (isset($_form[$var])) {
                $temp_data[$var] = $_form[$var];
            }
        }
    }
    if (empty($config_error)) {
        filter_all_post($_form);
        //filters all data of html
        $error_post = check_error();
        //validation check
        if ($error_post['error'] == TRUE) {
            $error = TRUE;
            $error_msg = $error_post['error_msg'];
        }
        if (!$error_post) {
            //upload file
            if (!empty($_FILES['network_image']['name'])) {
                $file_upload_result = do_file_upload();
                if ($file_upload_result['error']) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                } else {
                    $header_image = $network_image = $file_upload_result['file'];
                }
            } else {
                //image hidden
                $header_image = $network_image = @$temp_data['header_image'];
            }
            //code to upload the icon image
            if (!empty($_FILES['inner_logo_image']['name'])) {
                $uploadfile = PA::$upload_path . basename($_FILES['inner_logo_image']['name']);
                $myUploadobj = new FileUploader();
                //creating instance of file.
                $image_type = 'image';
                $file = $myUploadobj->upload_file(PA::$upload_path, 'inner_logo_image', true, true, $image_type);
                if ($file == false) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                    unset($data_icon_image);
                } else {
                    $data_icon_image = array('inner_logo_image' => $file);
                }
            } else {
                unset($data_icon_image);
            }
            //...code to upload the icon image
            $network_basic_controls = PA::$network_defaults;
            $network_basic_controls['basic']['header_image']['name'] = $header_image;
            $network_basic_controls['basic']['header_image']['option'] = @$_form['header_image_option'] ? $_form['header_image_option'] : DESKTOP_IMAGE_ACTION_STRETCH;
            // for title of network group
            $network_basic_controls['network_group_title'] = '';
            $network_basic_controls['network_group_title'] = $_form['network_group_title'];
            $network_basic_controls['network_content_moderation'] = @$_form['network_content_moderation'];
            $temp_data['address'] = strtolower($temp_data['address']);
            $data = array('user_id' => $_SESSION['user']['id'], 'name' => strip_tags($temp_data['name']), 'address' => $temp_data['address'], 'tagline' => strip_tags($temp_data['tagline']), 'category_id' => $temp_data['category'], 'type' => $temp_data['type'], 'description' => $temp_data['desc'], 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time());
            //add icon image
            if (!empty($data_icon_image['inner_logo_image'])) {
                $data = array_merge($data, $data_icon_image);
                $temp_data['inner_logo_image'] = $data_icon_image['inner_logo_image'];
            }
            $network = new Network();
            $network->set_params($data);
            try {
                $nid = $network->save();
                //default_page_setting($network->address); // populate page_default setting
            } catch (PAException $e) {
                $error = TRUE;
                $error_msg = "{$e->message}";
            }
            if (!empty($nid)) {
                $_extra = serialize(array('user' => true, 'network' => true, 'groups' => array()));
                Roles::set_user_role_for_network($network->user_id, ADMINISTRATOR_ROLE, $network->address, $_extra);
                $location = "http://" . $temp_data['address'] . '.' . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_CONFIGURE_NETWORK;
            }
        }
        $msg_array = array();
        $msg_array['failure_msg'] = @$error_msg;
        $msg_array['success_msg'] = 7006;
        $return_array = @array('msg' => $msg_array, 'redirection_url' => $location, 'query_str' => $query_str);
    }
    return $return_array;
}
Esempio n. 21
0
         $start = $limit * $page - $limit;
         if ($start < 0) {
             $start = 0;
         }
         $sql = "";
         // TODO:
         // perbaiki query .. optimize it.
         if (sizeof($wh) > 2) {
             $sql = "select k.id, k.kode_keluarga, k.no_formulir, a.alamat,\n                a.rukun_tetangga, a.rukun_warga, kel.nama_kelurahan from keluarga k,\n                alamat a, kelurahan kel where k.alamat_id = a.id and\n                a.kelurahan_id = kel.id and kel.kecamatan_id = {$kec_id} and {$wh} order by {$sidx} {$sord} limit {$start}, {$limit}";
         } else {
             $sql = "select k.id, k.kode_keluarga, k.no_formulir, a.alamat, a.rukun_tetangga,\n                a.rukun_warga, kel.nama_kelurahan from keluarga k, alamat a,\n                kelurahan kel where k.alamat_id = a.id and a.kelurahan_id = kel.id\n                and kel.kecamatan_id = {$kec_id}  order by {$sidx} {$sord} limit {$start}, {$limit}";
         }
         //
         //exit();
         $result = $connection->query($sql);
         check_error($connection);
         $resp->page = $page;
         $resp->total = $total_pages;
         $resp->records = $count;
         $i = 0;
         while ($row = $result->fetch_object()) {
             $resp->rows[$i]['id'] = $row->id;
             $resp->rows[$i]['cell'] = array($row->id, $row->kode_keluarga, $row->no_formulir, $row->alamat, $row->rukun_tetangga, $row->rukun_warga, $row->nama_kelurahan);
             $i++;
         }
         echo json_encode($resp);
         break;
     case 2:
         break;
 }
 MysqlManager::close_connection($connection);
Esempio n. 22
0
check_error();
echo "Created RegistryValue objects :{$eol}";
foreach ($keys as $value) {
    echo "{$tab}" . str_replace("{$eol}", "{$eol}{$tab}", print_r($value, true));
}
// 7) Retrieve created key values - You must known the type of each key before doing that, or else use the GetValue() method,
//    which works only on REG_SZ, REG_EXPAND_SZ, REG_DWORD and REG_BINARY types.
echo "Created values :{$eol}";
echo "{$tab}{$test_key}/BinaryValueFromArray     : " . $registry->GetBinaryValue(Registry::HKCU, $test_key, 'BinaryValueFromArray') . $eol;
echo "{$tab}{$test_key}/BinaryValueFromHexString : " . $registry->GetBinaryValue(Registry::HKCU, $test_key, 'BinaryValueFromHexString') . $eol;
echo "{$tab}{$test_key}/BinaryValueFromString    : " . $registry->GetBinaryValue(Registry::HKCU, $test_key, 'BinaryValueFromString') . $eol;
echo "{$tab}{$test_key}/DWORDValue               : 0x" . sprintf("%08X", $registry->GetDWORDValue(Registry::HKCU, $test_key, 'DWORDValue')) . $eol;
echo "{$tab}{$test_key}/ExpandedStringValue      : " . $registry->GetExpandedStringValue(Registry::HKCU, $test_key, 'ExpandedStringValue') . $eol;
echo "{$tab}{$test_key}/BinaryValueFromHexString : " . $registry->GetBinaryValue(Registry::HKCU, $test_key, 'BinaryValueFromHexString') . $eol;
echo "{$tab}{$test_key}/MultiStringValueMultiple : " . implode(', ', $registry->GetMultiStringValue(Registry::HKCU, $test_key, 'MultiStringValueMultiple')) . $eol;
echo "{$tab}{$test_key}/MultiStringValueSingle   : " . implode(', ', $registry->GetMultiStringValue(Registry::HKCU, $test_key, 'MultiStringValueSingle')) . $eol;
echo "{$tab}{$test_key}/MultiStringValueMultiple : " . implode(', ', $registry->GetMultiStringValue(Registry::HKCU, $test_key, 'MultiStringValueMultiple')) . $eol;
echo "{$tab}{$test_key}/QWORDBigValue            : " . $registry->GetQWORDValue(Registry::HKCU, $test_key, 'QWORDBigValue') . $eol;
echo "{$tab}{$test_key}/QWORDValue               : " . $registry->GetQWORDValue(Registry::HKCU, $test_key, 'QWORDValue') . $eol;
echo "{$tab}{$test_key}/StringValue              : " . $registry->GetQWORDValue(Registry::HKCU, $test_key, 'StringValue') . $eol;
echo "{$tab}{$test_key}/WShellDWORDValue         : 0x" . sprintf("%08X", $registry->GetValue(Registry::HKCU, $test_key, 'WShellDWORDValue')) . $eol;
// Note that the GetValue() method for WShell does not seem to process variable expansion
echo "{$tab}{$test_key}/WShellExpandedStringValue: " . $registry->GetValue(Registry::HKCU, $test_key, 'WShellExpandedStringValue') . $eol;
echo "{$tab}{$test_key}/WShellStringValue        : " . $registry->GetValue(Registry::HKCU, $test_key, 'WShellStringValue') . $eol;
// 8) Delete a subkey (HKCU\TestRegistry\Values\WShellExpandedStringValue key)
$registry->DeleteValue(Registry::HKCU, $test_key, 'WShellExpandedStringValue');
check_error();
// 9) Delete the test subkey - leads to an error, since a key can only be deleted if it has no subkeys - so you'll have to delete TestRegistry manually under HKCU
$registry->DeleteKey(Registry::HKCU, 'TestRegistry');
check_error();
Esempio n. 23
0
        $result = $conn->query($sql);
        check_error($conn);
        MysqlManager::close_connection($conn);
    } elseif ($_POST['oper'] == 'del') {
        $conn = MysqlManager::get_connection();
        $id = $_POST['id'];
        $sql = "delete from pendidikan where id = {$id}";
        $result = $conn->query($sql);
        check_error($conn);
        MysqlManager::close_connection($conn);
    } elseif ($_POST['oper'] == 'add') {
        $conn = MysqlManager::get_connection();
        $pendidikan = $_POST['pendidikan'];
        $sql = "insert into pendidikan (pendidikan) values ('{$pendidikan}')";
        $result = $conn->query($sql);
        check_error($conn);
        MysqlManager::close_connection($conn);
    }
} elseif (isset($_GET['q'])) {
    $resp = "";
    $req = $_GET['q'];
    $page = $_GET['page'];
    $limit = $_GET['rows'];
    $sord = $_GET['sord'];
    $sidx = $_GET['sidx'];
    if (!$sidx) {
        $sidx = 1;
    }
    $wh = "";
    $searchOn = Strip($_REQUEST['_search']);
    if ($searchOn == 'true') {
Esempio n. 24
0
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $users = json_decode(file_get_contents("php://input"));
     if (!is_array($users)) {
         $users = array($users);
     }
     $User = D('User');
     check_error($User);
     $ManageTarget = M('ManageTarget');
     check_error($ManageTarget);
     foreach ($users as $user) {
         if (false === $ManageTarget->where("`user_id`='{$user->id}'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除用户', '删除用户管理对象失败', '失败:系统错误', '删除用户管理对象时出错:' . get_error($ManageTarget)));
             return_value_json(false, 'msg', '删除用户管理对象时出错:' . get_error($ManageTarget));
         }
         if (false === $User->where("`id`='" . $user->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除用户', '删除用户失败', '失败:系统错误', '删除用户出错:' + get_error($User)));
             return_value_json(false, 'msg', '删除删除用户出错:' + get_error($User));
         }
         //保存日志
         R('Log/adduserlog', array('删除用户', '删除用户成功', '成功', '被删除的用户' . $user->name));
     }
     return_value_json(true);
 }
     if (!empty($_POST[$var])) {
         $form_data[$var] = $_POST[$var];
     }
     if ($var == 'type') {
         if (isset($_POST[$var])) {
             $form_data[$var] = $_POST[$var];
         }
     }
 }
 // No need to verify category of MotherNetwork
 if ($network_info->type == MOTHER_NETWORK_TYPE) {
     $skip_check = array('address', 'category');
 } else {
     $skip_check = array('address');
 }
 $error_post = check_error($skip_check);
 //validation check
 if ($error_post['error'] == TRUE) {
     $error = TRUE;
     $error_msg = $error_post['error_msg'];
 }
 if (!$error_post) {
     //code to upload the icon image
     if (!empty($_FILES['inner_logo_image']['name'])) {
         $uploadfile = $uploaddir . basename($_FILES['inner_logo_image']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $myUploadobj->upload_file($uploaddir, 'inner_logo_image', true, true, $image_type);
         if ($file == false) {
             $error = TRUE;
Esempio n. 26
0
function checkUser($email, $password, &$errMsgs)
{
    $result = array();
    $returnData = "";
    $result['success'] = false;
    $con = connectDatabase();
    while (1) {
        $stmt = $con->prepare("CALL getUser(?)");
        $stmt->bind_param("s", $email);
        $stmt->execute();
        if (check_error($stmt->errno, $stmt->error, $errMsgs)) {
            break;
        }
        $stmt->bind_result($returnData);
        $stmt->fetch();
        $returnData = json_decode($returnData, true);
        if ($returnData['success'] == true) {
            if (password_verify($password, $returnData['hash'])) {
                $result['success'] = true;
                $result['type'] = $returnData['type'];
                $result['email'] = $email;
                if ($result['type'] === 'user') {
                    $result['firstName'] = $returnData['firstName'];
                    $result['lastName'] = $returnData['lastName'];
                    $result['nationality'] = $returnData['nationality'];
                    $result['dob'] = $returnData['dob'];
                    $result['middleName'] = getUserMiddleNames($email);
                    $result['aliasName'] = getUserAliasNames($email);
                }
                _updateUserLastLogin($result['email']);
            } else {
                array_push($errMsgs, "Wrong Username/Password Combination");
            }
        } else {
            array_push($errMsgs, "Wrong Username/Password Combination");
        }
        $stmt->close();
        break;
    }
    closeDatabase($con);
    return $result;
}
Esempio n. 27
0
 /**
  * 区域班列查询
  */
 public function inarea()
 {
     //先获取到参数
     $starttime = $this->_get('starttime');
     $endtime = $this->_get('endtime');
     $points = json_decode($_GET['area']);
     if (empty($starttime)) {
         return_value_json(false, 'msg', '系统出错:开始时间为空');
     }
     if (strlen($starttime) != 19 || strtotime($starttime) === false) {
         return_value_json(false, 'msg', '系统出错:开始时间格式不正确');
     }
     if (!empty($endtime) && (strlen($endtime) != 19 || strtotime($endtime) === false)) {
         return_value_json(false, 'msg', '系统出错:结束时间格式不正确');
     }
     if (empty($points) || !is_array($points) || count($points) < 2) {
         return_value_json(false, 'msg', '系统出错:多边形端点数量不够');
     }
     foreach ($points as $index => $point) {
         $points[$index] = (array) $point;
         //把对象转成数组
     }
     //首先查询数据库里指定时间内所有的定位信息
     $Location = M('Location');
     check_error($Location);
     $condition = array('_string' => " `location`.`time`>='{$starttime}' AND `train`.`number` IS NOT NULL ");
     if (!empty($endtime)) {
         $condition['_string'] .= " AND `location`.`time`<='{$endtime}' ";
     }
     $Location->join('`device` on `device`.`id`=`location`.`device_id`')->join("`train` on (`train`.`id`=`device`.`target_id` AND `device`.`target_type`='班列')")->join('`department` on `department`.`id`=`train`.`department_id`')->field(array('`location`.`id`', '`department`.`id`' => 'department_id', '`department`.`name`' => 'department', '`train`.`id`' => 'train_id', '`train`.`number`', '`train`.`due_date`', '`train`.`due_time`', '`location`.`device_id`', '`device`.`type`', '`device`.`label`', '`location`.`time`', 'state', 'online', '`location`.`address`', 'baidu_lat', 'baidu_lng', 'speed', 'direction', 'mcc', 'mnc', 'lac', 'cellid', '`location`.`range`'))->where($condition)->order('`department`.`sequence`, `train`.`id`, `time` ASC');
     //先按班列id,然后按时间顺序
     // 		$page = $_REQUEST['page'] + 0;
     // 		$limit = $_REQUEST['limit'] + 0;
     //		if($page && $limit) $Location->limit($limit)->page($page); //这里不用数据库的分页,而是用我们自己的分页(目前没法分页了)
     $locations = $Location->select();
     check_error($Location);
     $total = 0;
     $results = array();
     $curTrain = null;
     //当前在区域内的班列
     $alreadyIn = false;
     //目前是否已经在区域内
     $lastLocation = null;
     foreach ($locations as $location) {
         $in = Geometry::geoPointInPolygon(array('lat' => $location['baidu_lat'], 'lng' => $location['baidu_lng']), $points);
         //TODO 考虑当前点与上一个定位点的轨迹线段是否切割多边形?
         if ($in) {
             if ($alreadyIn && $curTrain != $location['train_id']) {
                 //已经在区域内,但是现在来了个不同的车(原来的车不知道跑哪里去了,这个车不知道是从哪里来的)
                 //那么我们认为前车的离开点就是他轨迹的最后一个点,并且它现在离开区域了
                 $lastTrainLocationsCount = count($results[$total - 1]['locations']);
                 if ($lastTrainLocationsCount > 0) {
                     $results[$total - 1]['time_out'] = $results[$total - 1]['locations'][$lastTrainLocationsCount - 1]['time'];
                     $results[$total - 1]['duration'] = $this->_getFriendlyDurationText($results[$total - 1]['time_in'], $results[$total - 1]['time_out']);
                     $alreadyIn = false;
                     $curTrain = null;
                 }
             }
             if (!$alreadyIn && $curTrain === null) {
                 //首次进入
                 $alreadyIn = true;
                 $curTrain = $location['train_id'];
                 $results[] = array('id' => $location['id'], 'department_id' => $location['department_id'], 'department' => $location['department'], 'train_id' => $location['train_id'], 'number' => $location['number'], 'device_id' => $location['device_id'], 'label' => $location['label'], 'time_in' => $location['time'], 'time_out' => '', 'duration' => '', 'locations' => array(), 'first_isout' => false, 'last_isout' => false);
                 $total++;
                 if ($lastLocation !== null && $lastLocation['train_id'] == $location['train_id']) {
                     $results[$total - 1]['locations'][] = $lastLocation;
                     $results[$total - 1]['first_isout'] = true;
                 }
             }
             $results[$total - 1]['locations'][] = $location;
         } else {
             //出了区域
             if ($alreadyIn) {
                 if ($curTrain != $location['train_id']) {
                     //原来的车不知道跑哪里去了
                     $lastTrainLocationsCount = count($results[$total - 1]['locations']);
                     if ($lastTrainLocationsCount > 0) {
                         $results[$total - 1]['time_out'] = $results[$total - 1]['locations'][$lastTrainLocationsCount - 1]['time'];
                     } else {
                         //这是不可能的。
                         $results[$total - 1]['time_out'] = $location['time'];
                     }
                 } else {
                     //记录班列离开的点
                     $results[$total - 1]['time_out'] = $location['time'];
                     $results[$total - 1]['locations'][] = $location;
                     $results[$total - 1]['last_isout'] = true;
                 }
                 $results[$total - 1]['duration'] = $this->_getFriendlyDurationText($results[$total - 1]['time_in'], $results[$total - 1]['time_out']);
                 $alreadyIn = false;
                 $curTrain = null;
             }
         }
         $lastLocation = $location;
     }
     return_json(true, $total, 'results', $results);
 }
Esempio n. 28
0
 /**
  * edit操作根据post数据更新数据库。
  */
 public function edit()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $vehicles = json_decode(file_get_contents("php://input"));
     if (!is_array($vehicles)) {
         $vehicles = array($vehicles);
     }
     $Vehicle = D('Vehicle');
     foreach ($vehicles as $vehicle) {
         $Vehicle->create($vehicle);
         check_error($Vehicle);
         if (false === $Vehicle->save()) {
             //保存日志
             R('Log/adduserlog', array('修改车辆资料', '修改车辆资料失败', '失败:系统错误', '更新车辆[' . $vehicle->number . ']时出错:' . get_error($Vehicle)));
             return_value_json(false, 'msg', '更新车辆[' . $vehicle->number . ']时出错:' . get_error($Vehicle));
         }
         //保存日志
         R('Log/adduserlog', array('修改车辆资料', '修改车辆资料成功', '成功', '车牌号码:' . $Vehicle->number));
     }
     return_value_json(true);
 }
Esempio n. 29
0
print "provider {$provider} {\n\tdefinition incomplete;\n\tdbType {$mdb->dbsyntax};\n";
$tables = $mdb->listTables();
check_error($tables);
$views = $mdb->listViews();
check_error($views);
$tablesViews = array_merge($tables, $views);
foreach ($tablesViews as $table) {
    print "\ttable {$table} {\n";
    //NOTE: http://pear.php.net/bugs/bug.php?id=15100
    $mdb->setOption('quote_identifier', true);
    $fields = $mdb->listTableFields($table);
    check_error($fields);
    foreach ($fields as $field) {
        //obtain definition
        $decl = $mdb->getTableFieldDefinition($table, $field);
        check_error($decl);
        $decl = $decl[0];
        //determine native type
        if (!array_key_exists($decl['nativetype'], $typeMap)) {
            perror("WARNING: Unknown nativetype: {$decl['nativetype']}\n");
            print "\t\t/*Omitting {$field}: Unknown nativetype: {$decl['nativetype']}*/\n";
            continue;
        }
        $type = $typeMap[$decl['nativetype']];
        $ext = '';
        //TODO: skip for now since not supported
        if ($type == 'Binary') {
            perror("WARNING: Omitting {$field}: Binary fields not yet supported\n");
            print "\t\t/*Omitting {$field}: Binary fields not yet supported*/\n";
            continue;
        }
Esempio n. 30
0
    if (empty($_SESSION['error_msg'])) {
        $_SESSION['ok_msg'] = __('USER_CREATED_OK', $_POST['v_username'], $_POST['v_username']);
        $_SESSION['ok_msg'] .= " / <a href=/login/?loginas=" . $_POST['v_username'] . ">" . __('login as') . " " . $_POST['v_username'] . "</a>";
        unset($v_username);
        unset($v_password);
        unset($v_email);
        unset($v_fname);
        unset($v_lname);
        unset($v_notify);
    }
}
// Header
include $_SERVER['DOCUMENT_ROOT'] . '/templates/header.html';
// Panel
top_panel($user, $TAB);
// List hosting packages
exec(VESTA_CMD . "v-list-user-packages json", $output, $return_var);
check_error($return_var);
$data = json_decode(implode('', $output), true);
unset($output);
// List languages
exec(VESTA_CMD . "v-list-sys-languages json", $output, $return_var);
$languages = json_decode(implode('', $output), true);
unset($output);
// Display body
include $_SERVER['DOCUMENT_ROOT'] . '/templates/admin/add_user.html';
// Flush session messages
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
// Footer
include $_SERVER['DOCUMENT_ROOT'] . '/templates/footer.html';