Exemplo n.º 1
0
/**
* ownCloud - ocDownloader plugin
*
* @author Xavier Beurois
* @copyright 2012 Xavier Beurois www.djazz-lab.net
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once '../../lib/base.php';
OC_Util::checkAppEnabled('ocdownloader');
OC_Util::checkLoggedIn();
$tmpl = new OC_Template('ocdownloader', 'downloader.tpl', 'user');
// Get user downloader settings
if (!in_array('curl', get_loaded_extensions())) {
    $tmpl->assign('curl_error', 'The application needs the <strong>PHP cURL</strong> extension to be loaded !');
} else {
    $tmpl->assign('user_prov_set', OC_ocDownloader::getProvidersList());
}
$tmpl->printPage();
Exemplo n.º 2
0
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OC_Util::checkAppEnabled('ocdownloader');
OC_Util::checkLoggedIn();
if (isset($_POST['ocdownloader']) && $_POST['ocdownloader'] == 1) {
    foreach ($_POST as $key => $value) {
        $value = trim($value);
        if (strcmp(substr($key, 0, 19), 'ocdownloader_pr_un_') == 0) {
            $pr_id = substr($key, strrpos($key, '_') + 1);
            if (strlen($value) != 0) {
                if (is_numeric($pr_id)) {
                    $pwd = trim($_POST['ocdownloader_pr_pw_' . $pr_id]);
                    if (strlen($pwd) != 0) {
                        OC_ocDownloader::updateUserInfo($pr_id, $value, $pwd);
                    }
                }
            } else {
                if (is_numeric($pr_id)) {
                    OC_ocDownloader::deleteUserInfo($pr_id);
                }
            }
        }
    }
}
$tmpl = new OC_Template('ocdownloader', 'personalsettings.tpl');
$tmpl->assign('pr_list', OC_ocDownloader::getUserProvidersList());
return $tmpl->fetchPage();
Exemplo n.º 3
0
		
		if(strcmp(substr($url,0,7), 'http://') != 0 && strcmp(substr($url,0,8), 'https://') != 0){
			$url = 'http://'.$url;
		}
		
		$url = parse_url($url);
		if(!isset($url['scheme']) || !isset($url['host']) || !isset($url['path'])){
			OC_ocDownloaderPB::setError($l->t('Connection error ...'));
		}else{
			$path = $url['path'];
			$url = $url['scheme'].'://'.$url['host'].(isset($url['port'])?':'.$url['port']:'').$url['path'];
			
			if(!preg_match('/^pr_([0-9]{1,4})$/', $pr, $m)){
				OC_ocDownloaderPB::setError($l->t('Unknown error'));
			}else{
				$user_info = OC_ocDownloader::getUserProviderInfo($m[1]);
				
				if(!preg_match('/^(http|https):\/\/rapidshare.com\/files\/(.*)\/(.+)$/', $url, $m)){
					OC_ocDownloaderPB::setError($l->t('This file does not exists'));
				}else{
					if(!is_numeric($m[2])){
						OC_ocDownloaderPB::setError($l->t('Wrong File iD'));
					}else{
						$pr_url = 'https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&bin=1';
						if(isset($user_info['us_username']) && isset($user_info['us_password'])){
							$pr_url .= '&login='******'us_username'].'&password='******'us_password']; 
						}
						$pr_url .= '&fileid='.$m[2].'&filename='.$m[3];
						
						$curl = OC_ocDownloaderHTTP::execURL($pr_url, 'rapidshare');
						if(strlen($curl) == 0){
Exemplo n.º 4
0
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

$pr = $_POST['p'];

OCP\JSON::checkAppEnabled('ocdownloader');
OCP\JSON::checkLoggedIn();

$k = Array('e' => TRUE);
if(preg_match('/^pr_([0-9]{1,4})$/', $pr, $m)){
	$p = OC_ocDownloader::getProvider($m[1]);
	if(isset($p['pr_name'])){
		$k['e'] = FALSE;
		$k['n'] = strtolower($p['pr_name']);
	}
}

OCP\JSON::encodedPrint($k);
Exemplo n.º 5
0
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

OCP\App::checkAppEnabled('ocdownloader');
OCP\User::checkLoggedIn();

$tmpl = new OCP\Template('ocdownloader', 'downloader.tpl', 'user');

// Get user downloader settings
if(!in_array('curl', get_loaded_extensions())){
	$tmpl->assign('curl_error', TRUE);
}else{
	$l = new OC_L10N('ocdownloader');
	
	$tmpl->assign('user_prov_set', OC_ocDownloader::getProvidersList());
	$tmpl->assign('user_history', OC_ocDownloader::getUserHistory($l));
}

$tmpl->printPage();
	/**
	 * Get the file by an URL
	 * @param $url URL of the file
	 * @param $path Simple path of the file
	 * @param $l Lang
	 * @param $overwrite Overwrite the target file
	 */
	public static function getFile($url, $path, $l, $overwrite = 0){
		try{
			$code = 0;
			if(!self::checkFileAccess($url, $code)){
				OC_ocDownloaderPB::setError($l->t(self::$errors[$code]));
				exit();
			}
			
			$pathinfo = pathinfo($path);
			$fs = OCP\Files::getStorage('files');
			if($fs->file_exists('/Downloads/' . $pathinfo['basename']) && !$overwrite){
				$pathinfo['basename'] = md5(rand()) . '_' . $pathinfo['basename'];
			}
			$fs = $fs->fopen('/Downloads/' . $pathinfo['basename'], 'w');
			
			$size = self::getRemoteFileSize($url);
			if($size == 0){
				OC_ocDownloaderPB::setError($l->t('Filesize is null'));
				exit();
			}
			$chunkSize = self::getChunkSize($size);
		
		    $fp = fopen($url, 'rb');
			$received = $last = 0;
			
		    while(!feof($fp)){
		        $data = @fread($fp, $chunkSize);
		        if($data == ''){
		        	break;
		        }
				$saved = fwrite($fs, $data);
				if($saved > -1){
					$received += $saved;
				}
				if($received >= $size){
	                $percent = 100;
	            }else{
	                $percent = @round(($received/$size)*100, 2);
	            }
				if($received > $last + $chunkSize){
					OC_ocDownloaderPB::setProgressBarProgress($percent);
					$last = $received;
				}
				usleep(100);
		    }
			OC_ocDownloaderPB::setProgressBarProgress(100);
			OC_ocDownloader::setUserHistory($pathinfo['basename'], 1);
		
		    fclose($fp);fclose($fs);
		}catch(exception $e){
			OC_ocDownloaderPB::setError($l->t('Unknown error'));
		}
	}
