Exemplo n.º 1
0
function addNotification()
{
    global $dbh, $action, $username, $activation, $installation, $password, $results, $wfield1, $wfield2, $wfield3, $wfield4, $id;
    $verifySQL = "SELECT * FROM notifications WHERE username ='******'";
    $message = "";
    if (findCount($verifySQL) <= 0) {
        $sql = "INSERT INTO notifications (\n   `username` ,`activation`,`installation`, `password`, `results`, `wfield1`, `wfield2`, `wfield3`, `wfield4`,) " . "VALUES('{$username}', '{$activation}', '{$installation}', '{$password}'" . ",'{$results}', '{$wfield1}', '{$wfield2}', '{$wfield3}', '{$wfield4}'";
        //   echo $sql;
        $db_result = $dbh->query($sql);
        $response["success"] = 1;
        $response["message"] = 'Notification sent successfully';
    } else {
        $response["success"] = 0;
        $response["message"] = 'Notification already exists';
    }
    echo json_encode($response);
}
Exemplo n.º 2
0
function addHomework()
{
    global $dbh, $action, $username, $activation, $installation, $password, $subject, $studentclass, $description, $teacher, $assignedDate, $dueDate, $wfield1, $wfield2, $wfield3, $wfield4, $id;
    $verifySQL = "SELECT * FROM homework WHERE username ='******'";
    $message = "";
    if (findCount($verifySQL) <= 0) {
        $sql = "INSERT INTO homework (\n   `username` ,`activation`,`installation`, `password`, `subject`, `studentclass`, `description`,`teacher`, `assignedDate`, `dueDate`, `wfield1`, `wfield2`, `wfield3`, `wfield4`) " . "VALUES('{$username}', '{$activation}', '{$installation}', '{$password}'" . ",'{$subject}', '{$studentclass}', '{$description}', '{$teacher}', '{$assignedDate}', '{$dueDate}', '{$wfield1}', '{$wfield2}', '{$wfield3}', '{$wfield4}' )";
        //   echo $sql;
        $db_result = $dbh->query($sql);
        $response["success"] = 1;
        $response["message"] = 'Homework sent successfully';
    } else {
        $response["success"] = 0;
        $response["message"] = 'Homework already exists';
    }
    echo json_encode($response);
}
Exemplo n.º 3
0
$_SESSION['cus_id'] = $cus_id;
$_SESSION['sessid'] = session_id();
$sessid = session_id();
$log = findLog($cus_id, $ip, $sessid, $db);
//var_dump($_SESSION);
//查找日志是否存在
if (empty($log)) {
    //如果不存在添加
    $dataLog = array('cus_id' => $cus_id, 'ip' => $ip, 'expires' => $expires, 'sessid' => $sessid, 'platform' => $platform);
    $insertLog = insertLog($dataLog, $db);
} else {
    $dataLog = array('expires' => $expires, 'ip' => $ip, 'sessid' => $sessid);
    $updateLog = updateLog($cus_id, $dataLog, $db);
}
//查看是否存在统计记录
$counter = findCount($cus_id, $db);
if (empty($counter)) {
    //不存在,添加
    $dataCount = array('cus_id' => $cus_id, 'record_date' => $date);
    $insertCount = insertCount($dataCount, $db);
}
if (isset($insertLog)) {
    $updateCount = updateCount($cus_id, $platform, $counter, $db);
    echo 'update statis succeed';
} else {
    echo 'not need update statis';
}
/**
 * 查找日志
 * @param type $cus_id
 * @param type $db