This commit is contained in:
botanic 2014-09-05 02:10:09 -07:00
parent 85910829a7
commit 6b92b85b04
9 changed files with 17 additions and 16 deletions

View file

@ -201,6 +201,7 @@ class DBLayer {
$field_option_values = ltrim($field_option_values, ','); $field_option_values = ltrim($field_option_values, ',');
try { try {
$sth = $this->PDO->prepare("UPDATE $tb_name SET $field_option_values WHERE $where "); $sth = $this->PDO->prepare("UPDATE $tb_name SET $field_option_values WHERE $where ");
error_log("UPDATE $tb_name SET $field_option_values WHERE $where ");
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value); $sth->bindValue(":$key", $value);

View file

@ -18,14 +18,15 @@ class Sync{
if (function_exists('pcntl_fork')) { if (function_exists('pcntl_fork')) {
$pid = pcntl_fork(); $pid = pcntl_fork();
} }
$pidfile = '/tmp/ams_cron_pid'; global $AMS_TMPDIR;
$pidfile = $AMS_TMPDIR.'/ams_cron_pid';
if(isset($pid)) { if(isset($pid) and function_exists('pcntl_fork') ) {
// We're the main process. // We're the main process.
} else { } else {
if(!file_exists($pidfile)) { if(!file_exists($pidfile)) {
$pid = getmypid(); $pid = getmypid();
$file = fopen($pidfile, 'w'); $file = fopen($pidfile, 'w+');
fwrite($file, $pid); fwrite($file, $pid);
fclose($file); fclose($file);
@ -57,13 +58,13 @@ class Sync{
$decode = json_decode($record['query']); $decode = json_decode($record['query']);
$values = array('Password' => $decode[1]); $values = array('Password' => $decode[1]);
//make connection with and put into shard db & delete from the lib //make connection with and put into shard db & delete from the lib
$db->update("user", $values, "Login = $decode[0]"); $db->update("user", $values, "Login = '$decode[0]'");
break; break;
case 'change_mail': case 'change_mail':
$decode = json_decode($record['query']); $decode = json_decode($record['query']);
$values = array('Email' => $decode[1]); $values = array('Email' => $decode[1]);
//make connection with and put into shard db & delete from the lib //make connection with and put into shard db & delete from the lib
$db->update("user", $values, "Login = $decode[0]"); $db->update("user", $values, "Login = '$decode[0]'");
break; break;
case 'createUser': case 'createUser':
$decode = json_decode($record['query']); $decode = json_decode($record['query']);

View file

@ -436,7 +436,7 @@ class Users{
try { try {
//make connection with and put into shard db //make connection with and put into shard db
$dbs = new DBLayer("shard"); $dbs = new DBLayer("shard");
$dbs->update("user", $values, "Login = $user"); $dbs->update("user", $values, "Login = '$user'");
return "ok"; return "ok";
} }
catch (PDOException $e) { catch (PDOException $e) {

View file

View file

@ -234,11 +234,11 @@ class WebUsers extends Users{
$hashpass = crypt($pass, WebUsers::generateSALT()); $hashpass = crypt($pass, WebUsers::generateSALT());
$reply = WebUsers::setAmsPassword($user, $hashpass); $reply = WebUsers::setAmsPassword($user, $hashpass);
$values = Array('pass' => $hashpass); $values = Array('Password' => $hashpass);
try { try {
//make connection with and put into shard db //make connection with and put into shard db
$dbw = new DBLayer("web"); $dbw = new DBLayer("web");
$dbw->update("ams_user", $values,"Login = $user"); $dbw->update("ams_user", $values,"Login = '$user'");
} }
catch (PDOException $e) { catch (PDOException $e) {
//ERROR: the web DB is offline //ERROR: the web DB is offline

View file

@ -5,8 +5,8 @@
* @author Daan Janssens, mentored by Matthew Lagoe * @author Daan Janssens, mentored by Matthew Lagoe
*/ */
require( '../libinclude.php' ); require( '../../config.php' );
require( '../../www/config.php' ); require_once( $AMS_LIB . '/libinclude.php' );;
$mail_handler = new Mail_Handler(); $mail_handler = new Mail_Handler();
$mail_handler->cron(); $mail_handler->cron();

View file

@ -4,8 +4,7 @@
* This small piece of php code calls the syncdata() function of Sync class. * This small piece of php code calls the syncdata() function of Sync class.
* @author Daan Janssens, mentored by Matthew Lagoe * @author Daan Janssens, mentored by Matthew Lagoe
*/ */
error_log('test2');
require( '../libinclude.php' ); require( '../../config.php' );
require( '../../www/config.php' ); require_once( $AMS_LIB . '/libinclude.php' );
Sync::syncdata(); Sync::syncdata();

View file

@ -37,7 +37,7 @@ if ( isset( $_GET["cron"] ) ) {
} }
// Always try to sync on page load, ie "lazy" cron // Always try to sync on page load, ie "lazy" cron
Sync :: syncdata( false ); Sync :: syncdata( true );
// Decide what page to load // Decide what page to load
if ( ! isset( $_GET["page"] ) ) { if ( ! isset( $_GET["page"] ) ) {

View file

@ -15,7 +15,7 @@
<script> <script>
function sync(){ function sync(){
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","../../../ams_lib/cron/sync_cron.php",true); xmlhttp.open("POST","cron/sync_cron.php",true);
xmlhttp.send(); xmlhttp.send();
} }
</script> </script>