Ejemplo n.º 1
0
    public function action_search()
    {
        $search = array('any' => explode(' ', @$_POST['any']), 'artist' => explode(' ', @$_POST['artist']), 'title' => explode(' ', @$_POST['title']), 'desc' => explode(' ', @$_POST['desc']), 'series' => explode(' ', @$_POST['series']), 'tags' => explode(' ', @$_POST['tags']));
        $order_choices = array('date desc', 'date asc', 'title asc', 'title desc', 'id desc', 'id asc');
        $perpage = isset($_POST['perpage']) ? (int) $_POST['perpage'] : 20;
        $order = isset($_POST['order']) ? $_POST['order'] : 'date desc';
        $curpage = isset($_POST['curpage']) ? (int) $_POST['curpage'] : 1;
        if (isset($_POST['next'])) {
            $curpage++;
        } else {
            if (isset($_POST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        ?>
		<form class="form-horizontal" method="post" role="form">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_POST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Artist', 'artist', @$_POST['artist']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Title', 'title', @$_POST['title']);
        ?>
				
				<?php 
        HH::print_form_field('Desc', 'desc', @$_POST['desc']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Series', 'series', @$_POST['series']);
        ?>
			
				<?php 
        HH::print_form_field('Tags', 'tags', @$_POST['tags']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $order_choices, $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
			
	<?php 
        $q = Model::factory('Hmanga')->limit($perpage)->offset(($curpage - 1) * $perpage);
        foreach ($order_choices as $choice) {
            if ($order == $choice) {
                list($column, $direction) = explode(' ', $choice);
                if ($direction == 'desc') {
                    $q->order_by_desc($column);
                } else {
                    $q->order_by_asc($column);
                }
            }
        }
        // filter
        foreach ($search['title'] as $term) {
            if ($term) {
                $q->where_like('title', "%{$term}%");
            }
        }
        foreach ($search['series'] as $term) {
            if ($term) {
                $q->where_like('series', "%{$term}%");
            }
        }
        foreach ($search['artist'] as $term) {
            if ($term) {
                $q->where_like('artist', "%{$term}%");
            }
        }
        foreach ($search['desc'] as $term) {
            if ($term) {
                $q->where_like('desc', "%{$term}%");
            }
        }
        foreach ($search['tags'] as $term) {
            if ($term) {
                $q->where_like('tags', "%#{$term}#%");
            }
        }
        foreach ($search['any'] as $term) {
            if ($term) {
                $q->where_raw('(title LIKE ? OR series LIKE ? OR artist LIKE ? OR desc LIKE ? OR tags LIKE ?)', array("%{$term}%", "%{$term}%", "%{$term}%", "%{$term}%", "%{$term}%"));
            }
        }
        $result = $q->find_many();
        ?>
		<?php 
        foreach ($result as $i => $hmanga) {
            ?>
			<?php 
            $samples = $hmanga->samples();
            ?>
			<?php 
            if ($hmanga->is_deleted) {
                continue;
            }
            ?>

			<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
			<div class="col-md-6 result">
				<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
" title="<?php 
            echo $hmanga->desc;
            ?>
">
					<img src="<?php 
            echo $samples[0];
            ?>
" alt="th" width="100" height="140">
					<img src="<?php 
            echo $samples[1];
            ?>
" alt="th" width="100" height="140">
				</a>

				<dl class="dl-horizontal result">
					<dt>Title</dt><dd><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
"><?php 
            echo $hmanga->title;
            ?>
</a></dd>
					<dt>Series</dt><dd><?php 
            echo $hmanga->series;
            ?>
</dd>
					<dt>Artist</dt><dd><?php 
            echo $hmanga->artist;
            ?>
</dd>
					<dt>Date</dt><dd><?php 
            echo $hmanga->date;
            ?>
</dd>
					<dt>Page</dt><dd><?php 
            echo $hmanga->count();
            ?>
</dd>
					<dt>Tags</dt><dd><?php 
            echo str_replace('#', ' ', $hmanga->tags);
            ?>
</dd>
					<dt><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">VIEW</a></dt>
					<dd>
						<a href="<?php 
            echo Fakku::$base . $hmanga->url;
            ?>
">ORIGIN</a>
						<a href="<?php 
            echo HH::url("action=dump&id={$hmanga->id}");
            ?>
">DUMP</a>
					</dd>
				</dl>
			</div>
			<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
		<?php 
        }
        ?>
		
		<div class="form-group" style="display:block;clear:both">
			<?php 
        HH::print_submit_buttons();
        ?>
		</div>
	</form>
	<?php 
    }
Ejemplo n.º 2
0
 public function action_redownload()
 {
     $id = $_GET['id'];
     $hmanga = Model::factory('Hmanga')->find_one($id);
     $p = new Page(self::$base . $hmanga->url);
     try {
         $data = $this->extract_from_page($p);
         foreach ($data as $key => $value) {
             $hmanga->{$key} = $value;
         }
         print_r($data);
         // echo '<pre>';print_r($data);exit;
         $hmanga->save();
         echo "<a href='" . HH::url($this, "action=view&id={$hmanga->id}") . "'>View</a>";
     } catch (Exception $e) {
         echo '<pre>' . $e . "</pre><br>\n";
         die;
     }
 }
Ejemplo n.º 3
0
    private function print_book($book)
    {
        ?>
		<div class="col-md-6 result">
			<?php 
        echo "{$book->title} | {$book->pages} pages | {$book->date}";
        ?>
			<a href="<?php 
        echo HH::url($this, "action=view&id={$book->id}");
        ?>
">VIEW</a>
			<a href="<?php 
        echo $book->url;
        ?>
">ORIGIN</a>
			<br>
			<?php 
        $samples = $book->samples();
        ?>
			<a href="<?php 
        echo HH::url($this, "action=view&id={$book->id}");
        ?>
" title="<?php 
        echo $book->title;
        ?>
">
				<?php 
        foreach ($samples as $img) {
            ?>
					<img src="<?php 
            echo $img;
            ?>
" alt="th" width="150" />
				<?php 
        }
        ?>
			</a>
			<?php 
        echo str_replace('#', ', ', trim($book->tags, '#'));
        ?>
		</div>
		<?php 
    }
Ejemplo n.º 4
0
    public function action_search()
    {
        $search = array('any' => explode(' ', @$_REQUEST['any']), 'title' => explode(' ', @$_REQUEST['title']), 'artist' => explode(' ', @$_REQUEST['artist']), 'origin' => explode(' ', @$_REQUEST['origin']), 'tags' => explode(' ', @$_REQUEST['tags']), 'include' => @$_REQUEST['include'], 'exclude' => @$_REQUEST['exclude']);
        $order_choices = array('added desc', 'added asc', 'title asc', 'title desc', 'id desc', 'id asc', 'length asc', 'length desc');
        $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'added desc';
        $perpage = isset($_REQUEST['perpage']) ? $_REQUEST['perpage'] : 20;
        $curpage = isset($_REQUEST['curpage']) ? $_REQUEST['curpage'] : 1;
        if (isset($_REQUEST['next'])) {
            $curpage++;
        } else {
            if (isset($_REQUEST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        ?>
		<form method="post" class="form-horizontal">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_REQUEST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Title', 'title', @$_REQUEST['title']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Artist', 'artist', @$_REQUEST['artist']);
        ?>

				<?php 
        HH::print_form_field('Origin', 'origin', @$_REQUEST['origin']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $order_choices, $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
	<?php 
        $q = Model::factory('Hmanga')->limit($perpage)->offset(($curpage - 1) * $perpage);
        foreach ($order_choices as $choice) {
            if ($order == $choice) {
                list($column, $direction) = explode(' ', $choice);
                if ($direction == 'desc') {
                    $q->order_by_desc($column);
                } else {
                    $q->order_by_asc($column);
                }
            }
        }
        // filter
        foreach ($search['title'] as $term) {
            if ($term) {
                $q->where_like('title', "%{$term}%");
            }
        }
        foreach ($search['origin'] as $term) {
            if ($term) {
                $q->where_like('origin', "%{$term}%");
            }
        }
        foreach ($search['artist'] as $term) {
            if ($term) {
                $q->where_like('artist', "%{$term}%");
            }
        }
        foreach ($search['any'] as $term) {
            if ($term) {
                $q->where_raw('(title LIKE ? OR origin LIKE ? OR artist LIKE ?)', array("%{$term}%", "%{$term}%", "%{$term}%"));
            }
        }
        if (@$_REQUEST['include']) {
            foreach ($_REQUEST['include'] as $key => $vals) {
                foreach ($vals as $val) {
                    $q->where_like($key, "%#{$val}#%");
                }
            }
        }
        if (@$_REQUEST['exclude']) {
            foreach ($_REQUEST['exclude'] as $key => $vals) {
                foreach ($vals as $val) {
                    $q->where_not_like($key, "%#{$val}#%");
                }
            }
        }
        $result = $q->find_many();
        $ref = $this->get_ref();
        ?>
			<?php 
        foreach ($result as $i => $hmanga) {
            ?>
				<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
				<div class="col-md-6 result">
					<?php 
            $samples = $hmanga->samples();
            ?>
					<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">
						<img src="<?php 
            echo $samples[0];
            ?>
" alt="th">
						<img src="<?php 
            echo $samples[1];
            ?>
" alt="th">
					</a>

					<dl class="dl-horizontal result">
						<dt>Title</dt><dd><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
"><?php 
            echo $hmanga->title;
            ?>
</a></dd>
						<dt>Origin</dt><dd><?php 
            echo $hmanga->origin;
            ?>
</dd>
						<dt>Artist</dt><dd><?php 
            echo $hmanga->artist;
            ?>
</dd>
						<dt>Date</dt><dd><?php 
            echo $hmanga->added;
            ?>
</dd>
						<dt>Page</dt><dd><?php 
            echo $hmanga->length;
            ?>
</dd>
						<dt>Tags</dt><dd><?php 
            echo str_replace('#', ' ', $hmanga->type);
            ?>
</dd>
						<dt><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">VIEW</a></dt>
						<dd><a href="<?php 
            echo $hmanga->link;
            ?>
">ORIGIN</a></dd>
					</dl>
				</div>
				<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
			<?php 
        }
        ?>
			
			<div class="form-group row" style="display:block;clear:both">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>

			<table border="2">
				<tr valign="top">
				<?php 
        $i = 0;
        ?>
				<?php 
        foreach ($ref as $key => $vals) {
            $i++;
            ?>
					<td>
					<table>
						<tr>
							<th><?php 
            echo $key;
            ?>
</th>
							<th>V</th>
							<th>X</th>
						</tr>
						<?php 
            foreach ($vals as $val) {
                ?>
							<tr>
								<td><?php 
                echo $val;
                ?>
</td>
								<td><input type="checkbox" name="include[<?php 
                echo $key;
                ?>
][]" value="<?php 
                echo $val;
                ?>
" <?php 
                if (in_array($val, (array) @$_REQUEST['include'][$key])) {
                    echo 'checked';
                }
                ?>
/></td>
								<td><input type="checkbox" name="exclude[<?php 
                echo $key;
                ?>
][]" value="<?php 
                echo $val;
                ?>
" <?php 
                if (in_array($val, (array) @$_REQUEST['exclude'][$key])) {
                    echo 'checked';
                }
                ?>
/></td>
							</tr>
						<?php 
            }
            ?>
					</table>
					</td>
					<?php 
            if ($i % 6 == 0) {
                ?>
				</tr>
				<tr valign="top">
					<?php 
            }
            ?>
				<?php 
        }
        ?>
				</tr>
			</table>
			<input type="submit" value="search" />
		</form>
		<?php 
    }