From a54ea3246cb2d20e3527211d3413f5d3a8dd529f Mon Sep 17 00:00:00 2001
From: Jan-Christoph Borchardt <JanCBorchardt@fsfe.org>
Date: Sat, 24 Sep 2011 23:03:28 +0200
Subject: [PATCH] removed 'share by publiclink' app as it has been superseded
 by Sharing

---
 apps/files_publiclink/admin.php            | 46 ------------
 apps/files_publiclink/ajax/deletelink.php  | 11 ---
 apps/files_publiclink/ajax/getlink.php     |  8 ---
 apps/files_publiclink/ajax/makelink.php    | 13 ----
 apps/files_publiclink/appinfo/app.php      |  6 --
 apps/files_publiclink/appinfo/database.xml | 47 ------------
 apps/files_publiclink/appinfo/info.xml     | 10 ---
 apps/files_publiclink/get.php              | 83 ---------------------
 apps/files_publiclink/js/admin.js          | 45 ------------
 apps/files_publiclink/lib_public.php       | 84 ----------------------
 apps/files_publiclink/templates/admin.php  | 18 -----
 11 files changed, 371 deletions(-)
 delete mode 100644 apps/files_publiclink/admin.php
 delete mode 100644 apps/files_publiclink/ajax/deletelink.php
 delete mode 100644 apps/files_publiclink/ajax/getlink.php
 delete mode 100644 apps/files_publiclink/ajax/makelink.php
 delete mode 100644 apps/files_publiclink/appinfo/app.php
 delete mode 100644 apps/files_publiclink/appinfo/database.xml
 delete mode 100644 apps/files_publiclink/appinfo/info.xml
 delete mode 100644 apps/files_publiclink/get.php
 delete mode 100644 apps/files_publiclink/js/admin.js
 delete mode 100644 apps/files_publiclink/lib_public.php
 delete mode 100644 apps/files_publiclink/templates/admin.php

