Beispiel #1
0
	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);
		}
	}
Beispiel #2
0
	function inner_set($field,$value,$allow_empty = true) {
		$parts = explode('.',$field);
		$settings = obj::db()->sql('select data from settings where cookie = "'.query::$cookie.'"',2);
		$settings = unserialize(base64_decode($settings));
		if ($allow_empty || !empty($settings)) {
			$settings[$parts[0]][$parts[1]] = $value;
			obj::db()->update('settings',array('data'),array(base64_encode(serialize($settings))),query::$cookie,'cookie');
		}
	}
Beispiel #3
0
	function get_comments($limit, $area) {
		global $error; global $def;
		$return = obj::db()->sql('select place, post_id from comment where (area != "deleted"'.$area.') group by place, post_id order by max(sortdate) desc limit '.$limit);
		if (is_array($return)) {
			$select = array(
				$def['type'][0] => "id, comment_count, title, last_comment",
				$def['type'][1] => "id, comment_count, title, id as image, last_comment",
				$def['type'][2] => "id, comment_count, id as title, thumb as image, last_comment",
				"orders" => "id, comment_count, title, email as image, last_comment",
				"news" => "id, comment_count, title, image, last_comment"
			);
			foreach ($return as $one) {
				$queries[$one['place']] .= '" or id="'.$one['post_id'];
				$comment_query .= ' or (post_id="'.$one['post_id'].'" and place="'.$one['place'].'")';
			}
			$return = array();
			foreach ($queries as $key => $query) {
				if ($_comments = obj::db()->sql('select '.$select[$key].', "'.$key.'" as "place" from '.$key.' where ('.substr($query,5).'")','last_comment')) {
					$return = $return + $_comments;
				}
			}
			krsort($return);
			$comments = obj::db()->sql('select * from comment where (('.substr($comment_query,4).') and area != "deleted") order by sortdate');
			foreach ($return as &$one) {
				foreach ($comments as $comment)
					if ($comment['post_id'] == $one['id'] && $comment['place'] == $one['place'])
						$one['comments'][] = $comment;
				switch ($one['place']) {
					case $def['type'][0]:
						$image = Database::order('order', 'asc')
							->get_field('post_image', 'file', 'post_id = ?', $one['id']);

						$one['image'] = '/images/post/thumb/'.$image.'.jpg';
						break;
					case $def['type'][1]:
						$one['image'] = 'http://www.gravatar.com/avatar/'.md5(strtolower($one['image'])).'?s=100&d=identicon&r=G';
						$one['title'] = "Видео: ".$one['title'];
						break;
					case $def['type'][2]:
						$one['image'] = '/images/booru/thumbs/'.$one['image'].'.jpg';
						$one['title'] = "Изображение №".$one['title'];
						break;
					case "orders":
						$one['image'] = 'http://www.gravatar.com/avatar/'.md5(strtolower($one['image'])).'?s=100&d=identicon&r=G';
						$one['title'] = "Заказ: ".$one['title'];
						break;
					case "news":
						$one['image'] = '/images/news/thumb/'.$one['image'].'.jpg';
						break;
				}
			}

			return $return;
		}
		else $error = true;
	}
Beispiel #4
0
	function replay_add() {
		
		if (query::$post['file']) {
			$file = current(query::$post['file']);
			obj::db()->insert('_atai_replays',array(
				$file['folder'].'/'.$file['filename'],
				query::$post['nickname1'],
				query::$post['character1'],
				query::$post['nickname2'],
				query::$post['character2'],
				query::$post['stage']
			));
		}
	}
Beispiel #5
0
 static function get_globals($get, $post)
 {
     self::$get = self::clean_globals($get, array());
     self::$post = self::clean_globals($post, array());
     if (isset($post['remember'])) {
         $md5 = md5(serialize($post));
         if (obj::db()->sql('select id from input_filter where md5 = "' . $md5 . '"', 2)) {
             unset($post);
         } else {
             obj::db()->insert('input_filter', array($md5, time()));
         }
     }
     unset($_GET, $_POST);
     return array(self::$get, self::$post);
 }
