/** * CricBD image upload API for Apps * @author Shahriar * @version 1.0.1 */ header('Content-Type: application/json;'); // if (isset($_FILES)) { // $api_key = md5($_POST['device_id']); $target_file = 'uploads/user.png'; if ($_FILES["image"]["name"] != '') { $target_dir = "uploads/"; $tmp = basename($_FILES["image"]["name"]); $imageFileType = pathinfo($tmp, PATHINFO_EXTENSION); $tmp = md5($tmp . '' . time()) . '.' . $imageFileType; $target_file = $target_dir . $tmp; move_uploaded_file($_FILES["image"]["tmp_name"], $target_file); $json = array(); $json['message'] = "Image uploaded!"; $json['success'] = 1; $json['profile'] = $target_file; print_r(json_encode($json)); } else { echo err_json('Upload Failed!'); } // } else { echo err_json('No Image!'); } //
* @author Shahriar * @version 1.0.1 */ $data = json_decode(file_get_contents("php://input")); if (!$data) { die; } $sub = mysql_real_escape_string($data->sub); if ($sub == 'addDoa') { // Add New Doa $args = array('doa_name' => $data->doaName, 'doa_details' => $data->doaDet, 'doa_lang' => $data->doaLang, 'doa_type' => $data->doaType); $chk = insert_data('q_doa', $args); if ($chk) { echo success_json(); } else { echo err_json(); } } elseif ($sub == 'getDoa') { // Get all Doa list print_r(table_data('q_doa', '1', 'doa_id,doa_name,doa_type,doa_lang')); } elseif ($sub == 'delDoa') { // Delete Doa $chk = delete_data('q_Doa', "doa_id='{$data->doaID}'"); if ($chk) { success_json(); } else { echo err_json(); } } else { echo err_json(); }
<?php /** * SPA comment API * @author Shahriar * @version 1.0.1 */ session_start(); $data = json_decode(file_get_contents("php://input")); if (!$data) { die; } $sub = mysql_real_escape_string($data->sub); if ($sub == 'addComment') { // Add new comment date_default_timezone_set('Asia/Dhaka'); $args = array('postid' => $data->postid, 'viewer' => $data->name, 'comment' => $data->comment, 'comdate' => date("d-m-Y")); $chk = insert_data('comments', $args); if ($chk) { echo success_json(); } else { echo err_json('Submission error'); } } elseif ($sub == 'getComment') { // Get single post $chk = table_data("comments", "postid='" . $data->postid . "' order by comid desc"); print_r($chk); } else { echo err_json('Login Error'); }
} $json['success'] = 1; if ($json['data'] == null) { $json['message'] = 'Hadith not found!'; $json['data'] = array(); $json['success'] = 0; } else { $json['message'] = 'Hadith Found!'; } echo json_encode($json, JSON_UNESCAPED_UNICODE); // } else { echo err_json('Wrong API Key'); } } else { echo err_json('No API Key'); } // function getHadithList($lang, $page_start) { if ($lang != '') { return table_data('q_hadith', "hadith_lang='{$lang}' limit {$page_start},10"); } return table_data('q_hadith', "1 limit {$page_start},10"); } function totalHadithPage($lang = '') { if ($lang != '') { $query = @mysql_query("select count(hadith_id) as total_hadith from q_hadith where hadith_lang='{$lang}'"); } else { $query = @mysql_query("select count(hadith_id) as total_hadith from q_hadith");
<?php $data = json_decode(file_get_contents("php://input")); if (!$data) { die; } $auth = mysql_real_escape_string($data->auth); if (isset($auth) && $auth == 'true') { echo success_json('Registration successful.'); } else { echo err_json('Registration failed!'); }
$json['data']['meaning'] = array(); } else { array_walk($json['data']['meaning'], "detailsInfo"); $json['data']['meaning'] = $json['data']['meaning'][0]->sura_details; } } $json['success'] = 1; if ($json['data']['arabic'] == null) { $json['message'] = 'Sura not found!'; $json['success'] = 0; $json['data']['arabic'] = array(); } else { $json['message'] = 'Sura Found!'; array_walk($json['data']['arabic'], "detailsInfo"); $json['data']['arabic'] = $json['data']['arabic'][0]->sura_details; } echo json_encode($json, JSON_UNESCAPED_UNICODE); } else { echo err_json('Wrong API key'); } } else { echo err_json('No API key'); } function getSura($select, $serial, $type) { return table_data('q_sura', "sura_lang='" . $select . "' and sura_no='" . $serial . "' and sura_type='" . $type . "'", "sura_details"); } function detailsInfo(&$item) { $item->sura_details = json_decode($item->sura_details); }
$json['data'][0]['post_like'] = count($arr); $com = post_comment($postId); $json['data'][0]['comments'] = json_decode($com, true); $len = count($json['data'][0]['comments']); $json['data'][0]['total_comment'] = $len; if ($len == 0) { $json['data'][0]['comments'] = array(); } else { for ($i = 0; $i < $len; $i++) { $tmp = $json['data'][0]['comments'][$i]['comment_id']; $json['data'][0]['comments'][$i]['subcomment'] = sub_comments($postId, $tmp); if ($json['data'][0]['comments'][$i]['subcomment'] == null) { $json['data'][0]['comments'][$i]['subcomment'] = array(); } } } echo json_encode($json); } else { echo err_json('No posts found!'); } } else { err_json('Post ID not found!'); } } else { echo err_json('Please login!'); } // } else { echo err_json('Wrong API Key.'); } //
* CricBD register API for Apps * @author Shahriar * @version 1.0.1 */ header('Content-Type: application/json;'); // if (isset($_POST['device_id'])) { $var = sql_data('forum_user', "device_id='" . $_POST['device_id'] . "'"); if (!$var) { // $api_key = md5($_POST['device_id']); date_default_timezone_set('Asia/Dhaka'); $json = array(); $args = array('device_id' => $_POST['device_id'], 'social_id' => isset($_POST['social_id']) ? $_POST['social_id'] : 0, 'image' => isset($_POST['image']) ? $_POST['image'] : 'uploads/user.png', 'name' => isset($_POST['name']) ? $_POST['name'] : '', 'password' => md5($_POST['password']), 'api_key' => $api_key, 'join_date' => date('d-m-Y')); $chk = insert_data('forum_user', $args); if ($chk) { $json['message'] = "Successfully Registered!"; $json['success'] = 1; $json['api_key'] = $api_key; echo json_encode($json); } else { echo err_json('Registration Failed!'); } // } else { echo err_json('Device Already Registered.'); } } else { echo err_json('Wrong Device ID.'); } //
<?php $data = json_decode(file_get_contents("php://input")); if (!$data) { echo err_json('You are unauthorized!'); die; } $auth = $data->code; if (isset($auth) && $auth == 1) { session_start(); $_SESSION['logged'] = $data->userinfo->id; $_SESSION['hash'] = $data->hash; $_SESSION['type'] = $data->userinfo->type; echo success_json('Login successful.'); } else { if (isset($auth) && $auth == 7) { session_start(); $response = array(); $response['hash'] = $_SESSION['hash']; print_r(json_encode($response)); } else { echo err_json('Login failed!'); } }
* @author Shahriar * @version 1.0.1 */ $data = json_decode(file_get_contents("php://input")); if (!$data) { die; } $sub = mysql_real_escape_string($data->sub); if ($sub == 'addSura') { // Add new language $args = array('sura_id' => '', 'sura_no' => $data->suraNo, 'sura_name' => $data->suraName, 'sura_details' => isset($data->suraAyat) ? json_encode($data->suraAyat) : '', 'sura_info' => json_encode($data->suraInfo), 'sura_lang' => $data->suraLang, 'sura_type' => $data->suraType); $chk = insert_data('q_sura', $args); if ($chk) { success_json(); } else { err_json(); } } elseif ($sub == 'getSura') { // Get all sura list print_r(table_data('q_sura', '1', 'sura_id,sura_no,sura_name,sura_lang,sura_type')); } elseif ($sub == 'delSura') { // Delete sura $chk = delete_data('q_sura', "sura_id='" . $data->suraID . "'"); if ($chk) { success_json(); } else { err_json(); } } else { err_json(); }
/** * CricBD user API for Apps * @author Shahriar * @version 1.0.1 */ header('Content-Type: application/json;'); // if (isset($_POST['api_key'])) { $var = sql_data('forum_user', "api_key='" . $_POST['api_key'] . "'"); if ($var) { // $json = array(); $json['data'] = array(); $json['success'] = 1; $json['message'] = 'User information'; $json['data'] = array(); $json['data']['uid'] = $var['uid']; $json['data']['social_id'] = $var['social_id']; $json['data']['image'] = $var['image']; $json['data']['name'] = $var['name']; $json['data']['join_date'] = $var['join_date']; $json['data']['api_key'] = $var['api_key']; echo json_encode($json); // } else { echo err_json('Wrong info! Please login.'); } } else { echo err_json('Please Login!'); } //