Пример #1
0
 public static function resetCrontab()
 {
     $cron_file = 'cron.txt';
     $cron = new FileWriter($cron_file, 'a');
     $setSessionPath = '/home1/enderrac/SpirePHP/setSessionWinner.php';
     $stm = "SELECT EXTRACT(MINUTE from end_ts) as minute, " . "\tEXTRACT(HOUR from end_ts) as hour, " . "\tEXTRACT(day from end_ts) as day_of_month, " . "\tEXTRACT(MONTH from end_ts) as month, " . "\tEXTRACT(dow from end_ts) as day_of_week, " . "\tid " . "FROM SPIRE.SESSIONS ";
     $result = ConnDB::query_db($stm);
     $fnHash = null;
     if (!$result) {
         $cron->writeLine("ERROR");
         $fnHash = MyUtil::fnOk(false, "SQL Error getting Session Info", null);
     } else {
         while ($row = pg_fetch_assoc($result)) {
             $cron->writeLine($row['minute'] . " " . $row['hour'] . " " . $row['day_of_month'] . " " . $row['month'] . " " . $row['day_of_week'] . " {$setSessionPath} " . $row['id']);
         }
         $rmCron = shell_exec('crontab -r');
         if ($rmCron != null) {
             $setCron = shell_exec('crontab $cron_file');
             if ($setCron != null) {
                 $delCronTmp = shell_exec('rm $cron_file');
                 if ($delCronTmp != null) {
                     $fnHash = MyUtil::fnOk(true, "Updated Cron and Session", null);
                 }
                 $fnHash = MyUtil::fnOk(false, "Cron Tmp File not Deleted", null);
             }
             $fnHash = MyUtil::fnOk(false, "Cron not set to tmp", null);
         } else {
             $fnHash = MyUtil::fnOk(false, "Original cron not deleted", null);
         }
         return $fnHash;
     }
     return $fnHash;
 }
Пример #2
0
        $log->close();
    } catch (Exception $e) {
        // ignore
    }
    header('HTTP/1.0 500 Error');
    die;
}
// connect to DB
try {
    $db = DbConnection::getInstance();
    $db->connect($website->getConfig('db_host'), $website->getConfig('db_user'), $website->getConfig('db_passwort'), $website->getConfig('db_name'));
} catch (Exception $e) {
    // write to log
    try {
        $log = new FileWriter('dberrorlog.txt');
        $log->writeLine('DB Error: ' . $e->getMessage());
        $log->close();
    } catch (Exception $e) {
        // ignore
    }
    die('<h1>Sorry, our data base is currently not available</h1><p>We are working on it.</p>');
}
// register own session handler
$handler = new DbSessionManager($db, $website);
session_set_save_handler(array($handler, 'open'), array($handler, 'close'), array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'));
// the following prevents unexpected effects when using objects as save handlers
// see http://php.net/manual/en/function.session-set-save-handler.php
register_shutdown_function('session_write_close');
session_start();
// always set time zone in order to prevent PHP warnings
try {
Пример #3
0
		<input type='submit' class='btn btn-primary' accesskey='s' title='Alt + s' value='<?php 
    echo $i18n->getMessage('button_save');
    ?>
'> 
		<input type='reset' class='btn' value='<?php 
    echo $i18n->getMessage('button_reset');
    ?>
'>
	</div>    
  </form>

  
  <?php 
} elseif ($show == 'save') {
    if (!isset($_POST['content']) || !$_POST['content']) {
        $err[] = $i18n->getMessage('imprint_validationerror_content');
    }
    if ($admin['r_demo']) {
        $err[] = $i18n->getMessage('validationerror_no_changes_as_demo');
    }
    if (isset($err)) {
        include 'validationerror.inc.php';
    } else {
        echo '<h1>' . $mainTitle . ' &raquo; ' . $i18n->getMessage('subpage_save_title') . '</h1>';
        $fw = new FileWriter(IMPRINT_FILE);
        $fw->writeLine(stripslashes($_POST['content']));
        $fw->close();
        echo createSuccessMessage($i18n->getMessage('alert_save_success'), '');
        echo '<p>&raquo; <a href=\'?site=' . $site . '\'>' . $i18n->getMessage('back_label') . '</a></p>';
    }
}
Пример #4
0
/**
 * Writes a log statement into the entity log file.
 * 
 * @param WebSoccer $websoccer application context.
 * @param string $type edit|delete
 * @param string $username name of admin who executed an action.
 * @param string $entity name of affacted entity.
 * @param string $entityValue string value which identifies the entity item.
 */
function logAdminAction(WebSoccer $websoccer, $type, $username, $entity, $entityValue)
{
    $userIp = getenv('REMOTE_ADDR');
    $message = $websoccer->getFormattedDatetime($websoccer->getNowAsTimestamp()) . ';' . $username . ';' . $userIp . ';' . $type . ';' . $entity . ';' . $entityValue;
    $file = BASE_FOLDER . '/generated/entitylog.php';
    $fw = new FileWriter($file, FALSE);
    $fw->writeLine($message);
    $fw->close();
}