Beispiel #6
0
	function change_link() {
		global $check;
		if ($check->num(query::$post['id'])) {
			obj::db()->update('orders','link',query::$post['link'],query::$post['id']);
			$data = obj::db()->sql('select email, spam from orders where id='.query::$post['id'],1);
			if ($data['spam']) {
				if (substr(query::$post['link'],0,1) == '/') query::$post['link'] = 'http://'.$_SERVER['HTTP_HOST'].query::$post['link'];
				$this->set_events(query::$post['id'],$data['email']);
				$text = 'В вашем заказе на сайте 4отаку.орг, <a href="http://4otaku.org/order/'.$id.'/">http://4otaku.org/order/'.$id.'/</a> добавили ссылку на найденное:<br /><br />
				<a href="'.query::$post['link'].'">'.query::$post['link'].'</a>'.$this->unsubscribe($id);
				obj::db()->insert('misc',array('mail_notify',0,$data['email'],'',$text,query::$post['id']));
			}
			else $this->set_events(query::$post['id']);
		}
	}
Beispiel #7
0
	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;
	}
Beispiel #8
0
	function action($action,$id) {
		if ($id) {
			if ($action == 'prolong') {
				$data = obj::db()->sql('select email,spam from orders where id='.$id,1);
				$action = new input__common();
				if ($data['spam']) $action->set_events($id,$data['email']);
				else $action->set_events($id);
				$this->add_res('Заказ успешно продлен');
			}
			elseif ($action == 'unsubscribe') {
				obj::db()->update('orders','spam',0,$id);
				obj::db()->sql('delete from misc where (type="mail_notify" and data5="'.$id.'")',0);
				$this->add_res('Вы отписались от уведомлений по заказу <a href="/order/'.$id.'/">http://4otaku.org/order/'.$id.'/</a>');
			}
		}
		else {
			$this->add_res('Ошибка, неправильный URL', true);
		}
	}
Beispiel #9
0
	function author($authors){
		foreach ($authors as &$author) {
			$author = preg_replace('/#.*$/','',$author);
			if ($check = obj::db()->sql('select alias from author where name = "'.$author.'" or alias="'.$author.'"',2))
				$author = $check;
			else {
				$alias = $this->make_alias($author);
				obj::db()->insert('author',array($alias,$author));
				$author = $alias;
			}
		}
		return '|'.implode('|',$authors).'|';
	}
Beispiel #10
0
	function track_similar_pictures() {
		if (
			!function_exists('puzzle_fill_cvec_from_file') ||
			!function_exists('puzzle_vector_normalized_distance') ||
			!function_exists('puzzle_compress_cvec') ||
			!function_exists('puzzle_uncompress_cvec')
		) {
			return;
		}
/*
		$max  = obj::db()->sql('select max(id) from art_similar',2);
		$arts = obj::db()->sql('select id, thumb from art where id > '.($max ? $max : 0).' and area != "deleted" order by id limit 2000');

		foreach ($arts as $art) {
			$image = ROOT_DIR.SL.'images'.SL.'booru'.SL.'thumbs'.SL.'large_'.$art['thumb'].'.jpg';
			$vector = puzzle_fill_cvec_from_file($image);
			$vector = base64_encode(puzzle_compress_cvec($vector));

			obj::db()->insert('art_similar',array($art['id'], $vector, 0, ''),false);
		}
*/
		$all = obj::db()->sql('select id, vector from art_similar where vector != ""','id');
		$arts = obj::db()->sql('select * from art_similar where vector != "" and checked=0 limit 100','id');

		if (is_array($all) && is_array($arts)) {
			foreach ($all as $compare_id => $vector) {
				$all[$compare_id] = puzzle_uncompress_cvec(base64_decode($vector));
			}

			foreach ($arts as $id => $art) {
				$art['vector'] = puzzle_uncompress_cvec(base64_decode($art['vector']));
				$similar = '|';
				$art_area = false;
				foreach ($all as $compare_id => $vector) {
					if (
						$id != $compare_id &&
						puzzle_vector_normalized_distance($art['vector'], $vector) < 0.3
					) {
						if (empty($art_area)) {
							$art_area = Database::get_field('art', 'area', $id);
						}

						if ($art_area == 'cg' &&
							Database::get_field('art', 'area', $compare_id) == 'cg') {

							continue;
						}

						$similar .= $compare_id.'|';
					}
				}
				obj::db()->update('art_similar',array('checked','similar'),array(1,$similar),$id);
			}
		}
	}
