473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

GD Library Problem

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( "&amp;", "&quot;", "'", " &lt; ", " &gt; ",
"&iexcl;", "&cent;", "&pound;", "&copy;" );

$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;

}

?>

Jul 17 '05 #1
0 2706

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
5
by: Venky | last post by:
We have a strange error here. We have an application that is built in VC++ 6.0 and uses a C library built using the same. Now, we have migrated to .Net and have used the same source code to be...
3
by: Tee | last post by:
Hi guys, I have a problem with my VS project, it keeps saying COM Interop registration failed. Could not find a type library for assembly 'Class1'. If I choose to continue, everything still work...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
4
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
87
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
7
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library...
0
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.