Example #1
0
 /**
  * 登入方法
  * @param null $input
  * @return array
  */
 public function login($input = null)
 {
     $input = $input ? $input : rq();
     if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) {
         $d = M('doctor');
         $d = $d->where('cust_id', $input['cust_id'])->first();
         if ($d) {
             log_him_in(['uid' => $d->id]);
             add_chara($input['user_type']);
             return ss();
         }
         return $d ? ss($d) : ee(2);
     }
     if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) {
         $input['password'] = hash_password($input['password']);
         $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password']));
         if ($user) {
             log_him_in(['username' => $user->username, 'uid' => $user->id]);
             add_chara($input['user_type']);
             return ss();
         }
     } else {
         return ee(2);
     }
     return ee(2);
 }
Example #2
0
 public function robot()
 {
     if (!he_is('agency')) {
         abort(403);
     }
     $data = DB::table('i_robot')->select('i_robot.*', 'i_robot_lease_log.*', 'i_hospital.name as hospital_name', 'i_employee.name as employee_name')->leftJoin('i_robot_lease_log', 'i_robot.id', '=', 'i_robot_lease_log.robot_id')->leftJoin('i_hospital', 'i_hospital.id', '=', 'i_robot_lease_log.hospital_id')->leftJoin('i_employee', 'i_employee.id', '=', 'i_robot.employee_id')->where('i_robot_lease_log.recent', 1)->where('i_robot_lease_log.agency_id', uid())->orderBy('i_robot.id', 'i_robot_lease_log.lease_ended_at desc')->get();
     return ss($data);
 }
Example #3
0
 public function change_password($row = null)
 {
     $row = $row ? $row : rq();
     $ins = $this->find($row['id']);
     $ins->password = hash_password($row['password']);
     $r = $ins->save();
     return $r ? ss($r) : ee(1);
 }
Example #4
0
function chs($var, $def = 0)
{
    if (isset($_REQUEST[$var])) {
        return ss($_REQUEST[$var]);
    } else {
        return $def;
    }
}
Example #5
0
 public function r()
 {
     if (!intval(rq('id'))) {
         ss('无效ID', 0);
     }
     $data = $this->find(rq('id'));
     $this->eventFire('r', $data);
     return ss($data);
 }
Example #6
0
 public function index()
 {
     if (ss('uid')) {
         header('Location: /?c=default&a=main');
     }
     $this->data['side'] = true;
     $this->data['title'] = $this->data['top_title'] = '首页';
     render($this->data);
 }
Example #7
0
 public function change_password($row = null)
 {
     $row = $row ? $row : rq();
     $ins = $this->find($row['id']);
     $ins->password = hash_password($row['password']);
     $r = $ins->save();
     // trigger log
     $this->eventFire('pass', $ins);
     return $r ? ss($r) : ee(1);
 }
Example #8
0
 function ss($n)
 {
     foreach ($n as $k => $v) {
         if (is_array($v)) {
             $n[$k] = ss($v);
         } else {
             $n[$k] = stripslashes($v);
         }
     }
 }
Example #9
0
 public function read()
 {
     $id = rq('id');
     $data = $this->find($id);
     $res = 0;
     if ($data->recipientid == uid()) {
         $data->read = 1;
         $res = $data->save();
     }
     return ss($res);
 }
Example #10
0
 public function recover()
 {
     if (rq('id')) {
         $row = $this->find(rq('id'));
         $row->update(['status' => 1, 'wechat_id' => null]);
         $this->eventFire('recover', $row);
         return ss($row);
     } else {
         ee(2);
     }
 }
Example #11
0
 function __construct()
 {
     // 载入默认的
     parent::__construct();
     $a = g('a');
     $c = g('c');
     session_start();
     if (!ss('uid') && $c != 'login') {
         header('Location: /?c=login');
         exit;
     }
 }
Example #12
0
 public function index()
 {
     //include_once( AROOT . 'controller'.DS.'api_admin_folder.class.php' );
     //$folder = new api_admin_folderController();
     //echo $folder->getlist();die();
     if (ss('uid')) {
         header('Location: /?c=default&a=main');
     }
     $this->data['side'] = true;
     $this->data['title'] = $this->data['top_title'] = '首页';
     render($this->data);
 }