diff --git a/apps/files_publiclink/admin.php b/apps/files_publiclink/admin.php
deleted file mode 100644
index 03d7a2ff6c5..00000000000
--- a/apps/files_publiclink/admin.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-/**
-* ownCloud - ajax frontend
-*
-* @author Robin Appelman
-* @copyright 2010 Robin Appelman icewind1991@gmail.com
-*
-* 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 Affero General Public
-* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-
-// Init owncloud
-require_once('../../lib/base.php');
-require_once( 'lib_public.php' );
-
-
-// Check if we are a user
-OC_Util::checkLoggedIn();
-
-OC_App::setActiveNavigationEntry( "files_publiclink_administration" );
-
-OC_Util::addScript( 'files_publiclink', 'admin' );
-
-$baseUrl = OC_Helper::linkTo('files_publiclink','get.php', null, true);
-
-
-// return template
-$tmpl = new OC_Template( "files_publiclink", "admin", "user" );
-$tmpl->assign( 'links', OC_PublicLink::getLinks());
-$tmpl->assign('baseUrl',$baseUrl);
-$tmpl->printPage();
-
-?>
diff --git a/apps/files_publiclink/ajax/deletelink.php b/apps/files_publiclink/ajax/deletelink.php
deleted file mode 100644
index e2e4ff944a6..00000000000
--- a/apps/files_publiclink/ajax/deletelink.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-$RUNTIME_NOAPPS=true; //no need to load the apps
-
-require_once '../../../lib/base.php';
-
-require_once '../lib_public.php';
-
-$token=$_GET['token'];
-
-OC_PublicLink::delete($token);
-?>
\ No newline at end of file
diff --git a/apps/files_publiclink/ajax/getlink.php b/apps/files_publiclink/ajax/getlink.php
deleted file mode 100644
index 551bcc8780c..00000000000
--- a/apps/files_publiclink/ajax/getlink.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-$RUNTIME_NOAPPS = true;
-
-require_once('../../../lib/base.php');
-require_once('../lib_public.php');
-
-$path = $_GET['path'];
-echo json_encode(OC_PublicLink::getLink($path));
\ No newline at end of file
diff --git a/apps/files_publiclink/ajax/makelink.php b/apps/files_publiclink/ajax/makelink.php
deleted file mode 100644
index 685feb2fb89..00000000000
--- a/apps/files_publiclink/ajax/makelink.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-$RUNTIME_NOAPPS=true; //no need to load the apps
-
-require_once '../../../lib/base.php';
-
-require_once '../lib_public.php';
-
-$path=$_GET['path'];
-$expire=0;
-
-$link=new OC_PublicLink($path,$expire);
-echo $link->getToken();
-?>
diff --git a/apps/files_publiclink/appinfo/app.php b/apps/files_publiclink/appinfo/app.php
deleted file mode 100644
index 5866e2d1c5e..00000000000
--- a/apps/files_publiclink/appinfo/app.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-// OC_App::addNavigationEntry(array( "id" => "files_publiclink_administration", "order" => 2, "href" => OC_Helper::linkTo( "files_publiclink", "admin.php" ), "name" => "Public Links"));
-
-
-?>
diff --git a/apps/files_publiclink/appinfo/database.xml b/apps/files_publiclink/appinfo/database.xml
deleted file mode 100644
index 4fe6be47d8d..00000000000
--- a/apps/files_publiclink/appinfo/database.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-	 <name>*dbname*</name>
-	 <create>true</create>
-	 <overwrite>false</overwrite>
-	 <charset>latin1</charset>
-	 <table>
-		<name>*dbprefix*publiclink</name>
-		<declaration>
-			<field>
-				<name>token</name>
-				<type>text</type>
-				<default></default>
-				<notnull>true</notnull>
-				<length>40</length>
-			</field>
-			<field>
-				<name>path</name>
-				<type>text</type>
-				<default></default>
-				<notnull>true</notnull>
-				<length>128</length>
-			</field>
-			<field>
-				<name>user</name>
-				<type>text</type>
-				<default>
-				</default>
-				<notnull>true</notnull>
-				<length>64</length>
-			 </field>
-			 <field>
-				<name>expire_time</name>
-				<type>timestamp</type>
-				<notnull>true</notnull>
-			</field>
-			<index>
-				<name>a_files_publiclink_token</name>
-				<unique>true</unique>
-				<field>
-					<name>token</name>
-					<sorting>ascending</sorting>
-				</field>
-			</index>
-		</declaration>
-	</table>
-</database>
diff --git a/apps/files_publiclink/appinfo/info.xml b/apps/files_publiclink/appinfo/info.xml
deleted file mode 100644
index 1d41ea96662..00000000000
--- a/apps/files_publiclink/appinfo/info.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<info>
-	<id>files_publiclink</id>
-	<name>Share by Publiclink</name>
-	<description>Simple file sharing by creating a public link to a file</description>
-	<version>0.2</version>
-	<licence>AGPL</licence>
-	<author>Robin Appelman</author>
-	<require>2</require>
-</info>
\ No newline at end of file
diff --git a/apps/files_publiclink/get.php b/apps/files_publiclink/get.php
deleted file mode 100644
index 2e1ba4bf363..00000000000
--- a/apps/files_publiclink/get.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-$RUNTIME_NOAPPS=true; //no need to load the apps
-$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
-
-require_once '../../lib/base.php';
-
-require_once 'lib_public.php';
-
-//get the path of the shared file
-$token=$_GET['token'];
-$path=OC_PublicLink::getPath($token);
-$root=$path;
-
-if($path!==false){
-	if(isset($_GET['path']) and !strstr($_GET['path'],'..')){
-		$subPath=$_GET['path'];
-	}else{
-		$subPath='';
-	}
-	$path.=$subPath;
-	if(!OC_Filesystem::file_exists($path)){
-		header("HTTP/1.0 404 Not Found");
-		$tmpl = new OC_Template( '', '404', 'guest' );
-		$tmpl->assign('file',$subPath);
-		$tmpl->printPage();
-		exit;
-	}
-	if(OC_Filesystem::is_dir($path)){
-		$files = array();
-		$rootLength=strlen($root);
-		foreach( OC_Files::getdirectorycontent( $path ) as $i ){
-			$i['date'] = OC_Util::formatDate($i['mtime'] );
-			$i['directory']=substr($i['directory'],$rootLength);
-			if($i['directory']=='/'){
-				$i['directory']='';
-			}
-			$files[] = $i;
-		}
-		
-		// Make breadcrumb
-		$breadcrumb = array();
-		$pathtohere = "/";
-		foreach( explode( "/", $subPath ) as $i ){
-			if( $i != "" ){
-				$pathtohere .= "$i/";
-				$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
-			}
-		}
-		
-		$breadcrumbNav = new OC_Template( "files_publiclink", "breadcrumb", "" );
-		$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
-		$breadcrumbNav->assign('token',$token);
-		
-		$list = new OC_Template( 'files_publiclink', 'files', '' );
-		$list->assign( 'files', $files );
-		$list->assign('token',$token);
-		
-		$tmpl = new OC_Template( 'files_publiclink', 'index', 'user' );
-		$tmpl->assign('fileList', $list->fetchPage());
-		$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
-		$tmpl->printPage();
-	}else{
-		//get time mimetype and set the headers
-		$mimetype=OC_Filesystem::getMimeType($path);
-		header('Content-Transfer-Encoding: binary');
-		header('Expires: 0');
-		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-		header('Pragma: public');
-		header('Content-Disposition: filename="'.basename($path).'"');
-		header('Content-Type: ' . $mimetype);
-		header('Content-Length: ' . OC_Filesystem::filesize($path));
-		
-		//download the file
-		@ob_clean();
-		OC_Filesystem::readfile($path);
-	}
-}else{
-	header("HTTP/1.0 404 Not Found");
-	$tmpl = new OC_Template( '', '404', 'guest' );
-	$tmpl->printPage();
-	die();
-}
-?>
\ No newline at end of file
diff --git a/apps/files_publiclink/js/admin.js b/apps/files_publiclink/js/admin.js
deleted file mode 100644
index 91ee58beda8..00000000000
--- a/apps/files_publiclink/js/admin.js
+++ /dev/null
@@ -1,45 +0,0 @@
-$(document).ready(function() {
-	$( "#path" ).autocomplete({
-		source: "../../files/ajax/autocomplete.php",
-		minLength: 1
-	});
-	$(".delete").live('click', function( event ) {
-		event.preventDefault();
-		var token=$(this).attr('data-token');
-		var data="token="+token;
-		$.ajax({
-			type: 'GET',
-			url: 'ajax/deletelink.php',
-			cache: false,
-			data: data,
-			success: function(){
-				$('#'+token).remove();
-			}
-		});
-	});
-	$('#newlink').submit(function( event ){
-		event.preventDefault();
-		var path=$('#path').val();
-		var expire=0;
-		var data='path='+path+'&expire='+expire;
-		$.ajax({
-			type: 'GET',
-			url: 'ajax/makelink.php',
-			cache: false,
-			data: data,
-			success: function(token){
-				if(token){
-					var html="<tr class='link' id='"+token+"'>";
-					html+="<td class='path'>"+path+"</td>";
-					html+="<td class='link'><input type='text' value='"+$('#baseUrl').val()+"?token="+token+"' /></td>"
-					html+="<td><input type='submit' class='delete' data-token='"+token+" value='Delete' /></td>"
-					html+="</tr>"
-					$(html).insertAfter($('#newlink_row'));
-					$('#path').val('');
-					$('#'+token+' input').focus();
-					$('#'+token+' input').select();
-				}
-			}
-		});
-	});
-});
diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php
deleted file mode 100644
index f895615380d..00000000000
--- a/apps/files_publiclink/lib_public.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-class OC_PublicLink{
-	/**
-	 * create a new public link
-	 * @param string path
-	 * @param int (optional) expiretime time the link expires, as timestamp
-	 */
-	public function __construct($path,$expiretime=0){
-		if($path and  OC_Filesystem::file_exists($path) and OC_Filesystem::is_readable($path)){
-			$user=OC_User::getUser();
-			$token=sha1("$user-$path-$expiretime");
-			$query=OC_DB::prepare("INSERT INTO *PREFIX*publiclink VALUES(?,?,?,?)");
-			$result=$query->execute(array($token,$path,$user,$expiretime));
-			if( PEAR::isError($result)) {
-				$entry = 'DB Error: "'.$result->getMessage().'"<br />';
-				$entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-				if(defined("DEBUG") && DEBUG) {error_log( $entry );}
-				die( $entry );
-			}
-			$this->token=$token;
-		}
-	}
-	
-	/**
-	 * get the path of that shared file
-	 */
-	public static function getPath($token) {
-		//get the path and the user
-		$query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?");
-		$result=$query->execute(array($token));
-		$data=$result->fetchAll();
-		if(count($data)>0){
-			$path=$data[0]['path'];
-			$user=$data[0]['user'];
-			
-			//prepare the filesystem
-			OC_Util::setupFS($user);
-			
-			return $path;
-		}else{
-			return false;
-		}
-	}
-	
-	/**
-	 * get the token for the public link
-	 * @return string
-	 */
-	public function getToken(){
-		return $this->token;
-	}
-
-	public static function getLink($path) {
-		$query=OC_DB::prepare("SELECT token FROM *PREFIX*publiclink WHERE user=? AND path=? LIMIT 1");
-		$result=$query->execute(array(OC_User::getUser(),$path))->fetchAll();
-		if(count($result)>0){
-			return $result[0]['token'];
-		}
-	}
-
-	/**
-	 * gets all public links
-	 * @return array
-	 */
-	static public function getLinks(){
-		$query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?");
-		return $query->execute(array(OC_User::getUser()))->fetchAll();
-	}
-
-	/**
-	 * delete a public link
-	 */
-	static public function delete($token){
-		$query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?");
-		$result=$query->execute(array($token))->fetchAll();
-		if(count($result)>0 and $result[0]['user']==OC_User::getUser()){
-			$query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?");
-			$query->execute(array($token));
-		}
-	}
-	
-	private $token;
-}
-?>
diff --git a/apps/files_publiclink/templates/admin.php b/apps/files_publiclink/templates/admin.php
deleted file mode 100644
index b5c04b838bd..00000000000
--- a/apps/files_publiclink/templates/admin.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<input type="hidden" id="baseUrl" value="<?php echo $_['baseUrl'];?>"/>
-<table id="linklist">
-	<thead id="controls">
-		<tr id="newlink_row"><form action="#" id="newlink">
-			<td class="path"><input placeholder="Path" id="path"/></td>
-			<td><input type="submit" value="Share" /></td>
-		</form></tr>
-	</thead>
-	<tbody>
-		<?php foreach($_['links'] as $link):?>
-		<tr class="link" id="<?php echo $link['token'];?>">
-			<td class="path"><?php echo $link['path'];?></td>
-			<td class="link"><input type="text" value="<?php echo $_['baseUrl'];?>?token=<?php echo $link['token'];?>" /></td>
-			<td><input type="submit" class="delete" data-token="<?php echo $link['token'];?>" value="<?php echo $l->t( 'Delete' ); ?>" /></td>
-		</tr>
-		<?php endforeach;?>
-	</tbody>
-</table>
-- 
GitLab