Thread: [Openupload-svn-update] SF.net SVN: openupload:[104] trunk/lib/general.inc.php
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-11-04 17:42:05
|
Revision: 104
http://openupload.svn.sourceforge.net/openupload/?rev=104&view=rev
Author: tsdogs
Date: 2008-11-04 17:41:57 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
remove leasing slash from requested files from templates
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-11-04 17:41:13 UTC (rev 103)
+++ trunk/lib/general.inc.php 2008-11-04 17:41:57 UTC (rev 104)
@@ -87,6 +87,9 @@
if ($file == '') return '';
+ if (strpos($file,'/')===0) { /* remove leading slash */
+ $file = substr($file,1,strlen($file)-1);
+ }
if (file_exists($CONFIG['WEB_ROOT'].'/templates/'.$CONFIG['site']['template'].'/'.$file))
return $CONFIG['WWW_ROOT'].'/templates/'.$CONFIG['site']['template'].'/'.$file;
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-04 17:55:32
|
Revision: 105
http://openupload.svn.sourceforge.net/openupload/?rev=105&view=rev
Author: tsdogs
Date: 2008-11-04 17:55:26 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
remove leading slash from requested files from templates WWW_ROOT
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-11-04 17:41:57 UTC (rev 104)
+++ trunk/lib/general.inc.php 2008-11-04 17:55:26 UTC (rev 105)
@@ -15,6 +15,10 @@
include ($CONFIG['INSTALL_ROOT'].'/templates/'.$CONFIG['site']['template'].'/init.inc.php');
}
+/* remove trailing slash from WWW_ROOT */
+if (strrpos($CONFIG['WWW_ROOT'],'/')===strlen($CONFIG['WWW_ROOT'])-1)
+ $CONFIG['WWW_ROOT']=substr($CONFIG['WWW_ROOT'],0,strlen($CONFIG['WWW_ROOT'])-1);
+
/*************************************************************************************
* GLOBAL FUNCTIONS *
*************************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-04 18:00:32
|
Revision: 106
http://openupload.svn.sourceforge.net/openupload/?rev=106&view=rev
Author: tsdogs
Date: 2008-11-04 18:00:26 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
fix bug #2220935 trailing slashes
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-11-04 17:55:26 UTC (rev 105)
+++ trunk/lib/general.inc.php 2008-11-04 18:00:26 UTC (rev 106)
@@ -19,6 +19,10 @@
if (strrpos($CONFIG['WWW_ROOT'],'/')===strlen($CONFIG['WWW_ROOT'])-1)
$CONFIG['WWW_ROOT']=substr($CONFIG['WWW_ROOT'],0,strlen($CONFIG['WWW_ROOT'])-1);
+/* remove trailing slash from WWW_SERVER */
+if (strrpos($CONFIG['WWW_SERVER'],'/')===strlen($CONFIG['WWW_SERVER'])-1)
+ $CONFIG['WWW_SERVER']=substr($CONFIG['WWW_SERVER'],0,strlen($CONFIG['WWW_SERVER'])-1);
+
/*************************************************************************************
* GLOBAL FUNCTIONS *
*************************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-20 19:05:37
|
Revision: 164
http://openupload.svn.sourceforge.net/openupload/?rev=164&view=rev
Author: tsdogs
Date: 2008-11-20 19:05:32 +0000 (Thu, 20 Nov 2008)
Log Message:
-----------
Be sure translator is loaded before calling the translation
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-11-20 18:39:47 UTC (rev 163)
+++ trunk/lib/general.inc.php 2008-11-20 19:05:32 UTC (rev 164)
@@ -59,7 +59,8 @@
function translate($txt,$domain,$args) {
/* now we retrieve the translated message */
- $txt = app()->tr->translate($txt,$domain);
+ if (is_object(app()->tr))
+ $txt = app()->tr->translate($txt,$domain);
/* if there are arguments replace them */
if (count($args)>0) {
$trargs = array();
@@ -77,7 +78,7 @@
* @name tr
* @param $txt
* @param ...
- * @description translates a string either from template or from code.
+ * @description translates a string from code string.
*
*/
function tr($txt) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rl...@us...> - 2008-12-29 09:55:06
|
Revision: 213
http://openupload.svn.sourceforge.net/openupload/?rev=213&view=rev
Author: rlelek
Date: 2008-12-29 09:54:56 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
-- Windows Bug Fix --
* Bug Update (2008-12-29 by Ryan Lelek):
-- Support on Windows PHP for the function 'checkdnsrr'
used within the 'validEmail' function has been added.
-- Pending further investigation.
-- Discovery/Solution thanks to: Korne?\204?\129l
-- http://hu.php.net/manual/en/function.checkdnsrr.php#75158
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-12-25 04:15:31 UTC (rev 212)
+++ trunk/lib/general.inc.php 2008-12-29 09:54:56 UTC (rev 213)
@@ -112,9 +112,39 @@
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
+
+* Bug Update (2008-12-29 by Ryan Lelek):
+ -- Support on Windows PHP for the function 'checkdnsrr'
+ used within the 'validEmail' function has been added.
+ -- Pending further investigation.
+ -- Discovery/Solution thanks to: Korn\x8El
+ -- http://hu.php.net/manual/en/function.checkdnsrr.php#75158
*/
-function validEmail($email)
-{
+function validEmail($email){
+
+ // Begin Bug Fix
+ if(!function_exists('checkdnsrr')){
+ function checkdnsrr($hostName, $recType = ''){
+ if(!empty($hostName)){
+ if($recType == ''){
+ $recType = "MX";
+ }
+ exec("nslookup -type=$recType $hostName", $result);
+ // check each line to find the one that starts with the host
+ // name. If it exists then the function succeeded.
+ foreach ($result as $line) {
+ if(eregi("^$hostName",$line)) {
+ return true;
+ }
+ }
+ // otherwise there was no mail handler for the domain
+ return false;
+ }
+ return false;
+ }
+ }
+ // End Bug Fix
+
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-01-18 08:37:05
|
Revision: 220
http://openupload.svn.sourceforge.net/openupload/?rev=220&view=rev
Author: tsdogs
Date: 2009-01-18 08:36:55 +0000 (Sun, 18 Jan 2009)
Log Message:
-----------
fix bug 2516440 (mysqlDB::close() and warning if url is empty)
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-01-15 12:12:21 UTC (rev 219)
+++ trunk/lib/general.inc.php 2009-01-18 08:36:55 UTC (rev 220)
@@ -39,16 +39,15 @@
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! */
-//echo '<pre>'; print_r( debug_backtrace()); echo '</pre>'; exit();
- if (strpos('http://',$url)===FALSE and strpos('https://',$url)===FALSE) {
+
+ if ($url == '') {
+ header('location: '.$_SERVER['PHP_SELF']);
+ } else if (strpos('http://',$url)===FALSE and strpos('https://',$url)===FALSE) {
header('location: '.$_SERVER['PHP_SELF'].$url);
} else {
header('location: '.$url);
}
- app()->db->close();
+ app()->db->free();
exit(0);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-01-19 12:55:26
|
Revision: 221
http://openupload.svn.sourceforge.net/openupload/?rev=221&view=rev
Author: tsdogs
Date: 2009-01-19 11:55:42 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
fix wrong parameter order to strpos (should have spotted this before!!!)
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-01-18 08:36:55 UTC (rev 220)
+++ trunk/lib/general.inc.php 2009-01-19 11:55:42 UTC (rev 221)
@@ -42,7 +42,7 @@
if ($url == '') {
header('location: '.$_SERVER['PHP_SELF']);
- } else if (strpos('http://',$url)===FALSE and strpos('https://',$url)===FALSE) {
+ } else if (strpos($url,'http://')===FALSE and strpos($url,'https://')===FALSE) {
header('location: '.$_SERVER['PHP_SELF'].$url);
} else {
header('location: '.$url);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-02-05 15:40:10
|
Revision: 227
http://openupload.svn.sourceforge.net/openupload/?rev=227&view=rev
Author: tsdogs
Date: 2009-02-05 15:40:07 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
add alphanumerical random string generation option
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-02-03 18:48:50 UTC (rev 226)
+++ trunk/lib/general.inc.php 2009-02-05 15:40:07 UTC (rev 227)
@@ -51,10 +51,28 @@
exit(0);
}
-function randomName($min = 10, $max = 20) {
+/* generates a random string of length between min and max
+ * if alpha is true it will generate an alphanumeric string
+ */
+function randomName($min = 10, $max = 20, $alpha = false) {
$result = '';
- for ($i = 1; $i<rand($min,$max); $i++) {
- $result.= rand(0,9);
+ $rmax = rand($min,$max);
+ for ($i = 0; $i<$rmax; $i++) {
+ if ($alpha) {
+ $x = rand(0,58);
+ echo $x;
+ if ($x<25) {
+ $x = chr(ord('a') + $x);
+ } else if ($x < 35 ) {
+ $x = $x - 25;
+ } else {
+ $x = chr(ord('A') + ($x - 35));
+ }
+ echo '='.$x.'<br>';
+ $result .= $x;
+ } else {
+ $result.= rand(0,9);
+ }
}
return $result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-02-21 13:40:58
|
Revision: 262
http://openupload.svn.sourceforge.net/openupload/?rev=262&view=rev
Author: tsdogs
Date: 2009-02-21 13:40:52 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Remove not necessary WEB_ROOT setting for templates
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-02-21 12:35:30 UTC (rev 261)
+++ trunk/lib/general.inc.php 2009-02-21 13:40:52 UTC (rev 262)
@@ -115,12 +115,16 @@
function template_file($file) {
global $CONFIG;
-
if ($file == '') return '';
if (strpos($file,'/')===0) { /* remove leading slash */
$file = substr($file,1,strlen($file)-1);
}
- if (file_exists($CONFIG['WEB_ROOT'].'/templates/'.$CONFIG['site']['template'].'/'.$file))
+ /* guess where "public" template files are placed */
+ $base = '.';
+ if (defined('__NOT_MAIN_SCRIPT')) {
+ $base = './www';
+ }
+ if (file_exists($base.'/templates/'.$CONFIG['site']['template'].'/'.$file))
return $CONFIG['WWW_ROOT'].'/templates/'.$CONFIG['site']['template'].'/'.$file;
else
return $CONFIG['WWW_ROOT'].'/templates/default/'.$file;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-03-03 12:40:45
|
Revision: 276
http://openupload.svn.sourceforge.net/openupload/?rev=276&view=rev
Author: tsdogs
Date: 2009-03-03 12:40:42 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
fix typo
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-03-03 10:46:16 UTC (rev 275)
+++ trunk/lib/general.inc.php 2009-03-03 12:40:42 UTC (rev 276)
@@ -239,7 +239,7 @@
$tpl->assign('to',$to);
/* generate a boundary */
$bound1 = "==Multipart_Bounday_x".md5(time())."x";
- /* generate a second boundary for the alternativa */
+ /* generate a second boundary for the alternative */
$header = "From: ".$from."\nReply-To: ".$reply."\n";
$header .= "Mime-Version: 1.0\n";
if (count($attach)>0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-11-07 22:46:28
|
Revision: 354
http://openupload.svn.sourceforge.net/openupload/?rev=354&view=rev
Author: tsdogs
Date: 2009-11-07 22:46:21 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
OUSESSION name
couple of new useful functions
Modified Paths:
--------------
trunk/lib/general.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2009-11-07 22:45:26 UTC (rev 353)
+++ trunk/lib/general.inc.php 2009-11-07 22:46:21 UTC (rev 354)
@@ -2,6 +2,8 @@
/* Main library containing the general code for the application */
ob_start();
+/* so it should only affect open upload */
+session_name('OUSESSION');
session_start();
if (isset($CONFIG['SMARTY_DIR']))
@@ -9,6 +11,7 @@
else
define('SMARTY_DIR', $CONFIG['INSTALL_ROOT'].'/lib/smarty/');
require(SMARTY_DIR . 'Smarty.class.php');
+require_once($CONFIG['INSTALL_ROOT'].'/lib/base.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/classes.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/user.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/main.inc.php');
@@ -60,7 +63,6 @@
for ($i = 0; $i<$rmax; $i++) {
if ($alpha) {
$x = rand(0,58);
- echo $x;
if ($x<25) {
$x = chr(ord('a') + $x);
} else if ($x < 35 ) {
@@ -68,7 +70,6 @@
} else {
$x = chr(ord('A') + ($x - 35));
}
- echo '='.$x.'<br>';
$result .= $x;
} else {
$result.= rand(0,9);
@@ -269,7 +270,45 @@
return mail($to,$subject,$msg,$header,'-f "'.$from.'"');
}
+/* from php manual page */
+function return_bytes($val) {
+ $val = trim($val);
+ $last = strtolower($val[strlen($val)-1]);
+ switch($last) {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+ return $val;
+}
+/* tries to use all available methods to determine a file mime type */
+function get_mime_type($file,$type) {
+ global $CONFIG;
+ $mime = $type;
+ if (function_exists('finfo_open')) {
+ if ($CONFIG['mime_magic_file']!='')
+ $finfo = finfo_open(FILEINFO_MIME, $CONFIG['mime_magic_file']);
+ else
+ $finfo = finfo_open(FILEINFO_MIME);
+ $mime = finfo_file($finfo,$file);
+ if (strpos($mime,';')) { /* remove the charset */
+ $mime = substr($mime,0,strpos($mime,';'));
+ }
+ if (strpos($mime,' ')) { /* remove the charset */
+ $mime = substr($mime,0,strpos($mime,' '));
+ }
+ finfo_close($finfo);
+ } else if (function_exists('mime_content_type')) {
+ $mime = mime_content_type($file);
+ } else { /* TODO: try to do it internally ??? */
+ }
+ return $mime;
+}
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|