Beispiel #11
0
	static function search_tags($query, $current, $step) {
		$locate = redo_safety(urldecode($query));		
		$tags = obj::db()->sql('select * from tag where locate("'.$locate.'",alias) or locate("'.$locate.'",variants) or locate("'.$locate.'",name) order by id desc limit '.(($current-1)*$step).', '.$step,'id');
		$page_count = ceil(obj::db()->sql('select count(id) from tag where locate("'.$locate.'",alias) or locate("'.$locate.'",variants) or locate("'.$locate.'",name)',2)/$step);
		return array($tags, $page_count);
	}
Beispiel #12
0
	function title_news() {
		global $url;
		if ($url[2])
			return $this->def['site']['short_name'] . ' '.obj::db()->sql('select title from news where url="'.$url[2].'"',2);
		else
			return $this->def['site']['name'];
	}
Beispiel #13
0
	protected function add_content($content, $id) {
		$i = 0;
		foreach ($content as $type => $items) {
			foreach ($items as $item) {
				obj::db()->insert('board_attachment',
					array($id,$type,base64_encode(serialize($item)),$i++)
				);
			}
		}
	}
Beispiel #14
0
	function masstag() {
		return obj::db()->sql('select alias, name from category where locate("|art|",area) order by id','alias');
	}
Beispiel #15
0
	function fetch_comment($id) {
		$item = obj::db()->sql('select * from comment where id='.$id.' limit 1',1);

		if ($item['place'] == 'news') {
			$item['title'] = 'Комментарий к новости "'.
				obj::db()->sql('select title from '.$item['place'].' where url="'.$item['post_id'].'"',2).
				'"';
		} elseif ($item['place'] == 'art') {
			$item['title'] = 'Комментарий к изображению';
			$item['preview_picture'] = obj::db()->sql('select thumb from art where id='.$item['post_id'],2);
		} else {
			$item['title'] = 'Комментарий к '.
				$this->comment_titles[$item['place']].' "'.
				obj::db()->sql('select title from '.$item['place'].' where id='.$item['post_id'],2).
				'"';
		}

		if ($item['place'] == 'orders') {
			$item['place'] = 'order';
		}
		$item['template'] = 'comment';
		return $item;
	}
Beispiel #16
0
 public function get_rating($id)
 {
     $cookie = query::$cookie;
     $ip = ip2long($_SERVER['REMOTE_ADDR']);
     $return = array();
     $return['voted'] = obj::db()->sql("select id from art_rating where art_id = {$id} and (ip = {$ip} or cookie = '{$cookie}')", 2);
     $return['score'] = (int) obj::db()->sql("select SUM(rating) from art_rating where art_id = {$id}", 2);
     return $return;
 }
Beispiel #17
0
	function convert_comment($item) {
		if ($item['place'] == 'art') {
			$item['title'] = 'Комментарий к изображению №'.$item['post_id'];
			$item['preview_picture'] = obj::db()->sql('select thumb from '.$item['place'].' where id='.$item['post_id'],2);
		} elseif ($item['place'] == 'video') {
			$item['title'] = 'Комментарий к видео "'.obj::db()->sql('select title from '.$item['place'].' where id='.$item['post_id'],2).'"';
		} elseif ($item['place'] != 'news') {
			$item['title'] = 'Комментарий к записи "'.obj::db()->sql('select title from '.$item['place'].' where id='.$item['post_id'],2).'"';
		} else {
			$item['title'] = 'Комментарий к записи "'.obj::db()->sql('select title from '.$item['place'].' where url="'.$item['post_id'].'"',2).'"';
		}

		if ($item['place'] == 'orders') $item['place'] = 'order';
		$item['rss_link'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$item['place'].'/'.$item['post_id'].'/';
		$item['text'] = str_replace('href="/go?','href="',$item['text']);
		$item['text'] = $this->replace_spoilers($item['text'],$item['rss_link']);
		$item['comments_link'] = $item['rss_link'].'comments/all/';
		return $item;
	}
Beispiel #18
0
	public function comment () {
		global $check;
		if (!$check->num(query::$get['id'])) {
			return false;
		}

		$return = obj::db()->sql('select pretty_text,username,cookie from comment where id='.query::$get['id'],1);

		if (empty($return)) {
			return false;
		}

		if (query::$cookie != $return['cookie'] && !$check->rights()) {
			return false;
		}

		return $return;
	}
Beispiel #19
0
	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);
	}
