This commit is contained in:
kaetemi 2014-09-05 11:22:18 +02:00
parent f037b88d28
commit c7054fadb7
15 changed files with 43 additions and 24 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

@ -22,19 +22,20 @@ class Helpers {
global $SITEBASE; global $SITEBASE;
global $AMS_TRANS; global $AMS_TRANS;
global $INGAME_LAYOUT; global $INGAME_LAYOUT;
global $AMS_CACHEDIR;
// define('SMARTY_SPL_AUTOLOAD',1); // define('SMARTY_SPL_AUTOLOAD',1);
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
spl_autoload_register( '__autoload' ); spl_autoload_register( '__autoload' );
$smarty = new Smarty; $smarty = new Smarty;
$smarty -> setCompileDir( $SITEBASE . '/templates_c/' ); $smarty -> setCompileDir( $SITEBASE . '/templates_c/' );
$smarty -> setCacheDir( $SITEBASE . '/cache/' ); $smarty -> setCacheDir( $AMS_CACHEDIR );
$smarty -> setConfigDir( $SITEBASE . '/configs/' ); $smarty -> setConfigDir( $SITEBASE . '/configs/' );
// turn smarty debugging on/off // turn smarty debugging on/off
$smarty -> debugging = false; $smarty -> debugging = false;
// caching must be disabled for multi-language support // caching must be disabled for multi-language support
$smarty -> caching = false; $smarty -> caching = false;
$smarty -> cache_lifetime = 5; $smarty -> cache_lifetime = 300;
if (function_exists('apc_cache_info')) { if (function_exists('apc_cache_info')) {
// production // production

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

@ -216,6 +216,18 @@ class Ticket{
foreach ($fetchall as &$value) { foreach ($fetchall as &$value) {
$webUser = new WebUsers($value['Uploader']); $webUser = new WebUsers($value['Uploader']);
$fetchall[$base]['Username'] = $webUser->getUsername(); $fetchall[$base]['Username'] = $webUser->getUsername();
$bytes = $fetchall[$base]['Filesize'];
$precision = 2;
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
$fetchall[$base]['Filesize'] = round($bytes, $precision) . ' ' . $units[$pow];;
$base++; $base++;
} }
return $fetchall; return $fetchall;

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

@ -1,2 +0,0 @@
RewriteEngine On
RewriteRule ^$ /ams [R=301,L]

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,6 @@
* 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
*/ */
require( '../../config.php' );
require( '../libinclude.php' ); require_once( $AMS_LIB . '/libinclude.php' );
require( '../../www/config.php' );
Sync::syncdata(); Sync::syncdata();

View file

View file

@ -28,7 +28,13 @@ session_start();
$fileParts = pathinfo($_FILES['Filedata']['name']); $fileParts = pathinfo($_FILES['Filedata']['name']);
Ticket::add_Attachment($_GET['id'],$_FILES['Filedata']['name'],$_SESSION['id'],$tempFile); Ticket::add_Attachment($_GET['id'],$_FILES['Filedata']['name'],$_SESSION['id'],$tempFile);
echo "Uploaded :".$_FILES['Filedata']['name'];
} else {
echo "Upload Failed!";
} }
echo "Upload Failed!";
} }
echo "Upload Failed!";
} }
echo "Upload Failed!";
?> ?>

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

@ -42,7 +42,7 @@
<tr> <tr>
<td><a href="{$FILE_WEB_PATH}{$array['Path']}">{$array['Filename']}</a></td> <td><a href="{$FILE_WEB_PATH}{$array['Path']}">{$array['Filename']}</a></td>
<td>{$array['Timestamp']}</td> <td>{$array['Timestamp']}</td>
<td>{$array['Filesize']} Bytes</td> <td>{$array['Filesize']}</td>
<td>{if $permission > 1} <td>{if $permission > 1}
<a href="{$BASE_WEBPATH}index.php?page=show_user&id={$array['Uploader']}">{$array['Username']}</a> <a href="{$BASE_WEBPATH}index.php?page=show_user&id={$array['Uploader']}">{$array['Username']}</a>
{else} {else}
@ -136,17 +136,19 @@
$(document).ready( function () { $(document).ready( function () {
$('#file_upload').uploadify({ $('#file_upload').uploadify({
'formData' : {'PHPSESSID': '{/literal}{$sessionid}{literal}'}, 'formData' : {'PHPSESSID': '{/literal}{nocache}{$sessionid}{/nocache}{literal}'},
'auto' : true, 'auto' : true,
'multi' : true, 'multi' : true,
'method' : 'post', 'method' : 'post',
'swf': 'misc/uploadify.swf', 'swf': 'misc/uploadify.swf',
'uploader': 'func/upload.php?id='+{/literal}{$ticket_id}{literal} 'displayData': 'percentage',
'uploader': 'func/upload.php?id='+{/literal}{$ticket_id}{literal},
'removeCompleted' : false
}); });
}); });
</script> </script>
{/literal} {/literal}
<div id="filesUploaded"></div>
<div class="control-group"> <div class="control-group">
<label class="control-label"></label> <label class="control-label"></label>
<div class="controls"> <div class="controls">

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>