move data to data folder
This commit is contained in:
parent
29cebb44f9
commit
7cbb62c8cc
@ -167,7 +167,7 @@ class AdminPage extends Extension {
|
|||||||
|
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
$images = $database->get_all("SELECT * FROM images");
|
$images = $database->get_all("SELECT * FROM images");
|
||||||
$filename = 'data/imgdump-'.date('Ymd').'.zip';
|
$filename = data_path('imgdump-'.date('Ymd').'.zip');
|
||||||
|
|
||||||
if($zip->open($filename, 1 ? ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE) === TRUE){
|
if($zip->open($filename, 1 ? ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE) === TRUE){
|
||||||
foreach($images as $img){
|
foreach($images as $img){
|
||||||
|
@ -24,12 +24,10 @@ class Oekaki extends Extension {
|
|||||||
if(isset($_FILES["picture"])) {
|
if(isset($_FILES["picture"])) {
|
||||||
header('Content-type: text/plain');
|
header('Content-type: text/plain');
|
||||||
|
|
||||||
$uploaddir = './data/oekaki_unclaimed/';
|
|
||||||
if(!file_exists($uploaddir)) mkdir($uploaddir, 0755, true);
|
|
||||||
$file = $_FILES['picture']['name'];
|
$file = $_FILES['picture']['name'];
|
||||||
$ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
|
$ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
|
||||||
$uploadname = $_SERVER['REMOTE_ADDR'] . "." . time();
|
$uploadname = $_SERVER['REMOTE_ADDR'] . "." . time();
|
||||||
$uploadfile = $uploaddir . $uploadname;
|
$uploadfile = data_path('oekaki_unclaimed/'.$uploadname);
|
||||||
|
|
||||||
log_info("oekaki", "Uploading file [$uploadname]");
|
log_info("oekaki", "Uploading file [$uploadname]");
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ class Oekaki extends Extension {
|
|||||||
// FIXME: move .chi to data/oekaki/$ha/$hash mirroring images and thumbs
|
// FIXME: move .chi to data/oekaki/$ha/$hash mirroring images and thumbs
|
||||||
// FIXME: .chi viewer?
|
// FIXME: .chi viewer?
|
||||||
// FIXME: clean out old unclaimed images?
|
// FIXME: clean out old unclaimed images?
|
||||||
$pattern = './data/oekaki_unclaimed/' . $_SERVER['REMOTE_ADDR'] . ".*.png";
|
$pattern = data_path('oekaki_unclaimed/' . $_SERVER['REMOTE_ADDR'] . ".*.png");
|
||||||
foreach(glob($pattern) as $tmpname) {
|
foreach(glob($pattern) as $tmpname) {
|
||||||
assert(file_exists($tmpname));
|
assert(file_exists($tmpname));
|
||||||
|
|
||||||
|
@ -265,7 +265,6 @@ class ResizeImage extends Extension {
|
|||||||
$new_hash = md5_file($tmp_filename);
|
$new_hash = md5_file($tmp_filename);
|
||||||
$new_size = filesize($tmp_filename);
|
$new_size = filesize($tmp_filename);
|
||||||
$target = warehouse_path("images", $new_hash);
|
$target = warehouse_path("images", $new_hash);
|
||||||
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
|
||||||
if(!@copy($tmp_filename, $target)) {
|
if(!@copy($tmp_filename, $target)) {
|
||||||
throw new ImageResizeException("Failed to copy new image file from temporary location ({$tmp_filename}) to archive ($target)");
|
throw new ImageResizeException("Failed to copy new image file from temporary location ({$tmp_filename}) to archive ($target)");
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class Update extends Extension {
|
|||||||
$commit = $matches[2];
|
$commit = $matches[2];
|
||||||
mkdir("./backup");
|
mkdir("./backup");
|
||||||
$html .= "<br>backup folder created!";
|
$html .= "<br>backup folder created!";
|
||||||
$d_dir = "data/cache";
|
$d_dir = data_path("cache");
|
||||||
//This should empty the /data/cache/ folder.
|
//This should empty the /data/cache/ folder.
|
||||||
if (is_dir($d_dir)) {
|
if (is_dir($d_dir)) {
|
||||||
$objects = scandir($d_dir);
|
$objects = scandir($d_dir);
|
||||||
|
@ -1080,7 +1080,6 @@ class Tag {
|
|||||||
*/
|
*/
|
||||||
function move_upload_to_archive(DataUploadEvent $event) {
|
function move_upload_to_archive(DataUploadEvent $event) {
|
||||||
$target = warehouse_path("images", $event->hash);
|
$target = warehouse_path("images", $event->hash);
|
||||||
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
|
||||||
if(!@copy($event->tmpname, $target)) {
|
if(!@copy($event->tmpname, $target)) {
|
||||||
$errors = error_get_last(); // note: requires php 5.2
|
$errors = error_get_last(); // note: requires php 5.2
|
||||||
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target): {$errors['type']} / {$errors['message']}");
|
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target): {$errors['type']} / {$errors['message']}");
|
||||||
|
@ -246,17 +246,13 @@ class Page {
|
|||||||
$this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>");
|
$this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>");
|
||||||
$this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>");
|
$this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>");
|
||||||
|
|
||||||
if(!file_exists("data/cache")) {
|
|
||||||
mkdir("data/cache");
|
|
||||||
}
|
|
||||||
|
|
||||||
$css_files = array();
|
$css_files = array();
|
||||||
$css_latest = 0;
|
$css_latest = 0;
|
||||||
foreach(array_merge(zglob("lib/*.css"), zglob("ext/*/style.css"), zglob("themes/$theme_name/style.css")) as $css) {
|
foreach(array_merge(zglob("lib/*.css"), zglob("ext/*/style.css"), zglob("themes/$theme_name/style.css")) as $css) {
|
||||||
$css_files[] = $css;
|
$css_files[] = $css;
|
||||||
$css_latest = max($css_latest, filemtime($css));
|
$css_latest = max($css_latest, filemtime($css));
|
||||||
}
|
}
|
||||||
$css_cache_file = "data/cache/style.$css_latest.css";
|
$css_cache_file = data_path("cache/style.$css_latest.css");
|
||||||
if(!file_exists($css_cache_file)) {
|
if(!file_exists($css_cache_file)) {
|
||||||
$css_data = "";
|
$css_data = "";
|
||||||
foreach($css_files as $file) {
|
foreach($css_files as $file) {
|
||||||
@ -276,7 +272,7 @@ class Page {
|
|||||||
$js_files[] = $js;
|
$js_files[] = $js;
|
||||||
$js_latest = max($js_latest, filemtime($js));
|
$js_latest = max($js_latest, filemtime($js));
|
||||||
}
|
}
|
||||||
$js_cache_file = "data/cache/script.$js_latest.js";
|
$js_cache_file = data_path("cache/script.$js_latest.js");
|
||||||
if(!file_exists($js_cache_file)) {
|
if(!file_exists($js_cache_file)) {
|
||||||
$js_data = "";
|
$js_data = "";
|
||||||
foreach($js_files as $file) {
|
foreach($js_files as $file) {
|
||||||
|
@ -645,6 +645,12 @@ function warehouse_path(/*string*/ $base, /*string*/ $hash, /*bool*/ $create=tru
|
|||||||
return $pa;
|
return $pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function data_path($filename) {
|
||||||
|
$filename = "data/" . $filename;
|
||||||
|
if($create && !file_exists(dirname($filename))) mkdir(dirname($filename), 0755, true);
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
function transload($url, $mfile) {
|
function transload($url, $mfile) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -1075,10 +1081,7 @@ function _load_extensions() {
|
|||||||
$p .= ");\n";
|
$p .= ");\n";
|
||||||
|
|
||||||
$p .= "?".">";
|
$p .= "?".">";
|
||||||
if(!file_exists("data/cache")) {
|
file_put_contents(data_path("cache/event_listeners.php"), $p);
|
||||||
mkdir("data/cache", 755, true);
|
|
||||||
}
|
|
||||||
file_put_contents("data/cache/event_listeners.php", $p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,11 +1235,9 @@ function _start_cache() {
|
|||||||
$_cache_hash = md5($_SERVER["QUERY_STRING"]);
|
$_cache_hash = md5($_SERVER["QUERY_STRING"]);
|
||||||
$ab = substr($_cache_hash, 0, 2);
|
$ab = substr($_cache_hash, 0, 2);
|
||||||
$cd = substr($_cache_hash, 2, 2);
|
$cd = substr($_cache_hash, 2, 2);
|
||||||
$_cache_filename = "data/http_cache/$ab/$cd/$_cache_hash";
|
$_cache_filename = data_path("http_cache/$ab/$cd/$_cache_hash");
|
||||||
|
@chmod(data_path('http_cache'), 750);
|
||||||
|
|
||||||
if(!file_exists(dirname($_cache_filename))) {
|
|
||||||
mkdir(dirname($_cache_filename), 0750, true);
|
|
||||||
}
|
|
||||||
if(file_exists($_cache_filename) && (filemtime($_cache_filename) > time() - 3600)) {
|
if(file_exists($_cache_filename) && (filemtime($_cache_filename) > time() - 3600)) {
|
||||||
$gmdate_mod = gmdate('D, d M Y H:i:s', filemtime($_cache_filename)) . ' GMT';
|
$gmdate_mod = gmdate('D, d M Y H:i:s', filemtime($_cache_filename)) . ' GMT';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user