function error_out($type, $message)
{
    log_("ERROR", "[statserver] {$type}: {$message}");
    header("HTTP/1.1 {$type}:", true, $type);
    exit;
}
Ejemplo n.º 2
0
 /**
  * @return boolean
  */
 function write()
 {
     global $targets, $locales;
     log_('Writing POTFile ' . $this->filename . '..');
     $fh = @fopen($this->filename, 'w');
     if (!$fh) {
         log_(sprintf('<p class="error">Could not open %s for writing.</p>', $this->filename));
         return false;
     }
     fwrite($fh, '# SOME DESCRIPTIVE TITLE.' . "\n" . '# Copyright (C) YEAR Francois PLANQUE' . "\n" . '# This file is distributed under the same license as the PACKAGE package.' . "\n" . '# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.' . "\n" . '#' . "\n" . '#, fuzzy' . "\n" . 'msgid ""' . "\n" . 'msgstr ""' . "\n" . '"Project-Id-Version: PACKAGE VERSION\\n"' . "\n" . '"Report-Msgid-Bugs-To: http://fplanque.net/\\n"' . "\n" . '"POT-Creation-Date: 2004-04-26 03:00+0200\\n"' . "\n" . '"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"' . "\n" . '"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"' . "\n" . '"Language-Team: LANGUAGE <*****@*****.**>\\n"' . "\n" . '"MIME-Version: 1.0\\n"' . "\n" . '"Content-Type: text/plain; charset=CHARSET\\n"' . "\n" . '"Content-Transfer-Encoding: 8bit\\n"' . "\n");
     $count = 0;
     foreach ($this->msgids as $msgid => $arr) {
         if (isset($arr['source'])) {
             // write sources of string
             foreach ($arr['source'] as $source) {
                 fwrite($fh, '#: ../../' . $source . "\n");
             }
         }
         fwrite($fh, 'msgid "' . $msgid . '"' . "\nmsgstr " . '""' . "\n\n");
         $count++;
     }
     fclose($fh);
     log_($count . ' msgids written.');
     return true;
 }
