Example #1
0
 public function process()
 {
     $tag = $this->get('tag');
     $type = $this->get('type');
     if (empty($tag)) {
         throw new Error_Api('Пропущено обязательное поле: tag', Error_Api::MISSING_INPUT);
     }
     if (empty($type)) {
         throw new Error_Api('Пропущено обязательное поле: type', Error_Api::MISSING_INPUT);
     }
     if (!array_key_exists($type, $this->types)) {
         throw new Error_Api('Неправильно заполнено поле: type', Error_Api::INCORRECT_INPUT);
     }
     $color = $this->types[$type];
     $tag = trim(undo_safety($tag));
     $args = array($tag, '|' . $tag . '|', $tag);
     $exists = Database::get_field('tag', 'alias', 'name = ? or locate(?, variants) or alias = ?', $args);
     if ($exists) {
         $alias = $exists;
     } else {
         $alias = Transform_Meta::make_alias($tag);
         Database::insert('tag', array('alias' => $alias, 'name' => $tag, 'variants' => '|'));
         $this->add_error(Error_Api::UNKNOWN_TAG);
     }
     Database::update('tag', array('color' => $color), 'alias = ?', $alias);
     $this->set_success(true);
     $this->add_answer('tag', $alias);
 }
Example #2
0
 protected function process()
 {
     $torrent = new Transform_Torrent($this->file);
     if (!$torrent->is_valid()) {
         throw new Error_Upload(Error_Upload::NOT_A_TORRENT);
     }
     $torrent->delete('announce-list');
     $torrent->set('announce', def::tracker('announce'));
     $data = $torrent->encode();
     $hash = $torrent->get_hash();
     $post_id = Database::get_field('post_torrent', 'post_id', 'hash = ?', $hash);
     if ($post_id) {
         throw new Error_Upload(Error_Upload::ALREADY_EXISTS);
     }
     $filename = pathinfo(urldecode($this->name), PATHINFO_FILENAME);
     $filename = Transform_File::make_name($filename);
     $filename = substr($filename, 0, 200) . '.torrent';
     if (!is_dir(FILES . SL . 'torrent' . SL . $hash)) {
         mkdir(FILES . SL . 'torrent' . SL . $hash, 0755);
     }
     $newfile = FILES . SL . 'torrent' . SL . $hash . SL . $filename;
     file_put_contents($newfile, $data);
     $size = $torrent->get_size();
     $size = Transform_File::weight_short($size);
     $return_data = '<input size="24%" type="text" name="torrent[0][name]" value="Скачать" />:' . "\n" . '<input readonly size="24%" type="text" name="torrent[0][file]" value="' . $filename . '" />' . "\n" . '<input type="hidden" name="torrent[0][hash]" value="' . $hash . '" />' . "\n" . '<input readonly size="4%" type="text" name="torrent[0][size]" value="' . $size . '" />' . "\n" . '<input type="submit" class="disabled sign remove_link" rel="torrent" value="-" />';
     $this->set(array('success' => true, 'data' => $return_data, 'file' => $filename, 'hash' => $hash, 'name' => 'Скачать', 'size' => $size));
 }
Example #3
0
	public function add ($query) {

		list($place, $item_id) = $this->parse_referer($query);

		if (!empty($query['parent'])) {
			$root = Database::get_field('comment', 'root', $query['parent']);

			if (empty($root)) {
				$root = $query['parent'];
			}
		} else {
			$root = 0;
		}

		$insert = array(
			'root' => $root,
			'parent' => $query['parent'],
			'place' => $place,
			'item_id' => $item_id,
			'area' => 'main',
			'username' => $query['name'],
			'email' => $query['email'],
			'ip' => Globals::$user_data['ip'],
			'cookie' => Globals::$user_data['cookie'],
			'text' => Transform_Text::format($query['text']),
			'pretty_text' => $query['text'],
		);

		Database::insert('comment', $insert);
		
		Database::update($place, $item_id, array('comments' => '++'));

		$this->redirect_address = $this->referer;
	}
