Example #1
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 #2
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->set('comment_rights', sets::user('rights') || $this->get('cookie') == query::$cookie);
     $this->set('text', Transform_Text::cut_long_words($this->get('text')));
     $this->set('delete_rights', sets::user('rights'));
     $this->set('avatar', md5(strtolower($this->get('email'))));
 }
Example #3
0
 public function insert()
 {
     $this->set('pretty_date', Transform_Text::rudate());
     $this->set('sortdate', ceil(microtime(true) * 1000));
     $this->set('area', def::area(1));
     parent::insert();
     return $this;
 }
Example #4
0
 protected function get_data()
 {
     $strip = Database::get_full_row('strip', $this->id);
     if (empty($strip)) {
         return array('error' => true);
     }
     $strip['text'] = Transform_Text::format($strip['text']);
     return array('strip' => $strip, 'images' => Database::join('file', 'sf.id_file = f.id')->order('sf.order', 'asc')->get_full_table('strip_file', 'id_strip = ?', $strip['id']), 'next' => $strip['order'] ? Database::order('order', 'asc')->get_full_row('strip', '`order` > ?', $strip['order']) : false);
 }
Example #5
0
 public function insert()
 {
     $this->set('pretty_date', Transform_Text::rudate());
     $this->set('sortdate', ceil(microtime(true) * 1000));
     $this->set('area', def::area(0));
     parent::insert();
     Database::update('post', array('update_count' => '++'), $this->get('post_id'));
     $this->add_children();
     return $this;
 }
Example #6
0
	public function edit ($query) {
		
		if (!($this->test_rights($query))) {
			return;
		}
		
		$insert = array(
			'type' => $query['type'],
			'description_id' => $query['id'],
			'pretty_text' => $query['text'],
			'text' => Transform_Text::format($query['text']),
		);
		
		Database::replace('description', $insert, array('type', 'description_id'));
	}
Example #7
0
 protected function get_data()
 {
     if (!$this->id) {
         return array('error' => true);
     }
     $strip = Database::get_full_row('strip', '`order` = ?', $this->id);
     if (empty($strip)) {
         return array('error' => true);
     }
     $strip['text'] = Transform_Text::format($strip['text']);
     $logs = Database::order('order')->limit(30)->get_vector('strip', array('id', 'order', 'title', 'date'), '`order` > 0');
     foreach ($logs as &$log) {
         $log['date'] = strtotime($log['date']);
         $log['date'] = $log['date'] > 0 ? date('y/m/d', $log['date']) : '';
     }
     return array('page' => $this->id, 'logs' => $logs, 'strip' => $strip, 'images' => Database::join('file', 'sf.id_file = f.id')->order('sf.order', 'asc')->get_full_table('strip_file', 'id_strip = ?', $strip['id']), 'next' => Database::order('order', 'asc')->get_full_row('strip', '`order` > ?', $strip['order']), 'back' => Database::order('order')->get_field('strip', 'order', '`order` < ?', $strip['order']), 'autosave' => isset($_COOKIE['autosave']) ? (int) $_COOKIE['autosave'] : 0);
 }
Example #8
0
	public function postprocess () {
		$this->data['settings'] = $this->flag;
		
		if (!empty($this->data['latest'])) {
			$latest = & $this->data['latest'];
			$latest = (array) $latest;
			
			foreach ($latest as & $item) {
				if (is_array($item) && !empty($item['text'])) {
					$item['headline'] = Transform_Text::headline($item['text']);
					unset($item['text']);
				}
			}
		}
		
		parent::postprocess();
	} 
