public function __construct() { $rules = Database::get_full_vector('post_url_rule'); foreach ($rules as $rule) { switch ($rule['type']) { case 'alias': $this->alias[$rule['domain']] = $rule['value']; break; case 'works': if (empty($this->works[$rule['domain']])) { $this->works[$rule['domain']] = array($rule['value']); } else { $this->works[$rule['domain']][] = $rule['value']; } break; case 'broken': if (empty($this->broken[$rule['domain']])) { $this->broken[$rule['domain']] = array($rule['value']); } else { $this->broken[$rule['domain']][] = $rule['value']; } break; default: break; } } $this->worker = new Http(array(CURLOPT_FOLLOWLOCATION => true)); }
function plugins () { $plugins = Database::get_full_vector('plugin'); $used = sets::array_get('plugins'); foreach ($plugins as $id => &$plugin) { $plugin['on'] = !empty($used[$id]); } return $plugins; }
<?php include '../inc.common.php'; ob_end_clean(); $news = Database::get_full_vector('news'); Database::sql('ALTER TABLE `news` ADD `extension` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `image`'); foreach ($news as $id => $item) { rename(IMAGES . SL . 'full' . SL . $item['image'], IMAGES . SL . 'news' . SL . 'full' . SL . $item['image']); rename(IMAGES . SL . 'thumbs' . SL . $item['image'], IMAGES . SL . 'news' . SL . 'thumb' . SL . preg_replace('/\\.[a-z]+$/ui', '.jpg', $item['image'])); Database::update('news', array('image' => preg_replace('/\\.[a-z]+$/ui', '', $item['image']), 'extension' => preg_replace('/^.*\\./ui', '', $item['image'])), $id); Database::update('comment', array('post_id' => $id), 'post_id = ?', $item['url']); } Database::sql('ALTER TABLE `news` DROP `url`;'); Database::sql('ALTER TABLE `news` ADD `author` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `extension` , ADD `category` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `author`;'); Database::sql('update news set category = \'|website|\' where 1;'); Database::sql('update news set author = \'|nameless|\' where 1;'); Database::sql('update news set pretty_text = \'\' where 1;'); Database::sql('INSERT INTO `category` (`id` ,`alias` ,`name` ,`area`)VALUES (NULL , \'website\', \'Новости сайта\', \'|news|\');'); Database::sql('INSERT INTO `category` (`id` ,`alias` ,`name` ,`area`)VALUES (NULL , \'otaku\', \'Новости индустрии\', \'|news|\');');
Database::insert('post_file', array('post_id' => $id, 'type' => $type, 'name' => $file['name'], 'folder' => $file['folder'], 'file' => $file['filename'], 'size' => str_replace(',', '.', $size[0]), 'sizetype' => $sizetype, 'order' => $i)); $i++; } $i = 0; foreach ($images as $image) { $file = IMAGES . SL . 'full' . SL . $image; $sizes = getimagesize($file); $weight = filesize($file); $name = explode('.', $image); Database::insert('post_image', array('post_id' => $id, 'file' => $name[0], 'extension' => $name[1], 'width' => $sizes[0], 'height' => $sizes[1], 'weight' => $weight, 'order' => $i)); rename($file, IMAGES . SL . 'post' . SL . 'full' . SL . $image); rename(IMAGES . SL . 'thumbs' . SL . $name[0] . '.jpg', IMAGES . SL . 'post' . SL . 'thumb' . SL . $name[0] . '.jpg'); $i++; } } $updates = Database::get_full_vector('updates'); foreach ($updates as $id => $update) { Database::insert('post_update', array('id' => $id, 'post_id' => $update['post_id'], 'username' => $update['username'], 'text' => $update['text'], 'pretty_text' => $update['pretty_text'], 'pretty_date' => $update['pretty_date'], 'sortdate' => $update['sortdate'], 'area' => $update['area'])); $links = (array) unserialize($update['link']); $i = 0; foreach ($links as $link) { if (empty($link['url'])) { continue; } switch ($link['sizetype']) { case 'гб': $type = 2; break; case 'мб': $type = 1; break;
public function single ($query) { $config = Globals::user('comments', 'single_item'); $perpage = $config['per_page']; $display = $config['display']; $inverted = $config['inverted']; if ($query['page'] != 'all') { $page = $query['page']; $start = ($page - 1) * $perpage; $limit = " limit $start, $perpage"; } else { $limit = ""; $page = 1; $start = 0; } $root = $display == 'ladder' ? "and root = 0" : ""; $direction = (bool) $inverted ? "desc" : "asc"; $params = array('deleted', $query['place'], $query['item_id']); $condition = "area != ? and place = ? and item_id = ? $root order by date $direction $limit"; $comments = Database::set_counter()->get_full_vector('comment', $condition, $params, false); $total = Database::get_counter(); $current = (bool) $inverted ? $total - $start : $start; if ($display == 'ladder') { $roots = array_keys($comments); $condition = "area != ? and place = ? and item_id = ? and ". Database::array_in('root', $roots)." order by date"; $params = array_merge($params, $roots); $children = Database::get_full_vector('comment', $condition, $params, false); $this->build_tree($children); } else { $children = array(); } if ($display == 'quotation') { $parents = array(); foreach ($comments as $comment) { $parents[] = $comment['parent']; } $condition = "area != ? and place = ? and item_id = ? and ". Database::array_in('id', $parents); $params = array_merge($params, $parents); $parents = Database::get_full_vector('comment', $condition, $params, false); } else { $parents = array(); } foreach ($comments as $id => $comment) { $item_children = array(); $item_parent = null; foreach ($children as $child_id => $child) { if ($id == $child['root']) { $item_children[$child_id] = new Item_Comment($child, $display); } } foreach ($parents as $parent_id => $parent) { if ($parent_id == $comment['parent']) { $item_parent = new Item_Comment($parent); } } $this->items[$id] = new Item_Comment( array_merge( $comment, array( 'items' => $item_children, 'quotation' => $item_parent, 'index' => (bool) $inverted ? $current-- : ++$current, ) ), $display ); } $this->items[] = new Item_Comment_Navi(array( 'curr_page' => $page, 'pagecount' => ceil($total / $perpage), 'query' => $query, 'module' => 'comments', )); }
<?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); }
<?php include '../inc.common.php'; $string = 'http://www.pixiv.net/member_illust.php?mode=medium&illust_id='; $arts = Database::get_full_vector('art', 'source like "%img%pixiv%"'); foreach ($arts as $id => $art) { $source = (int) basename($art['source']); if (empty($source)) { continue; } Database::update('art', array('source' => $string . $source), $id); }
<?php die; include '../inc.common.php'; $videos = Database::get_full_vector('video', 'link = ?', '***'); foreach ($videos as $id => $video) { if (preg_match('/src="[^"]+youtube.*v\\/([^"&]+)/ui', $video['object'], $link)) { $link = 'http://www.youtube.com/watch?v=' . $link[1]; } elseif (preg_match('/src="[^"]+nicovideo.*\\/([^"\\/]+)"/ui', $video['object'], $link)) { $link = 'http://www.nicovideo.jp/watch/' . $link[1]; } elseif (preg_match('/id.3D([^&]+)&searchbar=false/ui', $video['object'], $link)) { $link = 'http://amvnews.ru/index.php?go=Files&in=view&id=' . $link[1]; } elseif (preg_match('/mid=([^"]+)/ui', $video['object'], $link)) { $link = 'http://www.gametrailers.com/video/lost_url_part/' . $link[1]; } else { $link = false; } if (!empty($link)) { Database::update('video', array('link' => $link), $id); } }