Пример #1
0
<?php

require 'libMysqli.php';
require 'libFunction.php';
header("Access-Control-Allow-Origin: *");
//无限制
//读取参数btih,并字符串化,小写化
$btih = getBtih();
$result = NULL;
$count = safe_query("SELECT `d_index` FROM `video` WHERE `btih` = UNHEX(?);", &$result, array('s', $btih));
if ($count != 1) {
    die(json_err('btih_unavailable', -1, 'Error: Video Not Yet Exists, Do You Want to Create It?'));
}
//无返回值
exit($result[0]['d_index']);
//返回字段d_index,该字段是json字符串
Пример #2
0
//加10分
$const_DelayNewLink = 60;
//60秒硬直
//获取Cookie对应用户数据,如果key不符合,退出
checkCookie();
$uid = getUid();
//$_GET和$_REQUEST已经urldecode()了!
$linkage = explode(';', trim($_REQUEST['linkage']));
//元素都是字符串
$head = trim(array_shift($linkage));
$head_comma = explode(',', trim($head));
if (count($head_comma) < 3) {
    die(json_err('btih_incorrect', -1, 'Error: Link is Not Valid'));
}
$btih_1 = getBtih(trim($head_comma[0]));
$btih_2 = getBtih(trim($head_comma[1]));
$count = intval(trim($head_comma[2]));
//偏移量的计数,下面与shift过后的数组$linkage的元素数比较
if (count($linkage) < $count) {
    die(json_err('link_incomplete', -1, 'Error: Linkage is Not Complete.'));
}
//正常应该相等,允许大于
//if (!checkBtih($btih_1))  die(json_err('btih_unavailable',-1,'Error: First Video is Not Available.'));//返回空
//if (!checkBtih($btih_2))  die(json_err('btih_unavailable',-1,'Error: Second Video is Not Available.'));//返回空
//直接在下面取l_index时检测好了,不要额外消耗sql资源
$key_1 = array(implode(',', array($btih_1, $btih_2, strval($count))));
//反正不用来索引,都是$btih_1开头又如何
$key_2 = array(implode(',', array($btih_2, $btih_1, strval($count))));
//反正不用来索引,都是$btih_2开头又如何
//其实数值会被implode自动转化成字符串的,http://php.net/manual/zh/function.implode.php#109916
$i = 1;