Beispiel #20
0
	function set_events($id, $mail = false) {

		obj::db()->sql('delete from misc where ((type="close_order" and data2="'.$id.'") or (type="mail_notify" and data5="'.$id.'" and data1 > 0))',0);
		obj::db()->insert('misc',array('close_order',(time()+86400*60),$id,'','',''));
		return;
		// @todo проверять статус заказа
		if ($mail) {
			$encrypt = encrypt($id.'extra string');
			$text = 'Ваш заказ на сайте 4отаку.орг, <a href="http://4otaku.org/order/'.$id.'/">http://4otaku.org/order/'.$id.'/</a> до сих пор не выполнен.<br />
				Прошло уже не менее месяца с последнего комментария к заказу, прогресса, или емейл-уведомления. Вы все еще заинтересованы в выполнении заказа? <br />
				Если да, то пройдите пожалуйста по ссылке <a href="http://4otaku.org/order/do/prolong/'.$encrypt.'/">http://4otaku.org/order/do/prolong/'.$encrypt.'/</a><br />
				Если нет, то просто ничего не делайте, через 30 суток заказ закроется автоматически.'.$this->unsubscribe($id);
			obj::db()->insert('misc',array('mail_notify',(time()+86400*30),$mail,'',$text,$id));
		}
	}