Exemplo n.º 7
0
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

OCP\App::checkAppEnabled('ocdownloader');

OC::$CLASSPATH['OC_ocDownloader'] = 'apps/ocdownloader/lib/ocDownloader.class.php';

$l = OC_L10N::get('ocdownloader');

if(!OC_ocDownloader::isUpToDate(OCP\Config::getAppValue('ocdownloader', 'installed_version'))){
	OC_ocDownloader::initProviders(dirname(__FILE__) . '/providers.xml');
}

OCP\App::register(Array(
	'order' => 30,
	'id' => 'ocdownloader',
	'name' => 'ocDownloader'
));

OCP\App::addNavigationEntry(Array(
	'id' => 'ocdownloader_index',
	'order' => 30,
	'href' => OCP\Util::linkTo('ocdownloader', 'downloader.php'),
	'icon' => OCP\Util::imagePath('ocdownloader', 'dl.png'),
	'name' => 'ocDownloader'
));
    private static function get_curl_binary(){
      	$size = self::getRemoteFileSize(self::$flv_url);
		if($size == 0){
			OC_ocDownloaderPB::setError($l->t('Filesize is null'));
			exit();
		}
		$chunkSize = self::getChunkSize($size);
	
	    self::$fp = fopen(self::$flv_url, 'rb');
		$received = $last = 0;
		
	    while(!feof(self::$fp)){
	        $data = @fread(self::$fp, $chunkSize);
	        if($data == ''){
	        	break;
	        }
			$saved = fwrite(self::$fs, $data);
			if($saved > -1){
				$received += $saved;
			}
			if($received >= $size){
                $percent = 100;
            }else{
                $percent = @round(($received/$size)*100, 2);
            }
			if($received > $last + $chunkSize){
				OC_ocDownloaderPB::setProgressBarProgress($percent);
				$last = $received;
			}
			usleep(100);
	    }
		OC_ocDownloaderPB::setProgressBarProgress(100);
		OC_ocDownloader::setUserHistory(self::$final_flv_filename, 1);
		
		fclose(self::$fp);fclose(self::$fs);
    }