Example #4
0
 protected function insert_url($url)
 {
     $id = Database::get_field('post_url', 'id', 'url = ?', $url);
     if (empty($id)) {
         Database::insert('post_url', array('url' => $url));
         $id = Database::last_id();
     }
     return $id;
 }
Example #5
0
 protected function test_file()
 {
     parent::test_file();
     $md5 = md5_file($this->file);
     if ($id = Database::get_field('art_pack', 'id', 'title = ?', $this->title)) {
         throw new Error_Upload($id, Error_Upload::ALREADY_EXISTS);
     }
     $this->md5 = $md5;
 }
Example #6
0
 protected function test_file()
 {
     parent::test_file();
     $md5 = md5_file($this->file);
     if (($id = Database::get_field('art', 'id', 'md5 = ?', $md5)) || ($id = Database::get_field('art_variation', 'id', 'md5 = ?', $md5))) {
         throw new Error_Upload($id, Error_Upload::ALREADY_EXISTS);
     }
     $this->md5 = $md5;
 }
Example #7
0
 protected function do_set($data)
 {
     if (!isset($data['setting']) || !preg_match('/^[a-z_]+$/uis', $data['setting']) || !isset($data['value']) || !is_numeric($data['value'])) {
         return array('success' => false);
     }
     $setting = Database::get_field('setting', 'id', 'setting = ?', $data['setting']);
     if (empty($setting)) {
         return array('success' => false);
     }
     Database::replace('user_setting', array('id_user' => $this->user, 'id_setting' => $setting, 'value' => $data['value']), array('id_user', 'id_setting'));
     return array('success' => true);
 }
Example #8
0
	public function checkpassword() {
		if (Check::num(query::$get['id'])) {

			$pass = Database::get_field('art_pool', 'password', query::$get['id']);
			if ($pass == md5(query::$get['val'])) {

				echo 'success';
				return;
			}
		}

		echo 'fail';
	}
Example #9
0
 public function add_similar($data)
 {
     if (!$this->last_order_known) {
         $this->last_order = Database::get_field('art_variation', 'max(`order`)', 'art_id = ?', $this->get_id());
         $this->last_order_known = true;
     }
     if (is_numeric($this->last_order)) {
         $insert_order = $this->last_order + 1;
     } else {
         $insert_order = 0;
     }
     Database::insert('art_variation', array('art_id' => $this->get_id(), 'md5' => $data['md5'], 'thumb' => $data['thumb'], 'extension' => $data['extension'], 'resized' => $data['resized'], 'order' => $insert_order, 'animated' => $data['animated']));
     $this->last_order = $insert_order;
 }
Example #10
0
 protected function do_login($data)
 {
     $password = $this->encode_password($data['password']);
     $login = preg_replace('/[^a-zа-яё_\\s\\d]/ui', '', $data['login']);
     if (!Database::get_count('user', 'login = ?', $login)) {
         return array('error' => 'login_not_exist', 'success' => false);
     }
     $cookie = Database::get_field('user', 'cookie', 'login = ? and password = ?', array($login, $password));
     if (empty($cookie)) {
         return array('error' => 'password_incorrect', 'success' => false);
     }
     setcookie('user', $cookie, time() + MONTH, '/');
     return array('success' => true);
 }
Example #11
0
 /**
  * @param {Integer} $id
  * @return Game_Abstract
  */
 public static function factory($id)
 {
     $type = Database::get_field('game', 'type', $id);
     switch ($type) {
         case 1:
             return new Game_Draft($id);
         case 2:
             return new Game_Sealed($id);
         case 3:
             return new Game_Masters($id);
         default:
             return false;
     }
 }
