]> source.dussan.org Git - nextcloud-server.git/commitdiff
port sharing by publiclink fully to the 2.0 codebase and provide a simple gui for it
authorRobin Appelman <icewind1991@gmail.com>
Thu, 2 Jun 2011 00:45:35 +0000 (02:45 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 2 Jun 2011 00:46:50 +0000 (02:46 +0200)
22 files changed:
apps/files_publiclink/admin.php [new file with mode: 0644]
apps/files_publiclink/ajax/deletelink.php [new file with mode: 0644]
apps/files_publiclink/ajax/makelink.php [new file with mode: 0644]
apps/files_publiclink/appinfo/app.php [new file with mode: 0644]
apps/files_publiclink/appinfo/database.xml [new file with mode: 0644]
apps/files_publiclink/appinfo/info.xml [new file with mode: 0644]
apps/files_publiclink/css/admin.css [new file with mode: 0644]
apps/files_publiclink/get.php [new file with mode: 0644]
apps/files_publiclink/js/admin.js [new file with mode: 0644]
apps/files_publiclink/lib_public.php [new file with mode: 0644]
apps/files_publiclink/templates/admin.php [new file with mode: 0644]
apps/files_publiclink/templates/breadcrumb.php [new file with mode: 0644]
apps/files_publiclink/templates/files.php [new file with mode: 0644]
apps/files_publiclink/templates/index.php [new file with mode: 0644]
plugins/publiclink/db_structure.xml [deleted file]
plugins/publiclink/get.php [deleted file]
plugins/publiclink/lib_public.php [deleted file]
plugins/publiclink/makelink.php [deleted file]
plugins/publiclink/plugin.xml [deleted file]
plugins/publiclink/templates/breadcrumb.php [deleted file]
plugins/publiclink/templates/files.php [deleted file]
plugins/publiclink/templates/index.php [deleted file]

diff --git a/apps/files_publiclink/admin.php b/apps/files_publiclink/admin.php
new file mode 100644 (file)
index 0000000..a48076b
--- /dev/null
@@ -0,0 +1,55 @@
+<?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' );
+require( 'template.php' );
+
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+       header( "Location: ".OC_HELPER::linkTo( "index.php" ));
+       exit();
+}
+
+OC_APP::setActiveNavigationEntry( "files_publiclink_administration" );
+
+OC_UTIL::addStyle( 'files_publiclink', 'admin' );
+OC_UTIL::addScript( 'files_publiclink', 'admin' );
+
+if(isset($_SERVER['HTTPS'])) {
+       $baseUrl= "https://". $_SERVER['SERVER_NAME'] . OC_HELPER::linkTo('files_publiclink','get.php');
+}else{
+       $baseUrl= "http://". $_SERVER['SERVER_NAME'] . OC_HELPER::linkTo('files_publiclink','get.php');
+}
+
+
+// return template
+$tmpl = new OC_TEMPLATE( "files_publiclink", "admin", "admin" );
+$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
new file mode 100644 (file)
index 0000000..e2e4ff9
--- /dev/null
@@ -0,0 +1,11 @@
+<?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/makelink.php b/apps/files_publiclink/ajax/makelink.php
new file mode 100644 (file)
index 0000000..5abd1e8
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+$RUNTIME_NOAPPS=true; //no need to load the apps
+
+require_once '../../../lib/base.php';
+
+require_once '../lib_public.php';
+
+$path=$_GET['path'];
+$expire=(isset($_GET['expire']))?$_GET['expire']:0;
+if($expire!==0){
+       
+       $expire=strtotime($expire);
+}
+// echo $expire;
+// die();
+
+$link=new OC_PublicLink($path,$expire);
+echo $link->getToken();
+?>
\ No newline at end of file
diff --git a/apps/files_publiclink/appinfo/app.php b/apps/files_publiclink/appinfo/app.php
new file mode 100644 (file)
index 0000000..894327e
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+OC_APP::addSettingsPage( array( "id" => "files_publiclink_administration", "order" => 1, "href" => OC_HELPER::linkTo( "files_publiclink", "admin.php" ), "name" => "Public Links", "icon" => OC_HELPER::imagePath( "files_publiclink", "share.png" )));
+
+
+?>
diff --git a/apps/files_publiclink/appinfo/database.xml b/apps/files_publiclink/appinfo/database.xml
new file mode 100644 (file)
index 0000000..de63b03
--- /dev/null
@@ -0,0 +1,47 @@
+<?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>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
new file mode 100644 (file)
index 0000000..1d41ea9
--- /dev/null
@@ -0,0 +1,10 @@
+<?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/css/admin.css b/apps/files_publiclink/css/admin.css
new file mode 100644 (file)
index 0000000..f21b289
--- /dev/null
@@ -0,0 +1,2 @@
+td.path{min-width:200px}
+td.expire{width:120px}
\ No newline at end of file
diff --git a/apps/files_publiclink/get.php b/apps/files_publiclink/get.php
new file mode 100644 (file)
index 0000000..60570ac
--- /dev/null
@@ -0,0 +1,84 @@
+<?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( 'template.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('Content-Disposition: attachment; filename="'.basename($path).'"');
+               header('Expires: 0');
+               header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+               header('Pragma: public');
+               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
new file mode 100644 (file)
index 0000000..017c62c
--- /dev/null
@@ -0,0 +1,52 @@
+$(document).ready(function() {
+       $( "#expire" ).datepicker({
+               dateFormat:'MM d, yy',
+               altField: "#expire_time",
+               altFormat: "yy-mm-dd"
+       });
+       $( "#path" ).autocomplete({
+               source: "../../files/ajax/autocomplete.php",
+               minLength: 1
+       });
+       $("button.delete").live('click', function() {
+               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.preventDefault();
+               var path=$('#path').val();
+               var expire=$('#expire_time').val()||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>";
+                                       var expire=($('#expire').val())?$('#expire').val():'Never'
+                                       html+="<td class='expire'>"+expire+"</td>"
+                                       html+="<td class='link'><a href='get.php?token="+token+"'>"+$('#baseUrl').val()+"?token="+token+"</a></td>"
+                                       html+="<td><button class='delete fancybutton' data-token='"+token+"'>Delete</button></td>"
+                                       html+="</tr>"
+                                       $(html).insertBefore($('#newlink_row'));
+                                       $('#expire').val('');
+                                       $('#expire_time').val('');
+                                       $('#path').val('');
+                               }
+                       }
+               });
+       })
+});
\ No newline at end of file
diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php
new file mode 100644 (file)
index 0000000..aeef921
--- /dev/null
@@ -0,0 +1,80 @@
+<?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=$_SESSION['user_id'];
+                       $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 />';
+                               error_log( $entry );
+                               die( $entry );
+                       }
+                       $this->token=$token;
+               }
+       }
+       
+       /**
+        * get the path of that shared file
+        */
+       public static function getPath($token){
+               //remove expired links
+               $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < NOW() AND expire_time!=0");
+               $query->execute();
+               
+               //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;
+       }
+       
+       /**
+        * gets all public links
+        * @return array
+        */
+       static public function getLinks(){
+               $query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?");
+               return $query->execute(array($_SESSION['user_id']))->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']==$_SESSION['user_id']){
+                       $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?");
+                       $query->execute(array($token));
+               }
+       }
+       
+       private $token;
+}
+?>
\ No newline at end of file
diff --git a/apps/files_publiclink/templates/admin.php b/apps/files_publiclink/templates/admin.php
new file mode 100644 (file)
index 0000000..2483eef
--- /dev/null
@@ -0,0 +1,28 @@
+<input type='hidden' id='baseUrl' value='<?php echo $_['baseUrl'];?>'/>
+<table id='linklist'>
+       <thead>
+               <tr>
+                       <td class='path'>Path</td>
+                       <td class='expire'>Expires</td>
+                       <td class='link'>Link</td>
+               </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='expire'><?php echo ($link['expire_time']==0)?'Never':OC_UTIL::formatdate($link['expire_time'],true);?></td>
+                               <td class='link'><a href='get.php?token=<?php echo $link['token'];?>'><?php echo $_['baseUrl'];?>?token=<?php echo $link['token'];?></a></td>
+                               <td><button class='delete fancybutton' data-token='<?php echo $link['token'];?>'>Delete</button></td>
+                       </tr>
+               <?php endforeach;?>
+               <tr id='newlink_row'>
+                       <form action='#' id='newlink'>
+                               <input type='hidden' id='expire_time'/>
+                               <td class='path'><input placeholder='Path' id='path'/></td>
+                               <td class='expire'><input placeholder='Expires' id='expire'/></td>
+                               <td><input type='submit' value='Share'/></td>
+                       </form>
+               </tr>
+       </tbody>
+</table>
\ No newline at end of file
diff --git a/apps/files_publiclink/templates/breadcrumb.php b/apps/files_publiclink/templates/breadcrumb.php
new file mode 100644 (file)
index 0000000..3f4ae86
--- /dev/null
@@ -0,0 +1,4 @@
+       <a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
+       <?php foreach($_["breadcrumb"] as $crumb): ?>
+               <a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$crumb["dir"]); ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
+       <?php endforeach; ?>
\ No newline at end of file
diff --git a/apps/files_publiclink/templates/files.php b/apps/files_publiclink/templates/files.php
new file mode 100644 (file)
index 0000000..6473ad4
--- /dev/null
@@ -0,0 +1,9 @@
+               <?php foreach($_["files"] as $file): ?>
+                       <tr>
+                               <td class="selection"><input type="checkbox" /></td>
+                               <td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); else echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo htmlspecialchars($file["name"]); ?></a></td>
+                               <td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
+                               <td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
+                               <td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
+                       </tr>
+               <?php endforeach; ?>
\ No newline at end of file
diff --git a/apps/files_publiclink/templates/index.php b/apps/files_publiclink/templates/index.php
new file mode 100644 (file)
index 0000000..9e23845
--- /dev/null
@@ -0,0 +1,17 @@
+<p class="nav">
+       <?php echo($_['breadcrumb']); ?>
+</p>
+<table cellspacing="0">
+       <thead>
+               <tr>
+                       <th><input type="checkbox" id="select_all" /></th>
+                       <th>Name</th>
+                       <th>Size</th>
+                       <th>Modified</th>
+                       <th></th>
+               </tr>
+       </thead>
+       <tbody id="fileList">
+               <?php echo($_['fileList']); ?>
+       </tbody>
+</table>
\ No newline at end of file
diff --git a/plugins/publiclink/db_structure.xml b/plugins/publiclink/db_structure.xml
deleted file mode 100644 (file)
index de63b03..0000000
+++ /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>token</name>
-                               <unique>true</unique>
-                               <field>
-                                       <name>token</name>
-                                       <sorting>ascending</sorting>
-                               </field>
-                       </index>
-               </declaration>
-       </table>
-</database>
diff --git a/plugins/publiclink/get.php b/plugins/publiclink/get.php
deleted file mode 100644 (file)
index 41b1048..0000000
+++ /dev/null
@@ -1,84 +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( 'template.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( "plugins/publiclink", "breadcrumb", "" );
-               $breadcrumbNav->assign( "breadcrumb", $breadcrumb );
-               $breadcrumbNav->assign('token',$token);
-               
-               $list = new OC_TEMPLATE( 'plugins/publiclink', 'files', '' );
-               $list->assign( 'files', $files );
-               $list->assign('token',$token);
-               
-               $tmpl = new OC_TEMPLATE( 'plugins/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('Content-Disposition: attachment; filename="'.basename($path).'"');
-               header('Expires: 0');
-               header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-               header('Pragma: public');
-               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/plugins/publiclink/lib_public.php b/plugins/publiclink/lib_public.php
deleted file mode 100644 (file)
index 20b538d..0000000
+++ /dev/null
@@ -1,59 +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=$_SESSION['user_id'];
-                       $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 />';
-                               error_log( $entry );
-                               die( $entry );
-                       }
-                       $this->token=$token;
-               }
-       }
-       
-       /**
-        * get the path of that shared file
-        */
-       public static function getPath($token){
-               //remove expired links
-               $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < NOW() AND expire_time!=0");
-               $query->execute();
-               
-               //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;
-       }
-       
-       private $token;
-}
-?>
\ No newline at end of file
diff --git a/plugins/publiclink/makelink.php b/plugins/publiclink/makelink.php
deleted file mode 100644 (file)
index 1de65e7..0000000
+++ /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=(isset($_GET['expire']))?$_GET['expire']:0;
-
-$link=new OC_PublicLink($path,$expire);
-echo $link->getToken();
-?>
\ No newline at end of file
diff --git a/plugins/publiclink/plugin.xml b/plugins/publiclink/plugin.xml
deleted file mode 100644 (file)
index 75abed6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0"?>
-<plugin version="1.0">
-       <info>
-               <id>publiclink</id>
-               <name>Simple file sharing by creating a public link to a file</name>
-               <version>0.1</version>
-               <licence>AGPL</licence>
-               <author>Robin Appelman</author>
-               <require>1.1</require>
-       </info>
-       <runtime>
-               <include>lib_public.php</include>
-       </runtime>
-       <install>
-               <database>db_structure.xml</database>
-       </install>
-</plugin>
diff --git a/plugins/publiclink/templates/breadcrumb.php b/plugins/publiclink/templates/breadcrumb.php
deleted file mode 100644 (file)
index 3f4ae86..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-       <a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
-       <?php foreach($_["breadcrumb"] as $crumb): ?>
-               <a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$crumb["dir"]); ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
-       <?php endforeach; ?>
\ No newline at end of file
diff --git a/plugins/publiclink/templates/files.php b/plugins/publiclink/templates/files.php
deleted file mode 100644 (file)
index 6473ad4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-               <?php foreach($_["files"] as $file): ?>
-                       <tr>
-                               <td class="selection"><input type="checkbox" /></td>
-                               <td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); else echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo htmlspecialchars($file["name"]); ?></a></td>
-                               <td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
-                               <td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
-                               <td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
-                       </tr>
-               <?php endforeach; ?>
\ No newline at end of file
diff --git a/plugins/publiclink/templates/index.php b/plugins/publiclink/templates/index.php
deleted file mode 100644 (file)
index 9e23845..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<p class="nav">
-       <?php echo($_['breadcrumb']); ?>
-</p>
-<table cellspacing="0">
-       <thead>
-               <tr>
-                       <th><input type="checkbox" id="select_all" /></th>
-                       <th>Name</th>
-                       <th>Size</th>
-                       <th>Modified</th>
-                       <th></th>
-               </tr>
-       </thead>
-       <tbody id="fileList">
-               <?php echo($_['fileList']); ?>
-       </tbody>
-</table>
\ No newline at end of file