Jump to content

Moving code....


ThomasBalaban

Recommended Posts

Normally I avoid asking for help but I am really confused. This is working on another site of mine. Pretty much a user enters their information and it auto generates using this code onto a image and then saves it. I am getting a different result then on the other and I am not sure why. 

 

working: http://www.drwayneandersen.com/display-cert/?cert_name=test
Non: http://stopchallengechoose.com/testing-cert-display/?cert_name=testing

 

Working:

<?php

require_once("http://www.drwayneandersen.com/wp-load.php");

require('./wp-blog-header.php');

//get_header();

$current_user = wp_get_current_user();

$email=$current_user->user_email;

//echo "CURRENT TOP".$current_user->user_email;

//ini_set('display_errors', 1); // you can set to 0 for production version

//error_reporting(E_ALL);

//echo "In the file";



function LoadJpeg()

{

//create the background image



//if (file_exists($filename)) {

// echo "The file $filename exists";

//} else {

// echo "The file $filename does not exist";

//}

$cert_id=30;

if(isset($_REQUEST['cert_name'])){ $certname = $_REQUEST['cert_name']; }

if(isset($_REQUEST['cert_id'])){ $cert_id = $_REQUEST['cert_id']; }

if ($cert_id == 90) {

    $im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate90Day.jpg');

    $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate90Day.jpg";

} else if ($cert_id == 60) {

$im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate60Day.jpg');

    $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/03/DrACertificate60Day.jpg";

} else {

        $im = imagecreatefromjpeg('http://www.drwayneandersen.com/wp-content/uploads/2013/02/cert.jpg');

        $filename ="http://www.drwayneandersen.com/wp-content/uploads/2013/02/cert.jpg";

}

/* See if it failed */

if(!$im)

{

/* Create a black image */

$im = imagecreatetruecolor(150, 30);

$bgc = imagecolorallocate($im, 255, 255, 255);

$tc = imagecolorallocate($im, 0, 0, 0);



imagefilledrectangle($im, 0, 0, 150, 30, $bgc);



/* Output an error message */

imagestring($im, 1, 5, 5, 'Error loading FILE ' . $filename, $tc);

}

$textcolor = imagecolorallocate($im, 89, 88, 93);

$font = '/home1/drwaynea/public_html/arial.ttf';

imagettftext($im, 55, 0, 370, 1050, $textcolor, $font, $certname);



// createCert($clientGoalImage[0], $im, $textColor, $fontfile, $clientGoalStatement[0], $galleryArray, $galleryCtr, $source);



return $im;

}

header('Content-Type: image/jpeg');



$img = LoadJpeg();

$filePath='certs/'.$email.'/cert'.$cert_id.'.jpg';

$ckdirname = ("certs/" . "$email" . "/");

if (!(file_exists($ckdirname))) {

mkdir("certs/" . "$email", 0777);

    }

imagejpeg($img, $filePath);

imagejpeg($img);

imagedestroy($img);

//get_footer();

?>

Not working

<?php


require_once("http://www.stopchallengechoose.com//wp-load.php");


require('./wp-blog-header.php');


//get_header();


$current_user = wp_get_current_user();


$email=$current_user->user_email;


//echo "CURRENT TOP".$current_user->user_email;


//ini_set('display_errors', 1); // you can set to 0 for production version 


//error_reporting(E_ALL);


//echo "In the file";






function LoadJpeg()


{


//create the background image






//if (file_exists($filename)) {


//    echo "The file $filename exists";


//} else {


//    echo "The file $filename does not exist";


//}


    $cert_id=30;


    if(isset($_REQUEST['cert_name'])){ $certname = $_REQUEST['cert_name']; }


    if(isset($_REQUEST['cert_id'])){ $cert_id = $_REQUEST['cert_id']; }


    if ($cert_id == 90) {


     $im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg');


     $filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg";


    } else if ($cert_id == 60) {


        $im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg');


     $filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg";


    } else {


$im = imagecreatefromjpeg('http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg');


$filename ="http://stopchallengechoose.com/wp-content/uploads/2014/03/certtesting.jpeg";


}


    /* See if it failed */


    if(!$im)


    {


        /* Create a black image */


        $im  = imagecreatetruecolor(150, 30);


        $bgc = imagecolorallocate($im, 255, 255, 255);


        $tc  = imagecolorallocate($im, 0, 0, 0);






        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);






        /* Output an error message */


        imagestring($im, 1, 5, 5, 'Error loading FILE ' . $filename, $tc);


     }


     $textcolor = imagecolorallocate($im, 89, 88, 93);


     $font = '/tank/www/users/medideascc/medideascc.pairserver.com/arial.ttf';


     imagettftext($im, 55, 0, 370, 1050, $textcolor, $font, $certname);






   // createCert($clientGoalImage[0], $im, $textColor, $fontfile, $clientGoalStatement[0], $galleryArray, $galleryCtr, $source);


        


    return $im;


}


header('Content-Type: image/jpeg');


echo "<p>".$img."</p>";


$img = LoadJpeg();


$filePath='certs/'.$email.'/cert'.$cert_id.'.jpg';


   $ckdirname = ("certs/" . "$email" . "/");


    if (!(file_exists($ckdirname))) {


        mkdir("certs/" . "$email", 0777);


}


imagejpeg($img, $filePath);


imagejpeg($img);


imagedestroy($img);


//get_footer();


?>
Link to comment
https://forums.phpfreaks.com/topic/287191-moving-code/
Share on other sites

require_once("http://www.stopchallengechoose.com//wp-load.php");

 

There is a double slash after domain name

 

require_once("http://www.stopchallengechoose.com/wp-load.php");

 

But this is all you should need to include it

 

require('./wp-load.php');
Link to comment
https://forums.phpfreaks.com/topic/287191-moving-code/#findComment-1473579
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.