mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-24 16:16:14 +00:00
Implimented lazy cron and fixed syncronize button.
This commit is contained in:
parent
2861bd9bef
commit
4cb47986bb
3 changed files with 25 additions and 5 deletions
|
@ -13,7 +13,7 @@ class Sync{
|
||||||
* This is done because the shard could have been offline and we want changes made on the website (which is still online) to eventually hit the shard.
|
* This is done because the shard could have been offline and we want changes made on the website (which is still online) to eventually hit the shard.
|
||||||
* These changes are: createPermissions, createUser, change_pass, change_mail
|
* These changes are: createPermissions, createUser, change_pass, change_mail
|
||||||
*/
|
*/
|
||||||
static public function syncdata () {
|
static public function syncdata ($display = true) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
|
@ -56,11 +56,15 @@ class Sync{
|
||||||
}
|
}
|
||||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||||
}
|
}
|
||||||
print('Syncing completed');
|
if ($display == true) {
|
||||||
|
print('Syncing completed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (PDOException $e) {
|
catch (PDOException $e) {
|
||||||
print('Something went wrong! The shard is probably still offline!');
|
if ($display == true) {
|
||||||
print_r($e);
|
print('Something went wrong! The shard is probably still offline!');
|
||||||
|
print_r($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!@include '../config.php') {
|
||||||
}
|
}
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
//Running Cron?
|
||||||
|
if ( isset( $_GET["cron"]) ){
|
||||||
|
if ($_GET["cron"] == "true"){
|
||||||
|
Sync::syncdata(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Always try to sync on page load, ie "lazy" cron
|
||||||
|
Sync::syncdata(false);
|
||||||
|
|
||||||
//Decide what page to load
|
//Decide what page to load
|
||||||
if ( ! isset( $_GET["page"]) ){
|
if ( ! isset( $_GET["page"]) ){
|
||||||
if(isset($_SESSION['user'])){
|
if(isset($_SESSION['user'])){
|
||||||
|
|
|
@ -25,4 +25,10 @@ function show_help(help_tip)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#sync").click(function() {alert("Handler for .click() called.");});
|
function syncRun()
|
||||||
|
{
|
||||||
|
$.get("index.php?cron=true");
|
||||||
|
alert("Sync function called.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#sync").click(function() {syncRun();});
|
Loading…
Reference in a new issue