Exemplo n.º 1
0
 public static function resetCrontab()
 {
     $cron_file = 'cron.txt';
     $cron = new FileWriter($cron_file, 'a');
     $setSessionPath = '/home1/enderrac/SpirePHP/setSessionWinner.php';
     $stm = "SELECT EXTRACT(MINUTE from end_ts) as minute, " . "\tEXTRACT(HOUR from end_ts) as hour, " . "\tEXTRACT(day from end_ts) as day_of_month, " . "\tEXTRACT(MONTH from end_ts) as month, " . "\tEXTRACT(dow from end_ts) as day_of_week, " . "\tid " . "FROM SPIRE.SESSIONS ";
     $result = ConnDB::query_db($stm);
     $fnHash = null;
     if (!$result) {
         $cron->writeLine("ERROR");
         $fnHash = MyUtil::fnOk(false, "SQL Error getting Session Info", null);
     } else {
         while ($row = pg_fetch_assoc($result)) {
             $cron->writeLine($row['minute'] . " " . $row['hour'] . " " . $row['day_of_month'] . " " . $row['month'] . " " . $row['day_of_week'] . " {$setSessionPath} " . $row['id']);
         }
         $rmCron = shell_exec('crontab -r');
         if ($rmCron != null) {
             $setCron = shell_exec('crontab $cron_file');
             if ($setCron != null) {
                 $delCronTmp = shell_exec('rm $cron_file');
                 if ($delCronTmp != null) {
                     $fnHash = MyUtil::fnOk(true, "Updated Cron and Session", null);
                 }
                 $fnHash = MyUtil::fnOk(false, "Cron Tmp File not Deleted", null);
             }
             $fnHash = MyUtil::fnOk(false, "Cron not set to tmp", null);
         } else {
             $fnHash = MyUtil::fnOk(false, "Original cron not deleted", null);
         }
         return $fnHash;
     }
     return $fnHash;
 }
Exemplo n.º 2
0
 public static function close_conn()
 {
     if (self::$is_conn_set) {
         pg_close(self::$conn);
         self::$is_conn_set = false;
     }
 }
Exemplo n.º 3
0
 private static function saveToken($user_id, $token, $session_id)
 {
     $stm = "INSERT INTO " . self::$table_name . "(USER_ID, TOKEN_ID, SESSION_ID) VALUES ('{$user_id}', '{$token}', CAST(COALESCE(nullIf('{$session_id}',''),'0') as integer))";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Token Inserted", $result);
 }
Exemplo n.º 4
0
 /**
  * Статическая функция, которая возвращает
  * экземпляр класса или создает новый при
  * необходимости
  *
  * @return DBH
  */
 public static function connDB()
 {
     // проверяем актуальность экземпляра
     if (null === self::$_DBH) {
         // создаем новый экземпляр
         self::$_DBH = new self();
     }
     // возвращаем созданный или существующий экземпляр
     return self::$_DBH;
 }
<?php

require "system.smarty.inc.php";
//包含Smarty配置类
require "system.class.inc.php";
//包含数据库连接和操作类
$connobj = new ConnDB("mysql", "localhost", "louss", "123456", "online_meal_data");
//数据库连接类实例化
$conn = $connobj->GetConnId();
//执行连接操作,返回连接标识
$admindb = new AdminDB();
//数据库操作类实例化
$seppage = new SepPage();
//分页类实例化
$smarty = new SmartyProject();
//调用smarty模板
Exemplo n.º 6
0
 private static function hasUserVoted($user, $session)
 {
     $stm = "SELECT COUNT(*) as is_vote FROM " . self::$table_name . " WHERE SESSION_ID = {$session} AND USER_ID = {$user} AND INSERT_DT = CURRENT_DATE ";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     $row = pg_fetch_assoc($result);
     return MyUtil::fnOk(true, "", $row['is_vote'] == 1);
 }
