[Openupload-svn-update] SF.net SVN: openupload:[8] trunk
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-15 13:54:56
|
Revision: 8
http://openupload.svn.sourceforge.net/openupload/?rev=8&view=rev
Author: tsdogs
Date: 2008-10-15 13:53:52 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
First svn commit
Added Paths:
-----------
trunk/data/
trunk/lib/
trunk/lib/classes.inc.php
trunk/lib/general.inc.php
trunk/lib/main.inc.php
trunk/lib/modules/
trunk/lib/smarty/
trunk/locale/
trunk/locale/en.inc.php
trunk/locale/it/
trunk/locale/it.inc.php
trunk/locale/tools/
trunk/plugins/
trunk/plugins/banned.inc.php
trunk/plugins/captcha.inc.php
trunk/plugins/email.inc.php
trunk/plugins/mimetypes.inc.php
trunk/plugins/password.inc.php
trunk/plugins/securimage/
trunk/sql/
trunk/sql/mysql/
trunk/templates/
trunk/templates/default/
trunk/templates_c/
trunk/txtdb/
trunk/www/templates/default/img/admin/files.png
trunk/www/templates/default/img/admin/groups.png
trunk/www/templates/default/img/admin/plugins.png
trunk/www/templates/default/img/admin/rights.png
trunk/www/templates/default/img/admin/settings.png
trunk/www/templates/default/img/admin/users.png
trunk/www/templates/default/img/download.png
trunk/www/templates/default/img/openupload.jpg
trunk/www/templates/default/img/upload.png
trunk/www/templates/default/main.css
Added: trunk/lib/classes.inc.php
===================================================================
--- trunk/lib/classes.inc.php (rev 0)
+++ trunk/lib/classes.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,203 @@
+<?php
+
+class translatorBase {
+ function translatorBase() {}
+
+ function init() {}
+
+ function translate($txt) {
+ return $txt;
+ }
+}
+
+class authBase {
+
+ function authBase() {
+ }
+
+
+}
+
+class dbBase {
+
+ function dbBase() {
+
+ }
+
+ function init() {
+
+ }
+
+ function addFile($info = array()) {
+ }
+
+ function addFileOption($info = array(),$module,$field) {
+ }
+
+ function removeFile($id) {
+ }
+
+ function getFileInfo($id = 0) {
+ return array();
+ }
+
+ function userInfo($login) {
+ return array();
+ }
+
+ function addUser($info) {
+ }
+
+ function deleteUser($login) {
+ }
+
+}
+
+class User {
+ function User() {
+ }
+
+ function init() {
+ $this->auth = app()->auth;
+ /* setup the user if not yet done */
+ }
+
+ function logout() {
+ global $_SESSION;
+
+ $messages = $_SESSION['user']['messages'];
+ $errors = $_SESSION['user']['errors'];
+ unset($_SESSION['user']);
+ $_SESSION['user']['messages'] = $messages;
+ $_SESSION['user']['errors'] = $errors;
+ redirect('?action=login');
+ }
+
+ function loggedin() {
+ global $_SESSION;
+ if (isset($_SESSION['user']['login']) and $_SESSION['user']['login']!='') {
+ return true;
+ }
+ return false;
+ }
+
+ function userInfo($field = '') {
+ if ($field != '') {
+ return $_SESSION['user'][$field];
+ } else {
+ return $_SESSION['user'];
+ }
+ }
+
+ function userGroup() {
+ if ($this->userInfo('group_id')!='')
+ $group = $this->userInfo('group_id');
+ else
+ $group = app()->config['register']['nologingroup'];
+ return $group;
+ }
+
+ function setUserInfo($user) {
+ $_SESSION['user']=$user;
+ }
+
+ function authenticate() {
+ global $_SESSION;
+ global $_GET;
+ global $_POST;
+
+ /* logout if requested */
+ if (isset($_GET['logout'])) {
+ $this->logout();
+ }
+
+ /* if already authenticated return */
+ if ($this->loggedin())
+ return true;
+
+ // if it's logging in save user and pwd
+ if (isset($_POST['username'])) {
+ $username = $_POST['username'];
+ $password = $_POST['pwd'];
+ }
+
+
+ if ($username != '') {
+ // use the default authentication method
+ $res = $this->auth->authenticate($username,$password);
+ if ($res) {
+ $_SESSION['user']['login']=$username;
+ /* retrieve user info */
+ $info = $this->auth->userinfo($username);
+ unset($info['password']);
+ $_SESSION['user'] = $info;
+ /* make the post not be resent on refresh */
+ redirect();
+ } else {
+ // set the error message for the login
+ app()->error(tr('Login incorrect!'));
+ }
+ }
+ return false;
+ }
+}
+
+class OpenUploadModule {
+var $actions = array();
+var $access = array();
+var $page = array();
+var $tpl;
+
+ function OpenUploadMoule() {
+ }
+
+ function nextStep($step = 0, $action = '') {
+ $step = $step==0?app()->step+1:$step;
+ $action = $action==''?app()->action:$action;
+ redirect('?action='.$action.'&step='.$step);
+ }
+
+ function prevStep() {
+ $step = app()->step>1?app()->step-1:1;
+ $action = app()->action;
+ redirect('?action='.$action.'&step='.$step);
+ }
+
+ function init() {
+ }
+
+}
+
+class OpenUploadPlugin {
+ var $pluginHTML = '';
+ var $messageHTML;
+ var $name;
+ var $fields = array();
+
+ function MySharePlugin() {
+ }
+
+ function assign($name, $value) {
+ app()->tpl->assign($name,$value);
+ }
+
+ function display($tpl) {
+ $this->pluginHTML .= app()->fetch('plugins/'.$this->name.'/'.$tpl);
+ }
+
+ function init() {
+ }
+
+/* functions that can be called
+ * all functions receive an array with the parameters
+ * some of them are called with an empty array = no params
+ * auth module = loginForm, authenticate, logout,
+ * registerForm, registerConfirm, registerEnable
+ * files module = uploadRequest, uploadOptions, uploadConfirm, UploadFileInfo,
+ * downloadForm, downloadRequest, downloadConfirm, serveFile,
+ * removeRequest, removeResult
+ */
+
+}
+
+?>
\ No newline at end of file
Added: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php (rev 0)
+++ trunk/lib/general.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,196 @@
+<?php
+/* Main library containing the general code for the application */
+
+ob_start();
+session_start();
+
+define('SMARTY_DIR', $CONFIG['INSTALL_ROOT'].'/lib/smarty/');
+require(SMARTY_DIR . 'Smarty.class.php');
+require_once($CONFIG['INSTALL_ROOT'].'/lib/classes.inc.php');
+require_once($CONFIG['INSTALL_ROOT'].'/lib/main.inc.php');
+
+/* check if the selected template needs personalizations code of some sort */
+if (file_exists($CONFIG['INSTALL_ROOT'].'/templates/'.$CONFIG['site']['template'].'/init.inc.php')) {
+ include ($CONFIG['INSTALL_ROOT'].'/templates/'.$CONFIG['site']['template'].'/init.inc.php');
+}
+
+/*************************************************************************************
+ * GLOBAL FUNCTIONS *
+ *************************************************************************************/
+
+function app() {
+ global $application;
+
+ return $application;
+}
+
+function redirect($url = '') {
+ global $_SERVER;
+ ob_clean();
+//echo 'redirect '.$url; exit;
+ /* there might be problems with urls containing other urls but this is not my case
+ anyway! */
+ if (strpos('http://',$url)===FALSE and strpos('https://',$url)===FALSE) {
+ header('location: '.$_SERVER['PHP_SELF'].$url);
+ } else {
+ header('location: '.$url);
+ }
+ exit(0);
+}
+
+function randomName($min = 10, $max = 20) {
+ $result = '';
+ for ($i = 1; $i<rand($min,$max); $i++) {
+ $result.= rand(0,9);
+ }
+ return $result;
+}
+
+
+function translate($txt,$domain,$args) {
+ /* now we retrieve the translated message */
+ $txt = app()->tr->translate($txt,$domain);
+ /* if there are arguments replace them */
+ if (count($args)>0) {
+ $trargs = array();
+ $i = 1;
+ foreach ($args as $a) {
+ $trargs['%'.$i]=$a;
+ $i++;
+ }
+ $txt = strtr($txt,$trargs);
+ }
+ /* return the trasnalted text */
+ return $txt;
+}
+/**
+ * @name tr
+ * @param $txt
+ * @param ...
+ * @description translates a string either from template or from code.
+ *
+ */
+function tr($txt) {
+ /* now we retrieve the translated message */
+ $args = array();
+ if (func_num_args()>1) {
+ $args = func_get_args();
+ array_shift($args);
+ }
+ $txt = translate($txt,'openupload',$args);
+ return $txt;
+}
+
+/**
+Validate an email address.
+Provide email address (raw input)
+Returns true if the email address has the email
+address format and the domain exists.
+Note: taken from here: http://www.linuxjournal.com/article/9585
+*/
+function validEmail($email)
+{
+ $isValid = true;
+ $atIndex = strrpos($email, "@");
+ if (is_bool($atIndex) && !$atIndex)
+ {
+ $isValid = false;
+ }
+ else
+ {
+ $domain = substr($email, $atIndex+1);
+ $local = substr($email, 0, $atIndex);
+ $localLen = strlen($local);
+ $domainLen = strlen($domain);
+ if ($localLen < 1 || $localLen > 64)
+ {
+ // local part length exceeded
+ $isValid = false;
+ }
+ else if ($domainLen < 1 || $domainLen > 255)
+ {
+ // domain part length exceeded
+ $isValid = false;
+ }
+ else if ($local[0] == '.' || $local[$localLen-1] == '.')
+ {
+ // local part starts or ends with '.'
+ $isValid = false;
+ }
+ else if (preg_match('/\\.\\./', $local))
+ {
+ // local part has two consecutive dots
+ $isValid = false;
+ }
+ else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
+ {
+ // character not valid in domain part
+ $isValid = false;
+ }
+ else if (preg_match('/\\.\\./', $domain))
+ {
+ // domain part has two consecutive dots
+ $isValid = false;
+ }
+ else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
+ str_replace("\\\\","",$local)))
+ {
+ // character not valid in local part unless
+ // local part is quoted
+ if (!preg_match('/^"(\\\\"|[^"])+"$/',
+ str_replace("\\\\","",$local)))
+ {
+ $isValid = false;
+ }
+ }
+ if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
+ {
+ // domain not found in DNS
+ $isValid = false;
+ }
+ }
+ return $isValid;
+}
+
+/* this function generates a mail from a template */
+function sendmail($from,$reply,$to,$subject,$template, $attach = array()) {
+ $tpl = &app()->tpl;
+ $tpl->assign('subject',$subject);
+ $tpl->assign('from',$from);
+ $tpl->assign('to',$to);
+ /* generate a boundary */
+ $bound1 = "==Multipart_Bounday_x".md5(time())."x";
+ /* generate a second boundary for the alternativa */
+ $header = "From: ".$from."\nReply-To: ".$reply."\n";
+ $header .= "Mime-Version: 1.0\n";
+ if (count($attach)>0) {
+ $bound2 = "==Multipart_Bounday_z".md5(time())."z";
+ $header .= "Content-Type: multipart/mixed;\n boundary=\"".$bound1."\"";
+ } else {
+ $bound2 = $bound1;
+ $header .= "Content-Type: multipart/alternative;\n boundary=\"".$bound1."\"";
+ }
+ $tpl->assign('boudary',$bound2);
+ $msg = app()->fetch($template);
+
+ /* now add the attachements */
+ if (count($attach)>0) {
+ foreach ($attach as $a) {
+ $msg .="--".$bound1."\n";
+ $msg .="Content-Type: ".$a['mime'].";\n name=\"".$a['name']."\"\n";
+ $msg .="Content-Disposition: attachment; filename=\"".$a['name']."\"\n";
+ $msg .="Content-Transfer-Encoding: base64\n\n";
+ $msg .=chunk_split(base64_encode(file_get_contents($a['file'])));
+ }
+ $msg .="\n--".$bound1."--\n";
+ $msg .="\n--".$bound2."--\n";
+ } else {
+ $msg .="\n--".$bound1."--\n";
+ }
+ return mail($to,$subject,$msg,$header,'-f "'.$from.'"');
+}
+
+
+
+
+?>
Added: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php (rev 0)
+++ trunk/lib/main.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,274 @@
+<?php
+
+class Application {
+ var $db; /* database */
+ var $auth; /* authentication */
+ var $tr; /* trasnlation */
+ var $config; /* condifuration */
+ var $user; /* user */
+ var $modules; /* modules */
+ var $actions; /* actions related to modules */
+ var $plugins; /* plugins for modules */
+ var $page; /* page global config */
+ var $acl; /* module acl */
+ var $pluginAcl; /* plugin acl */
+
+ function Application($CONFIG) {
+ global $application;
+
+ $application = $this;
+ $this->config = $CONFIG;
+
+ /* initialize template engine */
+ $this->tpl = new Smarty();
+ $this->tpl->template_dir = $this->config['INSTALL_ROOT'].'/templates';
+ $this->tpl->compile_dir = $this->config['INSTALL_ROOT'].'/templates_c/';
+ $this->tpl->config_dir = SMARTY_DIR.'/config';
+ $this->tpl->cache_dir = $this->config['INSTALL_ROOT'].'/cache';
+ $this->tpl->caching = $this->config['site']['caching'];
+
+ $this->page['template']= $this->config['WWW_ROOT'].'/templates/'.$this->config['site']['template'];
+ /* initialize the application components */
+ if (!isset($_SESSIO['user']['lang'])) {
+ $_SESSION['user']['lang']='it';
+ }
+
+ /* include the class first */
+ $dbtype = $this->config['database']['type'];
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/db/'.$dbtype.'.inc.php');
+ $dbmname = $dbtype.'DB';
+ $this->db = new $dbmname();
+ $this->db->init($this->config['database']['prefix']);
+
+ /* authentication module */
+ if (isset($this->config['auth'])) {
+ $authmname = $this->config['auth'];
+ } else {
+ $authmname = 'default';
+ }
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/auth/'.$authmname.'.inc.php');
+ $auth = $authmname.'Auth';
+ $this->auth = new $auth();
+ $this->auth->init();
+
+ $this->user = new User();
+ $this->user->init();
+
+ /* translation module */
+ if (isset($this->config['translator'])) {
+ $trname = $this->config['translator'];
+ } else {
+ $trname = 'gettext';
+ }
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/tr/'.$trname.'.inc.php');
+ $tr = $trname.'Translator';
+ $this->tr = new $tr();
+ $this->tr->init();
+
+ $this->config['modules'][]='files';
+ $this->config['modules'][]='auth';
+ $this->config['modules'][]='admin';
+
+ $this->loadACL();
+ $this->initModules();
+ }
+
+ function fetch($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ return $this->tpl->fetch($this->config['site']['template'].'/'.$tname.'.tpl');
+ } else {
+ return $this->tpl->fetch('default/'.$tname.'.tpl');
+ }
+ }
+
+ function display($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ $this->tpl->display($this->config['site']['template'].'/'.$tname.'.tpl');
+ } else {
+ $this->tpl->display('default/'.$tname.'.tpl');
+ }
+ }
+
+ function message($msg) {
+ global $_SESSION;
+ $_SESSION['user']['messages'][] = $msg;
+ }
+
+ function error($msg) {
+ global $_SESSION;
+ $_SESSION['user']['errors'][] = $msg;
+ }
+
+ function initModules() {
+ /* initialize configured modules */
+ foreach ($this->config['modules'] as $module) {
+ /* create and initialize the module */
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/default/'.$module.'.inc.php');
+ $m = $module.'Module';
+ $m = new $m();
+ $m->name = $module;
+ $m->tpl = &$this->tpl;
+ foreach ($m->actions as $k => $l) {
+ $this->actions[$k] = $m->name;
+ $this->modules[$module] = $m;
+ }
+ }
+ foreach ($this->modules as $m) {
+ $m->init();
+ }
+ }
+
+ function initMenu($auth = false) {
+
+ $this->menu = array();
+ foreach ($this->modules as $m) {
+ foreach ($m->actions as $k => $a) {
+ if (isset($m->menu[$k])) {
+ $group = app()->user->userGroup();
+ if ($this->checkACL($group,$m->name,$k) == 'allow') {
+ $this->menu[$k]=$m->menu[$k];
+ }
+ }
+ }
+ }
+ $this->tpl->assign('menu',$this->menu);
+ }
+
+ function initPlugins() {
+ /* initialize plugin system */
+
+ $this->plugins = array();
+ /* load the plugins */
+ foreach ($this->config['plugins'] as $plugin) {
+ /* include the file */
+ if (file_exists($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php')) {
+ require_once($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php');
+ $pname = $plugin."Plugin";
+ $newp = new $pname();
+ $newp->name = $plugin;
+ $this->plugins[] = $newp;
+ } else {
+ $this->error(tr('plugin include file not found: %1',$plugin));
+ }
+ }
+ foreach ($this->plugins as $plugin) {
+ $plugin->init();
+ }
+ }
+
+ function pluginAction($action,&$finfo,$stop = true) {
+ $this->pluginHTML = '';
+ $result = true;
+
+ if (!is_array($this->plugins))
+ return true;
+ foreach ($this->plugins as $plugin) {
+ if (method_exists($plugin,$action)) {
+ /* check plugin acl */
+ $acl = 'disable'; /* disabled by default */
+ if (isset($this->pluginAcl[$plugin->name])) {
+ $acl = $this->pluginAcl[$plugin->name];
+ }
+ if (!$plugin->$action($finfo,$acl)) {
+ if ($stop) return false;
+ $result = false;
+ }
+ $this->pluginHTML .= $plugin->pluginHTML;
+ }
+ }
+ return $result;
+ }
+
+ function loadACL() {
+ /* loads the acl from the db */
+ $group = $this->user->userGroup();
+ $this->acl = $this->db->loadACL($group);
+ $this->pluginAcl = $this->db->loadPluginAcl($group);
+ }
+
+ function checkACL($group,$module,$action) {
+ $result = 'deny'; /* not defined are denyed by default */
+ if (isset($this->acl[$group][$module][$action])) {
+ $result = $this->acl[$group][$module][$action];
+ } else if (isset($this->acl[$group][$module]['*'])) {
+ $result = $this->acl[$group][$module]['*'];
+ } else if (isset($this->acl[$group]['*']['*'])) {
+ $result = $this->acl[$group]['*']['*'];
+ } else if (isset($this->acl['*'][$module][$action])) {
+ $result = $this->acl['*'][$module][$action];
+ } else if (isset($this->acl['*'][$module]['*'])) {
+ $result = $this->acl['*'][$module]['*'];
+ } else if (isset($this->acl['*']['*']['*'])) {
+ $result = $this->acl['*']['*']['*']; /* this should be avoided imho */
+ }
+
+ if ($this->config['debug_acl'] and $result == 'deny') {
+ echo 'group: '.$group.'<br>'; print_r($this->acl); exit;
+ }
+
+ return $result;
+ }
+
+ function run($action = '',$step = 0) {
+ global $_SERVER;
+ global $_SESSION;
+
+ $this->mainPage = 'index';
+
+ /* setup the template variable */
+ if (!isset($this->config['defaultaction'])) $this->config['defaultaction']='u';
+
+ $this->action= $action=='' ? $this->config['defaultaction']:$action;
+ $this->step= $step==0 ?1:$step;
+
+ $this->tpl->assign('action',$this->action);
+ $this->tpl->assign('step',$this->step);
+ $this->tpl->assign('nextstep',$this->step+1);
+ $this->tpl->assign('site',$this->config['site']);
+ $this->tpl->assign('script',$_SERVER['PHP_SELF']);
+ $this->tpl->assign('page',$this->page);
+
+
+ /* depending on the acl some actions need authentication others don't */
+ if (!isset($this->actions[$this->action])) {
+ /* no module can handle this action */
+ redirect();
+ }
+ /* get the handling module */
+ $mname = $this->actions[$this->action];
+ $m = &$this->modules[$mname];
+ $group = $this->user->userGroup();
+
+ if ($this->checkACL($group,$mname,$this->action)!='allow') {
+ redirect();
+ }
+ $this->initPlugins();
+
+ $this->initMenu($this->user->loggedin());
+
+ /* now run the module */
+ if (isset($m->actions[$this->action][$this->step])) {
+ $fun = $m->actions[$this->action][$this->step];
+ } else {
+ $fun = $m->actions[$this->action][1];
+ }
+ if (isset($m->page[$this->action])) {
+ foreach ($m->page[$this->action] as $k => $v) {
+ $this->page[$k] = $v;
+ }
+ }
+ $this->tpl->assign('user',$_SESSION['user']);
+ $m->$fun();
+
+ /* now display the final page */
+ $this->tpl->assign('user',$_SESSION['user']);
+ unset($_SESSION['user']['messages']);
+ unset($_SESSION['user']['errors']);
+ $this->tpl->assign('plugins',$this->pluginHTML);
+ $this->page['content']=$this->fetch('modules/'.$m->name.'/'.$fun);
+ $this->tpl->assign('page',$this->page);
+ $this->display($this->mainPage);
+ }
+}
+
+?>
Added: trunk/locale/en.inc.php
===================================================================
--- trunk/locale/en.inc.php (rev 0)
+++ trunk/locale/en.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,3 @@
+<?php
+// english is default, don't translate
+?>
\ No newline at end of file
Added: trunk/locale/it.inc.php
===================================================================
--- trunk/locale/it.inc.php (rev 0)
+++ trunk/locale/it.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,20 @@
+<?php
+$tr['Login']='Accedi';
+$tr['File upload']='Carica file';
+$tr['File download']='Scarica file';
+$tr['File Removal']='Rimuovi file';
+$tr['File Upload']='Carica file';
+$tr['User registration']='Registrazione utente';
+$tr['Carica file']='Carica file';
+$tr['Accedi']='Accedi';
+$tr['Login name must be at least 5 characters long!']='Il Nome utente deve essere lungo almeno 5 caratteri!';
+$tr['Please insert Full Name']='Inserire il nome completo';
+$tr['Please insert a valid e-mail!']='Inserire un indirizzo e-mail valido!';
+$tr['Password must be at least 5 characters long!']='La password deve essere lunga almeno 5 caratteri!';
+$tr['Wrong captcha code! please try again.']='Codice captcha errato! Prego riprovare.';
+$tr['Login incorrect!']='Login non valido!';
+$tr['Logout']='Esci';
+$tr['Your e-mail address isn\'t valid!']='L\'indirizzo e-mail non è valido!';
+$tr['Information about your uploaded file: %1']='Informazioni relative al file caricato: %1';
+$tr['Wrong password!']='Password errata!';
+?>
Added: trunk/plugins/banned.inc.php
===================================================================
--- trunk/plugins/banned.inc.php (rev 0)
+++ trunk/plugins/banned.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,91 @@
+<?php
+
+
+class BannedPlugin extends OpenUploadPlugin {
+
+ function BannedPlugin() {
+ }
+
+ function init() {
+ global $_SERVER;
+
+ $this->banned = app()->db->loadTable('banned','priority');
+ /* now check if the ip has been banned display the banned template */
+ foreach ($this->banned as $row) {
+ if ($this->matchIP($_SERVER['REMOTE_ADDR'],$row['ip'])) {
+ if ($row['access']!='allow') {
+ $this->banned();
+ } else {
+ return;
+ }
+ }
+ }
+ /* no match has been found */
+ $this->banned();
+ }
+
+ function banned() {
+
+ $this->display('banned');
+ app()->page['content'] = $this->pluginHTML;
+ app()->page['title']= tr('IP Banned');
+ app()->tpl->assign('page',app()->page);
+ app()->display(app()->mainPage);
+ exit;
+ }
+
+ function convertSubnet($val) {
+ $sub = array();
+ if ($val<0) $val = 0;
+ if ($val>32) $val = 32;
+ for ($i=0; $i<4; $i++) {
+ $x = 0; /* could be done with a for... */
+ if ($val>0) $x += 128;
+ if ($val>1) $x += 64;
+ if ($val>2) $x += 32;
+ if ($val>3) $x += 16;
+ if ($val>4) $x += 8;
+ if ($val>5) $x += 4;
+ if ($val>6) $x += 2;
+ if ($val>7) $x += 1;
+ $sub[$i] = $x;
+ $val = $val - 8;
+ }
+ return $sub;
+ }
+
+ function matchIP($sip,$exp) {
+ if (strpos($exp,'/')!==FALSE) {
+ $x = explode('/',$exp);
+ $net = $x[0];
+ $sub = $x[1];
+ if (strpos($sub,'.')===FALSE) {
+ /* it's a single number convert to subnet mask*/
+ $sub = $this->convertSubnet($sub);
+ } else {
+ $sub = explode('.',$sub);
+ }
+ } else { /* single ip */
+ $net = $exp;
+ $sub = array(255,255,255,255);
+ }
+ $ip = explode('.',$sip);
+ $net = explode('.',$net);
+
+ /* now do the match */
+ $mip[0] = $ip[0] & $sub[0];
+ $mip[1] = $ip[1] & $sub[1];
+ $mip[2] = $ip[2] & $sub[2];
+ $mip[3] = $ip[3] & $sub[3];
+ $dip[0] = $net[0] & $sub[0];
+ $dip[1] = $net[1] & $sub[1];
+ $dip[2] = $net[2] & $sub[2];
+ $dip[3] = $net[3] & $sub[3];
+ if (($mip[0] == $dip[0]) and ($mip[1] == $dip[1]) and
+ ($mip[2] == $dip[2]) and ($mip[3] == $dip[3]))
+ return true;
+ else
+ return false;
+ }
+}
+?>
\ No newline at end of file
Added: trunk/plugins/captcha.inc.php
===================================================================
--- trunk/plugins/captcha.inc.php (rev 0)
+++ trunk/plugins/captcha.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,63 @@
+<?php
+
+class CaptchaPlugin extends OpenUploadPlugin {
+
+ function CaptchaPlugin() {
+ $this->fields = array('captcha');
+ $this->description = tr('Add captcha protection to file download and user registration');
+ }
+
+ function uploadOptions(&$finfo,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('uploadOptions');
+ return true;
+ }
+
+ function uploadConfirm(&$finfo,$acl) {
+ global $_POST;
+
+ if ($acl!='enable') return true;
+ $finfo['captcha'] = $_POST['captcha'];
+ return true;
+ }
+
+ function downloadRequest($finfo,$acl) {
+ if ($finfo['captcha']==1) {
+ $this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
+ $this->display('downloadRequest');
+ return false;
+ }
+ return true;
+ }
+
+ function downloadConfirm($finfo,$acl) {
+ global $_POST;
+
+ if ($finfo['captcha']==1) {
+ require_once(app()->config['INSTALL_ROOT'].'/plugins/securimage/securimage.php');
+ $securimage = new Securimage();
+ $result = $securimage->check($_POST['captcha_code']);
+ if (!$result) app()->error(tr('Wrong captcha code! please try again.'));
+ return $result;
+ } else
+ return true;
+ }
+
+ function registerForm($uinfo,$acl) {
+ $this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
+ $this->display('registerForm');
+ return true;
+ }
+
+ function registerConfirm(&$uinfo,$acl) {
+ global $_POST;
+
+ require_once(app()->config['INSTALL_ROOT'].'/plugins/securimage/securimage.php');
+ $securimage = new Securimage();
+ $result = $securimage->check($_POST['captcha_code']);
+ if (!$result) app()->error(tr('Wrong captcha code! please try again.'));
+ return $result;
+ }
+}
+
+?>
\ No newline at end of file
Added: trunk/plugins/email.inc.php
===================================================================
--- trunk/plugins/email.inc.php (rev 0)
+++ trunk/plugins/email.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,71 @@
+<?php
+
+class emailPlugin extends OpenUploadPlugin {
+
+ function emailPlugin() {
+ $this->description = 'Add option to send e-mail to the uploader or to another e-mail address';
+ }
+
+ function uploadOptions(&$finfo,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('uploadOptions');
+ return true;
+ }
+
+ function uploadConfirm(&$finfo,$acl) {
+ global $_POST;
+ if ($acl!='enable') return true;
+ /* do e-mail checking and so */
+/* $this->display('upload'); */
+ $finfo['emailme']=$_POST['emailme'];
+ $finfo['emailfrom']=app()->config['site']['email'];
+ $finfo['emailto']=$_POST['emailto'];
+ $finfo['email_removelink']=$_POST['removelink'];
+ $finfo['subject']=$_POST['subject'];
+ $finfo['message']=$_POST['message'];
+ if ($finfo['emailme']=="yes") {
+ if ($_SESSION['user']['email']=='') {
+ /* check valid e-mail */
+ if (!validEmail($_POST['email'])) {
+ app()->error(tr('Your e-mail address isn\'t valid!'));
+ return false;
+ }
+ $finfo['emailfrom']=$_POST['email'];
+ } else {
+ $finfo['emailfrom']=$_SESSION['user']['name'].' <'.$_SESSION['user']['email'].'>';
+ }
+ }
+ if ($finfo['emailto']!='') {
+ if (!validEmail($_POST['emailto'])) {
+ app()->error(tr('Destination e-mail address isn\'t valid!'));
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ function uploadFileInfo(&$finfo,$acl) {
+ global $_SESSION;
+
+ if ($acl!='enable') return true;
+ /* send the e-mails */
+ app()->tpl->assign('finfo',$finfo);
+ if ($finfo['emailme']=="yes") {
+ app()->tpl->assign('remove','yes');
+ $subject = app()->config['site']['title'].': '.tr("Information about your uploaded file: %1",$finfo['name']);
+ sendMail(app()->config['site']['email'],'noreply',$finfo['emailfrom'],$subject,'plugins/email/notify');
+ }
+ if ($finfo['emailto']!='') {
+ $subject = $finfo['subject']!=''?$finfo['subject']:tr("An upload was delivered to you");
+ $subject = app()->config['site']['title'].': '.$subject;
+ app()->tpl->assign('remove',$finfo['email_removelink']);
+ sendMail($finfo['emailfrom'],$finfo['emailfrom'],$finfo['emailto'],$subject,'plugins/email/notify');
+ }
+ /* don't send it twice */
+ $finfo['emailme']=='';
+ $finfo['emailto']=='';
+//exit();
+ return true;
+ }
+}
\ No newline at end of file
Added: trunk/plugins/mimetypes.inc.php
===================================================================
--- trunk/plugins/mimetypes.inc.php (rev 0)
+++ trunk/plugins/mimetypes.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,31 @@
+<?php
+
+class MimeTypesPlugin extends OpenUploadPlugin {
+
+ function MimeTypes() {
+ $this->description = tr('Limit the mimetypes a user can upload');
+ }
+
+ function uploadForm(&$finfo,$acl) {
+ if ($acl!='enable') return true;
+ if (count(app()->config['mimetypes'])==0) {
+ app()->error(tr('WARNING: no mime types defined. Plugin has been disabled!'));
+ } else {
+ $this->assign('mimetypes',app()->config['mimetypes']);
+ $this->display('uploadForm');
+ }
+ return true;
+ }
+
+ function uploadOptions(&$finfo,$acl) {
+ if ($acl!='enable') return true;
+ if (count(app()->config['mimetypes'])==0) {
+ app()->error(tr('WARNING: no mime types defined. Plugin has been disabled!'));
+ } else if (array_search($finfo['mime'],app()->config['mimetypes'])===FALSE) {
+ app()->error(tr('This file type (%1) is not allowed on this site!',$finfo['mime']));
+ return false;
+ }
+ return true;
+ }
+}
+?>
\ No newline at end of file
Added: trunk/plugins/password.inc.php
===================================================================
--- trunk/plugins/password.inc.php (rev 0)
+++ trunk/plugins/password.inc.php 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,50 @@
+<?php
+
+class PasswordPlugin extends OpenUploadPlugin {
+
+ function PasswordPlugin() {
+ $this->fields = array('password');
+ $this->description = tr('Option to add password protection for file download');
+ }
+
+ function uploadOptions(&$finfo,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('uploadOptions');
+ return true;
+ }
+
+ function uploadConfirm(&$finfo,$acl) {
+ global $_POST;
+
+ if (isset($_POST['protect']) and $acl=='enable') {
+ $finfo['plainpassword'] = $_POST['protect'];
+ $finfo['password'] = crypt($_POST['protect']);
+ } else {
+ $finfo['password'] = crypt("");
+ $finfo['plainpassword'] = "";
+ }
+ return true;
+ }
+
+ function downloadRequest($finfo,$acl) {
+ if ($finfo['password']!=crypt("",$finfo['password'])) {
+ $this->display('downloadRequest');
+ return false;
+ }
+ return true;
+ }
+
+ function downloadConfirm($finfo,$acl) {
+ global $_POST;
+
+ if ($finfo['password']!=crypt("",$finfo['password'])) {
+ $result = $finfo['password']==crypt($_POST['protect'],$finfo['password']);
+ if (!$result) app()->error(tr('Wrong password!'));
+ return $result;
+ } else {
+ return true;
+ }
+ }
+}
+
+?>
\ No newline at end of file
Added: trunk/www/templates/default/img/admin/files.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/files.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/admin/groups.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/groups.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/admin/plugins.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/plugins.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/admin/rights.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/rights.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/admin/settings.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/settings.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/admin/users.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/admin/users.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/download.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/download.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/openupload.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/openupload.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/img/upload.png
===================================================================
(Binary files differ)
Property changes on: trunk/www/templates/default/img/upload.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/www/templates/default/main.css
===================================================================
--- trunk/www/templates/default/main.css (rev 0)
+++ trunk/www/templates/default/main.css 2008-10-15 13:53:52 UTC (rev 8)
@@ -0,0 +1,137 @@
+body {
+ font-family: Helvetica, Arial;
+ font-size: 10pt;
+ margin: auto;
+}
+#logo {
+ float:left;
+}
+#userinfo {
+ float: right;
+ height: 20px;
+ vertical-align: bottom;
+ margin-top: 60px;
+ margin-right: 20px;
+}
+#title {
+ background-color: #3161cf;
+ color: #ffffff;
+ font-size: 12pt;
+ font-weight: bold;
+ clear: right;
+ padding-left: 160px;
+ padding-top: 3px;
+ padding-bottom:3px;
+}
+#menu {
+ bottom: 0px;
+ text-align: center;
+ margin-top: 5px;
+}
+#menu ul {
+ list-style:none;
+ margin: 0;
+ padding: 0;
+}
+#menu li {
+ display: inline;
+ padding-right: 8px;
+ padding-left: 8px;
+ border-right: 1px solid #000000;
+}
+#wrapper {
+ clear: both;
+ maring: 0 auto;
+ text-align: center;
+ padding-top: 50px;
+}
+#content {
+ margin: 0 auto;
+ display: inline-block;
+ text-align: left;
+}
+#uploadbutton {
+ text-align: center;
+ margin: 0 auto;
+}
+#downloadbutton {
+ text-align: center;
+ margin: 0 auto;
+}
+
+#footer {
+ clear: both;
+ position: fixed;
+ bottom: 0px;
+ height: 20px;
+ width: 100%;
+ font-weight: bold;
+ font-size: 9pt;
+ border-top: 1px solid #000000;
+ text-align: center;
+}
+#footer a {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 9pt;
+ text-decoration: none;
+}
+#footer a:visited {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 9pt;
+ text-decoration: none;
+}
+a {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+a:visited {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+a:hover {
+ color: #4c8dff;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+input, textarea {
+ color: #132678;
+ background-color: #c7dbff;
+ border: 1px solid #2d55b4;
+ font-size: 10pt;
+}
+.file {
+ font-size: 20pt;
+ color: #132678;
+ background-color: #c7dbff;
+ border: 1px solid #2d55b4;
+ font-size: 10pt;
+}
+fieldset {
+ border: 1px solid #2d55b4;
+ width: 30em
+}
+legend {
+ color: #ffffff;
+ background-color: #4c8dff;
+ border: 1px solid #2d55b4;
+ padding: 2px 6px;
+ font-size: 10pt;
+ font-weight: bold;
+}
+.submit,button {
+ font-size: 10pt;
+ color: #fafafa;
+ background-color: #4c8dff;
+ border-left: 1px solid #e3edff;
+ border-top: 1px solid #e3edff;
+ border-right: 1px solid #2d55b4;
+ border-bottom: 1px solid #2d55b4;
+ font-weight: bold;
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|