first commit from filesAlias 0.6
This commit is contained in:
commit
223edca104
17 changed files with 824 additions and 0 deletions
32
_admin.php
Normal file
32
_admin.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||||
|
|
||||||
|
$_menu['Blog']->addItem(__('Medias sharing'),
|
||||||
|
$core->adminurl->get('admin.plugin.filesAlias'),
|
||||||
|
dcPage::getPF('filesAlias/icon.png'),
|
||||||
|
preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='filesAlias',
|
||||||
|
$core->auth->check('contentadmin',$core->blog->id));
|
||||||
|
|
||||||
|
$core->addBehavior('adminDashboardFavorites','filesAliasDashboardFavorites');
|
||||||
|
|
||||||
|
function filesAliasDashboardFavorites($core,$favs)
|
||||||
|
{
|
||||||
|
$favs->register('filesAlias', array(
|
||||||
|
'title' => __('Medias sharing'),
|
||||||
|
'url' => $core->adminurl->get('admin.plugin.filesAlias'),
|
||||||
|
'small-icon' => dcPage::getPF('filesAlias/icon.png'),
|
||||||
|
'large-icon' => dcPage::getPF('filesAlias/icon_b.png'),
|
||||||
|
'permissions' => 'usage,contentadmin'
|
||||||
|
));
|
||||||
|
}
|
27
_define.php
Normal file
27
_define.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
if (!defined('DC_RC_PATH')) { return; }
|
||||||
|
|
||||||
|
$this->registerModule(
|
||||||
|
/* Name */ 'filesAlias',
|
||||||
|
/* Description*/ "Manage aliases of your blog's medias",
|
||||||
|
/* Author */ "Osku & Pierre Van Glabeke",
|
||||||
|
/* Version */ '0.6',
|
||||||
|
array(
|
||||||
|
'permissions' => 'contentadmin',
|
||||||
|
'type' => 'plugin',
|
||||||
|
'dc_min' => '2.7',
|
||||||
|
'support' => 'http://forum.dotclear.org/viewtopic.php?id=42317',
|
||||||
|
'details' => 'http://plugins.dotaddict.org/dc2/details/filesAlias'
|
||||||
|
)
|
||||||
|
);
|
44
_install.php
Normal file
44
_install.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||||
|
|
||||||
|
$version = $core->plugins->moduleInfo('filesAlias','version');
|
||||||
|
|
||||||
|
if (version_compare($core->getVersion('filesAlias'),$version,'>=')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Database schema
|
||||||
|
-------------------------------------------------------- */
|
||||||
|
$s = new dbStruct($core->con,$core->prefix);
|
||||||
|
|
||||||
|
$s->filesalias
|
||||||
|
->blog_id('varchar',32,false)
|
||||||
|
->filesalias_url('varchar',255,false)
|
||||||
|
->filesalias_destination('varchar',255,false)
|
||||||
|
->filesalias_password('varchar',32,true,null)
|
||||||
|
->filesalias_disposable('smallint',0,false,0)
|
||||||
|
|
||||||
|
->primary('pk_filesalias','blog_id','filesalias_url')
|
||||||
|
|
||||||
|
->index('idx_filesalias_blog_id','btree','blog_id')
|
||||||
|
|
||||||
|
->reference('fk_filesalias_blog','blog_id','blog','blog_id','cascade','cascade')
|
||||||
|
;
|
||||||
|
|
||||||
|
# Schema installation
|
||||||
|
$si = new dbStruct($core->con,$core->prefix);
|
||||||
|
$changes = $si->synchronize($s);
|
||||||
|
|
||||||
|
$core->setVersion('filesAlias',$version);
|
||||||
|
return true;
|
25
_prepend.php
Normal file
25
_prepend.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
if (!defined('DC_RC_PATH')) { return; }
|
||||||
|
|
||||||
|
$__autoload['filesAliases'] = dirname(__FILE__).'/inc/class.files.alias.php';
|
||||||
|
$__autoload['aliasMedia'] = dirname(__FILE__).'/inc/class.files.alias.php';
|
||||||
|
$__autoload['PallazzoTools'] = dirname(__FILE__).'/inc/lib.files.alias.tools.php';
|
||||||
|
|
||||||
|
$core->filealias = new filesAliases($core);
|
||||||
|
|
||||||
|
$core->url->register('filesalias',
|
||||||
|
'pub',
|
||||||
|
'^pub/(.+)$',
|
||||||
|
array('urlFilesAlias','alias')
|
||||||
|
);
|
102
_public.php
Normal file
102
_public.php
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
|
if (!defined('DC_RC_PATH')) { return; }
|
||||||
|
|
||||||
|
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
|
||||||
|
$core->tpl->addValue('fileAliasURL',array('templateAlias','fileAliasURL'));
|
||||||
|
|
||||||
|
class templateAlias
|
||||||
|
{
|
||||||
|
public static function fileAliasURL($attr)
|
||||||
|
{
|
||||||
|
global $core, $_ctx;
|
||||||
|
|
||||||
|
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
||||||
|
return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("filesalias")."/".$_ctx->filealias->filesalias_url').'; ?>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class urlFilesAlias extends dcUrlHandlers
|
||||||
|
{
|
||||||
|
public static function alias($args)
|
||||||
|
{
|
||||||
|
$_ctx =& $GLOBALS['_ctx'];
|
||||||
|
$core =& $GLOBALS['core'];
|
||||||
|
$delete = false;
|
||||||
|
|
||||||
|
$_ctx->filealias = $core->filealias->getAlias($args);
|
||||||
|
|
||||||
|
if ($_ctx->filealias->isEmpty()) {
|
||||||
|
self::p404();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_ctx->filealias->filesalias_disposable) {
|
||||||
|
$delete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_ctx->filealias->filesalias_password) {
|
||||||
|
|
||||||
|
# Check for match
|
||||||
|
if (!empty($_POST['filepassword']) && $_POST['filepassword'] == $_ctx->filealias->filesalias_password)
|
||||||
|
{
|
||||||
|
self::servefile($_ctx->filealias->filesalias_destination,$args,$delete);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::serveDocument('file-password-form.html','text/html',false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::servefile($_ctx->filealias->filesalias_destination,$args,$delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function servefile($target,$alias,$delete=false)
|
||||||
|
{
|
||||||
|
$core =& $GLOBALS['core'];
|
||||||
|
|
||||||
|
$a= new aliasMedia($core);
|
||||||
|
$media = $a->getMediaId($target);
|
||||||
|
|
||||||
|
if (empty($media))
|
||||||
|
{
|
||||||
|
self::p404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $core->media->getFile($media);
|
||||||
|
|
||||||
|
if (empty($file->file))
|
||||||
|
{
|
||||||
|
self::p404();
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-type: '.$file->type);
|
||||||
|
header('Content-Length: '.$file->size);
|
||||||
|
header('Content-Disposition: attachment; filename="'.$file->basename.'"');
|
||||||
|
|
||||||
|
if (ob_get_length() > 0) {
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
flush();
|
||||||
|
|
||||||
|
readfile($file->file);
|
||||||
|
if ($delete) {
|
||||||
|
$core->filealias->deleteAlias($alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
2
changelog
Normal file
2
changelog
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
v0.6 - 19-06-2015 - Osku & Pierre Van Glabeke
|
||||||
|
* première version publique
|
42
default-templates/file-password-form.html
Normal file
42
default-templates/file-password-form.html
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="{{tpl:BlogLanguage}}">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />
|
||||||
|
<title>{{tpl:lang Password needed}} - {{tpl:BlogName encode_html="1"}}</title>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
font: 0.8em Verdana,Arial,Geneva,sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display : block;
|
||||||
|
width : 500px;
|
||||||
|
margin : 0 auto;
|
||||||
|
padding : 1em;
|
||||||
|
background : #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 { font : 140% Arial,Helvetica,sans-serif; margin : 0; }
|
||||||
|
|
||||||
|
label { font-weight : bold; }
|
||||||
|
|
||||||
|
input { border-width : 1px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form action="{{tpl:fileAliasURL}}" method="post" role="form">
|
||||||
|
<h2>{{tpl:lang Password needed}}</h2>
|
||||||
|
|
||||||
|
<p>{{tpl:lang You must give a password to access this area.}}</p>
|
||||||
|
<p><label>{{tpl:lang Password:}} <input type="password" name="filepassword" value=""
|
||||||
|
tabindex="1" /></label> <input type="submit" value="ok" /></p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 442 B |
BIN
icon_b.png
Normal file
BIN
icon_b.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
130
inc/class.files.alias.php
Normal file
130
inc/class.files.alias.php
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
|
class filesAliases
|
||||||
|
{
|
||||||
|
protected $core;
|
||||||
|
protected $aliases;
|
||||||
|
|
||||||
|
public function __construct($core)
|
||||||
|
{
|
||||||
|
$this->core =& $core;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAliases()
|
||||||
|
{
|
||||||
|
if (is_array($this->aliases)) {
|
||||||
|
return $this->aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->aliases = array();
|
||||||
|
$sql = 'SELECT filesalias_url, filesalias_destination, filesalias_password, filesalias_disposable '.
|
||||||
|
'FROM '.$this->core->prefix.'filesalias '.
|
||||||
|
"WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ".
|
||||||
|
'ORDER BY filesalias_url ASC ';
|
||||||
|
$this->aliases = $this->core->con->select($sql)->rows();
|
||||||
|
return $this->aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAlias($url)
|
||||||
|
{
|
||||||
|
$strReq = 'SELECT filesalias_url, filesalias_destination, filesalias_password, filesalias_disposable '.
|
||||||
|
'FROM '.$this->core->prefix.'filesalias '.
|
||||||
|
"WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ".
|
||||||
|
"AND filesalias_url = '".$this->core->con->escape($url)."' ".
|
||||||
|
'ORDER BY filesalias_url ASC ';
|
||||||
|
|
||||||
|
$rs = $this->core->con->select($strReq);
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateAliases($aliases)
|
||||||
|
{
|
||||||
|
$this->core->con->begin();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->deleteAliases();
|
||||||
|
foreach ($aliases as $k => $v)
|
||||||
|
{
|
||||||
|
if (!empty($v['filesalias_url']) && !empty($v['filesalias_destination']))
|
||||||
|
{
|
||||||
|
$v['filesalias_disposable'] = isset($v['filesalias_disposable']) ? true : false;
|
||||||
|
$this->createAlias($v['filesalias_url'],$v['filesalias_destination'],$v['filesalias_disposable'],$v['filesalias_password']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->core->con->commit();
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$this->core->con->rollback();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createAlias($url,$destination,$disposable=0,$password=null)
|
||||||
|
{
|
||||||
|
if (!$url) {
|
||||||
|
throw new Exception(__('File URL is empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$destination) {
|
||||||
|
throw new Exception(__('File destination is empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$cur = $this->core->con->openCursor($this->core->prefix.'filesalias');
|
||||||
|
$cur->blog_id = (string) $this->core->blog->id;
|
||||||
|
$cur->filesalias_url = (string) $url;
|
||||||
|
$cur->filesalias_destination = (string) $destination;
|
||||||
|
$cur->filesalias_password = $password;
|
||||||
|
$cur->filesalias_disposable = abs((integer) $disposable);
|
||||||
|
$cur->insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAliases()
|
||||||
|
{
|
||||||
|
$this->core->con->execute(
|
||||||
|
'DELETE FROM '.$this->core->prefix.'filesalias '.
|
||||||
|
"WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAlias($url)
|
||||||
|
{
|
||||||
|
$this->core->con->execute(
|
||||||
|
'DELETE FROM '.$this->core->prefix.'filesalias '.
|
||||||
|
"WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ".
|
||||||
|
"AND filesalias_url = '".$this->core->con->escape($url)."' "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class aliasMedia extends dcMedia
|
||||||
|
{
|
||||||
|
public function __construct($core)
|
||||||
|
{
|
||||||
|
parent::__construct($core);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMediaId($target)
|
||||||
|
{
|
||||||
|
$strReq =
|
||||||
|
'SELECT media_id '.
|
||||||
|
'FROM '.$this->table.' '.
|
||||||
|
"WHERE media_path = '".$this->path."' ".
|
||||||
|
"AND media_file = '".$this->con->escape($target)."' ";
|
||||||
|
|
||||||
|
$rs = $this->core->con->select($strReq);
|
||||||
|
return $rs->media_id;
|
||||||
|
}
|
||||||
|
}
|
54
inc/lib.files.alias.tools.php
Normal file
54
inc/lib.files.alias.tools.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapted from Enrico Pallazzo class
|
||||||
|
**/
|
||||||
|
class PallazzoTools
|
||||||
|
{
|
||||||
|
public static function rand_uniqid()
|
||||||
|
{
|
||||||
|
$index = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
$in = time();
|
||||||
|
$passKey = md5(uniqid(rand(), true));
|
||||||
|
|
||||||
|
for ($n = 0; $n<strlen($index); $n++) {
|
||||||
|
$i[] = substr( $index,$n ,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$passhash = hash('sha256',$passKey);
|
||||||
|
$passhash = (strlen($passhash) < strlen($index))
|
||||||
|
? hash('sha512',$passKey)
|
||||||
|
: $passhash;
|
||||||
|
|
||||||
|
for ($n=0; $n < strlen($index); $n++) {
|
||||||
|
$p[] = substr($passhash, $n ,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
array_multisort($p, SORT_DESC, $i);
|
||||||
|
$index = implode($i);
|
||||||
|
|
||||||
|
$base = strlen($index);
|
||||||
|
|
||||||
|
$out = "";
|
||||||
|
for ($t = floor(log($in, $base)); $t >= 0; $t--) {
|
||||||
|
$bcp = pow($base, $t);
|
||||||
|
$a = floor($in / $bcp) % $base;
|
||||||
|
$out = $out . substr($index, $a, 1);
|
||||||
|
$in = $in - ($a * $bcp);
|
||||||
|
}
|
||||||
|
$out = strrev($out);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
}
|
178
index.php
Normal file
178
index.php
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||||
|
|
||||||
|
$page_title = __('Medias sharing');
|
||||||
|
|
||||||
|
$o = $core->filealias;
|
||||||
|
$aliases = $o->getAliases();
|
||||||
|
$media = new dcMedia($core);
|
||||||
|
$a= new aliasMedia($core);
|
||||||
|
|
||||||
|
# Update aliases
|
||||||
|
if (isset($_POST['a']) && is_array($_POST['a']))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$o->updateAliases($_POST['a']);
|
||||||
|
http::redirect($p_url.'&up=1');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$core->error->add($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# New alias
|
||||||
|
if (isset($_POST['filesalias_url']))
|
||||||
|
{
|
||||||
|
$url = empty($_POST['filesalias_url']) ? PallazzoTools::rand_uniqid() : $_POST['filesalias_url'];
|
||||||
|
|
||||||
|
$target = $_POST['filesalias_destination'];
|
||||||
|
$totrash = isset ($_POST['filesalias_disposable']) ? true : false;
|
||||||
|
$password = empty($_POST['filesalias_password'])? '' : $_POST['filesalias_password'];
|
||||||
|
|
||||||
|
if (preg_match('/^'.preg_quote($media->root_url,'/').'/',$target)) {
|
||||||
|
$target = preg_replace('/^'.preg_quote($media->root_url,'/').'/','',$target);
|
||||||
|
$media = $a->getMediaId($target);
|
||||||
|
|
||||||
|
if (!empty($media))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$o->createAlias($url,$target,$totrash,$password);
|
||||||
|
http::redirect($p_url.'&created=1');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$core->error->add($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$core->error->add(__('Target is not in medias manager.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$media = $a->getMediaId($target);
|
||||||
|
|
||||||
|
if (!empty($media))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$o->createAlias($url,$target,$totrash,$password);
|
||||||
|
http::redirect($p_url.'&created=1');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$core->error->add($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$core->error->add(__('Target is not in medias manager.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title><?php echo $page_title; ?></title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo dcPage::breadcrumb(
|
||||||
|
array(
|
||||||
|
html::escapeHTML($core->blog->name) => '',
|
||||||
|
__('Medias sharing') => ''
|
||||||
|
)).
|
||||||
|
dcPage::notices();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
if (!empty($_GET['up'])) {
|
||||||
|
dcPage::success(__('Aliases successfully updated.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_GET['created'])) {
|
||||||
|
dcPage::success(__('Alias for this media created.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_GET['modified'])) {
|
||||||
|
dcPage::success(__('Configuration successfully updated.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($aliases))
|
||||||
|
{
|
||||||
|
echo '<p>'.__('No alias').'</p>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$root_url = html::escapeHTML($media->root_url);
|
||||||
|
echo
|
||||||
|
'<form action="'.$p_url.'" method="post">'.
|
||||||
|
'<div class="table-outer">'.
|
||||||
|
'<table ><thead>
|
||||||
|
<caption class="as_h3">'.__('Aliases list').'</caption>
|
||||||
|
<tr class="line">'.
|
||||||
|
'<th>'.__('Destination').' - <ins>'.$root_url.'</ins><code>(-?-)</code></th>'.
|
||||||
|
'<th>'.__('Alias').' - <ins>'.$core->blog->url.$core->url->getBase('filesalias').'/'.'</ins><code>(-?-)</code></th>'.
|
||||||
|
'<th>'.__('Disposable').'</th>'.
|
||||||
|
'<th>'.__('Password').'</th>'.
|
||||||
|
'</tr></thead><body>';
|
||||||
|
|
||||||
|
foreach ($aliases as $k => $v)
|
||||||
|
{
|
||||||
|
$url = $core->blog->url.$core->url->getBase('filesalias').'/'.html::escapeHTML($v['filesalias_url']);
|
||||||
|
|
||||||
|
$link = '<a href="'.$url.'">'.__('link').'</a>';
|
||||||
|
$v['filesalias_disposable'] = isset ($v['filesalias_disposable']) ? $v['filesalias_disposable'] : false;
|
||||||
|
echo
|
||||||
|
'<tr class="line">'.
|
||||||
|
'<td class="row">'.form::field(array('a['.$k.'][filesalias_destination]'),40,255,html::escapeHTML($v['filesalias_destination'])).'</td>'.
|
||||||
|
'<td class="row">'.form::field(array('a['.$k.'][filesalias_url]'),20,255,html::escapeHTML($v['filesalias_url'])).'<a href="'.$url.'">'.__('link').'</a></td>'.
|
||||||
|
'<td class="row">'.form::checkbox(array('a['.$k.'][filesalias_disposable]'),1,$v['filesalias_disposable']).'</td>'.
|
||||||
|
'<td>'.form::field(array('a['.$k.'][filesalias_password]'),10,255,html::escapeHTML($v['filesalias_password'])).'</td>'.
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</tobdy></table>'.
|
||||||
|
'<p class="form-note">'.__('To remove a link, empty its alias or destination.').'</p>'.
|
||||||
|
'<p>'.$core->formNonce().
|
||||||
|
'<input type="submit" value="'.__('Update').'" /></p>'.
|
||||||
|
'</div>'.
|
||||||
|
'</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
'<form action="'.$p_url.'" method="post">
|
||||||
|
<div class="fieldset">
|
||||||
|
<h3>'.__('New alias').'</h3>
|
||||||
|
<p ><label for="filesalias_destination" class="required">
|
||||||
|
<abbr title="'.__('Required field').'">*</abbr> '.
|
||||||
|
__('Destination:').' </label>'.form::field('filesalias_destination',70,255).'
|
||||||
|
</p>
|
||||||
|
<p class="form-note warn">'.__('Destination file must be in media manager.').'</p>
|
||||||
|
<p class="form-note">'.sprintf(__('Root URL "<code>%s</code>" will be automatically removed.'),$media->root_url).'</p>
|
||||||
|
<p class="field"><label for="filesalias_url">'.
|
||||||
|
__('URL (alias):').' '.form::field('filesalias_url',70,255).
|
||||||
|
'</label></p>
|
||||||
|
<p class="form-note info">'.__('Leave empty to get a randomize alias.').'</p>
|
||||||
|
<p>'.form::checkbox('filesalias_disposable',1).'<label for="filesalias_disposable" class="classic">'.
|
||||||
|
__('Disposable').
|
||||||
|
'</label></p>
|
||||||
|
<p class="field"><label for="filesalias_password">'.
|
||||||
|
__('Password:').' '.form::field('filesalias_password',70,255).
|
||||||
|
'</label></p>
|
||||||
|
<p>'.$core->formNonce().'<input type="submit" value="'.__('Save').'" /></p>
|
||||||
|
</div>
|
||||||
|
</form>';
|
||||||
|
|
||||||
|
dcPage::helpBlock('filesAlias');
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
locales/en/help/filesAlias.html
Normal file
26
locales/en/help/filesAlias.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Help for filesAlias</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Aliases allow you to set any URL that returns the contents of any resource
|
||||||
|
available in the <code>/public</code> for your blog.</p>
|
||||||
|
<p>The target of the alias must be an element of the media manager's blog.
|
||||||
|
The URL alias will deliver the target without revealing the real media URL.</p>
|
||||||
|
<p>Otherwise, it's a classic redirect to the destination of the alias.</p>
|
||||||
|
<p>And if in addition you have chosen to create an alias disposable, it
|
||||||
|
self-delete after the first access to the URL in your browser.</p>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Destination</dt>
|
||||||
|
<dd>The destination of the alias is an existing item in the library of blog.
|
||||||
|
This field is required.</dd>
|
||||||
|
|
||||||
|
<dt>URL (alias)</dt>
|
||||||
|
<dd>The alias is the URL that you create, not the blog URL. URL aliases
|
||||||
|
called "about" will be recognized when someone called http://yourblog/about.</dd>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
</body>
|
||||||
|
</html>
|
17
locales/en/resources.php
Normal file
17
locales/en/resources.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
|
if (!isset($__resources['help']['filesAlias']))
|
||||||
|
{
|
||||||
|
$__resources['help']['filesAlias'] = dirname(__FILE__).'/help/filesAlias.html';
|
||||||
|
}
|
27
locales/fr/help/filesAlias.html
Normal file
27
locales/fr/help/filesAlias.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Aide filesAlias</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Les alias vous permettent de définir n'importe quelle URL renvoyant le
|
||||||
|
contenu de n'importe quelle ressource disponible dans le dossier <code>/public</code> de votre blog.</p>
|
||||||
|
<p>La cible de l'alias doit être un élément de la médiathèque du blog.
|
||||||
|
L'URL de l'alias délivrera la cible sans révéler l'URL réelle du média.</p>
|
||||||
|
<p>Sinon, c'est une redirection classique vers la destination de l'alias.</p>
|
||||||
|
<p>Et si en plus vous avez choisi de créer un alias jetable, celui-ci
|
||||||
|
s'auto-supprimera après le premier accès à l'URL dans votre navigateur.</p>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Destination</dt>
|
||||||
|
<dd>La destination de l'alias est un élément existant dans la médiathèque du
|
||||||
|
blog. Ce champ est obligatoire.</dd>
|
||||||
|
|
||||||
|
<dt>URL (alias)</dt>
|
||||||
|
<dd>L'alias est l'URL que vous créez, sans l'URL du blog. Une URL
|
||||||
|
d'alias appelée "a-propos" sera reconnue quand quelqu'un appellera la page
|
||||||
|
http://votreblog/a-propos.</dd>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
</body>
|
||||||
|
</html>
|
101
locales/fr/main.po
Normal file
101
locales/fr/main.po
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
# Language: Français
|
||||||
|
# Module: filesAlias - 0.6beta
|
||||||
|
# Date: 2015-06-16 17:26:03
|
||||||
|
# Translated with translater 2015.03.02
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Project-Id-Version: filesAlias 0.6beta\n"
|
||||||
|
"POT-Creation-Date: \n"
|
||||||
|
"PO-Revision-Date: 2015-06-16T17:26:03+00:00\n"
|
||||||
|
"Last-Translator: brol\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#: _admin.php:15
|
||||||
|
#: _admin.php:24
|
||||||
|
#: index.php:15
|
||||||
|
#: index.php:91
|
||||||
|
msgid "Medias sharing"
|
||||||
|
msgstr "Partage de médias"
|
||||||
|
|
||||||
|
#: inc/class.files.alias.php:78
|
||||||
|
msgid "File URL is empty."
|
||||||
|
msgstr "L'URL du fichier est vide."
|
||||||
|
|
||||||
|
#: inc/class.files.alias.php:82
|
||||||
|
msgid "File destination is empty."
|
||||||
|
msgstr "La destination du fichier est vide."
|
||||||
|
|
||||||
|
#: index.php:57
|
||||||
|
#: index.php:75
|
||||||
|
msgid "Target is not in medias manager."
|
||||||
|
msgstr "La cible n'est pas dans le gestionnaire de médias."
|
||||||
|
|
||||||
|
#: index.php:98
|
||||||
|
msgid "Aliases successfully updated."
|
||||||
|
msgstr "Les alias ont été mis à jour avec succès."
|
||||||
|
|
||||||
|
#: index.php:102
|
||||||
|
msgid "Alias for this media created."
|
||||||
|
msgstr "L'alias pour votre fichier a été créé."
|
||||||
|
|
||||||
|
#: index.php:111
|
||||||
|
msgid "No alias"
|
||||||
|
msgstr "Aucun alias"
|
||||||
|
|
||||||
|
#: index.php:120
|
||||||
|
msgid "Aliases list"
|
||||||
|
msgstr "Liste des alias"
|
||||||
|
|
||||||
|
#: index.php:122
|
||||||
|
msgid "Destination"
|
||||||
|
msgstr "Destination"
|
||||||
|
|
||||||
|
#: index.php:123
|
||||||
|
msgid "Alias"
|
||||||
|
msgstr "Alias"
|
||||||
|
|
||||||
|
#: index.php:124
|
||||||
|
#: index.php:166
|
||||||
|
msgid "Disposable"
|
||||||
|
msgstr "Jetable"
|
||||||
|
|
||||||
|
#: index.php:132
|
||||||
|
#: index.php:137
|
||||||
|
msgid "link"
|
||||||
|
msgstr "lien"
|
||||||
|
|
||||||
|
#: index.php:144
|
||||||
|
msgid "To remove a link, empty its alias or destination."
|
||||||
|
msgstr "Pour supprimer un lien, vider son alias ou sa destination."
|
||||||
|
|
||||||
|
#: index.php:154
|
||||||
|
msgid "New alias"
|
||||||
|
msgstr "Nouvel alias"
|
||||||
|
|
||||||
|
#: index.php:157
|
||||||
|
msgid "Destination:"
|
||||||
|
msgstr "Destination :"
|
||||||
|
|
||||||
|
#: index.php:159
|
||||||
|
msgid "Destination file must be in media manager."
|
||||||
|
msgstr "Le fichier de destination doit se trouver dans la médiathèque."
|
||||||
|
|
||||||
|
#: index.php:160
|
||||||
|
msgid "Root URL \"<code>%s</code>\" will be automatically removed."
|
||||||
|
msgstr "La racine URL '<code>%s</code>' sera automatiquement supprimée."
|
||||||
|
|
||||||
|
#: index.php:162
|
||||||
|
msgid "URL (alias):"
|
||||||
|
msgstr "URL (alias) :"
|
||||||
|
|
||||||
|
#: index.php:164
|
||||||
|
msgid "Leave empty to get a randomize alias."
|
||||||
|
msgstr "Laisser vide pour obtenir un alias aléatoire."
|
||||||
|
|
||||||
|
msgid "Manage aliases of your blog's medias"
|
||||||
|
msgstr "Gérer les alias des médias de votre blog"
|
||||||
|
|
17
locales/fr/resources.php
Normal file
17
locales/fr/resources.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of filesAlias, a plugin for Dotclear 2.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009-2015 Osku & Pierre Van Glabeke
|
||||||
|
#
|
||||||
|
# Licensed under the GPL version 2.0 license.
|
||||||
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
|
if (!isset($__resources['help']['filesAlias']))
|
||||||
|
{
|
||||||
|
$__resources['help']['filesAlias'] = dirname(__FILE__).'/help/filesAlias.html';
|
||||||
|
}
|
Loading…
Reference in a new issue