Example #13
0
 function Set($var, $val, $perm = true)
 {
     $this->data[$var] = $val;
     if ($perm) {
         global $NATS;
         $q = "UPDATE fnconfig SET fnc_val=\"" . ss($val) . "\" WHERE fnc_var=\"" . ss($var) . "\"";
         $NATS->DB->Query($q);
         if ($NATS->DB->Affected_Rows() <= 0) {
             $q = "INSERT INTO fnconfig(fnc_var,fnc_val) VALUES(\"" . ss($var) . "\",\"" . ss($val) . "\")";
             mysql_query($q);
         }
     }
 }
Example #14
0
 /**
  * 找回密码 
  * @param  [type] $p3 找回密码类型 - employee , agency
  * @return [type]     [description]
  */
 public function forget($p3 = null)
 {
     $email = rq('email');
     $ins = Route::current()->parameter('p3');
     $row = M($ins)->where('email', $email)->first();
     if ($row) {
         // 发送邮件
         $hash = hash_password($row->email . time());
         Mail::send('emails.reminder', ['user' => $row, 'hash' => $hash], function ($m) use($row) {
             $m->to($row->email, $row->name)->subject('密码重置');
         });
         // 发送log
         Event::fire(new LogEvent('reminder', 'auth', ['type' => $ins, 'user' => $row, 'hash' => $hash]));
         return ss('邮件已发送');
     } else {
         return ss('无相关用户', 0);
     }
 }
Example #15
0
 /**
  * 登入方法
  * @param null $input
  * @return array
  */
 public function login($input = null)
 {
     $input = $input ? $input : rq();
     if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) {
         $d = M('doctor');
         $d = $d->where('cust_id', $input['cust_id'])->first();
         if ($d) {
             log_him_in(['uid' => $d->id]);
             add_chara($input['user_type']);
             return ss();
         }
         return $d ? ss($d) : ee(2);
     }
     if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) {
         $input['password'] = hash_password($input['password']);
         $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password']));
         if ($user) {
             $lifetime = 6000;
             log_him_in(['username' => $user->username, 'uid' => $user->id], $lifetime);
             add_chara($input['user_type']);
             if ($input['user_type'] == 'employee') {
                 sess('permission', $user->permissions);
             } else {
                 sess('permission', []);
             }
             if ($input['user_type'] == 'agency') {
                 sess('org', $user->name);
                 sess('name_in_charge', $user->name_in_charge);
             }
             if ($input['user_type'] == 'department') {
                 sess('org', $user->hospital_name . ':' . $user->name);
             }
             if ($input['user_type'] == 'employee') {
                 sess('org', $user->name);
             }
             // 添加日志
             ILog::login($input['user_type'], $user);
             return ss($user);
         }
     } else {
         return ee(2);
     }
     return ee(2);
 }
Example #16
0
 public function scan_u()
 {
     if (rq('cust_id')) {
         $ins = $this->where('cust_id', rq('cust_id'))->first();
     } else {
         return ee(2, 'missing_cust_id');
     }
     if (!$ins) {
         return ee(2, 'record_not_found');
     }
     if ($ins->used_at) {
         return ee(2, 'mark_is_already_used');
     }
     $ins->doctor_id = uid();
     $ins->used_at = \Carbon\Carbon::now();
     if ($ins->save()) {
         return ss();
     }
 }
Example #17
0
 /**
  * 自定义查询
  * @return [type] [description]
  */
 public function r()
 {
     $builder = $this;
     if (Input::has('where.start')) {
         $builder = $builder->where('at', '>', Input::get('where.start'));
     }
     if (Input::has('where.end')) {
         $builder = $builder->where('at', '<', Input::get('where.end'));
     }
     if (Input::has('where.memo')) {
         $builder = $builder->where('memo', 'like', '%' . Input::get('where.memo') . '%');
     }
     $page = rq('pagination') ? rq('pagination') : 1;
     $per_page = rq('limit') ? rq('limit') : $this->default_limit;
     $skip = ($page - 1) * $per_page;
     $count = $builder->count();
     $builder = $builder->skip($skip)->take($per_page)->orderBy('at', 'desc');
     $data = $builder->get();
     return ss(['main' => $data, 'count' => $count, 'per_page' => $per_page, 'start' => Input::get('where.start')]);
 }
