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); }
function edit_art_translations() { global $def; global $check; if ($check->num(query::$post['id']) && query::$post['type'] == 'art') { $time = microtime(true)*1000; $date = obj::transform('text')->rudate(); obj::db()->update('art_translation','active',0,query::$post['id'],'art_id'); if (query::$post['size'] == 'resized') { $info = obj::db()->sql('select resized, md5 from art where id='.query::$post['id'],1); $full_size = explode('x',$info['resized']); $small_size = getimagesize(ROOT_DIR.SL.'images/booru/resized/'.$info['md5'].'.jpg'); $coeff = $full_size[0] / $small_size[0]; } else { $coeff = 1; } foreach (query::$post['trans'] as $key => $translation) { if (!$text = obj::transform('text')->format($translation['text'])) unset (query::$post['trans'][$key]); else { foreach ($translation as $key2 => $one) if ($key2 != 'text') query::$post['trans'][$key][$key2] = round(intval($one) * $coeff); query::$post['trans'][$key]['pretty_text'] = $translation['text']; query::$post['trans'][$key]['text'] = $text; } } obj::db()->insert('art_translation',array(query::$post['id'],base64_encode(serialize(query::$post['trans'])),query::$post['author'],$date,$time,1)); obj::db()->sql('update art set translator="'.query::$post['author'].'" where id='.query::$post['id'].' and translator=""',0); } }
function update() { $return = obj::db()->sql('select * from post_update order by sortdate desc limit 3'); if (!empty($return) && is_array($return)) foreach ($return as & $update) { $update['text'] = obj::transform('text')->cut_long_text(strip_tags($update['text'],'<br>'),100); $update['text'] = preg_replace('/(<br(\s[^>]*)?>\n*)+/si','<br />',$update['text']); $update['text'] = obj::transform('text')->cut_long_words($update['text']); $update['author'] = mb_substr($update['username'],0,20); $update['post_title'] = obj::db()->sql('select title from post where id = '.$update['post_id'],2); } return $return; }
function archive_author() { global $url; if ($url[2] != 'art') { $title = ' title,'; $return['display'] = array('archive_body'); } else $return['display'] = array('archive_artbody'); $items = obj::db()->sql('select author,'.$title.' id, comment_count from '.$url[2].' where area="main" order by sortdate'); $return['count'] = count($items).' '.obj::transform('text')->wcase(count($items),$this->wcase[$url[2]][0],$this->wcase[$url[2]][1],$this->wcase[$url[2]][2]); if (is_array($items)) foreach ($items as $item) { $authors = explode('|',trim($item['author'],'|')); foreach ($authors as $author) if ($url[2] != 'art') $return['archives'][$author][] = $item; else $return['archives'][$author]++; } $return['name'] = obj::db()->sql('select alias,name from author','alias'); return $return; }
function duplicates($return) { $return['display'][] = 'admin_duplicateslist'; $duplicates = obj::db()->sql('select id, similar from art_similar where similar != "|" and similar != ""','id'); if(is_array($duplicates)) { $art_ids = array(); $pairings = array(); foreach ($duplicates as $id => $similar) { $similar = explode('|', trim($similar, '|')); foreach ($similar as $item) { $art_ids[] = $item; $pairings[] = min($id,$item).'-'.max($id,$item); } $art_ids[] = $id; } $art_ids = array_unique($art_ids); $return['doubles'] = array_unique($pairings); $return['arts'] = obj::db()->sql('select * from art where id in ("'.implode('","', $art_ids).'")','id'); $translations = obj::db()->sql('select art_id from art_translation where art_id in ("'.implode('","', $art_ids).'")'); foreach ($return['arts'] as $id => $art) { $image = ROOT_DIR.SL.'images'.SL.'booru'.SL.'full'.SL.$art['md5'].'.'.$art['extension']; $fileinfo = getimagesize($image); $return['arts'][$id]['width'] = $fileinfo[0]; $return['arts'][$id]['height'] = $fileinfo[1]; $return['arts'][$id]['size'] = obj::transform('file')->weight(filesize($image)); $return['arts'][$id]['translation'] = in_array($id, (array) $translations); } unset ($art); $meta = $this->get_meta($return['arts'],array('tag')); foreach ($return['arts'] as &$art) foreach ($meta['tag'] as $alias => $name) if (stristr($art['tag'],'|'.$alias.'|')) $art['meta']['tag'][$alias] = $name['name']; unset ($art); } return $return; }
target="_blank" class="board_flash with_help" title="<?php echo $flash['full_size_info']; ?> "> <img align="left" src="<?php echo $def['site']['dir']; ?> /images/flash.png"> </a> <? } } ?> <? if (!empty($thread['multi_content'])) { ?> <div class="clear"></div> <? } ?> <div class="posttext"> <? if ($url[3] != 'thread') { ?> <?php echo obj::transform('text')->cut_long_text($thread['text'], 1000, $read_all, 100); ?> <? } else { ?> <?php echo $thread['text']; ?> <? } ?> </div> </div> <? if (!empty($thread['multi_content'])) { ?> <div class="clear"></div> <? } ?> </div>
<? if (!empty($thread['skipped']['images'])) { ?> , <?php echo $thread['skipped']['images']; ?> <?php echo obj::transform('text')->wcase($thread['skipped']['images'], 'картинка', 'картинки', 'картинок'); ?> <? } ?> <? if (!empty($thread['skipped']['flash'])) { ?> , <?php echo $thread['skipped']['flash']; ?> <?php echo obj::transform('text')->wcase($thread['skipped']['flash'], 'флешка', 'флешки', 'флешек'); ?> <? } ?> <? if (!empty($thread['skipped']['video'])) { ?> , <?php echo $thread['skipped']['video']; ?> видео <? } ?> </div> <? } ?> <? foreach ($thread['posts'] as $post) { ?> <? include TEMPLATE_DIR .SL.'main'.SL.'board'.SL.'message.php'; ?> <? } }
?> <td class="imageholder"> <div class="image-0"> <img src="<?php echo $block['image']; ?> " /> </div> </td> <? } ?> <td valign="top"> <?php echo $block['comment_count'] > $sets['pp']['comment_in_post'] ? '<p class="help"> Показываются только ' . $sets['pp']['comment_in_post'] . ' последних ' . obj::transform('text')->wcase(sets::pp('comment_in_post'), 'комментарий', 'комментария', 'комментариев') . '. <a href="' . $def['site']['dir'] . '/' . $block['place'] . '/' . $block['id'] . '/comments/all"> Читать все </a>. </p>' : ''; ?> <? $i = $block['comment_count']; foreach ($block['comments'] as $comment) { $i--; if ($i < $sets['pp']['comment_in_post']) { ?> <div class="comment" id="comment-<?php echo $comment['id']; ?> "<?php
<?php die; include '../inc.common.php'; $posts = Database::get_full_vector('board'); foreach ($posts as $id => $post) { $text = obj::transform('text')->wakaba(redo_safety($post['pretty_text'])); Database::update('board', array('text' => $text), $id); }
public function pack_edit () { global $check; if ($check->rights()) { $id = query::$post['id']; $text = obj::transform('text')->format(trim(query::$post['text'])); $pretty_text = trim(query::$post['text']); $update = array( 'title' => query::$post['name'], 'text' => $text, 'pretty_text' => $pretty_text, ); obj::db()->update('art_pack',array_keys($update),array_values($update), $id); } }
function process_content(&$array) { global $url; $images_count = 0; $video_count = 0; $flash_count = 0; if (!empty($array)) { $ids = array_keys($array); $content_array = (array) obj::db()->sql(' SELECT * FROM board_attachment WHERE post_id in ('.implode(',',$ids).') ORDER BY `order` '); foreach ($array as $key => $item) { $array[$key]['content'] = array( 'image' => array(), 'flash' => array(), 'video' => array(), ); } foreach ($content_array as $content) { $array[$content['post_id']]['content'][$content['type']][] = unserialize(base64_decode($content['data'])); } foreach ($array as $key => $item) { if (!empty($item['content'])) { $content = $item['content']; $current_count = 0; if (!empty($content['image'])) { foreach ($content['image'] as $image_key => $image) { $content['image'][$image_key]['full_size_info'] = obj::transform('file')->weight($image['weight']) . ', ' . $image['sizes'] . ' пикселей'; $images_count++; $current_count++; } } if (!empty($content['random'])) { foreach ($content['random'] as $random_key => $image) { $content['random'][$random_key]['full_size_info'] = obj::transform('file')->weight($image['size']) . ', ' . $image['width'] . 'x' . $image['height'] . ' пикселей'; $images_count++; $current_count++; } } if (!empty($content['flash'])) { foreach ($content['flash'] as $flash_key => $flash) { $content['flash'][$flash_key]['full_size_info'] = obj::transform('file')->weight($flash['weight']); $flash_count++; $current_count++; } } if (!empty($content['video'])) { $width = def::board('thumbwidth'); foreach ($content['video'] as $video_key => $video) { $height = $width * $video['aspect']; $content['video'][$video_key]['object'] = str_replace( array('%video_width%','%video_height%'), array($width,$height), $video['object'] ); $content['video'][$video_key]['height'] = $height; $video_count++; $current_count++; } } $array[$key]['content'] = $content; } if (!empty($item['boards'])) { $array[$key]['boards'] = array_values(array_filter(array_unique(explode('|',$item['boards'])))); } if ($url[2] && strlen($url[2]) < 3) { $array[$key]['current_board'] = $url[2]; } elseif (!empty($array[$key]['categories'])) { $c_key = array_rand($array[$key]['categories']); $array[$key]['current_board'] = $array[$key]['categories'][$c_key]['alias']; } if (!empty($item['text'])) { preg_match_all('/>>(\d+)(\s|$|<br[^>]*>)/',$item['text'],$inner_links); foreach ($inner_links[1] as $inner_link) { $this->inner_links[] = $inner_link; } } if ($current_count > 1) { $array[$key]['multi_content'] = true; } } } return array($images_count, $flash_count, $video_count); }
function format_logs($text, $author = false, $mark = array()) { $text = str_replace(array('<', '>'), array('<', '>'), $text); foreach ($mark as $one) { $text = preg_replace('/(?<=\\b)' . preg_quote($one, '/') . '(?=\\b)/uis', '<span style="background-color:yellow;">$0</span>', $text); } $text = preg_replace(array("/[\r\n]+/su"), array("<br />"), $text); $text = preg_replace(transform__text::URL_REGEX, '<a href="$0">$0</a>', $text); $text = obj::transform('text')->cut_long_words($text, 40); if (substr($text, 0, 3) == '/me') { return '<span class="logs-nick">' . $author . '</span>' . substr($text, 3); } else { return ($author ? '<span class="logs-nick"><' . $author . '></span> ' : '') . $text; } }
echo $flash['full']; ?> " target="_blank" class="board_flash with_help" title="<?php echo $flash['full_size_info']; ?> "> <img align="left" src="<?php echo $def['site']['dir']; ?> /images/flash.png"> </a> <? } } ?> <? if (!empty($post['multi_content'])) { ?> <div class="clear"></div> <? } ?> <div class="posttext"> <? if ($url[3] != 'thread') { ?> <?php echo obj::transform('text')->cut_long_text($post['text'], 800, $read_all, 100); ?> <? } else { ?> <?php echo $post['text']; ?> <? } ?> </div> </div> </div>
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 substract_category($category,$id) { Check::rights(); $categories = explode('|',trim(obj::db()->sql('select category from art where id='.$id,2),'|')); $categories = array_diff($categories,array($category)); if (empty($categories)) $categories = array('none'); $category = obj::transform('meta')->category($categories); obj::db()->update('art','category',$category,$id); }
function transfer($post, $display_warnings = true) { if (empty($post)) $post = query::$post; global $add_res; global $check; global $def; global $sets; if (isset($post['sure'])) { $check->rights(); if ($post['do'][0] == 'order') $post['do'][0] .= 's'; if ($post['do'][0] != 'orders') { $data = obj::db()->sql('select area, tag from '.$post['do'][0].' where id='.$post['id'],1); $tags = array_unique(array_filter(explode('|',$data['tag']))); if ($data['area'] == $post['where']) { if ($display_warnings) { self::add_res(self::$messages['same_target'],true); return; } else { return 'same_target'; } } if ($post['do'][0] == 'art' && count($tags) < 5 && $post['where'] == $def['area'][0]) { if ($display_warnings) { self::add_res(self::$messages['not_enough_tags'], true); return; } else { return 'not_enough_tags'; } } if (in_array($data['area'],$def['area']) && $data['area'] != $def['area'][1]) obj::transform('meta')->erase_tags($tags,$post['do'][0].'_'.$data['area']); if (in_array($post['where'],$def['area']) && $post['where'] != $def['area'][1]) obj::transform('meta')->add_tags($tags,$post['do'][0].'_'.$post['where']); } if ($post['do'][0] != 'orders') obj::db()->update($post['do'][0],array('area','pretty_date','sortdate'),array($post['where'],obj::transform('text')->rudate(),ceil(microtime(true)*1000)),$post['id']); else obj::db()->update($post['do'][0],'area',$post['where'],$post['id']); obj::db()->insert('versions',array($post['do'][0],$post['id'],$post['where'],ceil(microtime(true)*1000),$sets['user']['name'],$_SERVER['REMOTE_ADDR'])); obj::db()->sql('update search set lastupdate=0 where place="'.$post['do'][0].'" and item_id="'.$post['id'].'"',0); if (!in_array($post['where'], $def['area'])) { obj::db()->sql('update comment set area="deleted" where place="'.$post['do'][0].'" and post_id='.$post['id'],0); } $add_res['meta'] = $post['where']; } else { if ($display_warnings) { self::add_res(self::$messages['uncheked_confirmation'],true); } else { return 'uncheked_confirmation'; } } }
<?php if (!empty($data['main']['threads'])) { foreach ($data['main']['threads'] as $id => $thread) { ?> <div class="catalog_item"> <? $thread_url = '/board/'.$thread['current_board'].'/thread/'.$id; ?> <? $thread_title = $thread['name'] . (empty($thread['trip']) ? '' : ' ' .$thread['trip']); ?> <? $thread_title .= ' в разделе '; ?> <? foreach($thread['categories'] as $key => $board) { ?> <? if (!empty($key)) { ?> <? $thread_title .= ' / '; ?> <? } ?> <? $thread_title .= $board['alias']; ?> <? } ?> <? $thread_title .= '; ' . $thread['pretty_date'] . "\n<br />"; ?> <? $thread_title .= obj::transform('text')->cut_long_text(strip_tags($thread['text'],'<br><em><strong><s>'),500); ?> <? if (!empty($thread['content']['video'])) { $video = reset($thread['content']['video']); ?> <a href="<?=$thread_url;?>" target="_blank" class="board_image_thumb with_help" title="<?=$thread_title;?>"> <img src="<?=$def['site']['dir']?>/images/video.png"> </a> <? } elseif (!empty($thread['content']['image'])) { $image = reset($thread['content']['image']); ?> <a href="<?=$thread_url;?>" target="_blank" class="board_image_thumb with_help" title="<?=$thread_title;?>"> <img src="<?=$def['site']['dir']?>/images/board/thumbs/<?=$image['thumb'];?>"> </a> <? } elseif (!empty($thread['content']['random'])) {