예제 #1
0
파일: cron.php 프로젝트: hackingman/TradeX
function CronAppendLog($file, $message, $time = false)
{
    if ($time) {
        $message = '[' . date('r') . '] ' . $message;
    } else {
        $message = "\t{$message}";
    }
    file_append($file, "{$message}\n");
}
예제 #2
0
function error_handler($errno, $errstr, $errfile, $errline)
{
    $reporting = error_reporting();
    if ($reporting == 0 || !($errno & $reporting)) {
        return;
    }
    require_once 'utility.php';
    file_append(DIR_LOGS . '/error.log', "[" . date('r') . "] {$errstr} in {$errfile} on {$errline}\n");
    if (defined('IN_CONTROL_PANEL')) {
        echo "A fatal error has occurred: {$errstr} in {$errfile} on {$errline}\n";
    } else {
        echo "A fatal error has occurred.  If you are the administrator check the error log for details\n";
    }
    exit;
}
예제 #3
0
 /**
  * @param IHttpRequest $request
  * @param array $data
  */
 protected function addToTrunk(IHttpRequest $request, array $data)
 {
     $trunk = $request->getUrl()->getQuery()->get('trunk', 'default');
     if ($trunk !== null || $this->trunkAll) {
         $trunk = str_replace(['/', '.'], '', $trunk);
         if (strlen($trunk) > 0) {
             $path = path($this->trunksPath, $trunk . '.txt');
             if (!file_exists($path)) {
                 file_create($path);
             }
             file_append($path, s("\n\n%s %s\n\n", date('c'), str_repeat('=', 80)));
             file_append($path, json_encode($data, JSON_PRETTY_PRINT));
         }
     }
 }
예제 #4
0
 public function test_file()
 {
     $file1 = self::getDir() . '/dir1/foo.txt';
     $file2 = self::getDir() . '/dir2/bar.txt';
     $file3 = self::getDir() . '/dir2/baz.txt';
     $file3_name = 'baz.txt';
     $file4 = self::getDir() . '/dir4/yolo.txt';
     $this->assertFalse(file_exists($file1));
     file_create($file1);
     file_write($file1, '');
     $this->assertTrue(file_exists($file1));
     $this->assertEquals('', file_read($file1));
     file_write($file1, 'foo');
     $this->assertEquals('foo', file_read($file1));
     file_append($file1, '_bar');
     $this->assertEquals('foo_bar', file_read($file1));
     file_prepend($file1, '#');
     $this->assertEquals('#foo_bar', file_read($file1));
     file_append($file1, '_bar');
     file_prepend($file1, '#');
     $this->assertEquals('##foo_bar_bar', file_read($file1));
     file_append($file1 . '_append', '_bar');
     $this->assertEquals(file_read($file1 . '_append'), '_bar');
     file_prepend($file1 . '_prepend', '#');
     $this->assertEquals(file_read($file1 . '_prepend'), '#');
     $this->assertFalse(file_exists($file2));
     file_copy($file1, $file2);
     $this->assertTrue(file_exists($file2));
     $this->assertEquals(file_read($file1), file_read($file2));
     $this->assertFalse(file_exists($file3));
     file_rename($file2, $file3_name);
     $this->assertFalse(file_exists($file2));
     $this->assertTrue(file_exists($file3));
     $this->assertEquals(file_read($file1), file_read($file3));
     $this->assertFalse(file_exists($file4));
     file_move($file3, $file4);
     $this->assertFalse(file_exists($file3));
     $this->assertTrue(file_exists($file4));
     $this->assertEquals(file_read($file1), file_read($file4));
     file_delete($file4);
     file_delete($file4);
     $this->assertFalse(file_exists($file4));
     $this->assertEquals(self::getDir() . '/dir1', file_get_directory($file1));
     $this->assertEquals('txt', file_get_extension($file1));
     $this->assertEquals('foo.txt', file_get_name($file1));
 }
예제 #5
0
function add_task($task)
{
    $tasks = unstock(file_read(DATA_FILE));
    $tasks[] = $task;
    file_append(DATA_FILE, stock($tasks), false);
}
예제 #6
0
function ofdbscraperDbg($text, $append = true)
{
    file_append('debug.txt', $text, $append);
}
예제 #7
0
<?php

$outputPath = 'safariballs.js';
include 'files.php';

function file_append( $target, $source ) {
	$content = file_get_contents( $source );
	return file_put_contents( $target, "\n". $content . "\n", FILE_APPEND );
}


file_put_contents( $outputPath, file_get_contents( 'src/__pre.js' ) );
foreach( $files as $file ) {
	file_append( $outputPath, 'src/' . $file . '.js' );
}
file_append( $outputPath, 'src/__post.js' );
예제 #8
0
/**
 * Write to debug log
 *
 * @author  Andreas Goetz   <*****@*****.**>
 * @param   mixed   $var    Variable to dump
 */
function dlog($var)
{
    file_append(LOG_FILE, $var);
}
예제 #9
0
function log_append($file, $message, $date = null)
{
    if (empty($date)) {
        $date = date('r');
    }
    file_append(DIR_LOGS . '/' . $file, "[" . $date . "] {$message}\n");
}
예제 #10
0
파일: xhr.php 프로젝트: hackingman/TradeX
function _xUpdateExtractInstaller()
{
    chdir('..');
    define('ITEM_TYPE_DIR', 'DIR');
    define('ITEM_TYPE_FILE', 'FILE');
    $installer_file = DIR_DATA . '/install.dat';
    file_append(FILE_LOG_UPDATE, "[" . date('r') . "] Update started...\n");
    $fp = fopen($installer_file, 'r');
    while (!feof($fp)) {
        list($type, $name, $permissions, $su_permissions, $on_install, $on_patch, $chunk, $b64contents) = explode('|', trim(fgets($fp)));
        $permissions = $_REQUEST['su'] ? octdec($su_permissions) : octdec($permissions);
        switch ($type) {
            case ITEM_TYPE_DIR:
                if (!file_exists($name)) {
                    file_append(FILE_LOG_UPDATE, "\tCreating directory {$name}\n");
                    mkdir($name);
                    @chmod($name, $permissions);
                }
                break;
            case ITEM_TYPE_FILE:
                if ($on_patch == 1 || !file_exists($name) && $on_patch == 2) {
                    if ($chunk == 0) {
                        file_append(FILE_LOG_UPDATE, "\tExtracting file {$name}\n");
                    }
                    $fp_out = fopen($name, $chunk == 0 ? 'w' : 'a');
                    fwrite($fp_out, base64_decode($b64contents));
                    fclose($fp_out);
                    @chmod($name, $permissions);
                }
                break;
        }
    }
    fclose($fp);
    file_delete($installer_file);
    JSON::Success();
}