Example #18
0
File: db.php Project: newset/robot
 /**
  * create type ins record.
  * @param $arr
  * @return array
  */
 function c_t($arr)
 {
     //        dd($arr);
     $required_field = ['type_name'];
     if (!has_keys($arr, $required_field)) {
         return ee(2);
     }
     if (array_has($arr, 'is_status')) {
         $ins = M($arr['ins_name'], 'ts');
     } else {
         $ins = M($arr['ins_name'], 't');
     }
     if (!array_has($arr, 'status_id')) {
         $arr['status_id'] = 1;
     }
     unset($arr['ins_name']);
     unset($arr['is_status']);
     $r = $ins->create($arr);
     return $r ? ss($ins) : ee(1);
 }
Example #19
0
 /**
  * 保存设置
  * @param  [type] $rq [description]
  * @return [type]     [description]
  */
 public function c($rq = NULL)
 {
     // add pattern
     $rq = rq('data');
     $res = [];
     $cache = [];
     if ($rq) {
         foreach ($rq as $key => $value) {
             $item = $this->firstOrNew(['k' => $key]);
             $item->k = $key;
             $item->v = $value;
             $item->save();
             $res[] = $item;
             $cache[$item->k] = $value;
         }
     }
     // reset cache
     Cache::forever('i_settings', $cache);
     return ss($res);
 }
Example #20
0
function nats_eval($testid, $value)
{
    global $NATS;
    if (!is_numeric($value)) {
        return 2;
    }
    // fails if not numeric!
    $lvl = 0;
    $q = "SELECT * FROM fneval WHERE testid=\"" . ss($testid) . "\"";
    $r = $NATS->DB->Query($q);
    //echo $q;
    while ($row = $NATS->DB->Fetch_Array($r)) {
        //echo "\n".$row['eoperator']."\n";
        $nl = 0;
        switch ($row['eoperator']) {
            case "ET":
                if ($row['evalue'] == $value) {
                    $nl = $row['eoutcome'];
                }
                break;
            case "GT":
                if ($row['evalue'] < $value) {
                    $nl = $row['eoutcome'];
                }
                break;
            case "LT":
                if ($row['evalue'] > $value) {
                    $nl = $row['eoutcome'];
                }
                break;
        }
        if ($nl > $lvl) {
            $lvl = $nl;
        }
    }
    $NATS->DB->Free($r);
    return $lvl;
}
Example #21
0
 public function front()
 {
     $cache = Cache::get('i_settings', null);
     $per_page = array_get($cache, 'user.per_page');
     $d = ['debug' => debugging(), 'is_logged_in' => sess('is_logged_in'), 'his_chara' => sess('his_chara'), 'username' => sess('username'), 'uid' => sess('uid'), 'per_page' => $per_page, 'agency_end' => $this->retrieve('system.agency_end')];
     $type = ['employee' => 1, 'agency' => 2, 'doctor' => 3];
     // 获取未读通知
     if (uid()) {
         $d['unread'] = M('message')->where('recipientid', uid())->where('recipienttype', $type[his_chara()[0]])->where('read', 0)->count();
     } else {
         $d['unread'] = 0;
     }
     $d['org'] = '';
     if (he_is('agency')) {
         $org = DB::table(table_name('agency'))->select('name')->where('id', uid())->first();
         sess('org', $org->name);
         $d['org'] = sess('org');
     }
     if (he_is('employee')) {
         $d['org'] = sess('org');
     }
     return ss($d);
 }
