queryFirstRow() public method

public queryFirstRow ( )
示例#1
0
文件: list.php 项目: koala87/backup
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
$pageNum = isset($_REQUEST["page"]) ? intval($_REQUEST["page"]) : 0;
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
$sphinx = new SphinxClient();
$sphinx->SetServer(SPHINX_HOST, SPHINX_PORT);
$sphinx->SetArrayResult(true);
$sphinx->SetLimits($pageNum * $number, $number, 5000);
$sphinx->SetMaxQueryTime(10);
$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$sphinx->SetFilter('enabled', array(1));
if (isset($_REQUEST["type"])) {
    $r1 = $mdb->queryFirstRow("SELECT id, name FROM media_type WHERE name=%s", $_REQUEST["type"]);
    $type = $r1["id"];
    //set type
    if ($type == "") {
        echo json_encode(array("result" => null, "status" => false, "error" => "请求的类型不存在"));
        exit;
    }
    $sphinx->SetFilter('type', array($type));
}
if (isset($_REQUEST['language'])) {
    $r2 = $mdb->queryFirstRow("SELECT id, name FROM media_language WHERE name=%s", $_REQUEST["language"]);
    $language = $r2["id"];
    //set language
    if ($language == "") {
        echo json_encode(array("result" => null, "status" => false, "error" => "请求的语种不存在"));
        exit;
示例#2
0
文件: _list.php 项目: koala87/backup
            $use_cache = false;
            $handle = '%' . strval($_REQUEST["name"]) . '%';
            $queryParamater = $queryParamater . " AND name LIKE %s";
        }
    }
}
if (isset($_REQUEST['words'])) {
    $use_cache = false;
    $words = intval($_REQUEST['words']);
    if (intval($words) < 9) {
        $queryParamater = $queryParamater . " AND words=" . $words;
    } else {
        $queryParamater = $queryParamater . " AND words>8";
    }
}
$countResult = $mdb->queryFirstRow("SELECT COUNT(*) AS count FROM media_music" . $queryParamater, $handle);
$totalNumber = 0;
$countValue = $countResult['count'];
if ($countValue == 0) {
    $pageCount = 0;
} else {
    $pageCount = (int) ($countValue / $number);
    if ($countValue % $number != 0) {
        $pageCount = $pageCount + 1;
    }
    $totalNumber = intval($countValue);
}
// echo $pageCount."<br />";
if (isset($_REQUEST["page"]) && intval($_REQUEST["page"]) > $pageCount) {
    echo json_encode(array("result" => null, "status" => false, "error" => "请求页数超过总页数"));
    exit;
示例#3
0
<?php 
header("content-type:application/json");
require_once '../tools/db.php';
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
$queryString = "SELECT B.mid, B.serial_id, B.name, B.singer, B.path, B.original_track, B.sound_track, B.start_volume_1, B.start_volume_2, B.lyric, B.prelude, B.match, C.name AS effect, D.name AS version \r\nFROM media_recommand A \r\nLEFT JOIN media B ON A.rmid = B.mid \r\nLEFT JOIN media_effect C ON B.effect = C.id \r\nLEFT JOIN media_version D ON B.version=D.id";
$queryParamater = " WHERE B.enabled=1";
if (!isset($_REQUEST["mid"])) {
    echo json_encode(array("result" => null, "status" => false, "error" => "需提交歌曲编号(mid)"));
    exit;
}
$queryParamater = $queryParamater . " AND A.mid=%d";
//Check the black list option is open or not
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND B.black = 0";
}
$queryString = $queryString . $queryParamater;
// echo $queryString."<br />";
$results = $mdb->query($queryString, $_REQUEST["mid"]);
$songs = formatSongsResult($results);
//When ther is no recommend, add songs from this singer.
if (count($songs) < 5) {
    $add_result = $mdb->query("SELECT A.mid, A.serial_id, A.name, A.singer, A.path, A.original_track, A.sound_track, A.start_volume_1, A.start_volume_2, A.lyric, A.prelude,A.match, B.name AS effect, C.name AS version \r\n        FROM media A \r\n        LEFT JOIN media_effect B ON A.effect = B.id \r\n        LEFT JOIN media_version C ON A.version=C.id\r\n        LEFT JOIN media D ON A.mid <> D.mid AND A.artist_sid_1=D.artist_sid_1 OR A.artist_sid_1=D.artist_sid_2\r\n        WHERE D.mid=%d LIMIT 0,10", $_REQUEST["mid"]);
    foreach ($add_result as $row) {
        $song = formatSongResult($row);
        array_push($songs, $song);
        if (count($songs) == 5) {
            break;
        }
    }
示例#4
0
<?php 
header("content-type:application/json");
require_once '../tools/db.php';
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
$queryString = "SELECT B.mid, B.serial_id, B.name, B.singer, B.path, B.original_track, B.sound_track, B.start_volume_1, B.start_volume_2, B.lyric, B.prelude, B.match, C.name AS effect, D.name AS version \r\nFROM media_list A \r\nLEFT JOIN media B ON A.mid = B.mid \r\nLEFT JOIN media_effect C ON B.effect = C.id \r\nLEFT JOIN media_version D ON B.version=D.id \r\nWHERE A.type='pro'";
$queryParamater = "";
//Check the black list option is open or not
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND B.black = 0";
}
$countResult = $mdb->queryFirstRow("SELECT COUNT(*) as count FROM media_list LEFT JOIN media ON media_list.mid = media.mid WHERE media_list.type = 'pro'" . $queryParamater);
$totalNumber = 0;
$countValue = $countResult['count'];
if ($countValue == 0) {
    $pageCount = 0;
} else {
    $pageCount = (int) ($countValue / $number);
    if ($countValue % $number != 0) {
        $pageCount = $pageCount + 1;
    }
    $totalNumber = intval($countValue);
}
if (isset($_REQUEST["page"]) && intval($_REQUEST["page"]) > $pageCount) {
    echo json_encode(array("result" => null, "status" => false, "error" => "请求页数超过总页数"));
示例#5
0
 function editBase($formvars = array())
 {
     global $SERVER_EXTENSIONS;
     $tpl = $this->tpl;
     // add all missing keys to array
     fixFormVars($formvars, array('IDbase'));
     // assign menu highlighter
     $tpl->assign('page_id', 'base');
     // assign notifications
     $tpl->assign('notifs', $this->notifs);
     $bases = array();
     if ($formvars['IDbase'] <= 0) {
         $bases[] = array('IDbase' => '-1', 'basename' => '', 'baseid' => '', 'timezone' => '0', 'dst' => '0', 'TXbase' => '0', 'crypt_key' => '', 'linked_clients' => '0', 'pending_messages' => '0', 'online' => '0');
         // add Server Extensions related parameters
         // Android GCM is here?
         if (isset($SERVER_EXTENSIONS['se_android_gcm']) && $SERVER_EXTENSIONS['se_android_gcm']['enabled'] == 1) {
             $bases[0]['se_android_gcm_disable_status_change_event'] = '0';
             $bases[0]['se_android_gcm_disable_new_data_event'] = '0';
         }
     } else {
         // fetch data from db
         $bases = $this->getBase($formvars['IDbase']);
         if (count($bases) <= 0) {
             return false;
         }
         // Add Server Extensions related parameters
         // Note: We can safely do SELECT...WHERE IDbase=$formvars['IDbase'] because getBase()+if() from above would stop us if security check failed
         // Android GCM is here?
         if (isset($SERVER_EXTENSIONS['se_android_gcm']) && $SERVER_EXTENSIONS['se_android_gcm']['enabled'] == 1) {
             $se_mdb = new MeekroDB(mysql_host, mysql_username, mysql_password, $SERVER_EXTENSIONS['se_android_gcm']['mysql_database']);
             $base_config = $se_mdb->queryFirstRow("SELECT * FROM base_config WHERE IDbase = %i", $formvars['IDbase']);
             if ($base_config === NULL) {
                 $base_config['disable_status_change_event'] = '0';
                 $base_config['disable_new_data_event'] = '0';
             }
             $bases[0]['se_android_gcm_disable_status_change_event'] = $base_config['disable_status_change_event'];
             $bases[0]['se_android_gcm_disable_new_data_event'] = $base_config['disable_new_data_event'];
         }
     }
     $mdb = $this->mdb;
     // current timestamp
     $tpl->assign('current_time', date('Y-m-d H:i:s', time()));
     // get linked clients for this IDbase
     $linked_clients = $mdb->query("SELECT c.IDclient, c.clientname, IF(bc.IDclient IS NULL, -1, bc.IDclient) AS sel_IDclient FROM client c LEFT JOIN base_client bc ON (bc.IDclient=c.IDclient AND bc.IDbase = %i) WHERE c.IDaccount = %i ORDER BY clientname", $formvars['IDbase'], $_SESSION['IDaccount']);
     $opt = array();
     $val = array();
     $selected = array();
     for ($i = 0; $i < count($linked_clients); $i++) {
         $r = $linked_clients[$i];
         $val[] = $r['IDclient'];
         $opt[] = $r['clientname'];
         if ($r['sel_IDclient'] != -1) {
             $selected[] = $r['IDclient'];
         }
     }
     $tpl->assign('IDclient_val', $val);
     $tpl->assign('IDclient_opt', $opt);
     $tpl->assign('IDclient_sel', $selected);
     $tpl->assign('data', $bases[0]);
     $path = server_basesock_log_path;
     $file = $path . $formvars['IDbase'] . '.json';
     $tpl->assign('log_available', file_exists($file));
     // enable/disable Server Extensions management
     $se_ext_cnt = 0;
     foreach ($SERVER_EXTENSIONS as $extension => $params) {
         if ($params['enabled']) {
             // lets not even assign it to $tpl if it is not enabled
             $tpl->assign($extension, $params['enabled']);
             $se_ext_cnt++;
         }
     }
     $tpl->assign('server_extensions_count', $se_ext_cnt);
     $tpl->display('bases_edit.html');
     return true;
 }
示例#6
0
文件: songid.php 项目: koala87/backup
header("content-type:application/json");
require_once '../tools/db.php';
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (!isset($_REQUEST["serialid"]) && !isset($_REQUEST["mmid"])) {
    echo json_encode(array("result" => null, "status" => false, "error" => "请提交正确的参数"));
    exit;
}
$queryString = "SELECT mmid, serial_id, name, singer, path, lyric, prelude, has_lyric\r\nFROM media_music";
$queryParamater = " WHERE enabled=1";
if (isset($_REQUEST["serialid"])) {
    $queryParamater = $queryParamater . " AND serial_id=%d";
    $handler = $_REQUEST["serialid"];
} else {
    if (isset($_REQUEST["mmid"])) {
        $queryParamater = $queryParamater . " AND mmid=%d";
        $handler = $_REQUEST["mmid"];
    }
}
$queryString = $queryString . $queryParamater;
//echo $queryString."<br />";
$result = $mdb->queryFirstRow($queryString, $handler);
if (!$result) {
    echo json_encode(array("result" => null, "status" => false, "error" => "查询内容不存在"));
    exit;
}
$finalResult = array("song" => formatMusicResult($result));
echo json_encode(array("result" => $finalResult, "status" => true, "error" => ""));
saveLog($GLOBALS['timeStart'], $_SERVER['REQUEST_URI']);
unset($GLOBALS['timeStart']);
示例#7
0
文件: media.php 项目: koala87/backup
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
$queryString = "SELECT A.mid, A.serial_id, A.name, A.singer, A.path, A.original_track, A.sound_track, A.start_volume_1, A.start_volume_2, A.lyric, A.prelude,A.match, B.name AS effect, C.name AS version \r\n    FROM songlist_detail D \r\n    LEFT JOIN media A ON D.mid = A.mid \r\n    LEFT JOIN media_effect B ON A.effect = B.id \r\n    LEFT JOIN media_version C ON A.version=C.id";
$queryParamater = " WHERE A.enabled=1";
if (!isset($_REQUEST["lid"])) {
    echo json_encode(array("result" => null, "status" => false, "error" => "需提交歌单编号(lid)"));
    exit;
}
$queryParamater = $queryParamater . " AND D.lid = %d";
//Check the black list option is open or not
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND B.black = 0";
}
$countResult = $mdb->queryFirstRow("SELECT COUNT(*) AS count FROM songlist_detail WHERE lid=%d", intval($_REQUEST["lid"]));
$totalNumber = 0;
$countValue = $countResult['count'];
if ($countValue == 0) {
    $pageCount = 0;
} else {
    $pageCount = (int) ($countValue / $number);
    if ($countValue % $number != 0) {
        $pageCount = $pageCount + 1;
    }
    $totalNumber = intval($countValue);
}
示例#8
0
文件: _list.php 项目: koala87/backup
require_once '../tools/db.php';
require_once '../tools/main.php';
require_once '../tools/redisCache.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
$redis = new redisCache(REDIS_HOST, REDIS_PORT);
$use_cache = true;
$redis_key = 'songlist#singer#list';
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 12) {
    $number = $_REQUEST["number"];
} else {
    $number = 12;
}
$queryString = "SELECT sid, serial_id, A.name, nation, A.sex, B.name AS sexType, stars, song_count, baiwei_recommend\r\nFROM actor A \r\nLEFT JOIN actor_sex B ON A.sex=B.id\r\n";
$queryParamater = " WHERE enabled = 1";
//Check the black list option is open or not
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND A.black=0";
}
$typeID = -1;
if (isset($_REQUEST["type"])) {
    for ($x = 0; $x <= 15; $x++) {
        if ($singerType[$x] == strval($_REQUEST["type"])) {
            $typeID = $x;
        }
    }
    if ($typeID == -1) {
        echo json_encode(array("result" => null, "status" => false, "error" => "请求的类型不存在"));
        exit;
    }
}
示例#9
0
文件: songs.php 项目: koala87/backup
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
$queryString = "SELECT A.mid, A.serial_id, A.name, A.singer, A.path, A.original_track, A.sound_track, A.start_volume_1, A.start_volume_2, A.lyric, A.prelude, A.match, B.name AS effect, C.name AS version \r\nFROM media A \r\nLEFT JOIN media_effect B ON A.effect = B.id \r\nLEFT JOIN media_version C ON A.version=C.id";
$queryParamater = " WHERE A.enabled=1";
if (!isset($_REQUEST["sid"])) {
    echo json_encode(array("result" => null, "status" => false, "error" => "需提交歌手编号(sid)"));
    exit;
}
$artistid = intval($_REQUEST["sid"]);
$queryParamater = $queryParamater . " AND (A.artist_sid_1=%d OR A.artist_sid_2=%d)";
//Check the black list option is open or not
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND A.black=0";
}
$handle = '';
if (isset($_REQUEST["header"])) {
    $handle = '%' . strval($_REQUEST["header"]) . '%';
    $queryParamater = $queryParamater . " AND A.header LIKE %s";
} else {
    if (isset($_REQUEST["pinyin"])) {
        $handle = '%' . strval($_REQUEST["pinyin"]) . '%';
        $queryParamater = $queryParamater . " AND A.pinyin LIKE %s";
    } else {
        if (isset($_REQUEST["name"])) {
            $handle = '%' . strval($_REQUEST["name"]) . '%';
            $queryParamater = $queryParamater . " AND A.name LIKE %s";
示例#10
0
文件: board.php 项目: koala87/backup
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
if (isset($_REQUEST["type"])) {
    $type = strval($_REQUEST["type"]);
    $redis_key .= "#" . $type;
} else {
    echo json_encode(array("result" => null, "status" => false, "error" => "没有上传列表类型"));
    exit;
}
$queryString = "SELECT B.mid, B.serial_id, B.name, B.singer, B.path, B.original_track, B.sound_track, B.start_volume_1, B.start_volume_2, B.lyric, B.prelude, B.match, C.name AS effect, D.name AS version, B.artist_sid_1 AS singer_id\r\nFROM media_list A \r\nLEFT JOIN media B ON A.mid = B.mid \r\nLEFT JOIN media_effect C ON B.effect = C.id \r\nLEFT JOIN media_version D ON B.version=D.id \r\nWHERE B.enabled = 1 AND A.type=%s";
$queryParamater = "";
//Check the black list option is open or not
$black = false;
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $black = true;
    $queryParamater = $queryParamater . " AND B.black = 0";
}
$handle = '';
$hot_filter = '';
if (isset($_REQUEST["header"])) {
    $use_cache = false;
    $handle = '%' . strval($_REQUEST["header"]) . '%';
    $queryParamater = $queryParamater . " AND B.header LIKE %s";
    $hot_filter = " AND B.header LIKE %s";
} else {
    if (isset($_REQUEST["pinyin"])) {
        $use_cache = false;
        $handle = '%' . strval($_REQUEST["pinyin"]) . '%';
示例#11
0
<?php

header("content-type:text/html; charset=utf-8");
require_once 'tools/db.php';
require_once 'tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (isset($_REQUEST["number"]) && $_REQUEST["number"] > 10) {
    $number = $_REQUEST["number"];
} else {
    $number = 10;
}
$queryString = "SELECT aid, title, thumb, type, member_count, start_date, end_date, start_time, end_time, status, address, fee, sponsor, photos, description FROM activity";
$queryParamater = "";
$countResult = $mdb->queryFirstRow("SELECT COUNT(*) AS count FROM activity");
$totalNumber = 0;
$countValue = $countResult['count'];
if ($countValue == 0) {
    $pageCount = 0;
} else {
    $pageCount = (int) ($countValue / $number);
    if ($countValue % $number != 0) {
        $pageCount = $pageCount + 1;
    }
    $totalNumber = intval($countValue);
}
//echo $count."<br />";
if (isset($_REQUEST["page"]) && $_REQUEST["page"] > $count) {
    echo json_encode(array("result" => "", "status" => false, "error" => "请求页数超过总页数"));
    exit;
}
if (isset($_REQUEST["page"]) && $_REQUEST["page"] != 0) {
 $database->insert("InfoGroup", array("Id" => $groupId, "LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => "0", "Name" => trim($parts[0]), "Description" => trim($parts[1]), "Position" => $position));
 $position++;
 preg_match_all($regexEntry, $groupMatches[2][$id], $entryMatches);
 $epos = 0;
 foreach ($entryMatches[1] as $entryId => $entry) {
     Log::info(sprintf("  Importing Entry %s", trim($entry)));
     $links = [];
     $images = [];
     // Images / Links
     if ($entryMatches[4][$entryId] != "") {
         preg_match_all($regexLinks, $entryMatches[4][$entryId], $linkMatches);
         foreach ($linkMatches[1] as $linkId => $linkTarget) {
             $linkText = $linkMatches[2][$linkId];
             if (strtolower($linkText) == "image") {
                 $imageTag = "info:import[" . strtolower($linkTarget) . "]";
                 $existingImageRow = $database->queryFirstRow("SELECT * FROM image WHERE Title=%s", $imageTag);
                 if ($existingImageRow) {
                     Log::info(sprintf("  Skipping import %s (exists)", $imageTag));
                     $images[] = $existingImageRow["Id"];
                 } else {
                     Log::info(sprintf("  Fetching %s (new)", $imageTag));
                     $imageData = file_get_contents($linkTarget);
                     $newImageId = insertOrUpdateImageByTitle($database, $imageData, $imageTag);
                     $images[] = $newImageId;
                 }
             } else {
                 $links[] = array("Target" => $linkTarget, "Text" => $linkText);
             }
         }
     }
     $database->insert("Info", array("Id" => GUID(), "InfoGroupId" => $groupId, "LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => "0", "Title" => trim($entry), "Text" => trim($entryMatches[2][$entryId]), "Position" => $epos, "ImageIds" => json_encode($images), "Urls" => json_encode($links)));
示例#13
0
文件: _list.php 项目: koala87/backup
require_once '../tools/redisCache.php';
// header("content-type:text/html");
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
$redis = new redisCache(REDIS_HOST, REDIS_PORT);
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 9;
}
$use_cache = true;
$redis_key = "songlist#media#list";
$queryString = "SELECT A.mid, A.serial_id, A.name, A.singer, A.path, A.original_track, A.sound_track, A.start_volume_1, A.start_volume_2, A.lyric, A.prelude, A.match, B.name AS effect, C.name AS version, A.artist_sid_1 AS singer_id \r\nFROM media A \r\nLEFT JOIN media_effect B ON A.effect = B.id \r\nLEFT JOIN media_version C ON A.version=C.id";
$queryParamater = " WHERE A.enabled=1";
$type = "";
if (isset($_REQUEST["type"])) {
    $r1 = $mdb->queryFirstRow("SELECT id, name FROM media_type WHERE name=%s", $_REQUEST["type"]);
    $type = $r1["id"];
    //set type
    if ($type == "") {
        echo json_encode(array("result" => null, "status" => false, "error" => "请求的类型不存在"));
        exit;
    } else {
        $queryParamater = $queryParamater . " AND A.type=" . $type;
    }
}
if ($type) {
    $redis_key .= "#" . $type;
}
$language = "";
if (isset($_REQUEST["language"])) {
    $r2 = $mdb->queryFirstRow("SELECT id, name FROM media_language WHERE name=%s", $_REQUEST["language"]);
示例#14
0
文件: list.php 项目: koala87/backup
require_once '../tools/db.php';
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (isset($_REQUEST["number"]) && intval($_REQUEST["number"]) > 9) {
    $number = $_REQUEST["number"];
} else {
    $number = 10;
}
$queryString = "SELECT lid, title, image, type, count, special FROM songlist";
$queryParamater = "";
$type = "";
if (isset($_REQUEST["type"])) {
    $queryParamater = " WHERE type = %s";
    $type = strval($_REQUEST["type"]);
}
$countResult = $mdb->queryFirstRow("SELECT COUNT(*) AS count FROM songlist" . $queryParamater, $type);
$totalNumber = 0;
$countValue = $countResult['count'];
if ($countValue == 0) {
    $pageCount = 0;
} else {
    $pageCount = (int) ($countValue / $number);
    if ($countValue % $number != 0) {
        $pageCount = $pageCount + 1;
    }
    $totalNumber = intval($countValue);
}
//echo $count."<br />";
if (isset($_REQUEST["page"]) && $_REQUEST["page"] > $pageCount) {
    echo json_encode(array("result" => null, "status" => false, "error" => "请求页数超过总页数"));
    exit;
示例#15
0
文件: songid.php 项目: koala87/backup
<?php

header("content-type:application/json");
require_once '../tools/db.php';
require_once '../tools/main.php';
$mdb = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_TABLE_NAME, DB_PORT, DB_CHARSET);
if (!isset($_REQUEST["serialid"]) && !isset($_REQUEST["mid"])) {
    echo json_encode(array("result" => null, "status" => false, "error" => "请提交正确的参数"));
    exit;
}
$queryString = "SELECT A.mid, A.serial_id, A.name, A.singer, A.path, A.original_track, A.sound_track, A.start_volume_1, A.start_volume_2, A.lyric, A.prelude, A.match, B.name AS effect, C.name AS version \r\nFROM media A \r\nLEFT JOIN media_effect B ON A.effect = B.id \r\nLEFT JOIN media_version C ON A.version=C.id";
$queryParamater = " WHERE A.enabled=1";
$rb = $mdb->queryFirstRow("SELECT value FROM config_resource WHERE name = 'filter_black'");
if ($rb["value"] == 1) {
    $queryParamater = $queryParamater . " AND A.black=0";
}
if (isset($_REQUEST["serialid"])) {
    $queryParamater = $queryParamater . " AND serial_id=%d";
    $handler = $_REQUEST["serialid"];
} else {
    if (isset($_REQUEST["mid"])) {
        $queryParamater = $queryParamater . " AND mid=%d";
        $handler = $_REQUEST["mid"];
    }
}
$queryString = $queryString . $queryParamater;
//echo $queryString."<br />";
$result = $mdb->queryFirstRow($queryString, $handler);
if (!$result) {
    //未获取mv 则查找MP3
    if (isset($_REQUEST["serialid"])) {
示例#16
0
define('VENDOR_PATH', SHARED_PATH . './vendor/');
require SHARED_PATH . 'config.inc.php';
require VENDOR_PATH . 'autoload.php';
require VENDOR_PATH . 'sergeytsalkov/meekrodb/db.class.php';
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Http\Stream;
$endpointDatabase = new MeekroDB(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_PORT, DB_CHARSET);
$endpointDatabase->param_char = "##";
$endpointConfiguration = $endpointDatabase->query("SELECT * FROM EndpointConfiguration");
$endpointEntities = $endpointDatabase->query("SELECT Id, Name, TableName, SelectFields, DATE_FORMAT(DeltaStartDateTimeUtc, '%Y-%m-%dT%TZ') AS DeltaStartDateTimeUtc, JsonFields FROM EndpointEntity");
$app = new \Slim\App(['settings' => ['displayErrorDetails' => true]]);
// Register Endpoint Metadata
$app->get('/Endpoint', function (Request $request, Response $response, $args) use($endpointConfiguration, $endpointEntities, $endpointDatabase) {
    foreach ($endpointEntities as $id => $entity) {
        $row = $endpointDatabase->queryFirstRow("SELECT DATE_FORMAT(MAX(LastChangeDateTimeUtc), '%Y-%m-%dT%TZ') AS LastChangeDateTimeUtc, COUNT(*) AS Count FROM " . $entity["TableName"]);
        $endpointEntities[$id]["LastChangeDateTimeUtc"] = $row["LastChangeDateTimeUtc"];
        $endpointEntities[$id]["Count"] = $row["Count"];
    }
    return $response->withJson(array("CurrentDateTimeUtc" => gmdate("Y-m-d\\TH:i:s\\Z"), "Configuration" => $endpointConfiguration, "Entities" => $endpointEntities));
});
// Register all Endpoints for Table Enumeration & Indexer
foreach ($endpointEntities as $id => $entity) {
    $app->get('/' . $entity["Name"], function (Request $request, Response $response) use($endpointDatabase, $entity) {
        $fields = preg_replace("(date:([^\$^,]+))", "DATE_FORMAT(\\1,'%Y-%m-%dT%TZ') AS \\1", $entity["SelectFields"]);
        $jsonFields = explode(",", $entity["JsonFields"]);
        $queryBase = "SELECT " . $fields . " FROM " . $entity["TableName"] . " tbl ";
        $since = isset($_GET["since"]) ? $_GET["since"] : null;
        $since = substr($since, 0, strlen($since) - (strtoupper($since[strlen($since) - 1]) == "Z" ? 1 : 0));
        $result = [];
        if ($since && strtotime($since)) {