Example #9
0
 protected function process()
 {
     Database::insert('art_pack', array('filename' => $this->name, 'title' => $this->title, 'text' => Transform_Text::format(trim($this->text)), 'pretty_text' => $this->text));
     $id = Database::last_id();
     Database::insert('misc', array('type' => 'pack_status', 'data1' => 'starting', 'data2' => $id));
     $newfile = ROOT_DIR . SL . 'files' . SL . 'pack_uploaded' . SL . $id . '.zip';
     if (!move_uploaded_file($this->file, $newfile)) {
         $contents = file_get_contents($this->file);
         $start = substr($contents, 0, 3000);
         $end = substr($contents, 3000);
         unset($contents);
         $new_start = preg_replace('/^.{0,2000}?Content-Type:\\s+application\\/zip\\s+/is', '', $start);
         if (empty($new_start)) {
             $new_start = $start;
         }
         file_put_contents($newfile, $start . $end);
     }
     $this->set(array('success' => true, 'id' => $id, 'file' => $this->name));
 }
Example #10
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 #11
0
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для новости.');
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $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_News();
     $item->set_array(array('title' => $post['title'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'image' => $post['image']['image'], 'extension' => $post['image']['extension'], 'author' => $author, 'category' => $category));
     $item->insert();
     $this->writer->set_success()->set_message('Ваша новость успешно добавлена, и доступна по адресу ' . '<a href="/news/' . $item->get_id() . '/">http://4otaku.org/news/' . $item->get_id() . '/</a>.');
 }
Example #12
0
 public function insert()
 {
     if (!Check::is_hash($this->get('md5')) || !Check::is_hash($this->get('thumb')) || !$this->get('extension') || Database::get_count('art', 'md5 = ?', $this->get('md5'))) {
         return $this;
     }
     if ($this->get('resized') == 1) {
         $this->calculate_resize();
     }
     $this->set('pretty_date', Transform_Text::rudate());
     $this->set('sortdate', ceil(microtime(true) * 1000));
     if (!$this->get('area')) {
         $this->set('area', def::area(1));
     }
     $this->correct_tags();
     parent::insert();
     if (function_exists('puzzle_fill_cvec_from_file') && function_exists('puzzle_compress_cvec')) {
         $imagelink = IMAGES . SL . 'booru' . SL . 'thumbs' . SL . 'large_' . $this->get('thumb') . '.jpg';
         $vector = puzzle_fill_cvec_from_file($imagelink);
         $vector = base64_encode(puzzle_compress_cvec($vector));
         Database::insert('art_similar', array('id' => $this->get_id(), 'vector' => $vector));
     }
     return $this;
 }
Example #13
0
 public function update()
 {
     if (!is_numeric(query::$post['id'])) {
         $this->writer->set_message('Что-то странное с формой обновления, сообщите администрации');
         return;
     }
     $author = trim(strip_tags(query::$post['author']));
     if (empty($author)) {
         $this->writer->set_message('Вы забыли указать автора обновления');
         return;
     }
     $text = Transform_Text::format(query::$post['text']);
     if (!trim(strip_tags($text))) {
         $this->writer->set_message('Вы забыли добавить описание обновления');
         return;
     }
     $links = array();
     foreach (query::$post['link'] as $link) {
         if (!empty($link['use'])) {
             unset($link['use']);
             $links[] = $link;
         }
     }
     $links = Transform_Link::parse($links);
     if (empty($links)) {
         $this->writer->set_message('Проверьте ссылки, с ними была какая-то проблема');
         return;
     }
     $update = new Model_Post_Update(array('post_id' => query::$post['id'], 'username' => $author, 'text' => $text, 'pretty_text' => undo_safety(query::$post['text'])));
     foreach ($links as $link) {
         $link = new Model_Post_Update_Link($link);
         $update->add_link($link);
     }
     $update->insert();
     $this->writer->set_success()->set_message('Запись успешно обновлена');
 }
Example #14
0
 protected function text($data)
 {
     $text = Transform_Text::format($data['text']);
     $this->model['text'] = $text;
     $this->model['pretty_text'] = $data['text'];
 }
Example #15
0
	public function get_short_text () {
		$text = $this->data['text'];
		
		$text = Transform_Text::cut_long_text(strip_tags($text,'<br><em><strong><s>'),100);
		$text = preg_replace('/(<br(\s[^>]*)?>\n*)+/si','<br />',$text);

		return Transform_Text::cut_long_words($text);
	}