diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..dbac8bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/config/config.php +/config/database.yml +/log/* +/public/assets +/public/data +/tmp/* +/vendor/* +!/vendor/assets +!/vendor/Horde +!/vendor/ZipStream.php diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..a31ccca --- /dev/null +++ b/composer.json @@ -0,0 +1,9 @@ +{ + "name": "myimouto/myimouto", + "require": { + "php": ">=5.4.0", + "myimouto/railsphp": "v1.0.6", + "railsphp/willpaginate": "dev-master", + "michelf/php-markdown": "lib" + } +} \ No newline at end of file diff --git a/log/.gitignore b/log/.gitignore new file mode 100755 index 0000000..e69de29 diff --git a/public/index b/public/index new file mode 100755 index 0000000..7535848 --- /dev/null +++ b/public/index @@ -0,0 +1,3 @@ +dispatch(); diff --git a/public/index.php b/public/index.php index d1d001d..9ab4d29 100755 --- a/public/index.php +++ b/public/index.php @@ -1,46 +1,5 @@ -dispatcher()->request()->path()) && Rails::application()->dispatcher()->request()->isGet()) { - // st(1); - // echo ' '; - // mu(); -} - -function st($end = false) { - static $starttime; - - $mtime = microtime(); - $mtime = explode(" ",$mtime); - $mtime = $mtime[1] + $mtime[0]; - - if (!$end) { - $starttime = $mtime; - } else { - $endtime = $mtime; - $totaltime = ($endtime - $starttime); - echo $totaltime; - } -} -function mu() { - echo 'Memory usage: '.number_to_human_size(memory_get_usage()); -} -function number_to_human_size($bytes){ - $size = $bytes / 1024; - if($size < 1024){ - $size = number_format($size, 1); - $size .= ' KB'; - } else { - if($size / 1024 < 1024){ - $size = number_format($size / 1024, 1); - $size .= ' MB'; - } else if ($size / 1024 / 1024 < 1024) { - $size = number_format($size / 1024 / 1024, 1); - $size .= ' GB'; - } - } - return $size; -} +dispatch(); diff --git a/public/index2.php b/public/index2.php deleted file mode 100755 index 4534d94..0000000 --- a/public/index2.php +++ /dev/null @@ -1,66 +0,0 @@ -limit(10)->take(); -// $m = Post::where(['width' => 1000])->where("user_id = ?", 4)->take(); - -// vpe(Post::find(1)); -// vpe($m); -// vpe($q);define('RAILS_ENV', 'development'); -require __DIR__ . '/../config/boot.php'; - -set_time_limit(0); -JobTask::execute_once(); -exit; -?> - - - - - -AAA - - - - \ No newline at end of file diff --git a/public/posts.php b/public/posts.php deleted file mode 100755 index a115006..0000000 --- a/public/posts.php +++ /dev/null @@ -1,101 +0,0 @@ -query("SELECT id FROM posts ORDER BY id DESC LIMIT 1")->fetchAll(); -if (!$current_id) - $current_id = 0; -else - $current_id = $current_id[0][0]; - -for ($i = 0; $i < $total_queries; $i++) { - echo "Inserting chunk " . ($i+1) . " of " . $total_queries . "...\n"; - - $values_clauses = []; - $params = []; - $posts_tags_sql = []; - - for ($c = 0; $c < $max_inserts; $c++) { - $filesize = rand(2000, 3000); - $md5 = md5($time); - $width = rand(1500, 2000); - $height = rand(1500, 2000); - $created_at = date('Y-m-d H:i:s', $time); - $rating = $ratings[array_rand($ratings)]; - $sample_width = rand(500, 1500); - $sample_height = rand(500, 1500); - $sample_size = rand(1000, 2000); - $index_timestamp = $created_at; - $random = rand(100, 9999999999); - - $values_clauses[] = sprintf($post_values, $filesize, $md5, $width, $height, $created_at, $rating, $sample_width, $sample_height, $sample_size, $index_timestamp, $random); - - $post_id = $pdo->lastInsertId(); - - $tag_count = rand(1, $max_tags); - - $current_id++; - - foreach (range(1, $tag_count) as $ii) { - $posts_tags_sql[] = '(' . $current_id . ', ' . rand(1, 32000) . ')'; - } - $time++; - } - - $sql = "INSERT INTO posts VALUES "; - $sql .= implode(', ', $values_clauses); - $pdo->query($sql); - - $sql = "INSERT INTO posts_tags VALUES " . implode(', ', $posts_tags_sql); - $pdo->query($sql); -} - -echo "Done inserting " . $total_posts . " rows.\n"; \ No newline at end of file diff --git a/public/tag_script.php b/public/tag_script.php deleted file mode 100755 index 46515f5..0000000 --- a/public/tag_script.php +++ /dev/null @@ -1,59 +0,0 @@ -validate_safe_ips()) { - require 'under_maintenance.html'; - exit; -} - -set_time_limit(0); - -# Change collation -ActiveRecord::connection()->exec("ALTER TABLE `tags` CHANGE `name` `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL"); - -# Non-utf8 connection. -$db_data = Rails::application()->config('activerecord'); -$db_data['connection'] = trim(str_replace('charset=utf8', '', $db_data['connection']), ';'); -ActiveRecord::add_connection($db_data, 'nonutf8'); - -$min = 1; -$max = 1000; - -$tags = Tag::find_all(['conditions' => "id > $min AND id < $max"]); - -while ($tags->any()) { - ActiveRecord::set_connection('nonutf8'); - foreach ($tags as $tag) { - $decoded = utf8_decode($tag->name); - if (!preg_match('!!u', $decoded)) { - try { - $t = Tag::find($tag->id); - ActiveRecord::set_connection('default'); - ActiveRecord::connection()->beginTransaction(); - $tag->update_attributes(['name' => $t->name, 'cached_related' => '', 'cached_related_expires_on' => null]); - } catch (Exception $e) { - $error = '

Error

'; - $error .= '

Type: ' .get_class($e). '

'; - $error .= '

Message: '.$e->getMessage().'

'; - $error .= '

Tag id: '.$t->id.'

'; - $error .= '

UTF8 name: '.$tag->name.'

'; - $error .= '

Non-UTF8 name: '.$t->name.'

'; - $error .= '
'; - echo $error; - ActiveRecord::connection()->rollBack(); - continue; - } - ActiveRecord::connection()->commit(); - } - } - - $min += 1000; - $max += 1000; - $tags = Tag::find_all(['conditions' => "id > $min AND id < $max"]); -} - -unlink(Rails::root() . '/public/under_maintenance.html'); -unlink(Rails::root() . '/public/index.php'); -rename(Rails::root() . '/public/index', Rails::root() . '/public/index.php'); - -header('Location: /'); \ No newline at end of file diff --git a/script/daemons/job_task_processor.php b/script/daemons/job_task_processor.php new file mode 100755 index 0000000..e5eb4c1 --- /dev/null +++ b/script/daemons/job_task_processor.php @@ -0,0 +1,6 @@ +