Exemplo n.º 7
0
<?php 
require "./conn/config.php";
define('pagesize', 4);
/************mysql*************/
$DB = new ConnDB(dbtype, host, user, pwd, dbname);
$conn = $DB->GetConnId();
$admindb = new AdminDB();
$seppage = new SepPage();
$seppagep = new SepPage();
$unhtml = new UseFun();
$teacher_id = array();
$course_id = array();
$teachermatch = false;
/******************先判断搜索内容是否为老师名字 *******************/
if ($newstr[0]) {
    $teasql = "select * from t_teacher where m_teacher like '{$newstr['0']}%'";
    for ($j = 1; $j < count($newstr); $j++) {
        $teasql .= " or m_teacher like '{$newstr[$j]}%'";
    }
    $rs = $conn->query($teasql);
    if ($rs) {
        while ($row = mysqli_fetch_array($rs)) {
            $teacher_id[] = $row['m_teacherid'];
        }
        if (count($teacher_id)) {
            $teachermatch = true;
        } else {
            $teachermatch = false;
        }
    } else {
        $teachermatch = false;
Exemplo n.º 8
0
//
//if (isset($_SESSION['unc']) && $_SESSION['unc']!=''){    //用户登录后指定不显示静态页的php页面
//    $sessionArray = explode(',', $arrayIni['sessionArray']);
//}else{
//    $sessionArray = null;
//}
//
//if ($makeStaticPage->isLocationToStaticPage($nowPage, $pageArray, $sessionArray)) {
//    header('location:' . $makeStaticPage->getStaticPagePath());    //将当前请求的页面定位到与之对应的静态页
//	exit();
//}
//
//$makeStaticPage->pageBegin();
/*************************************************************************/
require_once 'library/ConnDB.php';
require_once 'library/AdminDB.php';
require_once 'library/PageDB.php';
require_once 'library/SmartyConfig.php';
require_once 'library/Cart.php';
require_once 'library/Util.php';
$connDB = new ConnDB($arrayIni['dbType'], $arrayIni['host'], $arrayIni['userName'], $arrayIni['password'], $arrayIni['dbName'], $arrayIni['isDebug']);
$connID = $connDB->getConnID();
$adminDB = new AdminDB();
$pageDB = new PageDB();
$smarty = new SmartyConfig();
$util = new Util();
$smarty->register_object('util', $util, null, false);
/*********************需在页面最下加上如下语句*****************************
 * $connDB->closeConnID();
 * $makeStaticPage->pageEnd();
***************************************************************************/
Exemplo n.º 9
0
 public static function getArtistFromUser($orig_id)
 {
     //id must be an integer
     $id = MyUtil::parseInt($orig_id);
     if (!$id) {
         return MyUtil::fnOk(false, "Must be a valid id: {$orig_id}", null);
     }
     $stm = " SELECT art.* " . " FROM spire.user_to_artist ua " . "    JOIN spire.artists art ON ua.artist_id = art.id " . " WHERE ua.user_id = {$id} ";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     $retArray = [];
     while ($row = pg_fetch_assoc($result)) {
         array_push($retArray, $row);
     }
     return MyUtil::fnOk(true, "Found Artist Id", $retArray);
 }
Exemplo n.º 10
0
 public static function getArtistIdFromUser($id)
 {
     //id must be an integer
     $id = MyUtil::parseInt($id);
     if (!$id) {
         return MyUtil::fnOk(false, "Must be a valid id: {$id}", null);
     }
     $stm = "SELECT artist_id from spire.user_to_artist where user_id = {$id} ";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Found Artist Id", $result['artist_id']);
 }
Exemplo n.º 11
0
 public static function deleteSession($id)
 {
     //id must be an integer
     $orig_id = $id;
     $id = MyUtil::parseInt($id);
     if ($id == null) {
         return MyUtil::fnOk(false, "Must be a valid id: {$orig_id}", null);
     }
     $stm = "DELETE FROM " . self::$table_name . " WHERE id = {$id}";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Session Deleted", $result);
 }
Exemplo n.º 12
0
<?php

require "ConnDB.class.inc.php";
$host = SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT;
$dbuser = SAE_MYSQL_USER;
$dbpwd = SAE_MYSQL_PASS;
$dbname = SAE_MYSQL_DB;
$connClass = new ConnDB("mysql", "{$host}", "{$dbuser}", "{$dbpwd}", "{$dbname}");
$operatedb = new OperateDB();
$conn = $connClass->GetConn();