[Openupload-svn-update] SF.net SVN: openupload:[354] trunk/lib/general.inc.php
Status: Beta
Brought to you by:
tsdogs
|
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.
|