Ejemplo n.º 3
0
                log_('task#' . $task['id'] . ' original imageid#' . $or['image_id'] . ' ' . $or['width'] . 'x' . $or['height'] . ', ' . round($or['bytes'] / 1024 / 1024 * 1000) / 1000 . ' Mb');
                if (!is_readable($orig_file_path)) {
                    $to_delete[$task['id']] = $task['id'];
                    $to_error[$task['id']] = ImgStore::ERROR_NOT_READABLE;
                    log_($orig_file_path . ' is not readable');
                } else {
                    log_($orig_file_path . ' is readable, processing to ' . $task['width_requested'] . 'x' . $task['height_requested']);
                    $target_file_path = ImgStore::getFileLocalPath($task['image_id'], $task['size_id']);
                    $settings = array('width' => $or['width'], 'height' => $or['height'], 'crop_method' => $task['crop_method'], 'width_requested' => $task['width_requested'], 'height_requested' => $task['height_requested'], 'size_id' => $task['size_id']);
                    log_('saving to ' . $target_file_path);
                    list($new_width, $new_height, $target_width, $target_height) = ImgStore::resize($orig_file_path, $settings, $target_file_path);
                    $bytes = filesize($target_file_path);
                    log_('saved as ' . $new_width . 'x' . $new_height . '[requested ' . $target_width . 'x' . $target_height . '], ' . round($bytes / 1024 / 1024 * 1000) / 1000 . ' Mb');
                    Database::query('UPDATE `images` SET 
                        `width`=' . $new_width . ',
                        `height`=' . $new_height . ',
                        `ready`=1,
                        `server_id`=' . ImgStore::SERVER_ORIG . ',
                        `bytes` =' . $bytes . ' WHERE `id`=' . $task['id']);
                }
            } else {
                log_('task# ' . $task['id'] . ' original missed!');
                $to_delete[$task['id']] = $task['id'];
            }
        }
    }
}
function log_($txt)
{
    echo date('Y-m-d H:i:s') . ' ' . $txt . "\n";
}
Ejemplo n.º 4
0
                        $res = Amazon::delete($amazon_dest);
                        log_('deleted ' . $amazon_dest . ' from amazon with code:' . $res);
                        Database::query('UPDATE `images` SET `server_id`=' . ImgStore::SERVER_PRIVATE . ', `private_real`=1 WHERE `id`=' . $image['id']);
                    }
                } else {
                    // get from local file, delete amazon copy
                    $amazon_dest = str_replace(ImgStore::$server_urls[ImgStore::SERVER_AMAZONS3], '', ImgStore::getUrl($image['image_id'], $image['size_id'], 0));
                    $res = Amazon::delete($amazon_dest);
                    log_('deleted ' . $amazon_dest . ' from amazon with code:' . $res);
                    //
                    $real_path = ImgStore::getFileLocalPath($image['image_id'], $image['size_id']);
                    log_($image['id'] . ' at original server in ' . $real_path . ' ' . filesize($real_path) . ' bytes');
                    // change location to private folder
                    $real_private_path = ImgStore::getFileLocalPath($image['image_id'], $image['size_id'], $private = true);
                    log_('will be moved to ' . $real_private_path);
                    if (copy($real_path, $real_private_path)) {
                        log_('succesfully copied');
                        Database::query('UPDATE `images` SET `server_id`=' . ImgStore::SERVER_PRIVATE . ', `private_real`=1 WHERE `id`=' . $image['id']);
                        unlink($real_path);
                    } else {
                        log_('cant copy');
                    }
                }
            }
        }
    }
}
function log_($txt)
{
    echo date('Y-m-d H:i:s') . ' ' . $txt . "\n";
}
Ejemplo n.º 5
0
            if ($limit['uploaded_count'] > $day_limit_count) {
                log_('LIMIT REACHED[COUNT]:' . $limit['uploaded_count'] . ' FROM ' . $day_limit_count);
                exit(0);
            } else {
                log_('LIMIT [COUNT]:' . $limit['uploaded_count'] . ' FROM ' . $day_limit_count);
            }
            $real_path = ImgStore::getFileLocalPath($image['image_id'], $image['size_id']);
            log_($real_path . ' ' . floor($image['bytes'] / 1024 / 1024 * 1000) / 1000 . 'Mb');
            $target_path = str_replace(ImgStore::$server_urls[ImgStore::SERVER_ORIG], '', ImgStore::getUrl($image['image_id'], $image['size_id'], 0));
            log_('saving to ' . $target_path);
            $result = Amazon::store($real_path, $target_path);
            if ($result) {
                $limit['uploaded_count']++;
                $limit['uploaded_bytes'] += $image['bytes'];
                log_('Stored at amazon at ' . ImgStore::$server_urls[ImgStore::SERVER_AMAZONS3] . $target_path);
                Database::query('UPDATE `images` SET 
                    `server_id`=' . ImgStore::SERVER_AMAZONS3 . ',
                    `amazon_stored_time`=' . time() . ' WHERE `id`=' . $image['id']);
            } else {
                log_('Cant store file to amazon');
                Database::query('UPDATE `images` SET `amazon_stored_time`=' . time() . ' WHERE `id`=' . $image['id']);
            }
            Database::query('REPLACE INTO `amazon_limit` SET `day`=' . $day . ', `uploaded_bytes`=' . $limit['uploaded_bytes'] . ',`uploaded_count`=' . $limit['uploaded_count']);
        }
        log_('+');
    }
}
function log_($txt)
{
    echo date('Y-m-d H:i:s') . ' ' . $txt . "\n";
}
function reply_and_exit($http_status)
{
    global $g_log_file;
    header("HTTP/1.1 {$http_status}", true, $http_status);
    if ($http_status != HTTP_OK) {
        log_(ERROR, "[statserver] Returned HTTP status={$http_status}");
        $rc = 1;
    } else {
        $rc = 0;
    }
    if ($g_log_file) {
        fclose($g_log_file);
    }
    exit($rc);
}