Example #12
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для видео.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     if (!$post['link']) {
         $this->writer->set_message('Вы не предоставили ссылки, или же ссылка почему-то битая.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     $test = new Transform_Video($post['link']);
     if (!$test->enable_nico()->get_html()) {
         $this->writer->set_message('Ссылка не ведет на видео, либо этот видеохостинг не поддерживается')->set_error(Error_Create::INCORRECT_INPUT);
         return;
     }
     $already_have = Database::get_field('video', 'id', 'link = ?', $post['link']);
     if ($already_have) {
         $error = 'Это видео уже у нас есть, оно находится по адресу <a href="/video/' . $already_have . '/">http://4otaku.org/video/' . $already_have . '/</a>.';
         $this->writer->set_message($error)->set_error(Error_Create::ALREADY_EXISTS);
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $parsed_tags = $worker->parse_array($post['tag']);
     $tags = $worker->add_tags($parsed_tags);
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $item = new Model_Video();
     $item->set_array(array('title' => $post['title'], 'link' => $post['link'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'author' => $author, 'category' => $category, 'tag' => $tags));
     $item->insert();
     // TODO: перемести input__common::transfer в Model_Common
     if (!empty($post['transfer_to'])) {
         input__common::transfer(array('sure' => 1, 'do' => array('video', 'transfer'), 'where' => $post['transfer_to'], 'id' => $item->get_id()));
     }
     $this->writer->set_success()->set_message('Ваша видео успешно добавлено, и доступно по адресу ' . '<a href="/video/' . $item->get_id() . '/">http://4otaku.org/video/' . $item->get_id() . '/</a> или в ' . '<a href="/video/' . def::area(1) . '/">очереди на премодерацию</a>.')->set_param('id', $item->get_id());
 }
Example #13
0
	public function description ($query) {
		
		$params = array();
		
		if (isset($query['meta']) && $query['meta'] == 'author' && isset($query['alias'])) {
			$params['type'] = 'author';
			$params['id'] = $query['alias'];
		} elseif (isset($query['id'])) {
			$params['type'] = 'art';
			$params['id'] = $query['id'];			
		} else {
			return;
		}
		
		$text = Database::get_row(
			'description', 
			array('text', 'pretty_text'),
			'type = ? and description_id = ?', 
			$params
		);
		
		if (!empty($text)) {
			$params = array_merge($params, $text);
		}
		
		if ($params['type'] == 'author') {
			$user = Meta_Author::get_data_by_alias((array) $params['id']);
			$user = current($user);
			$params['username'] = $user['name'];
		} else {
			$params['data'] = Database::get_full_row('art', $query['id']);
			$params['username'] = Database::get_field('user', 'username', $params['data']['user_id']);
			$params['alias'] = Meta_Author::get_alias_by_name($params['username']);
			$params['data']['weight'] = Transform_File::weight($params['data']['weight']);
			$params['data']['date'] = Transform_String::rudate(Database::date_to_unix($params['data']['date']));
		}
		
		$params['can_edit'] = ($params['username'] == Globals::user_info('username'));
		
		return $params;
	}
Example #14
0
 public function parse_images()
 {
     $params = array('pack_art', $this->id);
     $art = Database::get_full_table('misc', 'type = ? and data1 = ? order by data4 limit ' . rand(4, 9), $params);
     $total = Database::get_field('misc', 'data4', 'type = ? and data2 = ?', array('pack_status', $this->id));
     $current_order = Database::get_field('art_in_pack', 'max(`order`)', 'pack_id = ?', $this->id);
     $next_order = !is_numeric($current_order) ? 0 : $current_order + 1;
     if (is_array($art)) {
         $insert_in_pack = array();
         foreach ($art as $one) {
             Database::delete('misc', 'type = ? and id = ?', array('pack_art', $one['id']));
             try {
                 $worker = new Transform_Upload_Art($one['data2'], $one['data4']);
                 $data = $worker->process_file();
                 $art = new Model_Art(array('md5' => $data['md5'], 'thumb' => $data['thumb'], 'extension' => $data['extension'], 'resized' => $data['resized'], 'animated' => $data['animated'], 'author' => '|', 'category' => '|nsfw|game_cg|', 'tag' => '|prostavte_tegi|', 'area' => 'cg'));
                 $art->insert();
             } catch (Error $e) {
                 $data = array();
                 if ($e->getCode() == Error_Upload::ALREADY_EXISTS) {
                     $art = new Model_Art($e->getMessage());
                     if ($art['area'] == 'deleted') {
                         $art['area'] = 'cg';
                         $art->commit();
                     }
                 } else {
                     continue;
                 }
             }
             $insert_in_pack[] = array($art->get_id(), $this->id, $next_order, pathinfo($one['data2'], PATHINFO_BASENAME));
             $next_order++;
         }
         Database::bulk_insert('art_in_pack', $insert_in_pack, array('art_id', 'pack_id', 'order', 'filename'));
     }
     if ($count = Database::get_count('misc', 'type = ? and data1 = ?', array('pack_art', $this->id))) {
         Database::update('misc', array('data3' => $total - $count), 'type = ? and data2 = ?', array('pack_status', $this->id));
     } else {
         Database::update('misc', array('data1' => 'done'), 'type = ? and data2 = ?', array('pack_status', $this->id));
         Database::update('art_pack', array('weight' => 0), $this->id);
     }
 }
Example #15
0
	protected function test_rights ($query) {
		if ($query['type'] == 'art') {
			
			$params = array(
				$query['id'],
				Globals::user_info('id')
			);
			
			return Database::get_field('art', 'id', 'id = ? and user_id = ?', $params);
		}
		
		if ($query['type'] == 'author') {
			
			$user = Meta_Author::get_data_by_alias((array) $query['id']);
			if (empty($user)) {
				return false;
			}
			
			$user = current($user);
			
			return (Globals::user_info('username') == $user['name']);
		}		
	}
Example #16
0
	public function get ($key) {

		$value = Database::get_field("cache", "value", "`key` = ? and `expires` > NOW()", $key);

		return Database::unpack($value);
	}
Example #17
0
 protected function get_title()
 {
     $short = def::site('short_name') . ' ';
     if (count($this->data['items']) == 1) {
         $item = reset($this->data['items']);
         if (empty($item['in_batch'])) {
             return $short . $item->get_title();
         }
     }
     if (count($this->meta) > 1) {
         return $short . 'Записи. Просмотр сложной выборки.';
     }
     if (count($this->meta) == 1) {
         $meta = reset($this->meta);
         if (!$meta->is_simple()) {
             return $short . 'Записи. Просмотр сложной выборки.';
         }
         $type = $meta->get_type();
         $alias = $meta->get_meta();
         $name = Database::get_field($type, 'name', 'alias = ?', $alias);
         $meta_name = $meta->get_type_rus();
         return $short . 'Записи. ' . $meta_name . ': ' . $name;
     }
     return def::site('name');
 }
Example #18
0
 protected function author($url)
 {
     $this->data['author'] = Database::get_field('post_update', 'username', $this->data['id']);
 }
Example #19
0
	public function pack_join () {

		Check::rights();

		$parent = (int) query::$post['parent'];
		$child = (int) query::$post['child'];

		Database::update('art_pack', array('weight' => 0), $parent);

		$child_arts = Database::get_full_table('art_in_pack', 'pack_id = ?', $child);
		$parent_order = Database::get_field('art_in_pack', 'max(`order`)', 'pack_id = ?', $parent);

		foreach ($child_arts as $child_art) {
			Database::update('art_in_pack',
				array(
					'order' => $child_art['order'] + $parent_order + 1,
					'pack_id' => $parent
				),
				'pack_id = ? and art_id = ?',
				array($child_art['pack_id'], $child_art['art_id'])
			);
		}

		Database::delete('art_pack', $child);
	}
Example #20
0
	function track_similar_pictures() {
		if (
			!function_exists('puzzle_fill_cvec_from_file') ||
			!function_exists('puzzle_vector_normalized_distance') ||
			!function_exists('puzzle_compress_cvec') ||
			!function_exists('puzzle_uncompress_cvec')
		) {
			return;
		}
/*
		$max  = obj::db()->sql('select max(id) from art_similar',2);
		$arts = obj::db()->sql('select id, thumb from art where id > '.($max ? $max : 0).' and area != "deleted" order by id limit 2000');

		foreach ($arts as $art) {
			$image = ROOT_DIR.SL.'images'.SL.'booru'.SL.'thumbs'.SL.'large_'.$art['thumb'].'.jpg';
			$vector = puzzle_fill_cvec_from_file($image);
			$vector = base64_encode(puzzle_compress_cvec($vector));

			obj::db()->insert('art_similar',array($art['id'], $vector, 0, ''),false);
		}
*/
		$all = obj::db()->sql('select id, vector from art_similar where vector != ""','id');
		$arts = obj::db()->sql('select * from art_similar where vector != "" and checked=0 limit 100','id');

		if (is_array($all) && is_array($arts)) {
			foreach ($all as $compare_id => $vector) {
				$all[$compare_id] = puzzle_uncompress_cvec(base64_decode($vector));
			}

			foreach ($arts as $id => $art) {
				$art['vector'] = puzzle_uncompress_cvec(base64_decode($art['vector']));
				$similar = '|';
				$art_area = false;
				foreach ($all as $compare_id => $vector) {
					if (
						$id != $compare_id &&
						puzzle_vector_normalized_distance($art['vector'], $vector) < 0.3
					) {
						if (empty($art_area)) {
							$art_area = Database::get_field('art', 'area', $id);
						}

						if ($art_area == 'cg' &&
							Database::get_field('art', 'area', $compare_id) == 'cg') {

							continue;
						}

						$similar .= $compare_id.'|';
					}
				}
				obj::db()->update('art_similar',array('checked','similar'),array(1,$similar),$id);
			}
		}
	}
Example #21
0
    public function pick($user, $card, $set, $shift)
    {
        $user_data = Database::get_row('game_user', array('order', 'force_picks'), 'id_user = ? and id_game = ?', array($user, $this->get_id()));
        $max = Database::get_field('game_user', 'max(`order`)', 'id_game = ?', $this->get_id());
        $order = ($user_data['order'] + ($max + 1) * 15 + $shift * ($set % 2 ? 1 : -1)) % ($max + 1);
        $user_booster = Database::get_field('game_user', 'id_user', '`order` = ? and id_game = ?', array($order, $this->get_id()));
        $id_booster = Database::join('game_set', 'gs.id = gb.id_game_set')->get_field('game_booster', 'gb.`id`', 'gs.`order` = ? and gs.id_game = ? and gb.id_user = ?', array($set, $this->get_id(), $user_booster));
        $pick = $shift + ($set - 1) * 15;
        Database::update('game_booster_card', array('id_user' => $user, 'pick' => $pick, 'forced' => 0), 'id = ? and id_user = 0 and not exists
			(select 1 from (select * from `game_booster_card` where id_game_booster = ?) as t
			where t.pick = ? and t.id_user > 0)', array($card, $id_booster, $shift));
        $success = Database::count_affected() > 0;
        if ($user_data['force_picks']) {
            Database::update('game_user', array('force_picks' => 0), 'id_user = ? and id_game = ?', array($user, $this->get_id()));
        }
        if ($success) {
            $picked_count = Database::join('game_booster', 'gb.id_game_set = gs.id')->join('game_booster_card', 'gbc.id_game_booster = gb.id')->get_count('game_set', 'gs.id_game = ? and gs.order = ? and gbc.pick = ? and gbc.id_user > 0', array($this->get_id(), $set, $pick));
            $force_users = Database::get_vector('game_user', 'id_user', 'id_game = ? and force_picks > ?', array($this->get_id(), 1));
            $user_count = Database::get_count('game_user', 'id_game = ?', $this->get_id());
            $cache_key = 'force_lock_' . $this->get_id() . '_' . $pick;
            if (count($force_users) + $picked_count >= $user_count && !Cache::get($cache_key)) {
                Cache::set($cache_key, 1);
                if (!empty($force_users)) {
                    $this->force_picks($force_users, $set, $shift);
                }
                $this->shift_game_steps();
                Cache::delete($cache_key);
            }
        }
        return $success;
    }
Example #22
0
 public function process()
 {
     $title = $this->get('title');
     if (empty($title)) {
         throw new Error_Api('Пропущено обязательное поле: title', Error_Api::MISSING_INPUT);
     }
     if ($id = Database::get_field('post', 'id', 'title = ? and area != "deleted"', $title)) {
         $this->add_answer('id', $id);
         throw new Error_Api('Запись с таким title уже есть', Error_Api::INCORRECT_INPUT);
     }
     $links = $this->get('link');
     $torrents = $this->get('torrent');
     if (empty($links) && empty($torrent)) {
         throw new Error_Api('Пропущены оба поля: link и torrent. Заполните хотя бы одно.', Error_Api::MISSING_INPUT);
     }
     $files = $this->get('file');
     $images = $this->get('image');
     $links = (array) $links;
     foreach ($links as $index => &$link) {
         if (strpos($link['size'], ' ')) {
             $linksize = preg_split('/ +/u', $link['size']);
         }
         $link['size'] = $linksize[0];
         $link['sizetype'] = $linksize[1];
         if (array_key_exists($link['sizetype'], $this->link_size_types)) {
             $link['sizetype'] = $this->link_size_types[$link['sizetype']];
         }
     }
     $torrents = (array) $torrents;
     foreach ($torrents as $index => &$torrent) {
         try {
             if (empty($torrent['name'])) {
                 $torrent['name'] = 'download';
             }
             $torrent['file'] = $this->get_file($torrent['file']);
             $uploader = new Transform_Upload_Post_Torrent($torrent['file'], $torrent['name'] . '.torrent');
             $torrent = $uploader->process_file();
         } catch (Error $e) {
             $number = $index + 1;
             $message = 'Не удалось добавить торрент №' . $number . '; Содержимое: ' . substr($torrent['file'], 0, 2000);
             if (strlen($torrent['file']) > 2000) {
                 $message .= ' ...';
             }
             $this->add_error($e->getCode(), $message);
             unset($torrents[$index]);
         }
     }
     $files = (array) $files;
     foreach ($files as $index => &$file) {
         try {
             if (empty($file['name'])) {
                 if (preg_match(Transform_Text::URL_REGEX, substr($file['file'], 0, 1000))) {
                     $file['name'] = basename($file['file']);
                 }
                 if (empty($file['name'])) {
                     $file['name'] = 'file';
                 }
             }
             $file['file'] = $this->get_file($file['file']);
             if (!strpos($file['name'], '.')) {
                 $extension = $this->get_extension($file['file']);
                 $file['name'] = $file['name'] . '.' . $extension;
             }
             $uploader = new Transform_Upload_Post_File($file['file'], $file['name']);
             $file = $uploader->process_file();
         } catch (Error $e) {
             $number = $index + 1;
             $message = 'Не удалось добавить файл №' . $number . '; Содержимое: ' . substr($file['file'], 0, 2000);
             if (strlen($file['file']) > 2000) {
                 $message .= ' ...';
             }
             $this->add_error($e->getCode(), $message);
             unset($files[$index]);
         }
     }
     $images = (array) $images;
     foreach ($images as $index => &$image) {
         try {
             $image = $this->get_file($image);
             $extension = $this->get_extension($image);
             $filename = 'image.' . $extension;
             $uploader = new Transform_Upload_Post_Image($image, $filename);
             $image = $uploader->process_file();
             $image = $image['data'];
         } catch (Error $e) {
             $number = $index + 1;
             $message = 'Не удалось добавить изображение №' . $number . '; Содержимое: ' . substr($image, 0, 2000);
             if (strlen($image) > 2000) {
                 $message .= ' ...';
             }
             $this->add_error($e->getCode(), $message);
             unset($images[$index]);
         }
     }
     $data = array('title' => $title, 'link' => $links, 'torrent' => $torrents, 'bonus_link' => $this->get('bonus_link'), 'file' => $files, 'image' => $images, 'tag' => (array) $this->get('tag'), 'category' => $this->transform_category(), 'author' => implode(',', (array) $this->get('author')), 'language' => $this->transform_language(), 'text' => (string) $this->get('text'));
     try {
         $worker = new Create_Post(new Action_Reader_Inner($data), new Action_Writer_Inner());
         $worker->main();
         $result = $worker->process_result();
     } catch (Error_Create $e) {
         throw new Error_Api($e->getMessage(), $e->getCode());
     }
     if ($result->get_error()) {
         throw new Error_Api($result->get_message(), $result->get_error());
     }
     $success = $result->get_success();
     $this->set_success($success);
     if ($success) {
         $this->add_answer('id', $result->get_data('id'));
     }
 }
Example #23
0
 protected function text($url)
 {
     ob_end_clean();
     $this->data['text'] = Database::get_field('post', 'pretty_text', $url[2]);
 }
Example #24
0
	protected function get_html($id) {
		$updated = Database::get_field('board', 'updated',
			'`type` != ? and id = ?', array('deleted', $id));

		if (!empty($updated)) {
			$file_name = 'thread_'.$id.'_'.$updated.'.html';

			if (!file_exists(self::$work_dir.$file_name)) {


				$css = file_get_contents(ROOT_DIR.SL.'jss'.SL.'main.css');
				$css_regex = '/^\/\*.+?\*\/(.*?)\/\*.*\/\*\s+Content,\s+борда\s+\*\/(.*?)\/\*/uis';
				preg_match($css_regex, $css, $css);
				$style = '<style>'.$css[1].$css[2].'</style>';

				$encoding = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
				$head = '<head>'.$encoding.$style.'</head>';

				$download_url = 'http://'.def::site('domain').
					'/board/download/thread/'.$id;
				$body = '<body>'.Http::download($download_url).'</body>';
				$body = preg_replace_callback('/<img[^>]+>/si',
					array('self', 'image_encode'), $body);

				$file = fopen(self::$work_dir.$file_name,'w');
				fwrite($file,preg_replace('/[\n\r\t]+/','','<html>'.$head.$body.'</html>'));
				fclose($file);
			}

			return self::$work_dir.$file_name;
		}

		return false;
	}
Example #25
0
<?php

$link = $_GET['link'];
include '../inc.common.php';
if (is_numeric($link)) {
    $link = Database::get_field('post_url', 'url', $link);
}
$worker = new Cron_Post_Gouf();
$worker->test($link);
Example #26
0
	protected function catalog($board) {
		global $error;

		$return = array('boards' => $this->board_categories);
		$return['display'] = array('board_menu', 'board_catalog', 'board_menu');

		$return['threads'] = $this->get_thread_records();

		if ($board) {
			$category_id = Database::get_field('category', 'id',
				'locate("|board|",area) and alias=?', $board);
			if (!$category_id) {
				$error = true;
				$this->side_modules['top'] = array('board_list');
				return array();
			}
			$condition = 'board_category.category_id = '.$category_id.' AND ';
		} else {
			$condition = '';
		}

		$return['threads'] = $this->get_thread_records($condition);

		return $return;
	}