Beispiel #1
0
 /**
  * api新增操作
  */
 public function doAdd()
 {
     $api = D('Api')->create();
     if (!$api) {
         $this->ajaxReturn(null, D('Api')->getError(), 'success:false');
     }
     //判断传入参数是否符合格式
     $api = D('Api')->parseRequestHeader($api);
     if (empty($api)) {
         $this->ajaxReturn(0, "请求头信息输入不正确,请检查格式!", "success:false");
     }
     $api['userId'] = getUserId();
     //判断传入参数是否重复
     $condition['host'] = $api['host'];
     $condition['method'] = $api['method'];
     $condition['path'] = $api['path'];
     $condition = $this->merge($condition);
     $temp = D('Api')->checkDuplicate($condition);
     if (!empty($temp)) {
         $this->ajaxReturn(0, "已经有相同的api存在,不允许重复录入", "success:false");
     }
     $ret = D('Api')->add($api);
     if ($ret) {
         $this->ajaxReturn($ret, "成功新增Api数据!", "success:true");
     } else {
         $this->ajaxReturn(0, "新增Api数据失败!", "success:false");
     }
 }
Beispiel #2
0
 /**
  * 执行新增操作
  */
 public function doAdd()
 {
     $plan = D("Plan");
     $data = M("Plan")->create();
     if (!empty($data['data'])) {
         $result = $plan->parseParam($data['data']);
         if (!$result) {
             $this->ajaxReturn(null, '您定义了私有参数,但是定义的格式有误!', 'success:false');
         }
         $ret = $plan->checkParam($result);
         if ($ret['status'] === false) {
             $this->ajaxReturn(null, "有部分参数定义无效[" . $ret['data'] . "]", 'success:false');
         }
     }
     if (empty($data['caseIds'])) {
         $this->ajaxReturn(null, "请添加测试用例", "success:false");
     }
     $data['caseIds'] = implode(',', $data['caseIds']);
     $data['appId'] = getAppId();
     $data['userId'] = getUserId();
     $data['updateTime'] = getCurrentTime();
     $ret = $plan->add($data);
     if (empty($ret)) {
         $this->ajaxReturn(null, '新增测试计划失败', 'success:false');
     }
     $this->ajaxReturn($ret, '成功', 'success:true');
 }
