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; }
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); }
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')); }
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); }
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)); }
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()); }
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>.'); }
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('Запись успешно обновлена'); }
protected function text($data) { $text = Transform_Text::format($data['text']); $this->model['text'] = $text; $this->model['pretty_text'] = $data['text']; }