Example #22
0
function ss_start()
{
    $sn = session_name();
    if (!ss($sn)) {
        if (!empty($_REQUEST[$sn]) && !empty($_SERVER['REMOTE_ADDR'])) {
            session_id($_REQUEST[$sn]);
        }
        session_start();
        if (false && ss('remote_ip') && ss('remote_ip') != $_SERVER['REMOTE_ADDR']) {
            session_unset();
            header('Location: /');
            exit;
        }
        if (!ss('remote_ip')) {
            ss_set('remote_ip', $_SERVER['REMOTE_ADDR']);
        }
        ss_set($sn, session_id());
        if (ss('weibo_user_info')) {
            setcookie('weibo_bind', '1');
        }
    } else {
    }
}
echo "</select> <input type=submit value=Add></td></tr>";
echo "</form>";


echo "</table>";
End_Round();
*/
$t = "<b class=\"sectitle\">" . $NATS->Lang->Item("test.evals") . "</b>";
Start_Round($t, 600);
echo "<table border=0 width=100%>";
echo "<tr><td colspan=2>&nbsp;<br>";
if ($row['simpleeval'] == 1) {
    echo "<i>" . $NATS->Lang->Item("test.evals.simple") . "</i><br>";
}
echo "</td></tr>";
$q = "SELECT * FROM fneval WHERE testid=\"N" . ss($_REQUEST['nstestid']) . "\" ORDER BY weight ASC";
$r = $NATS->DB->Query($q);
while ($row = $NATS->DB->Fetch_Array($r)) {
    echo "<tr><td colspan=2>";
    echo "<a href=\"eval.action.php?action=delete&back=" . urlencode("nodeside.edit.php?nstestid=" . $_REQUEST['nstestid'] . "&message=" . $NATS->Lang->Item("eval.deleted")) . "&evalid=" . $row['evalid'] . "\">";
    echo "<img src=images/options/action_delete.png border=0 style=\"vertical-align: bottom;\"></a>&nbsp;&nbsp;";
    echo $NATS->Lang->Item("result") . " " . eval_operator_text($row['eoperator']) . " " . $row['evalue'] . " =&gt; " . oText($row['eoutcome']) . "";
    //echo " | <a href=eval.action.php?action=move&dir=up&evalid=".$row['evalid'].">Up</a>/<a href=eval.action.php?action=move&dir=dn&evalid=".$row['evalid'].">Down</a>";
    echo "</td></tr>";
    //echo "<tr><td colspan=2>&nbsp;</td></tr>";
}
echo "<form action=eval.action.php>";
echo "<input type=hidden name=action value=create>";
echo "<input type=hidden name=testid value=N" . $_REQUEST['nstestid'] . ">";
echo "<input type=hidden name=back value=\"nodeside.edit.php?nstestid=" . $_REQUEST['nstestid'] . "\">";
echo "<tr><td colspan=2>&nbsp;<br></td></tr>";
Example #24
0
if ($node['nsenabled'] != 1) {
    echo "Nodeside Disabled for Node";
    exit;
}
if ($node['nspushenabled'] != 1) {
    echo "Nodeside Push Disabled for Node";
    exit;
}
if ($node['nspuship'] != "" && $node['nspuship'] != $remoteip) {
    echo "Remote IP Not Allowed for Push";
    exit;
}
if ($node['nskey'] != "" && $node['nskey'] != $nodekey) {
    echo "Nodekey Failure";
    exit;
}
// Got here so ok!
$xmlobj = new TNodeXML();
$xmlobj->Parse($xml);
if ($xmlobj->Error() != "") {
    echo "XML Error: " . $xmlobj->Error();
    exit;
}
$eventdata = array("nodeid" => $nodeid);
$NATS->EventHandler("nodeside_push", $eventdata);
$NATS->Nodeside_Process($nodeid, $xmlobj);
$uq = "UPDATE fnnode SET nsfreshpush=1,nslastx=" . time() . " WHERE nodeid=\"" . ss($nodeid) . "\"";
$NATS->DB->Query($uq);
echo "1";
$NATS->Stop();
exit;
Example #25
0
         // swap 'em
         $uq = "UPDATE fnnode SET weight=" . $myweight . " WHERE nodeid=\"" . $row['nodeid'] . "\"";
         $NATS->DB->Query($uq);
         $uq = "UPDATE fnnode SET weight=" . $row['weight'] . " WHERE nodeid=\"" . ss($_REQUEST['nodeid']) . "\"";
         $NATS->DB->Query($uq);
         $msg = "Updated Node Display Order";
     } else {
         $msg = "No Higher/Lower Node";
     }
     break;
 case "move_before":
     // get nodeid of what to move before the and movebefore weight
     $q = "UPDATE fnnode SET weight=weight+1 WHERE weight>=" . ss($_REQUEST['move_before']);
     $msg = $q;
     $NATS->DB->Query($q);
     $q = "UPDATE fnnode SET weight=" . ss($_REQUEST['move_before']) . " WHERE nodeid=\"" . ss($_REQUEST['nodeid']) . "\"";
     $NATS->DB->Query($q);
     //$msg="Moved Node";
     break;
 case "reorderweight":
     $q = "SELECT nodeid,weight FROM fnnode ORDER BY weight ASC";
     $r = $NATS->DB->Query($q);
     $p = 1;
     while ($row = $NATS->DB->Fetch_Array($r)) {
         $uq = "UPDATE fnnode SET weight=" . $p . " WHERE nodeid=\"" . $row['nodeid'] . "\"";
         $NATS->DB->Query($uq);
         $p++;
     }
     $msg = "Reorder Completed";
     break;
 default:
Example #26
0
    echo "<td>(" . dtago($row['lastrunx']) . ")</td>";
    echo "<td>";
    if ($row['testrecord'] == 1 || $row['testtype'] == "ICMP") {
        echo "[ <a href=\"history.test.php?testid=L" . $row['localtestid'] . "\">" . $NATS->Lang->Item("history") . "</a> ]";
    } else {
        echo "&nbsp;";
    }
    echo "</td>";
    echo "</tr>";
}
echo "</table>";
echo "<br><br>";
if ($node['nsenabled'] == 1) {
    echo "<b class=\"subtitle\">" . $NATS->Lang->Item("nodeside.tests") . "</b><br><br>";
    echo "<table class=\"nicetable\">";
    $q = "SELECT * FROM fnnstest WHERE nodeid=\"" . ss($_REQUEST['nodeid']) . "\" AND testenabled=1 ORDER BY testtype";
    $r = $NATS->DB->Query($q);
    while ($row = $NATS->DB->Fetch_Array($r)) {
        echo "<tr><td>";
        if ($row['testname'] == "") {
            echo $row['testdesc'];
        } else {
            echo $row['testname'];
        }
        echo "</td>";
        echo "<td><b class=\"al" . $row['alertlevel'] . "\">" . oText($row['alertlevel']) . "</b></td>";
        echo "<td>(" . dtago($row['lastrunx']) . ")</td>";
        echo "<td>";
        if ($row['testrecord'] == 1) {
            echo "[ <a href=\"history.test.php?testid=N" . $row['nstestid'] . "\">" . $NATS->Lang->Item("history") . "</a> ]";
        } else {
$nodelist = array();
for ($a = 1; $a < $argc; $a++) {
    $nodelist[] = $argv[$a];
}
echo "test-threaded.sh: spawning node tester processes\n";
$q = "SELECT nodeid FROM fnnode WHERE nodeenabled>0";
if (count($nodelist) > 0) {
    $q .= " AND nodeid IN(";
    $first = true;
    foreach ($nodelist as $node) {
        if ($first) {
            $first = false;
        } else {
            $q .= ",";
        }
        $q .= "\"" . ss($node) . "\"";
    }
    $q .= ")";
} else {
    $q .= " AND masterid=\"\"";
}
$q .= " ORDER BY weight ASC";
$r = $NATS->DB->Query($q);
$spawn_delay = $NATS->Cfg->Get("test.spawndelay", 0);
//echo "Delay: ".$spawn_delay."\n";
if ($spawn_delay > 0) {
    $spawn_delay = $spawn_delay * 1000000;
}
// convert to us (microseconds / millionths)
//echo "Delay: ".$spawn_delay."\n";
$first = true;
Example #28
0
imagestring($im, 1, 2, ty($height - 18), $dhigh, $c_txt);
if (isset($_REQUEST['units'])) {
    if (strpos($_REQUEST['units'], "/") === false) {
        imagestring($im, 1, 2, ty($height - 28), $_REQUEST['units'], $c_txt);
    } else {
        $unit_array = explode("/", $_REQUEST['units']);
        $a = 0;
        foreach ($unit_array as $unit_string) {
            imagestring($im, 1, 2, ty($height - 28 - $a * 8), $unit_string, $c_txt);
            $a++;
        }
    }
}
// get data and draw
$q = "SELECT testvalue,alertlevel,recordx FROM fnrecord WHERE testid=\"" . ss($_REQUEST['testid']) . "\" ";
$q .= "AND recordx>=" . ss($startx) . " AND recordx<=" . ss($finishx) . " ORDER BY recordx ASC";
//$q.="LIMIT 0,100";
$r = $NATS->DB->Query($q);
$lastx = 0;
$lasty = 0;
$startval = 0;
$finishval = 0;
while ($row = mysqli_fetch_array($r)) {
    $x = posx($row['recordx']);
    //$y=posy($row['testvalue']);
    $val = $row['testvalue'];
    if ($val < 0) {
        $y = posy(0);
    } else {
        $y = posy($val);
    }
Example #29
0
    echo "</td></tr></form>";
}
echo "</table>";
End_Round();
echo "<br><br>";
$title = "<b class=\"sectitle\">" . $NATS->Lang->Item("alert.actions") . "</b> " . hlink("AlertAction", 12);
Start_Round($title, 600);
echo "<table border=0><form action=node.edit.php>";
echo "<input type=hidden name=nodeid value=" . $_REQUEST['nodeid'] . ">";
echo "<input type=hidden name=action value=save_actions>";
$q = "SELECT aaid,aname FROM fnalertaction";
$r = $NATS->DB->Query($q);
$c = 0;
while ($row = $NATS->DB->Fetch_Array($r)) {
    // has link?
    $lq = "SELECT nalid FROM fnnalink WHERE nodeid=\"" . ss($_REQUEST['nodeid']) . "\" AND aaid=" . ss($row['aaid']) . " LIMIT 0,1";
    $lr = $NATS->DB->Query($lq);
    if ($NATS->DB->Num_Rows($lr) > 0) {
        $s = " checked";
    } else {
        $s = "";
    }
    $NATS->DB->Free($lr);
    echo "<tr><td><input type=checkbox name=\"links[" . $c++ . "]\" value=\"" . $row['aaid'] . "\"" . $s . ">";
    echo "</td><td>" . $row['aaid'] . " - " . $row['aname'] . "</td></tr>";
}
$NATS->DB->Free($r);
echo "<tr><td colspan=\"2\"><input type=submit value=\"" . $NATS->Lang->Item("update.alert.actions") . "\"></td></tr>";
echo "</form></table>";
End_Round();
?>
Example #30
0
                 }
             }
         }
     }
     if ($mode == "xml") {
         lo("</alerts>");
     }
     break;
 case "testdata":
     // param = testid
     // param1 = startx
     // param2 = finishx
     $q = "SELECT recordx,testvalue,alertlevel FROM fnrecord WHERE testid=\"" . ss($_REQUEST['param'][$a]) . "\" AND ";
     $sx = smartx($_REQUEST['param1'][$a]);
     $fx = smartx($_REQUEST['param2'][$a]);
     $q .= "recordx>=" . ss($sx) . " AND recordx<=" . ss($fx) . " ORDER BY recordx ASC";
     $r = $NATS->DB->Query($q);
     $count = $NATS->DB->Num_Rows($r);
     if ($mode == "xml") {
         lo("<testdata testid=\"" . $_REQUEST['param'][$a] . "\" counter=\"" . $count . "\" query=\"" . $a . "\">");
     } else {
         if ($mode == "js") {
             lo($dataid . "[" . $a . "]=new Array();");
         }
     }
     $ctr = 0;
     while ($row = $NATS->DB->Fetch_Array($r)) {
         if ($mode == "xml") {
             lo(" <record recordx=\"" . $row['recordx'] . "\" alertlevel=\"" . $row['alertlevel'] . "\">" . $row['testvalue'] . "</record>");
         } else {
             lo($dataid . "[" . $a . "][" . $ctr . "]=new Array();");