Beispiel #3
0
function CT_Start_Default($target)
{
    requireModel("blog.attachment");
    requireComponent("Eolin.PHP.Core");
    requireComponent("Textcube.Function.misc");
    global $blogid, $blogURL, $database, $service;
    $target .= '<ul>';
    $target .= '<li><a href="' . $blogURL . '/owner/entry/post">' . _t('새 글을 씁니다') . '</a></li>' . CRLF;
    $latestEntryId = Setting::getBlogSettingGlobal('LatestEditedEntry_user' . getUserId(), 0);
    if ($latestEntryId !== 0) {
        $latestEntry = CT_Start_Default_getEntry($blogid, $latestEntryId);
        if ($latestEntry != false) {
            $target .= '<li><a href="' . $blogURL . '/owner/entry/edit/' . $latestEntry['id'] . '">' . _f('최근글(%1) 수정', htmlspecialchars(Utils_Unicode::lessenAsEm($latestEntry['title'], 10))) . '</a></li>';
        }
    }
    if (Acl::check('group.administrators')) {
        $target .= '<li><a href="' . $blogURL . '/owner/skin">' . _t('스킨을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/sidebar">' . _t('사이드바 구성을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/setting">' . _t('블로그에 표시되는 값들을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/entry/category">' . _t('카테고리를 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/plugin">' . _t('플러그인을 켜거나 끕니다') . '</a></li>' . CRLF;
    }
    if ($service['reader'] != false) {
        $target .= '<li><a href="' . $blogURL . '/owner/network/reader">' . _t('RSS 리더를 봅니다') . '</a></li>' . CRLF;
    }
    $target .= '</ul>';
    return $target;
}
Beispiel #4
0
function authenticate(\Slim\Route $route)
{
    // Getting request headers
    $headers = apache_request_headers();
    $response = array();
    $app = \Slim\Slim::getInstance();
    // Verifying Authorization Header
    if (isset($headers['Authorization'])) {
        // get the api key
        $api_key = $headers['Authorization'];
        // validating api key
        if (!ValidateAPIKey($api_key)) {
            // api key is not present in users table
            $response["error"] = true;
            $response["message"] = "Access Denied. Invalid API key";
            echoRespnse(401, $response);
            $app->stop();
        } else {
            global $user_id;
            // get user primary key id
            $user_id = getUserId($api_key);
        }
    } else {
        // api key is missing in header
        $response["error"] = true;
        $response["message"] = "API key is missing.";
        echoRespnse(400, $response);
        $app->stop();
    }
}
 function getQueryList($sEmployeeId = '', $sDept = '', $sStat = '', $rType = '')
 {
     $sCondition = '';
     $sDeptCondition = '';
     $sStatCondition = '';
     $sRtype = '';
     if (!empty($sEmployeeId)) {
         $sCondition = "and e.id = {$sEmployeeId}";
     }
     if (!empty($sStat) && strpos($sStat, "All") === false) {
         $sStatCondition = "and g.status = '{$sStat}'";
     }
     if (!empty($sDept) && $sDept != -1) {
         $sDeptCondition = "and e.department_id = {$sDept}";
     }
     if (!empty($rType)) {
         $sRtype = '';
     }
     $iProfileId = getUserId($this);
     if (getRole($this) == 2) {
         $sdep = $this->mod->getDeptOfEmployee($iProfileId);
         $sDeptCondition = "and (e.department_id = {$sdep[0]->department_id})";
     } else {
         if (getRole($this) == 3) {
             $sDeptCondition = "and (e.id = {$iProfileId})";
         }
     }
     $query = $this->db->query("\r\n                select \r\n                    g.*,\r\n                    concat(e.fname,' ',e.lname) as employee,\r\n                    datediff(g.end_date, g.start_date) as leaves                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              \r\n                from \r\n                    leave_transactions g, \r\n                    employees e,\r\n                    employment em \r\n                where (g.employment_id = em.id and em.employee_id = e.id) \r\n                    {$sCondition} \r\n                    {$sStatCondition} \r\n                    {$sDeptCondition}\r\n                order by g.filing_date desc");
     $aResult = $query->result();
     return $query->result();
 }
 public function getOSData()
 {
     $cols = array('meta1', 'clicks', 'click_throughs', 'click_through_rates', 'leads', 'conv', 'payout', 'epc', 'income');
     $sql = 'select adv.platform_id, ';
     $sql .= getReportGeneralSelects() . 'from ';
     $sql .= getReportFilters('platforms/os', 'left join bt_s_clicks_advanced as adv on (click.click_id=adv.click_id)');
     $sql .= ' and adv.platform_id > 0 group by adv.platform_id ';
     $result = DB::getRows($sql);
     $cnt = count($result);
     DB::query("delete from bt_c_statcache where user_id='" . DB::quote(getUserId()) . "'  and type='platos'");
     $bulk = new DB_Bulk_Insert('bt_c_statcache', array('user_id', 'type', 'clicks', 'click_throughs', 'click_through_rates', 'leads', 'conv', 'payout', 'epc', 'income', 'meta1'));
     foreach ($result as $row) {
         $row['platform_name'] = Browser::getPlatformName($row['platform_id']);
         if (!$row['platform_name']) {
             $row['platform_name'] = '[unknown os]';
         }
         $bulk->insert(array(DB::quote(getUserId()), "'platos'", $row['clicks'], $row['click_throughs'], $row['click_through_rates'], $row['leads'], $row['conv'], $row['payout'], $row['epc'], $row['income'], "'" . DB::quote($row['platform_name']) . "'"));
     }
     $bulk->execute();
     $sql = "select * from bt_c_statcache where user_id='" . DB::quote(getUserId()) . "'  and type='platos' ";
     $sql .= getReportOrder($cols);
     $sql .= getReportLimits();
     $result = DB::getRows($sql);
     return array('data' => $result, 'cnt' => $cnt, 'cols' => $cols);
 }
 function getlist_json_employee($employee, $bool)
 {
     $list = $this->base_model->getLeaveCreditsByEmployee($employee, $bool);
     $date = $this->mod->getHireDateByEmployee(getUserId($this));
     $arrayList = objectToArray($list);
     $newArray = array();
     foreach ($arrayList as $key => $value) {
         $dayval = $value['days'];
         $usercount = 0;
         if ($value['date'] != '0000-00-00' && $value['date'] != '') {
             $hired = strtotime($date);
             $setdate = strtotime($value['date']);
             if ($hired > $setdate) {
                 $dayval = $value['days_after'];
             } else {
                 if ($hired < $setdate) {
                     $dayval = $value['days_before'];
                 }
             }
         }
         if ($value['schoolyear'] === getSchoolYear($this)) {
             $usercount = $value['usecount'];
         }
         array_push($newArray, array('id' => $value['id'], 'ltid' => $value['ltid'], 'title' => $value['title'], 'days' => $dayval, 'date' => $value['date'], 'days_before' => $value['days_before'], 'days_after' => $value['days_after'], 'usecount' => $usercount));
     }
     echo json_encode($newArray);
 }
Beispiel #8
0
function CT_Start_Default($target)
{
    importlib("model.blog.attachment");
    $context = Model_Context::getInstance();
    $blogURL = $context->getProperty('uri.blog');
    $blogid = $context->getProperty('blog.id');
    $target .= '<ul>';
    $target .= '<li><a href="' . $blogURL . '/owner/entry/post">' . _t('새 글을 씁니다') . '</a></li>' . CRLF;
    $latestEntryId = Setting::getBlogSettingGlobal('LatestEditedEntry_user' . getUserId(), 0);
    if ($latestEntryId !== 0) {
        $latestEntry = CT_Start_Default_getEntry($blogid, $latestEntryId);
        if ($latestEntry != false) {
            $target .= '<li><a href="' . $blogURL . '/owner/entry/edit/' . $latestEntry['id'] . '">' . _f('최근글(%1) 수정', htmlspecialchars(Utils_Unicode::lessenAsEm($latestEntry['title'], 10))) . '</a></li>';
        }
    }
    if (Acl::check('group.administrators')) {
        $target .= '<li><a href="' . $blogURL . '/owner/skin">' . _t('스킨을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/sidebar">' . _t('사이드바 구성을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/setting">' . _t('블로그에 표시되는 값들을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/entry/category">' . _t('카테고리를 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/plugin">' . _t('플러그인을 켜거나 끕니다') . '</a></li>' . CRLF;
    }
    if ($context->getProperty('service.reader', false) != false) {
        $target .= '<li><a href="' . $blogURL . '/owner/network/reader">' . _t('RSS 리더를 봅니다') . '</a></li>' . CRLF;
    }
    $target .= '</ul>';
    return $target;
}
 function getListByQuery($query, $department, $rtype = '')
 {
     $sDeptCondition = '';
     $sCondition = '';
     $sYear = getSchoolYear($this);
     if (getRole($this) == 2) {
         $sDept = $this->mod->getDeptOfEmployee(getUserId($this));
         $sDept = $sDept[0]->department_id;
         $sDeptCondition = "employees.department_id = {$sDept} and";
     }
     $sDeptCondition = '';
     $rCondition = '';
     if (getRole($this) != 2 && ($department != -1 && !empty($department))) {
         $sDeptCondition = "(employees.department_id = {$department}) and";
     }
     if (!empty($query)) {
         $sCondition = "(employees.empno like '%{$query}%' or employees.fname like '%{$query}%' or employees.lname like '%{$query}%') and";
     }
     $iProfileId = getUserId($this);
     if (getRole($this) == 2) {
         $sdep = $this->mod->getDeptOfEmployee($iProfileId);
         $sDeptCondition = "(employees.department_id = {$sdep[0]->department_id}) and ";
     }
     if (!empty($rtype)) {
         if (strpos($rtype, 'nal') !== false) {
             $rCondition = "and if(emp_types.time_unit = 'd', \r\n\r\n                    (select (sum(abs(datediff(g.end_date, g.start_date)) - abs(g.end_date_hw + g.start_date_hw)) +1)\r\n                        from \r\n                            leave_transactions g, leave_credits \r\n                        where \r\n\r\n                            employment_id = employment.id and \r\n                            leave_credits.id = leave_credits_id and \r\n                                                        leave_credits.is_base = 1 and g.schoolyear = '{$sYear}'),\r\n\r\n\r\n\r\n\r\n                    round((        select (sum(timediff(g.end_time,g.start_time)))/10000 from \r\n                            leave_transactions g \r\n                        where \r\n\r\n                            g.employment_id = employment.id and g.schoolyear = '{$sYear}'\r\n\r\n                    ),2)) is null";
         }
     }
     $query = $this->db->query("\r\n            select \r\n                employees.id as myid, \r\n                employment.*, \r\n                employees.*,\r\n                ranks.*,\r\n                roles.*,\r\n                departments.*,\r\n                emp_types.*,\r\n                status.*,\r\n                emp_types.time_unit as timeunit\r\n            from \r\n                employment, \r\n                emp_types, \r\n                status, \r\n                employees, \r\n                emp_types_stat,\r\n                ranks,\r\n                departments,\r\n                roles\r\n            where \r\n                ({$sCondition} {$sDeptCondition} \r\n                employment.emp_types_stat_id = emp_types_stat.id and\r\n                \r\n                emp_types.id = emp_types_stat.emp_types_id and \r\n                \r\n                status.id = emp_types_stat.status_id and \r\n                \r\n                employment.employee_id = employees.id and\r\n                \r\n                employees.rank_id = ranks.id and\r\n                \r\n                employees.department_id = departments.id and\r\n                \r\n                employees.role_id = roles.id) {$rCondition} \r\n\r\n                group by employees.department_id, lname, fname\r\n                ");
     if ($query->num_rows() > 0) {
         return $query->result();
     } else {
         return "";
     }
 }
Beispiel #10
0
 public function edit()
 {
     $this->checkAuth();
     if ($_POST) {
         $map['user_id'] = array('eq', getUserId());
         $user = M('auth_user');
         $user->startTrans();
         $user->username = $_POST['username'];
         $user->where('id = ' . getUserId())->save();
         $profile = M('profile');
         $profile->pic = $_POST['pic'];
         $profile->location = $_POST['location'];
         $profile->realname = $_POST['realname'];
         $profile->aboutme = $_POST['aboutme'];
         if ($_POST['birthday']) {
             $profile->birthday = $_POST['birthday'];
         } else {
             $profile->birthday = null;
         }
         $profile->where($map)->save();
         $user->commit();
     }
     $map['u.id'] = array('eq', getUserId());
     $profile = M('auth_user u')->join('left join profile p on p.user_id = u.id ')->where($map)->field('u.id,u.username,u.date_joined,u.email,p.pic,p.reputation,p.location,p.realname,p.aboutme,p.birthday')->select();
     $this->assign('profile', $profile[0]);
     $this->display();
 }
Beispiel #11
0
 public function verifyPurchase($userId, $itemId, $transactions)
 {
     $transactionId = null;
     $transactions = json_decode(stripslashes($transactions));
     for ($i = 0; $i < count($transactions); $i++) {
         if ($transactions[$i]->itemId == $itemId) {
             $transactionId = $transactions[$i]->transactionId;
         }
     }
     if ($transactionId) {
         $postDetails = array(USER => UID, PWD => PASSWORD, SIGNATURE => SIG, METHOD => "GetTransactionDetails", VERSION => VER, TRANSACTIONID => $transactionId);
         $arrPostVals = array_map(create_function('$key, $value', 'return $key."=".$value."&";'), array_keys($postDetails), array_values($postDetails));
         $postVals = rtrim(implode($arrPostVals), "&");
         $response = parseString(runCurl(URLBASE, $postVals));
         $custom = explode("%2c", $response["CUSTOM"]);
         if (getUserId() == $custom[0] && $itemId == $custom[1]) {
             // ADDED LINE TO GET KS SESSION
             $ks = getSession($itemId, $userId);
             // ADD KS to ARRAY
             $returnObj = array(success => true, error => "", transactionId => $response["TRANSACTIONID"], orderTime => $response["ORDERTIME"], paymentStatus => $response["PAYMENTSTATUS"], itemId => $itemId, userId => $userId, ks => $ks);
         }
     } else {
         $returnObj = array(success => false, error => "Item not found in transaction history");
     }
     echo json_encode($returnObj);
 }
 function changePassword($aDetails)
 {
     $password = md5($aDetails['password']);
     $id = getUserId($this);
     $comp = $this->db->query("UPDATE `employees` SET `password` = '{$password}' WHERE id = {$id}");
     return true;
 }
Beispiel #13
0
 public function addAction()
 {
     $task = new Todo();
     $task->title = $this->request->getPost('title');
     $task->description = $this->request->getPost('description');
     $task->user_id = getUserId();
     $task->save();
     $this->dispatcher->forward(['action' => 'index']);
 }
Beispiel #14
0
 /**
  * 新增测试报告
  * @param 测试用例id $caseId
  * @return 新增数据的id
  */
 public function addReport($objId, $type, $prid = -1)
 {
     $data['objId'] = $objId;
     $data['userId'] = getUserId();
     $data['status'] = ReportModel::RUNNING;
     $data['type'] = $type;
     $data['prid'] = $prid;
     return $this->add($data);
 }
 public function indexAction()
 {
     $this->loadModel("ClickModel");
     $model = new ClickModel();
     $top_stats = $model->dashboardTopStats(getUserId());
     $this->setVar("title", "Dashboard");
     $this->setVar("top_stats", $top_stats);
     $this->render("dashboard/dashboard");
 }
Beispiel #16
0
function showInformesDirectores() {
	$params = array(":idusuario" => getUserId());
	$sql =
		"SELECT 1
			 FROM web.wpe_permisosintranet
			WHERE pe_idusuario = :idusuario
				AND pe_idpagina = 78";
	return existeSql($sql, $params);
}
Beispiel #17
0
 protected function idisplay($title)
 {
     needLogin();
     $model = D('User');
     $uid = getUserId();
     $data = $model->find($uid);
     $this->assign("user", $data);
     $this->assign("tpname", 'inc:uc_order_' . ACTION_NAME);
     $this->display('User:user', $title);
 }
Beispiel #18
0
function conciergeStatus()
{
    $status = clearUser();
    if ($status === "user cleared.") {
        $userId = getUserId($_POST["user"]);
        parseInputs($userId);
    } else {
        echo $status;
    }
}
Beispiel #19
0
function isUserLoggedIn()
{
    $userId = getUserId();
    if ($userId != -1) {
        $account = DB::queryFirstRow("SELECT Id, Status FROM CWM_User WHERE Id=%?", $userId);
        $uidHashFromServer = sha1($account['Id']);
        $uidHash = getUserIdHash();
        return isset($uidHash) && $uidHashFromServer == $uidHash && !is_null($account) && $account['Status'] == 1;
    }
    return false;
}
 function _buildQuery()
 {
     $query = DBModel::getInstance();
     $query->reset('UserSettings');
     $query->setQualifier('userid', 'equals', getUserId());
     $query->setQualifier('name', 'equals', $this->name, false);
     if (isset($this->value)) {
         $query->setAttribute('value', $this->value, true);
     }
     return $query;
 }
Beispiel #21
0
function matchTrip($tripId)
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $myTripQuery = "SELECT * FROM " . $db_mysql_table_name . " WHERE id='" . $tripId . "'";
    $tripQuerySuccess = mysqli_query($link, $myTripQuery);
    if ($tripQuerySuccess) {
        if (mysqli_num_rows($tripQuerySuccess) == 1) {
            $matchTrip = mysqli_fetch_assoc($tripQuerySuccess);
        } else {
            $response = array("status" => 1, "error" => "Duplicate id in DB ");
            echo json_encode($response);
        }
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE state=0" . " AND id!='" . $tripId . "'" . " AND date='" . getTripDate($matchTrip) . "'";
    // Ensures rides are on the same day.
    $success = mysqli_query($link, $query);
    $rows = array();
    if ($success) {
        while ($row = mysqli_fetch_assoc($success)) {
            if (timeCoincides($row, $matchTrip)) {
                // Ensures that they start at around the same time.
                if (getDistance(getDestAddr($row), getDestAddr($matchTrip)) <= 3000) {
                    if (getDistance(getSourceAddr($row), getSourceAddr($matchTrip)) <= 3000) {
                        $rows[] = $row;
                    }
                }
            }
        }
        $response = array("status" => 0, "data" => $rows);
        $response = json_encode($response);
        foreach ($rows as $match) {
            send_email(getUserId($match), $response);
        }
        if (!empty($playerlist)) {
            // Do not send email if no match found
            send_email(getMailId(), $response);
        } else {
            // Send email of no match if needed.
        }
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
}
 function getpage($p)
 {
     $data = initializeData($this, "Leave Transactions");
     $data['page_url'] = main_url() . 'leave_transactions';
     if ($p == 'form') {
         $this->load->model('leave_credits_model');
         $list2 = $this->leave_credits_model->getLeaveCreditsByEmployee(getUserId($this), 1);
         $sJs = 'class="form-control form-text"';
         $data['leave_list'] = generateSelectUI($this, $list2, 'leave_credits_id', 'id', 'title', '', $sJs);
     }
     $data['eid'] = $this->mod->getEmploymentId(getUserId($this));
     renderPage($this, $this->table . '/' . $p, $data);
 }
function createAccount($connect, $name = "", $email)
{
    if (getUserId($connect, $email) > 0) {
        return 3;
    } else {
        $query = "INSERT INTO `users` (`id`, `name`, `password`, `email`,`is_google`,`last_login`) VALUES (NULL,'{$name}',NULL,'{$email}',1,CURRENT_TIMESTAMP)";
        $query_run = mysqli_query($connect, $query);
        if ($query_run) {
            return 1;
        } else {
            return 0;
        }
    }
}
function logQueueEnter($deviceID, $name, $ip, $raceID, $randomRaceString, $apiKey)
{
    require 'config.php';
    $con = mysqli_connect($config_var['mySQLHost'], $config_var['mySQLLogUsername'], $config_var['mySQLLogPassword'], $config_var['mySQLLogDatabase']);
    if (mysqli_connect_errno()) {
        echo "Failed to connect to log MySQL.";
        return;
    }
    $user_id = getUserId($con, $deviceID);
    $now = time();
    $name_id = getStringId($con, $name);
    $ip_id = getStringId($con, $ip);
    $raceID = (int) $raceID;
    $randomRaceString_id = getStringId($con, $randomRaceString);
    $apiKey_id = getStringId($con, $apiKey);
    mysqli_query($con, "INSERT INTO `entered_queue` (`user`, `datetime`, `name`, `ip`, `race`, `random_race_string`, `api_key`)\r\n\t\t\tVALUES ({$user_id}, {$now}, {$name_id}, {$ip_id}, {$raceID}, {$randomRaceString_id}, {$apiKey_id})");
}
Beispiel #25
0
 function base()
 {
     //$this->load->model('leave_transactions_model','mods');
     //$result = $this->mods->getTransactionSummary(getUserId($this));
     //var_dump($result);
     //exit;
     $data = initializeData($this, "Profile");
     $data['data'] = getUserData($this);
     $data['title_here'] = $data['data'][0]->lname . ', ' . $data['data'][0]->fname . ' ' . $data['data'][0]->mname . ' (' . $data['data'][0]->empno . ')';
     //error_reporting(E_ALL);
     $sDept = $this->mod->getDeptOfEmployee(getUserId($this));
     $aDept = $this->mod->getObjectById('departments', 'id', $sDept[0]->department_id);
     $sStat = $this->mod->getStatOfEmployee(getUserId($this));
     $aStat = $this->mod->getObjectById('status', 'id', $sStat[0]->id);
     $sEmp = $this->mod->getEmpTypeOfEmployee(getUserId($this));
     $aEmp = $this->mod->getObjectById('emp_types', 'id', $sEmp[0]->id);
     //var_dump($aDept);
     //var_dump($aStat);
     //var_dump($aEmp);
     $data['leave_balance'] = $this->mod->getLeaveBalanceOfEmployee(getUserId($this));
     $data['own_department'] = $aDept[0]->department_name;
     $data['own_employment'] = $aEmp[0]->emp_description . ' (' . $aStat[0]->status_name . ')';
     /*function getEmpTypeOfEmployee($employee_id){   
           $query = $this->db->query("SELECT de.id FROM emp_types de,employment e,emp_types_stat d WHERE e.employee_id = {$employee_id} AND e.emp_types_stat_id = d.id AND d.emp_types_id = de.id");
           return $query->result();        
       }
       function getStatOfEmployee($employee_id){   
           $query = $this->db->query("SELECT s.id FROM status s,employment e,emp_types_stat d WHERE e.employee_id = {$employee_id} AND e.emp_types_stat_id = d.id AND d.status_id = s.id");
           return $query->result();        
       }
       
       
       function getDeptOfEmployee($employee_id){   
           $query = $this->db->query("SELECT department_id FROM employees WHERE id = {$employee_id}");
           return $query->result();        
       }
       function getRankOfEmployee($employee_id){   
           $query = $this->db->query("SELECT ranks_id FROM employees WHERE id = {$employee_id}");
           return $query->result();        
       } 
       function getRoleOfEmployee($employee_id){   
           $query = $this->db->query("SELECT roles_id FROM employees WHERE id = {$employee_id}");
           return $query->result();        
       } */
     renderPage($this, $this->table . '/base', $data);
 }
Beispiel #26
0
 function form()
 {
     $data = initializeData($this, "Employee Form");
     $gen = '';
     $bt = '';
     $dept = '';
     $stat = '';
     $rank = '';
     $role = '';
     $deps = '';
     if (isset($_GET['id'])) {
         if (!empty($_GET['id'])) {
             //var_dump($this->mod->getObjectById($this->table, 'id', $_GET['id']));
             //exit;
             $data['data'] = $this->mod->getObjectById($this->table, 'id', $_GET['id']);
             $gen = $data['data'][0]->gender;
             $bt = $data['data'][0]->blood_type;
             $dept = $this->mod->getEmpTypeOfEmployee($data['data'][0]->id);
             $stat = $this->mod->getStatOfEmployee($data['data'][0]->id);
             $dept = $dept[0]->id;
             $stat = $stat[0]->id;
             $rank = $data['data'][0]->rank_id;
             $role = $data['data'][0]->role_id;
             $deps = $data['data'][0]->department_id;
             $data['datehired'] = $this->mod->getHireDateByEmployee(getUserId($this));
             $data['employment'] = $this->mod->getEmployment($data['data'][0]->id);
         }
     }
     $sJs = 'class="form-control form-text"';
     $rolelist = $this->roles_model->getObjectList('');
     $rankslist = $this->ranks_model->getObjectList('');
     $departmentslist = $this->departments_model->getObjectList('');
     $data['role_list'] = generateSelectUI($this, $rolelist, 'role_id', 'id', 'role_name', $role, $sJs);
     $data['rank_list'] = generateSelectUI($this, $rankslist, 'rank_id', 'id', 'rank_name', $rank, $sJs);
     $data['department_list'] = generateSelectUI($this, $departmentslist, 'department_id', 'id', 'department_name', $deps, $sJs);
     $list1 = $this->emp_types_model->getObjectList('');
     $list2 = $this->status_model->getObjectList('');
     $data['emptypes_list'] = genEmpTypesListUI($this, $list1, $dept);
     $data['status_list'] = genStatusListUI($this, $list2, $stat);
     $genderlist = $this->mod->getEnumValues('employees', 'employees', 'gender');
     $bloodtypelist = $this->mod->getEnumValues('employees', 'employees', 'blood_type');
     $data['gender_list'] = form_dropdown('gender', $genderlist, $gen, $sJs);
     $data['bloodtype_list'] = form_dropdown('blood_type', $bloodtypelist, $bt, $sJs);
     renderPage($this, $this->table . '/form', $data);
 }
 public function index()
 {
     islogin();
     $this->assign('searchurl', U('Search/index'));
     $model = new \Home\Model\MovieModel();
     $account = M('account');
     $user_id = getUserId();
     //var_dump($user_id);
     $join = ['left join schedule on schedule.schedule_id=account.schedule_id', 'left join movie on movie.movie_id=schedule.movie_id'];
     $userinfo = $model->select('user', 'user_id=' . $user_id);
     $where = 'account.user_id=' . $user_id;
     $filed = 'account_id,user_id,buy_time,schedule.schedule_id,name,schedule.movie_id,date,price';
     $records = $account->join($join)->where($where)->field($filed)->select();
     //var_dump($userinfo);
     $this->assign('records', $records);
     $this->assign('userinfo', $userinfo[0]);
     $this->display();
 }
Beispiel #28
0
function addUser($username, $password)
{
    // insert into users
    $query = "insert into `users` (`name`) values (\"{$username}\") ";
    if (preparedStatement($query)) {
        // get new user id
        $userId = getUserId($username);
        // hash password
        // insert into pass
        $query = "insert into `pass` (`user`, `word`) ";
        $query .= "values (" . $userId . ",\"" . $password . "\")";
        // return true or false
        return booleanReturn($query);
    } else {
        // something went wrong
        // delete user name from db?
        return false;
    }
}
 function vote($vote_type, $add = false)
 {
     $this->checkAuth();
     $answer = M('answer');
     $answer->startTrans();
     $uid = getUserId();
     $id = $_POST['id'];
     $map['user_id'] = array('eq', $uid);
     $map['answer_id'] = array('eq', $id);
     //删除相关记录
     M('avote')->where($map)->delete();
     //添加相关记录
     $r1 = true;
     if ($add) {
         $av = M('avote');
         $av->user_id = $uid;
         $av->answer_id = $id;
         $av->ct = date('Y-m-d H:i:s');
         $av->vote_type = $vote_type;
         $r1 = $av->add();
     }
     //统计
     $mapav['answer_id'] = array('eq', $id);
     $mapav['vote_type'] = array('eq', VOTEUP);
     $vote_up_count = M('avote')->where($mapav)->count();
     $mapav['vote_type'] = array('eq', VOTEDOWN);
     $vote_down_count = M('avote')->where($mapav)->count();
     $count = $vote_up_count - $vote_down_count;
     $answer->where(' id = ' . $id)->setField('votes', $count);
     if ($r1) {
         $answer->commit();
         $result['id'] = $id;
         $result['result'] = true;
         $result['votes'] = $count;
     } else {
         $answer->rollback();
         $result['result'] = false;
     }
     echo json_encode($result);
 }
 public function buy()
 {
     //  var_dump($_POST);
     //  $lockModel = new \Think\Model(); // 实例化一个model对象 没有对应任何数据表
     $model = new \Home\Model\MovieModel();
     $schedule_id = I('post.schedule_id');
     $tickets = I('post.seats');
     $user_id = getUserId();
     // $account = M('account');
     //$lockModel = M();
     M()->startTrans();
     //$lockModel->lockTable('account',1);
     $seats = $model->select('account', '', '', '', true);
     $tflag = true;
     foreach ($tickets as $ticket) {
         $flag = true;
         foreach ($seats as $seat) {
             if ($seat['col'] == $ticket['col'] && $seat['row'] == $ticket['row']) {
                 $flag = false;
                 break;
             }
         }
         if ($flag) {
             $data = ['buy_time' => date('Y-m-d h-i-s'), 'col' => $ticket['col'], 'row' => $ticket['row'], 'user_id' => $user_id, 'schedule_id' => $schedule_id];
             //var_dump($data);
             $model->addData('account', $data);
         } else {
             M()->rollback();
             echo '{"success":0}';
             $tflag = false;
             break;
         }
     }
     if ($tflag) {
         M()->commit();
         echo '{"success":1}';
         //  echo '{"success":1}';
     }
 }