Beispiel #21
0
<div class="shell">
<?
	$participants = obj::db()->sql('select * from _atai_players order by id','id');
	
	if ($participants) {
?>

	<table width="100%">
		<thead align="left" valign="top">
			<th width="100%" colspan="3" height="30px">
				Список зарегистрировавшихся:
			</th>
		</thead>
		<tbody>
		<? 	$i = 0;
			foreach ($participants as $participant) { 
			$i++;
		?>
			<? if ($i==1) { ?><tr><? } ?>
				<td width="33%">
					<?php 
echo $participant;
?>
				</td>
			<? if ($i==3) { ?></tr><? $i=0;} ?>
		<? } ?>
		</tbody>
	</table>
<? } else { ?>
	Пока никто не зарегистрировался. Будете первым?
<? } ?>
Beispiel #22
0
	function build_inner_links($links, &$threads) {
		$inner_links = (array) obj::db()->sql('
			select board.id, board.thread, board_category.category_id
			FROM board LEFT JOIN board_category ON
				board.thread=board_category.thread_id OR
				board.id=board_category.thread_id
			WHERE
				board.`type`!="deleted" and
				board.`type`!="old" and
				(board.id='.implode(' or board.id=',$links).') and
				board_category.actual = 1
		');

		$this->inner_links = array();
		foreach ($inner_links as $link) {
			if (empty($this->inner_links[$link['id']])) {
				$this->inner_links[$link['id']] = array(
					'thread' => $link['thread'],
					'boards' => array()
				);
			}

			$this->inner_links[$link['id']]['boards'][] =
				$this->board_categories[$link['category_id']]['alias'];
		}

		if (is_array($threads)) {
			foreach ($threads as $key => $thread) {
				$threads[$key]['text'] = $this->set_inner_links($thread['text']);
				if (is_array($thread['posts'])) {
					foreach ($thread['posts'] as $post_key => $post) {
						$threads[$key]['posts'][$post_key]['text'] = $this->set_inner_links($post['text']);
					}
				}
			}
		}
	}
Beispiel #23
0
 function search($query, $page)
 {
     global $search;
     if (!$search) {
         $search = new search();
     }
     $return = array();
     $return['display'] = array('logs_search', 'logs_results', 'navi');
     $perpage = 10;
     $start = ($page - 1) * $perpage;
     $base = substr(get_called_class(), 8);
     $query = $search->prepare_string(urldecode($query), true);
     $mark = preg_split('/\\s+/s', $query);
     $fixed_query = '+' . preg_replace('/\\s+/s', ' +', $query);
     $select_query = ' MATCH (text) AGAINST ("' . $fixed_query . '" IN BOOLEAN MODE) and cache_key = ' . static::$cache_key;
     $sql = 'SELECT id, date FROM raw_logs WHERE' . $select_query;
     $days = obj::db()->sql($sql . ' group by date order by date desc limit ' . $start . ', ' . $perpage, 'id');
     if (!empty($days)) {
         $select_days = '"' . implode('","', $days) . '"';
         $data = obj::db()->sql('SELECT `date`, `time`, `text` FROM raw_logs WHERE `date` in (' . $select_days . ') and' . $select_query);
         foreach ($days as $day) {
             foreach ($data as $key => $log) {
                 if ($log['date'] == $day) {
                     $return['days'][$day][] = array('time' => $log['time'], 'text' => $this->format_logs($log['text'], false, $mark));
                     unset($data[$key]);
                     if (count($return['days'][$day]) > 4) {
                         break;
                     }
                 }
             }
         }
         $return['navi']['meta'] = '/' . $base . '/search/' . $query . '/';
         $return['navi']['curr'] = $page;
         $return['navi']['start'] = max($return['navi']['curr'] - 5, 2);
         $return['navi']['last'] = ceil(obj::db()->sql('select count(distinct(date)) from raw_logs WHERE MATCH (text) AGAINST ("' . $fixed_query . '" IN BOOLEAN MODE) and cache_key = ' . static::$cache_key, 2) / $perpage);
     } else {
         $return['display'] = array('logs_search', 'logs_results');
     }
     $return['log_base'] = $base;
     return $return;
 }
Beispiel #24
0
<h2>Реплеи:</h2>
<div class="shell">
<?
	$replays = obj::db()->sql('select * from _atai_replays order by id','id');
	
	if ($replays) {
?>

	<table width="100%">
		<thead align="left" valign="top">
<? /*				<th height="30px">
				Номер игры
			</th> */ ?>
			<th height="30px">
				Первый игрок
			</th>
			<th height="30px">
				Второй игрок
			</th>
			<th height="30px">
				&nbsp;
			</th>
		</thead>
		<tbody>
		<? foreach ($replays as $replay) { ?>
			<tr>
<? /*				<td>
					<?php 
echo $replay['game_number'];
?>
				</td> */ ?>
Beispiel #25
0
	$content = unserialize(base64_decode($post['content']));
	
	if (!empty($content)) {
		$type = key($content);
		$content = ($type == 'video') ? current($content) : current(current($content));
	
		$data = obj::db()->insert('board_attachment',array(
			$post['id'],
			$type,
			base64_encode(serialize($content)),
			0
		));
	}
	
	if ($post['thread'] == 0) {
		$categories = array_unique(array_filter(explode('|', $post['boards'])));
		
		foreach ($categories as $category) {
			$data = obj::db()->insert('board_category',array(
				$post['id'],
				$category_ids[$category],
				(int) ($post['type'] != 'old')
			), false);		
		}
	}
}

obj::db()->sql('ALTER TABLE `board` DROP `content`',0);
obj::db()->sql('ALTER TABLE `board` DROP `links`',0);
obj::db()->sql('ALTER TABLE `board` DROP `boards`',0);
Beispiel #26
0
	public function pack_sort () {
		global $check;
		if ($check->rights()) {
			$pack_id = (int) query::$post['id'];

			if (!empty(query::$post['order'])) {
				foreach (query::$post['order'] as $id => $one) {
					$one = (int) $one;
					if ($one > 0) {
						obj::db()->sql('update art_in_pack set `order`='.$one.' where art_id='.$id.' and pack_id='.$pack_id,0);
					}

				}
			}

			if (!empty(query::$post['delete'])) {
				foreach (query::$post['delete'] as $id) {
					$id = (int) $id;
					if ($id > 0) {
						obj::db()->sql('delete from art_in_pack where art_id='.$id.' and pack_id='.$pack_id,0);
						if (!obj::db()->sql('select art_id from art_in_pack where art_id='.$id,2)) {
							obj::db()->sql('update art set area="deleted" where area="cg" and id='.$id,0);
						}
					}
				}
				obj::db()->update('art_pack','weight',0,$pack_id);
			}

			obj::db()->update('art_pack','cover',query::$post['chosen'],$pack_id);
		}
	}