function add() { global $check; global $def; global $cookie; global $sets; if (!$cookie) $cookie = new dynamic__cookie(); if (query::$post['mail'] && query::$post['subject']) { if ($check->email(query::$post['mail'],false) && query::$post['mail'] != $def['user']['mail']) { $cookie->inner_set('user.mail',query::$post['mail']); if (!trim(query::$post['user'])) query::$post['user'] = $def['user']['author']; if (query::$post['user'] != $def['user']['author']) $cookie->inner_set('user.name',query::$post['user']); else unset(query::$post['user']); query::$post['user'] = preg_replace('/#.*$/','',query::$post['user']); $category = obj::transform('meta')->category(query::$post['category']); $text = obj::transform('text')->format(trim(query::$post['description'])); if (query::$post['subscribe']) query::$post['subscribe'] = 1; obj::db()->insert('orders',$insert_data = array(query::$post['subject'],query::$post['user'],query::$post['mail'],query::$post['subscribe'],$text,undo_safety(query::$post['description']),"", $category,0,0,obj::transform('text')->rudate(),$time = ceil(microtime(true)*1000),$def['area'][1])); obj::db()->insert('versions',array('order',$id = obj::db()->sql('select @@identity from orders',2), base64_encode(serialize($insert_data)),$time,$sets['user']['name'],$_SERVER['REMOTE_ADDR'])); if (query::$post['subscribe']) $this->set_events($id,query::$post['mail']); else $this->set_events($id); $this->add_res('Заказ успешно добавлен. Страница заказа: <a href="/order/'.$id.'/">http://4otaku.org/order/'.$id.'</a>'); } else $this->add_res('Вы указали неправильный е-мейл.', true); } else $this->add_res('Не все обязательные поля заполнены.', true); }
public function __construct() { parent::__construct(); $cookie = new dynamic__cookie(); $cookie->inner_set('visit.post', time(), false); $this->per_page = sets::pp('post'); }
public function main() { $post = $this->correct_main_data($this->reader->get_data()); if (!$post['title'] || !$post['link'] && !$post['torrent']) { $this->writer->set_message('Не все обязательные поля заполнены.')->set_error(Error_Create::MISSING_INPUT); 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']); $language = $worker->language($post['language']); $parsed_author = $worker->parse($post['author'], def::user('author')); $author = $worker->author($parsed_author); $text = Transform_Text::format($post['text']); $links = Transform_Link::parse($post['link']); $extras = Transform_Link::parse($post['bonus_link']); $images = $post['image']; $torrents = $post['torrent']; $files = $post['file']; $item = new Model_Post(); $item->set_array(array('title' => $post['title'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'author' => $author, 'category' => $category, 'language' => $language, 'tag' => $tags)); foreach ($images as $image) { $image = explode('.', $image); $image = new Model_Post_Image(array('file' => $image[0], 'extension' => $image[1])); $item->add_image($image); } foreach ($links as $link) { $link = new Model_Post_Link($link); $item->add_link($link); } foreach ($torrents as $torrent) { $torrent = new Model_Post_Torrent($torrent); $item->add_torrent($torrent); } foreach ($extras as $extra) { $extra = new Model_Post_Extra($extra); $item->add_extra($extra); } foreach ($files as $file) { $file = new Model_Post_File($file); $item->add_file($file); } $item->insert(); // TODO: перемести input__common::transfer в Model_Common if (!empty($post['transfer_to'])) { input__common::transfer(array('sure' => 1, 'do' => array('post', 'transfer'), 'where' => $post['transfer_to'], 'id' => $item->get_id())); } $this->writer->set_success()->set_message('Ваша запись успешно добавлена, и доступна по адресу ' . '<a href="/post/' . $item->get_id() . '/">http://4otaku.org/post/' . $item->get_id() . '/</a> или в ' . '<a href="/post/' . 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('Вы забыли указать заголовок для видео.')->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>.'); }
function __construct() { global $cookie; global $url; global $sets; if (!$cookie) { $cookie = new dynamic__cookie(); } $cookie->inner_set('visit.art', time(), false); $this->parse_area(); if (!$url[2]) { $this->error_template = 'booru_empty'; } if ($url[2] == 'slideshow' && $url[3] && $url[4]) { foreach ($url as $key => $one) { if ($key > 2) { $url[$key - 1] = $one; } } unset($url[count($url) - 1]); $this->template = 'slideshow'; $this->side_modules = array(); } }
function __construct() { global $cookie; if (!$cookie) $cookie = new dynamic__cookie(); $cookie->inner_set('visit.board',time()+1,false); }
function add() { global $check; global $def; global $sets; global $cookie; global $add_res; if (!$cookie) $cookie = new dynamic__cookie(); $content = array(); $count_content = 0; if (!empty(query::$post['image']) && is_array(query::$post['image'])) { foreach (query::$post['image'] as $add_image) { if ($count_content >= def::board('maxcontent')) { continue; } $count_content++; if (array_key_exists($add_image, $this->random_codes)) { $random_art = $this->get_random_art($this->random_codes[$add_image]); if ($random_art) { $name = $random_art['md5'] . '.' . $random_art['extension']; $path = IMAGES . SL . 'booru' . SL . 'full' . SL . $name; try { $resizer = new Transform_Upload_Board_Image($path, $name); $result = $resizer->process_file(); } catch (Error_Upload $e) { continue; } if (empty($result['success'])) { continue; } $content['random'][] = array( 'id' => $random_art['id'], 'full' => $result['full'], 'thumb' => $result['thumb'], 'size' => $result['size'], 'width' => $result['width'], 'height' => $result['height'], ); } continue; } $parts = explode('#', $add_image); if ($parts[1] == 'flash') { $content['flash'][] = array( 'full' => $parts[0], 'weight' => $parts[2], ); } else { $content['image'][] = array( 'full' => $parts[0], 'thumb' => $parts[1], 'weight' => $parts[2], 'sizes' => $parts[3], ); } } } if (!empty(query::$post['video']) && is_array(query::$post['video'])) { query::$post['video'] = array_unique(query::$post['video']); foreach (query::$post['video'] as $add_video) { if (empty($add_video) || $count_content >= def::board('maxcontent')) { continue; } $video_link = undo_safety($add_video); $video_worker = new Transform_Video($video_link); $video_object = $video_worker->disable_nico()->get_html(); if (empty($video_object)) { $this->add_res( 'Извините, видеосервиса для ссылки '. '('.$add_video.') нет в нашей базе, '. 'либо с вашей ссылкой что-то не так.' ,true); continue; } $content['video'][] = array( 'link' => $video_link, 'object' => $video_object, 'service_id' => $video_worker->get_id(), 'aspect' => $video_worker->get_aspect(), ); $count_content++; } } $text = obj::transform('text')->wakaba(query::$post['text']); $is_thread = (bool) empty(query::$post['id']); if ($is_thread + empty($content) + empty($text) <= 1) { $trip = preg_split('/(?<!&)#/', query::$post['user']); $user = array_shift($trip); // $user = preg_replace('/#.*$/','',$user); $trip = array_slice($trip,0,3); $tripcode = $trip[0] ? $this->trip($trip[0]) : ''; $tripcode .= $trip[1] || $trip[2] ? '!'.$this->trip(_crypt($trip[1].$trip[2])) : ''; if (trim($user) && $user != $def['user']['name']) { $cookie->inner_set('user.name',$user); } if (!empty($trip)) { $cookie->inner_set('user.trip',implode('#',$trip)); } else { $cookie->inner_set('user.trip',''); } if ($is_thread) { $categories = (array) query::$post['category']; $board_categories = obj::db()->sql(' SELECT id, alias from category WHERE locate("|board|",area) ORDER BY id ', 'alias'); $insert_categories = array(); $limit = $this->max_threads_in_board - 1; $to_flush = array(); foreach ($categories as $category) { if (!array_key_exists($category, $board_categories)) { continue; } if (!in_array($category, $this->storing_boards)) { $to_flush = array_merge( $to_flush, (array) obj::db()->sql(' SELECT board.id, board_category.category_id FROM board LEFT JOIN board_category ON board.id=board_category.thread_id WHERE board.type="thread" AND board_category.actual = 1 AND board_category.category_id = '.$board_categories[$category].' ORDER by board.updated DESC LIMIT '.$limit.', 1000 ') ); } $insert_categories[] = $board_categories[$category]; } if (!empty($to_flush)) { $condition = ''; $check_ids = array(); foreach ($to_flush as $one) { $condition .= ' or (thread_id = '.$one['id'].' and category_id = '.$one['category_id'].')'; $check_ids[] = $one['id']; } $condition = substr($condition, 4); obj::db()->sql('update `board_category` set actual = 0 where'.$condition,0); $still_living = array_keys((array) obj::db()->sql(' SELECT board.id FROM board LEFT JOIN board_category ON board.id=board_category.thread_id WHERE board.id in ('.implode(',',$check_ids).') AND board_category.actual = 1 ','id')); $old_threads = array_diff($check_ids, $still_living); obj::db()->sql('update `board` set type = "old" where id in ('.implode(',',$old_threads).')',0); } } $time = ceil(microtime(true)*1000); $insert_data = array( $is_thread ? 'thread' : 'post', query::$post['id'], $is_thread ? $time : 0, trim($user) ? trim($user) : $def['user']['name'], $tripcode, undo_safety(query::$post['text']), $text, date('j.n.y - G:i'), $time, $cookie->get(), $_SERVER['REMOTE_ADDR'] ); obj::db()->insert('board',$insert_data); $id = obj::db()->sql('select @@identity from board',2); foreach ($insert_categories as $category) { obj::db()->insert('board_category',array($id,$category,1),false); } $this->add_content($content, $id); if (!empty(query::$post['id'])) { obj::db()->update('board','updated',$time,query::$post['id']); } else { $this->redirect = '/board/'.query::$post['category'][array_rand(query::$post['category'])].'/thread/'.$id; } } else { if (empty(query::$post['id'])) { $this->add_res('При создании нового треда вам надо написать текст, а также добавить картинку или видео',true); } else { $this->add_res('Для ответа надо добавить текст, картинку или видео',true); } } }
function logout() { global $sets; global $cookie; if (!$cookie) $cookie = new dynamic__cookie(); $cookie->inner_set('user.rights',0); $sets['user']['rights'] = 0; }