function likes($type, $id, $ip) { $ip_sql = mysql_query("select ip from votes_ip where vid='{$id}' and ip='{$ip}'"); $count = mysql_num_rows($ip_sql); if ($count == 0) { //还没有顶过 if ($type == 1) { //顶 $sql = "update competition set vote = vote+1 where id=" . $id; } mysql_query($sql); $sql_in = "insert into votes_ip (vid,ip) values ('{$id}','{$ip}')"; mysql_query($sql_in); if (mysql_insert_id() > 0) { echo jsons($id); } else { $arr['success'] = 0; $arr['msg'] = '操作失败,请重试'; echo json_encode($arr); } } else { $msg = $type == 1 ? '您已经投过票了' : '您已经投过票了'; $arr['success'] = 0; $arr['msg'] = $msg; echo json_encode($arr); } }
function likes($id, $ip) { $ip_sql = mysql_query("select ip from votes_ip where vid='{$id}' and ip='{$ip}'"); $count = mysql_num_rows($ip_sql); if ($count == 0) { //还没有顶过 $sql = "update votes set likes=likes+1 where id=" . $id; mysql_query($sql); $sql_in = "insert into votes_ip (vid,ip) values ('{$id}','{$ip}')"; mysql_query($sql_in); echo jsons($id); } else { $msg = 'repeat'; $arr['success'] = 0; $arr['msg'] = $msg; echo json_encode($arr); } }
function getLeaveType() { include "query_functions.php"; $gnpc = new query_functions(); $gnpc->getLeaveType(); $row = $gnpc->fetch(); if (!$row) { echo "{"; echo jsonn("result", 0) . ","; echo jsons("message", "no leave type found"); echo "}"; return; } echo "{"; echo '"gnpc_dms":'; $det = array(); do { array_push($det, $row); $row = $gnpc->fetch(); } while ($row); print_r(json_encode($det)); echo "}"; }
function addItem() { //$id=get_datan("fileId"); $filename = get_data("fName"); $description = get_data("description"); $file_type = get_data("fileType"); $fullname = get_data("fullname"); $email = get_data("email"); $date = get_datan("date"); $contact = get_datan("contact"); $conn = mysql_connect(DBHOST, DBUSER, DBPW); if (!$conn) { die('Could not connect: ' . mysql_error()); } $db = mysql_select_db(DBNAME, $conn) or die(mysql_error()); if ($db) { $query = "INSERT INTO data_saver_files(name, type, description, full_name, email, contact, date_added) VALUES('{$filename}','{$file_type}','{$description}','{$fullname}','{$email}',{$contact}, now())"; $result = mysql_query($query); echo mysql_error(); //$info = mysql_fetch_assoc($result); } if (!$result) { echo "{"; echo jsonn("result", 0) . ","; echo jsons("message", "add was not successful"); echo "}"; return; } echo "{"; echo jsonn("result", 1) . ","; echo jsons("message", "add was successful"); echo "}"; }
function get_two_days() { include "devotional.php"; //$title=get_two_days("title"); $did = get_datan("did"); $var = new Devotional(); $var->twodays_devotion(); $row = $var->fetch(); if (!$row) { echo "{"; echo jsonn("result", 0) . ","; echo jsons("message", "devotion unavailable"); echo "}"; return; } echo "{"; echo jsonn("result", 1) . ","; echo '"devotion":{'; echo jsons("title", $row['title']) . ","; echo jsons("date", $row['date']) . ","; echo jsons("verse", $row['verse']) . ","; echo jsons("bible_reading", $row['bible_reading']) . ","; echo jsons("devotional_reading", $row['devotional_reading']) . ","; echo jsons("prayer", $row['prayer']); echo "}"; echo "}"; }