Exemplo n.º 9
0
/**
* ownCloud - ocDownloader plugin
*
* @author Xavier Beurois
* @copyright 2012 Xavier Beurois www.djazz-lab.net
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
require_once '../../../../lib/base.php';
OC_JSON::checkAppEnabled('ocdownloader');
OC_JSON::checkLoggedIn();
$k = array();
if (is_numeric($_POST['prov'])) {
    $p = $_POST['prov'];
    $k = OC_ocDownloader::getProvider($p);
}
if (count($k) > 0) {
    OC_JSON::encodedPrint($k);
}
	/**
	 * Get file
	 * @param $path The remote file path
	 * @param $l Lang
	 * @param $overwrite Overwrite the target file
	 */
	public static function getFile($path, $l, $overwrite){
		try{
			$pathinfo = pathinfo($path);
			$fs = OCP\Files::getStorage('files');
			if($fs->file_exists('/Downloads/' . $pathinfo['basename']) && !$overwrite){
				$pathinfo['basename'] = md5(rand()) . '_' . $pathinfo['basename'];
			}
			
			$size = self::getRemoteFileSize($path);
			if($size == 0){
				OC_ocDownloaderPB::setError($l->t('Filesize is null'));
				self::closeConnection();
				exit();
			}
			$chunkSize = self::getChunkSize($size);
			
			$received = $last = 0;
			$ret = ftp_nb_get(self::$conn, $fs->getLocalFile('/Downloads/' . $pathinfo['basename']), $path, FTP_BINARY);
			while($ret == FTP_MOREDATA){
				$received += $fs->filesize('/Downloads/' . $pathinfo['basename']);
				if($received >= $size){
	                $percent = 100;
	            }else{
	                $percent = @round(($received/$size)*100, 2);
	            }
				
				if($received > $last + $chunkSize){
					OC_ocDownloaderPB::setProgressBarProgress($percent);
					$last = $received;
				}
				
				usleep(100);
			   	$ret = ftp_nb_continue(self::$conn);
			}
			if($ret != FTP_FINISHED){
			   	OC_ocDownloaderPB::setError($l->t('Download error'));
				self::closeConnection();
			   	exit();
			}else{
				OC_ocDownloaderPB::setProgressBarProgress(100);
				OC_ocDownloader::setUserHistory($pathinfo['basename'], 1);
			}
			
			self::closeConnection();
		}catch(exception $e){
			OC_ocDownloaderPB::setError($l->t('Unknown error'));
		}
	}
Exemplo n.º 11
0
*
* @author Xavier Beurois
* @copyright 2012 Xavier Beurois www.djazz-lab.net
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

OCP\JSON::checkAppEnabled('ocdownloader');
OCP\JSON::checkLoggedIn();

$l = new OC_L10N('ocdownloader');

$k = Array('e' => TRUE);
if($k['h'] = OC_ocDownloader::getUserHistory($l)){
	$k['e'] = FALSE;
}

OCP\JSON::encodedPrint($k);