The web site was on another server i switch to a new one but this server hav
now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put
PHP Safe mode to OFF. is ther any thing i can do so it will be able to
create the thumbnail again ?
site: www.jfl-media.com
Thanks
J-F
her is the script:
<?php
/*
Main functions and login
@author Terje Torkelsen
@version 1.0.0.0
@date 16.10.2002
*/
include_once('./phplib/var-main.php');
include_once('./phplib/cl-Database.php');
include_once('./phplib/cl-User.php');
// Checking if a user has logged in, should be an easyier way yo do this
$headfile = "index";
session_set_cookie_params( 60 * 60 * 2 );
session_start();
if( session_is_registered( "User" ) ) { // A user is logged in
if( $User->type == TELECOMUTER ) $headfile = "tele";
elseif( $User->type == ADMIN ) $headfile = "admin";
if( md5( $User->ID . $timestamp ) != $login[id] || $timestamp !=
$login[time] || $login[type] != $User->type ) {
$headfile = "index";
session_destroy();
header( "Location: index.php" );
exit;
}
}
if( !session_is_registered( "timestamp" ) ) {
session_register( "timestamp" );
$timestamp = microtime();
}
// End checking
if( !isset( $blang ) ) $blang = 'eng'; // Too be sure...
include_once("lang_$blang/language.php");
// Login thru the upper login menu
$login_error = "";
if( isset( $x ) && ($email != "E-mail" || $password != "Password") ) {
if( is_email( $email ) ) {
$Data = new Database( true );
if( $Data->is_admin( $email, $password ) ) {
session_register( "User" );
$User = new User( ADMIN );
$Data->getuser( $email, $User, ADMIN );
$Data->close();
set_login_cookie( $User->ID, ADMIN );
header( "Location: admin-login.php" );
exit;
} elseif( $Data->get_user_f( $email, "password", TELECOMUTER ) ==
$password ) {
session_register( "User" );
$User = new User( TELECOMUTER );
$Data->getuser( $email, $User, TELECOMUTER );
$Data->query("UPDATE telecomuter SET last_login = " . time() . " WHERE
(telecomuter_ID = $User->ID);");
$Data->close();
set_login_cookie( $User->ID, TELECOMUTER );
header( "Location: tele-login.php" );
exit;
} elseif( $Data->get_user_f( $email, "password", EMPLOYER ) == $password ) {
session_register( "User" );
$User = new User( EMPLOYER );
$Data->getuser( $email, $User, EMPLOYER );
$Data->close();
set_login_cookie( $User->ID, EMPLOYER );
header( "Location: client-login.php" );
exit;
} else { $Data->close(); $login_error = $LoginFailure; }
} else $login_error = $EmailNotValid;
}
// End Login
function set_login_cookie( $userID, $type ) {
global $timestamp;
setcookie( "login[type]", $type, time() + ( 60 * 60 * 24 ), '/', '', 0 );
setcookie( "login[time]", $timestamp, time() + ( 60 * 60 * 24 ), '/', '',
0 );
setcookie( "login[id]", md5( $userID . $timestamp ), time() + ( 60 * 60 *
24 ), '/', '', 0 );
}
function cut_string( $string, $len ) {
if( strlen( $string ) <= $len ) return $string;
$in_tag = false;
$first_lt = strpos( substr( $string, $len ), '<' );
$first_gt = strpos( substr( $string, $len ), '>' );
if( $first_lt != false || $first_gt != false ) {
if( $first_lt > $first_gt ) $in_tag = true;
}
for( $i = $len; $i>0; $i-- ) {
if( $string[$i] == '<' && $in_tag ) $in_tag = false;
if( $string[$i] == '>' && !$in_tag ) $in_tag = true;
if( $in_tag ) continue;
if( $string[$i] == ' ' ) return substr( $string, 0, $i ) . '...';
}
}
function more( $id, $description, $image, $len ) {
if( strlen( $description ) <= $len ) {
$result = "$image\n";
$result .= "$description\n";
} else {
$result = "<span class=\"\" id=desc_sh_$id style=\"display: inline\">\n";
$result .= "$image\n";
$result .= cut_string( $description, $len ) . "\n";
$result .= "<a href=\"#\" onclick=\"desc_sh_$id.style.display='none';
desc_ln_$id.style.display='inline'; return false; \">\n";
$result .= "<b>more</b></a></span>\n";
$result .= "<span class=\"\" id=desc_ln_$id style=\"display: none\">\n";
$result .= "$image\n";
$result .= "$description\n";
$result .= "<a href=\"#\" onclick=\"desc_sh_$id.style.display='inline';
desc_ln_$id.style.display='none'; return false; \">\n";
$result .= "<b>short</b></a></span>\n";
}
return $result;
}
function is_phone( $phonenr ) {
return !preg_match( "/[a-zA-Z]/", $phonenr );
}
function is_email( $email ) { // Regular expression found on
www.phpbuilder.com
return
preg_match("'^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$'",
$email);
}
function valid_pw( $pass ) {
$PCODE0 = true;
$PCODE1 = ( strlen( $pass ) >= MIN_PASS_LEN );
$PCODE2 = ( preg_match("/[a-z]/", $pass ) && preg_match("/[A-Z]/",
$pass ) );
$PCODE3 = ( $PCODE2 && preg_match("/[0-9]/", $pass ) );
$PCODE4 = ( $PCODE3 && preg_match("/\W/", $pass ) );
switch( PASS_CODE ) {
case 0: return ( $PCODE0 ); break;
case 1: return ( $PCODE1 ); break;
case 2: return ( $PCODE1 && ($PCODE2 || $PCODE3 || $PCODE4) ); break;
case 3: return ( $PCODE1 && ($PCODE3 || $PCODE4) ); break;
case 4: return ( $PCODE1 && $PCODE4 ); break;
default: return false; break;
}
}
function array_contains( $array, $contain ) {
if( !is_array( $array ) ) return false;
foreach( $array as $value )
if( $value == $contain ) return true;
}
function email_type( $message ) {
if( preg_match( "/<[\/\!]*?[^<>]*?>/i", $message ) )
return 'text/html';
else
return 'text/plain';
}
// Saves the given image and makes a thumbnail of it which it saves
// with a sm- in front of the filename.
function save_image( $tmpfile, $filename, $filetype, &$user, $dirname =
'projects', $userdir = true ) {
global $PATH_TRANSLATED;
$savepath = dirname( $PATH_TRANSLATED ) . "/$dirname";
if( $userdir ) $savepath .= "/$user->ID";
if( is_file( $savepath . "/$filename" ) ) return false;
if( empty( $tmpfile ) ) return false;
if( !is_dir( $savepath ) ) mkdir( $savepath, 0777 );
chmod ($savepath, 0777);
move_uploaded_file( $tmpfile, $savepath . "/$filename" );
$im = ImageCreateFrom( $savepath . "/$filename", $filetype );
if( !$im ) return false;
$im_width = ImageSX( $im );
$im_height = ImageSY( $im );
if( $im_width <= MAX_IMAGE_X && $im_height <= MAX_IMAGE_Y ) {
ImageSave( $im, $savepath . "/thumb_$filename", $filetype );
} else {
$scale_x = MAX_IMAGE_X / $im_width;
$scale_y = MAX_IMAGE_Y / $im_height;
if( $scale_x > $scale_y )
$srcim = ImageCreate( $im_width * $scale_y, $im_height * $scale_y );
elseif( $scale_x < $scale_y )
$srcim = ImageCreate( $im_width * $scale_x, $im_height * $scale_x );
else
$srcim = ImageCreate( $im_width * $scale_x, $im_height * $scale_y );
ImageCopyResized( $srcim, $im, 0, 0, 0, 0, ImageSX( $srcim ), ImageSY(
$srcim ), $im_width, $im_height );
ImageSave( $srcim, $savepath . "/thumb_$filename", $filetype );
ImageDestroy( $srcim );
}
ImageDestroy( $im );
}
function ImageCreateFrom( $filename, $filetype ) {
if( $filetype == 'image/png' || $filetype == 'image/x-png' )
return @ImageCreateFromPNG( $filename );
elseif( $filetype == 'image/jpeg' || $filetype == 'image/pjpeg' )
return @ImageCreateFromJPEG( $filename );
/*elseif( $filetype == 'image/gif' ) ONLY SUPPORTED FOR GD LIBRARY < v1.6
return @ImageCreateFromGIF( $filename );*/
else return false;
}
function ImageSave( &$image, $filename, $filetype ) {
if( $filetype == 'image/png' || $filetype == 'image/x-png' )
ImagePNG( $image, $filename );
elseif( $filetype == 'image/jpeg' || $filetype == 'image/pjpeg' )
ImageJPEG( $image, $filename );
/*elseif( $filetype == 'image/gif' ) ONLY SUPPORTED FOR GD LIBRARY < v1.6
ImageGIF( $image, $filename );*/
}
// Returns a text cleaned for php commands and html tags
function cleantext( $text ) {
$rettext = preg_replace( "'<script[^>]*?>.*?</script>'si", "", $text );
$rettext = @strip_tags( $rettext, "<b><center><a><i><u>" );
$search = array( "'&[^#]*?;'i", "'\"'i", "'\''i", "' < 'i", "' > 'i", "'" .
chr(161) . "'i", "'" . chr(162) . "'i", "'" . chr(163) . "'i", "'" .
chr(169) . "'i" );
$replace = array( "&", """, "'", " < ", " > ",
"¡", "¢", "£", "©" );
$rettext = preg_replace( $search, $replace, $rettext );
$rettext = nl2br( $rettext );
$rettext = preg_replace( "'[\n\r]'i", "", $rettext );
return $rettext;
}
// Returns a text opposite from the above... turns it back ( have to be done
for textareas )
function uncleantext( $text ) {
$search = array( "'’'i", "'&(quot|#34);'i", "'''i", "' &(lt|60);
'i", "' &(gt|#62); 'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i",
"'&(pound|#163);'i", "'&(copy|#169);'i", "'&(amp|#38);'i" );
$replace = array( "´", "\"", "\'", " < ", " > ", chr(161), chr(162),
chr(163), chr(169), "&" );
$rettext = preg_replace( $search, $replace, $text );
$rettext = preg_replace( "'<br>|<br />'i", "\n", $rettext );
return $rettext;
}
// Returns a string where input arrays are inserted into input string
function rstring( $str, $array ) {
if( !is_array( $array ) ) return $str;
foreach( $array as $key => $value ) {
$str = preg_replace( "/%$key%/", $value, $str );
}
return $str;
}
?>