Example #1
0
 protected function process()
 {
     $torrent = new Transform_Torrent($this->file);
     if (!$torrent->is_valid()) {
         throw new Error_Upload(Error_Upload::NOT_A_TORRENT);
     }
     $torrent->delete('announce-list');
     $torrent->set('announce', def::tracker('announce'));
     $data = $torrent->encode();
     $hash = $torrent->get_hash();
     $post_id = Database::get_field('post_torrent', 'post_id', 'hash = ?', $hash);
     if ($post_id) {
         throw new Error_Upload(Error_Upload::ALREADY_EXISTS);
     }
     $filename = pathinfo(urldecode($this->name), PATHINFO_FILENAME);
     $filename = Transform_File::make_name($filename);
     $filename = substr($filename, 0, 200) . '.torrent';
     if (!is_dir(FILES . SL . 'torrent' . SL . $hash)) {
         mkdir(FILES . SL . 'torrent' . SL . $hash, 0755);
     }
     $newfile = FILES . SL . 'torrent' . SL . $hash . SL . $filename;
     file_put_contents($newfile, $data);
     $size = $torrent->get_size();
     $size = Transform_File::weight_short($size);
     $return_data = '<input size="24%" type="text" name="torrent[0][name]" value="Скачать" />:' . "\n" . '<input readonly size="24%" type="text" name="torrent[0][file]" value="' . $filename . '" />' . "\n" . '<input type="hidden" name="torrent[0][hash]" value="' . $hash . '" />' . "\n" . '<input readonly size="4%" type="text" name="torrent[0][size]" value="' . $size . '" />' . "\n" . '<input type="submit" class="disabled sign remove_link" rel="torrent" value="-" />';
     $this->set(array('success' => true, 'data' => $return_data, 'file' => $filename, 'hash' => $hash, 'name' => 'Скачать', 'size' => $size));
 }
Example #2
0
 protected function check_resize($target)
 {
     $resized = false;
     $this->sizes = $this->worker->get_image_width() . 'x' . $this->worker->get_image_height();
     $resize_width = def::art('resizewidth') * def::art('resizestep');
     if ($this->worker->get_image_width() > $resize_width || $this->info[0] > $resize_width) {
         if ($this->scale(def::art('resizewidth'), $target, 95, false)) {
             $resized = $this->sizes;
         }
     } elseif ($sizefile > def::art('resizeweight')) {
         if ($this->scale(false, $target, 95, false)) {
             $resized = $this->sizes;
         }
     }
     if (!empty($resized)) {
         $resized .= 'px; ' . Transform_File::weight_short($this->size);
     }
     return $resized;
 }
Example #3
0
	public function description ($query) {
		
		$params = array();
		
		if (isset($query['meta']) && $query['meta'] == 'author' && isset($query['alias'])) {
			$params['type'] = 'author';
			$params['id'] = $query['alias'];
		} elseif (isset($query['id'])) {
			$params['type'] = 'art';
			$params['id'] = $query['id'];			
		} else {
			return;
		}
		
		$text = Database::get_row(
			'description', 
			array('text', 'pretty_text'),
			'type = ? and description_id = ?', 
			$params
		);
		
		if (!empty($text)) {
			$params = array_merge($params, $text);
		}
		
		if ($params['type'] == 'author') {
			$user = Meta_Author::get_data_by_alias((array) $params['id']);
			$user = current($user);
			$params['username'] = $user['name'];
		} else {
			$params['data'] = Database::get_full_row('art', $query['id']);
			$params['username'] = Database::get_field('user', 'username', $params['data']['user_id']);
			$params['alias'] = Meta_Author::get_alias_by_name($params['username']);
			$params['data']['weight'] = Transform_File::weight($params['data']['weight']);
			$params['data']['date'] = Transform_String::rudate(Database::date_to_unix($params['data']['date']));
		}
		
		$params['can_edit'] = ($params['username'] == Globals::user_info('username'));
		
		return $params;
	}