Jump to content

Interesting imagecreate() error


Mahngiel

Recommended Posts

Greetings guys.

 

I made up a few dynamic sigs for some friends and myself, and they came out fantastic. The problem is, when calling two imagecreate()'d  images, only one will load at a time.  The images are based off cURL'd data, so I'm thinking that maybe my web server has port problems?

 

Here are external links:

http://www.mahngiel.com/kat/sig/sig2.php

http://www.mahngiel.com/kat/sig/chew_sig.php

 

And here are image:

sig2.php

chew_sig.php

 

As you can see, only one image will load when trying to call multiples.  I've even used modrewrite to give it a whack, but no dice. 

Link to comment
Share on other sites

I don't see why you would need the code, I don't have any code issues per se as clicking the url link shows you that each image works on it's own. So you know, each image pulls data from a different file. 

 

I just can't seem to figure out why multiple images will not populate on a single page.

Link to comment
Share on other sites

I don't see why you would need the code, I don't have any code issues per se as clicking the url link shows you that each image works on it's own. So you know, each image pulls data from a different file. 

 

I just can't seem to figure out why multiple images will not populate on a single page.

 

Well, it could be something in the code that is the problem.  You don't have to post it, but you won't get any help.  I would bet overwriting is the problem.

Link to comment
Share on other sites

It wasn't my intent to appear hostile to post the code.  But since the code works, I figured that it wouldn't be necessary to post the code - as I felt there would be an issue elsewhere.  I pulled the imagecreate() functions and just tested the stdout as text, and it works just fine.  So i know it's not a problem to print the cURL'd data.

 

Alas, here's how I did it so you could offer more indepth analysis.  Cheers!

 

 

profile grabbing script on a cron:

<?php
$arr = array('.:Mahn:.', 'Chew', 'L4zyBear', 'BoWL', 'sundox');
foreach ($arr as $user){
$c = curl_init("http://www.kat.ph/user/".$user."/index.html");
$f = fopen($user."_profile.html", "w");
curl_setopt($c, CURLOPT_FILE, $f);
curl_setopt($c, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($c, CURLOPT_FORBID_REUSE, TRUE);
curl_exec($c);
curl_close($c);
fclose($f);
$c = curl_init("http://www.kat.ph/blog/".$user."/index.html");
$f = fopen($user."_blog.html", "w");
curl_setopt($c, CURLOPT_FILE, $f);
curl_setopt($c, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($c, CURLOPT_FORBID_REUSE, TRUE);
curl_exec($c);
curl_close($c);
fclose($f);
}
?>

 

sig2.php

<?php
$user = '.:Mahn:.';
$Joined = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'ago' | sed -n 1p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | sed 's/ / /g'");
$ACL = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' |  grep 'class=\"title\"' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Rep = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'class=\"green\"' | awk -F '\">' '{print $2}' | awk -F '<' '{print $1}'");
$Last_visit = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'ago' | sed -n 3p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | sed 's/ / /g'");
$Last_upload = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'torType' | awk -F '\">' '{print $3}' | awk -F '<' '{print $1}'");
$Last_blog = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_blog.html' | grep '\"plain\"' | sed -n 1p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Blog_date = shell_exec("(curl -s 'http://www.mahngiel.com/kat/sig/".$user."_blog.html' | grep 'h6' | sed -n 1p | awk -F 'posted ' '{print $2}' | awk -F ',' '{print $1}'");
$Friends= shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep '>Friends' | sed -n 1p | awk -F '>Friends' '{print $2}' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Veri = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'User is a verified uploader' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Posts = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep '<td>' | sed -n 7p |awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Achieves= shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/".$user."_profile.html' | grep 'Achievements' | awk -F '(' '{print $2}' | awk -F 'opened' '{print $1}'");


// Call Scripts
$goldAch = shell_exec("grep -c 'goldAch' profile.html");
$silverAch = shell_exec("grep -c 'silverAch' profile.html");
$bronzeAch = shell_exec("grep -c 'bronzeAch' profile.html");
$simpleAch = shell_exec("grep -c 'simpleAch' profile.html");


//Original Image for background
$img = imagecreatefrompng('sig2.png');
imagealphablending($img, true);


//Colors
$black = imagecolorallocate($img, 0, 0, 0);
$gold = imagecolorallocate($img, 247, 225, 114);
$red = imagecolorallocate($img, 127, 0, 0);
$green = imagecolorallocate($img, 0, 127, 0);
$dirty = imagecolorallocate($img, 119, 118, 81);


//Shapes
// imageline($img, 15,31, 80,31, $gold);
// imagerectangle($img, 4,80, 97,70, $red);

//Fonts
$font_parma = '../fonts/ParmaPetit-Normal.ttf';
$font_brush = '../fonts/LEVIBRUSH.TTF';
$font_phil = '../fonts/Philosopher.otf';
$font_mahn = '../fonts/HoneyLight.ttf';


//Strings
imagefttext($img, 12, 0, 215, 54, $red, $font_brush, $ACL);

imagefttext($img, 10, 0, 460, 55, $dirty, $font_phil, 'Last Seen:');
imagefttext($img, 10, 0, 460, 54, $gold, $font_phil, 'Last Seen:');
imagefttext($img, 10, 0, 520, 55, $dirty, $font_parma, $Last_visit);
imagefttext($img, 10, 0, 520, 54, $gold, $font_parma, $Last_visit);

// imagefttext($img, 12, 0, 230, 65, $gold, $font_parma, 'Joined:');
// imagefttext($img, 12, 0, 278, 65, $gold, $font_parma, $Joined);

imagefttext($img, 11, 0, 230, 74, $dirty, $font_phil, 'Forum Posts:');
imagefttext($img, 11, 0, 230, 73, $gold, $font_phil, 'Forum Posts:');
imagefttext($img, 12, 0, 320, 74, $dirty, $font_parma, $Posts);
imagefttext($img, 12, 0, 320, 73, $gold, $font_parma, $Posts);

imagefttext($img, 11, 0, 230, 89, $dirty, $font_phil, 'Last Upload:');
imagefttext($img, 11, 0, 230, 88, $gold, $font_phil, 'Last Upload:');
imagefttext($img, 12, 0, 317, 89, $dirty, $font_parma, $Last_upload);
imagefttext($img, 12, 0, 317, 88, $gold, $font_parma, $Last_upload);

imagefttext($img, 11, 0, 230, 104, $dirty, $font_phil, 'Friends:');
imagefttext($img, 11, 0, 230, 103, $gold, $font_phil, 'Friends:');
imagefttext($img, 12, 0, 290, 104, $dirty, $font_parma, $Friends);
imagefttext($img, 12, 0, 290, 103, $gold, $font_parma, $Friends);

imagefttext($img, 11, 0, 230, 119, $dirty, $font_phil, 'Achievements:');
imagefttext($img, 11, 0, 230, 118, $gold, $font_phil, 'Achievements:');
imagefttext($img, 12, 0, 490, 119, $dirty, $font_parma, '( '.$Achieves);
imagefttext($img, 12, 0, 490, 118, $gold, $font_parma, '( '.$Achieves);
imagefttext($img, 12, 0, 515, 119, $dirty, $font_parma, ' Opened)');
imagefttext($img, 12, 0, 515, 118, $gold, $font_parma, ' Opened)');
imagefttext($img, 12, 0, 340, 119, $dirty, $font_parma, $goldAch);
imagefttext($img, 12, 0, 380, 119, $dirty, $font_parma, $silverAch);
imagefttext($img, 12, 0, 420, 119, $dirty, $font_parma, $bronzeAch);
imagefttext($img, 12, 0, 460, 119, $dirty, $font_parma, $simpleAch);
imagefttext($img, 12, 0, 340, 118, $gold, $font_parma, $goldAch);
imagefttext($img, 12, 0, 380, 118, $gold, $font_parma, $silverAch);
imagefttext($img, 12, 0, 420, 118, $gold, $font_parma, $bronzeAch);
imagefttext($img, 12, 0, 460, 118, $gold, $font_parma, $simpleAch);

imagefttext($img, 11, 0, 230, 134, $dirty, $font_phil, 'Last Blog:');
imagefttext($img, 11, 0, 230, 133, $gold, $font_phil, 'Last Blog:');
imagefttext($img, 12, 0, 300, 134, $dirty, $font_parma, $Last_blog);
imagefttext($img, 12, 0, 300, 133, $gold, $font_parma, $Last_blog);

imagefttext($img, 20, 90, 123, 137, $black, $font_brush, $user);
imagefttext($img, 20, 90, 122, 135, $gold, $font_brush, $user);

//Output
$path = '../mahn_sig.png';
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>

Output: http://www.mahngiel.com/kat/sig/sig2.php

 

chew_sig.php

<?php
$user = 'Chew';
$Joined = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'ago' | sed -n 1p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | sed 's/ / /g'");
$ACL = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' |  grep 'class=\"title\"' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Rep = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'class=\"green\"' | awk -F '\">' '{print $2}' | awk -F '<' '{print $1}'");
$Last_visit = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'ago' | sed -n 3p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | sed 's/ / /g'");
$Last_upload = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'torType' | awk -F '\">' '{print $3}' | awk -F '<' '{print $1}'");
$Last_blog = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_blog.html' | grep '\"plain\"' | sed -n 1p | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Blog_date = shell_exec("(curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_blog.html' | grep 'h6' | sed -n 1p | awk -F 'posted ' '{print $2}' | awk -F ',' '{print $1}'");
$Friends= shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep '>Friends' | sed -n 1p | awk -F '>Friends' '{print $2}' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Veri = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'User is a verified uploader' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Posts = shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep '<td>' | sed -n 7p |awk -F '>' '{print $2}' | awk -F '<' '{print $1}'");
$Achieves= shell_exec("curl -s 'http://www.mahngiel.com/kat/sig/chew/".$user."_profile.html' | grep 'Achievements' | awk -F '(' '{print $2}' | awk -F 'opened' '{print $1}'");


// Call Scripts
$goldAch = shell_exec("grep -c 'goldAch' profile.html");
$silverAch = shell_exec("grep -c 'silverAch' profile.html");
$bronzeAch = shell_exec("grep -c 'bronzeAch' profile.html");
$simpleAch = shell_exec("grep -c 'simpleAch' profile.html");


//Original Image for background
$img = imagecreatefrompng('sig2.png');
imagealphablending($img, true);


//Colors
$black = imagecolorallocate($img, 0, 0, 0);
$gold = imagecolorallocate($img, 247, 225, 114);
$red = imagecolorallocate($img, 127, 0, 0);
$green = imagecolorallocate($img, 0, 127, 0);
$dirty = imagecolorallocate($img, 119, 118, 81);


//Shapes
// imageline($img, 15,31, 80,31, $gold);
// imagerectangle($img, 4,80, 97,70, $red);

//Fonts
$font_parma = '../../fonts/ParmaPetit-Normal.ttf';
$font_brush = '../../fonts/LEVIBRUSH.TTF';
$font_phil = '../../fonts/Philosopher.otf';
$font_mahn = '../../fonts/HoneyLight.ttf';


//Strings
imagefttext($img, 12, 0, 215, 54, $green, $font_brush, $ACL);

imagefttext($img, 10, 0, 460, 55, $dirty, $font_phil, 'Last Seen:');
imagefttext($img, 10, 0, 460, 54, $gold, $font_phil, 'Last Seen:');
imagefttext($img, 10, 0, 520, 55, $dirty, $font_parma, $Last_visit);
imagefttext($img, 10, 0, 520, 54, $gold, $font_parma, $Last_visit);

// imagefttext($img, 12, 0, 230, 65, $gold, $font_parma, 'Joined:');
// imagefttext($img, 12, 0, 278, 65, $gold, $font_parma, $Joined);

imagefttext($img, 11, 0, 230, 74, $dirty, $font_phil, 'Forum Posts:');
imagefttext($img, 11, 0, 230, 73, $gold, $font_phil, 'Forum Posts:');
imagefttext($img, 12, 0, 320, 74, $dirty, $font_parma, $Posts);
imagefttext($img, 12, 0, 320, 73, $gold, $font_parma, $Posts);

imagefttext($img, 11, 0, 230, 89, $dirty, $font_phil, 'Last Upload:');
imagefttext($img, 11, 0, 230, 88, $gold, $font_phil, 'Last Upload:');
imagefttext($img, 12, 0, 317, 89, $dirty, $font_parma, $Last_upload);
imagefttext($img, 12, 0, 317, 88, $gold, $font_parma, $Last_upload);

imagefttext($img, 11, 0, 230, 104, $dirty, $font_phil, 'Friends:');
imagefttext($img, 11, 0, 230, 103, $gold, $font_phil, 'Friends:');
imagefttext($img, 12, 0, 290, 104, $dirty, $font_parma, $Friends);
imagefttext($img, 12, 0, 290, 103, $gold, $font_parma, $Friends);

imagefttext($img, 11, 0, 230, 119, $dirty, $font_phil, 'Achievements:');
imagefttext($img, 11, 0, 230, 118, $gold, $font_phil, 'Achievements:');
imagefttext($img, 12, 0, 490, 119, $dirty, $font_parma, '( '.$Achieves);
imagefttext($img, 12, 0, 490, 118, $gold, $font_parma, '( '.$Achieves);
imagefttext($img, 12, 0, 515, 119, $dirty, $font_parma, ' Opened)');
imagefttext($img, 12, 0, 515, 118, $gold, $font_parma, ' Opened)');
imagefttext($img, 12, 0, 340, 119, $dirty, $font_parma, $goldAch);
imagefttext($img, 12, 0, 380, 119, $dirty, $font_parma, $silverAch);
imagefttext($img, 12, 0, 420, 119, $dirty, $font_parma, $bronzeAch);
imagefttext($img, 12, 0, 460, 119, $dirty, $font_parma, $simpleAch);
imagefttext($img, 12, 0, 340, 118, $gold, $font_parma, $goldAch);
imagefttext($img, 12, 0, 380, 118, $gold, $font_parma, $silverAch);
imagefttext($img, 12, 0, 420, 118, $gold, $font_parma, $bronzeAch);
imagefttext($img, 12, 0, 460, 118, $gold, $font_parma, $simpleAch);

imagefttext($img, 11, 0, 230, 134, $dirty, $font_phil, 'Last Blog:');
imagefttext($img, 11, 0, 230, 133, $gold, $font_phil, 'Last Blog:');
imagefttext($img, 12, 0, 300, 134, $dirty, $font_parma, $Last_blog);
imagefttext($img, 12, 0, 300, 133, $gold, $font_parma, $Last_blog);

imagefttext($img, 20, 90, 123, 117, $black, $font_brush, $user);
imagefttext($img, 20, 90, 122, 115, $gold, $font_brush, $user);

//Output
$path = '../mahn_sig.png';
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>

 

Output: http://www.mahngiel.com/kat/sig/chew_sig.php

Link to comment
Share on other sites

Did you look at the paths you have in your code, compared with where you are saving the curl results?

Yes, the chew_sig.php i pasted was actually a test from putting the files in diff directories.  The curl paths and output I am using actually sit in the same directory as eachother.

 

(Sorry, I cannot modify my post)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.