Example #1
0
	public function get_content ($query, $perpage, $page, $start) {
		
		$names = Database::set_counter()->get_vector(
			'user', 
			array('id', 'username'), 
			"last_draw != '0000-00-00 00:00:00' order by last_draw desc limit $start, $perpage"
		);

		$authors = Database::get_full_table(
			'meta', 
			Database::array_in('name', $names),
			$names
		);
		
		$items = array();
		$names = array_values($names);
		
		foreach ($authors as $author) {
			$order_id = array_search($author['name'], $names);
			$items[$order_id] = $author;
		}
		
		ksort($items);

		$return = array();
		$aliases = array();
		
		foreach ($items as $id => $item) {
			$return[$id] = new Item_Author($item);
			$aliases[] = $item['alias'];
		}
		unset ($items);
		
		$condition = Database::make_search_condition('meta', array(array('+', $aliases, 'author')));
		
		$arts = Database::get_table('art', 
			array('id', 'user_id', 'meta', 'name', 'comments'),
			$condition.' and area="main" order by date desc'
		);
	
		foreach ($return as $id => $gallery) {
			
			foreach ($arts as $art_id => $art) {
				
				if (strpos($art['meta'], 'author__'.$gallery['alias'])) {
					
					$gallery->add_to('images', $art);
					unset($arts[$art_id]);
				}
				
				if (count($gallery['images']) > 4) {
					break;
				}
			}
		}
	
		return $return;
	}
Example #2
0
 public function parse_images()
 {
     $params = array('pack_art', $this->id);
     $art = Database::get_full_table('misc', 'type = ? and data1 = ? order by data4 limit ' . rand(4, 9), $params);
     $total = Database::get_field('misc', 'data4', 'type = ? and data2 = ?', array('pack_status', $this->id));
     $current_order = Database::get_field('art_in_pack', 'max(`order`)', 'pack_id = ?', $this->id);
     $next_order = !is_numeric($current_order) ? 0 : $current_order + 1;
     if (is_array($art)) {
         $insert_in_pack = array();
         foreach ($art as $one) {
             Database::delete('misc', 'type = ? and id = ?', array('pack_art', $one['id']));
             try {
                 $worker = new Transform_Upload_Art($one['data2'], $one['data4']);
                 $data = $worker->process_file();
                 $art = new Model_Art(array('md5' => $data['md5'], 'thumb' => $data['thumb'], 'extension' => $data['extension'], 'resized' => $data['resized'], 'animated' => $data['animated'], 'author' => '|', 'category' => '|nsfw|game_cg|', 'tag' => '|prostavte_tegi|', 'area' => 'cg'));
                 $art->insert();
             } catch (Error $e) {
                 $data = array();
                 if ($e->getCode() == Error_Upload::ALREADY_EXISTS) {
                     $art = new Model_Art($e->getMessage());
                     if ($art['area'] == 'deleted') {
                         $art['area'] = 'cg';
                         $art->commit();
                     }
                 } else {
                     continue;
                 }
             }
             $insert_in_pack[] = array($art->get_id(), $this->id, $next_order, pathinfo($one['data2'], PATHINFO_BASENAME));
             $next_order++;
         }
         Database::bulk_insert('art_in_pack', $insert_in_pack, array('art_id', 'pack_id', 'order', 'filename'));
     }
     if ($count = Database::get_count('misc', 'type = ? and data1 = ?', array('pack_art', $this->id))) {
         Database::update('misc', array('data3' => $total - $count), 'type = ? and data2 = ?', array('pack_status', $this->id));
     } else {
         Database::update('misc', array('data1' => 'done'), 'type = ? and data2 = ?', array('pack_status', $this->id));
         Database::update('art_pack', array('weight' => 0), $this->id);
     }
 }
Example #3
0
<?php

die;
include '../inc.common.php';
$arts = Database::get_full_table('art_variation');
foreach ($arts as $art) {
    if ($art['resized']) {
        $file = IMAGES . SL . 'booru' . SL . 'full' . SL . $art['md5'] . '.' . $art['extension'];
        $sizes = getimagesize($file);
        $width = $sizes[0];
        $height = $sizes[1];
        $weight = filesize($file);
        if ($weight > 1024 * 1024) {
            $weight = round($weight / (1024 * 1024), 1) . ' мб';
        } elseif ($weight > 1024) {
            $weight = round($weight / 1024, 1) . ' кб';
        } else {
            $weight = $weight . ' б';
        }
        Database::update('art_variation', array('resized' => $width . 'x' . $height . 'px; ' . $weight), $art['id']);
    }
}
Example #4
0
	public function pack_join () {

		Check::rights();

		$parent = (int) query::$post['parent'];
		$child = (int) query::$post['child'];

		Database::update('art_pack', array('weight' => 0), $parent);

		$child_arts = Database::get_full_table('art_in_pack', 'pack_id = ?', $child);
		$parent_order = Database::get_field('art_in_pack', 'max(`order`)', 'pack_id = ?', $parent);

		foreach ($child_arts as $child_art) {
			Database::update('art_in_pack',
				array(
					'order' => $child_art['order'] + $parent_order + 1,
					'pack_id' => $parent
				),
				'pack_id = ? and art_id = ?',
				array($child_art['pack_id'], $child_art['art_id'])
			);
		}

		Database::delete('art_pack', $child);
	}