This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var captcha; | |
function init_google_captcha() { | |
var element = document.getElementById("your-element"); | |
if (typeof element != "undefined" && element != null) { | |
captcha = grecaptcha.render(element, { | |
sitekey: "SITE_KEY", | |
theme: "light" | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$reCAPTCHA_site_key = reCAPTCHA_SITE_KEY; //assume define constant somewhere | |
$reCAPTCHA_secret_key = reCAPTCHA_SECRET_KEY; //assume define constant somewhere | |
if ($_POST['g-recaptcha-response']) { | |
$recaptcha_response = $_POST['g-recaptcha-response']; | |
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $reCAPTCHA_secret_key . "&response=" . $recaptcha_response . "&remoteip=" . $_SERVER['REMOTE_ADDR'])); | |
if (isset($response->success) && $response->success == 1) { | |
//validate successfully. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $db; | |
$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
// Check connection | |
if ($db->connect_errno) { | |
echo "Failed to connect to MySQL: " . $db->connect_error; | |
exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `customer` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`cust_code` varchar(6) NOT NULL, | |
`cust_name` varchar(40) NOT NULL, | |
`cust_city` varchar(35) DEFAULT NULL, | |
`working_area` varchar(35) NOT NULL, | |
`cust_country` varchar(20) NOT NULL, | |
`phone_no` varchar(17) NOT NULL, | |
`agent_code` varchar(6) DEFAULT NULL | |
PRIMARY KEY (`id`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var dataTable; | |
$(document).ready(function() { | |
if ($('#dataTable').length !== 0) { | |
var data = { | |
'action': 'api-customers' | |
}; | |
dataTable = $('#dataTable').DataTable({ | |
"responsive": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"> | |
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css"> | |
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> | |
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script> | |
<script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $db; | |
$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
// Check connection | |
if ($db->connect_errno) { | |
echo "Failed to connect to MySQL: " . $db->connect_error; | |
exit(); | |
} | |
function apiCustomers($filter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $db; | |
$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
// Check connection | |
if ($db->connect_errno) { | |
echo "Failed to connect to MySQL: " . $db->connect_error; | |
exit(); | |
} | |
function apiCustomers($filter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function _time_elapsed($datetime, $full = false) { | |
$now = new DateTime; | |
$ago = new DateTime($datetime); | |
$diff = $now->diff($ago); | |
$diff->w = floor($diff->d / 7); | |
$diff->d -= $diff->w * 7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ellipsize String | |
* | |
* This function will strip tags from a string, split it at its max_length and ellipsize | |
* | |
* @param string string to ellipsize | |
* @param int max length of string | |
* @param mixed int (1|0) or float, .5, .2, etc for position to split | |
* @param string ellipsis ; Default '...' | |
* @return string ellipsized string |
OlderNewer