Become a Patron!

User Age off by a year [Now with 100% more sig banner code]

jae

Silver Contributor
Member For 4 Years
I was born in October 1971, which (correct me if i'm wrong - at this age i actually might be) should make me 43 as of Summer 2014. But my age is indicated here to be 42. I'm kind of ok with that! Kind of even wish it was even more off! But thought i should report it anyway.
 
Last edited:

egomama

Bronze Contributor
Member For 4 Years
According to my math, you will not be 43 until October of 2014. You still have 4 months till it will change. :D
 
  • Like
Reactions: jae

Hobby Kid

Brighton Boy
Gold Contributor
Member For 4 Years
Jeremy. I've only just clicked on your link and seen this. Have you ever heard the expression "silly sausage" haha
 

Hobby Kid

Brighton Boy
Gold Contributor
Member For 4 Years
I bet. I wonder if they announce your birthday on here. They do on some forums
 

jae

Silver Contributor
Member For 4 Years
Like you banner Jeremy. How does one get it?
I made mine myself, based on code i cobbled together from various sources. I haven't coded in several years but dammit i just had to have a banner, and i had to have it exactly like i wanted it. It's written in PHP. If you have a host, i could post the code, but i've got to sterilize and neutralize it first.
 

CaFF

Platinum Contributor
Member For 5 Years
I made mine myself, based on code i cobbled together from various sources. I haven't coded in several years but dammit i just had to have a banner, and i had to have it exactly like i wanted it. It's written in PHP. If you have a host, i could post the code, but i've got to sterilize and neutralize it first.

Nice..I haven't coded one of those in years either.
My poor Opera 12.16 browser is feeling badly that your script thinks it's on a console or phone though.. ;)

sig-bar.png


Don't worry, I didn't show the script...
 

jae

Silver Contributor
Member For 4 Years
Nice..I haven't coded one of those in years either.
My poor Opera 12.16 browser is feeling badly that your script thinks it's on a console or phone though.. ;)

View attachment 2079

Don't worry, I didn't show the script...
I don't even know what that is. There's no CSS involved at all. I think that's just what Opera uses to display a lone image. Anyway, the code is server-side, so you're not even looking at it at all. But i'm posting it here anyway.
 
Last edited:

jae

Silver Contributor
Member For 4 Years
This is probably super-inefficient code. It's been the better part of a decade since i've written anything at all. Feel free to tidy it up. I tried to comment the shit out of it for clarity; for best results, remove all that crap once you understand what you're doing.

Lastly, as evidenced in my original post on this thread, i'm clearly AWFUL at even the simplest math, so as the Department of Homeland Security might say, "if you see something, say something."

signature_bar.php
PHP:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
*                    PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
*                         This work is licensed under the
*     Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/New_York');

// set your quit date
$quitdate = "2010-08-16"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 5.00; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 2.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 30; // omit the dollar sign

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './trebuc.ttf';
$fontb = './trebucbd.ttf';

// number of pixels for the left margin
$left_margin = 5;

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
    $now = time(); // this is really NOW, for comparison to your quit date
    $your_date = strtotime($quitdate);
    $datediff = $now - $your_date;    // compare your quit date to right now (output in seconds)
    $datetime1 = new DateTime($quitdate);
    $datetime2 = new DateTime();
    $interval = date_diff($datetime1, $datetime2); // just another time comparison
    $howlong = $interval->format('%y years, %m months, %d days');
    $vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
    $vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
    $vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
    $vapesaved = $vapedays*$cigprice*$packsperday-$vapecost_ttl; // days x cost x ppd, minus vaping costs
    $cigsavoided = $packsperday*20*$vapedays;    // ppd x 20 smokes per pack x total days since quitting
    $packs = $cigsavoided/20;    // total number of packs avoided since quitting
// format numbers: decimal places, decimal separator, thousands separator
        $vapesaved = number_format($vapesaved, 2, '.', ',');
        $cigsavoided = number_format($cigsavoided, 0, '.', ',');
        $packs = number_format($packs, 0, '.', ',');
        $vapedays = number_format($vapedays, 0, '.', ',');

// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
    'The SubGenius must have SLACK! (B.Dobbs)',
    'Hail Eris! All Hail Discordia!',
    'How can I be free in the shadow of a chapel? (anon)',
    'Act like a dumbshit and they\'ll treat you like an equal (B.Dobbs)',
    'Nature abhors a moron. (HL Mencken)',
    'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
    'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = 'signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 140, 0);
$blue = imagecolorallocate($im, 216, 196, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, 18, $black, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin-2, 34, $black, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin-2, 50, $black, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin-1, 65, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, 16, $orange, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin, 32, $blue, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin, 48, $white, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin, 64, $yellow, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
 
Last edited:

CaFF

Platinum Contributor
Member For 5 Years
I don't even know what that is. There's no CSS involved at all. I think that's just what Opera uses to display a lone image. Anyway, the code is server-side, so you're not looking at it at all. But i'm posting it here anyway.
Well, I would hope the PHP script is server-side. :D

It's just Dragonfly viewing the signature_bar.php.
 

jae

Silver Contributor
Member For 4 Years
Well, I would hope the PHP script is server-side. :D

It's just Dragonfly viewing the signature_bar.php.
Right. So why were you trying to imply that you could actually see the code underneath? Or that Opera's own stylesheet was somehow part of it?
 

CaFF

Platinum Contributor
Member For 5 Years
Right. So why were you trying to imply that you could actually see the code underneath? Or that Opera's own stylesheet was somehow part of it?

Bah, it's late, I've been up for like 16 hrs and I just saw it wrong.
 
  • Like
Reactions: jae

Celcius666

Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
In my profile it written that I'm from 1 January 1970 that's 44 years, but I'm from 20 June 1978 :) LoL Don't know what happened when I was putting up my account, but know for sure that I didn't write that in it. Hehehe :):)
 

jae

Silver Contributor
Member For 4 Years
In my profile it written that I'm from 1 January 1970 that's 44 years, but I'm from 20 June 1978 :) LoL Don't know what happened when I was putting up my account, but know for sure that I didn't write that in it. Hehehe :):)
What happens when you try to update it?

[EDIT - never mind, i see that's not actually possible for some bizarre reason.]
 

Celcius666

Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Only tried changing it on TapaTalk but couldn't do that, a tekst was poping up that says that I should contact admin for changing it.. tryed to pm Joe about it but I apparently can't pm him either.. think I gonna try see if I can change it on the labtop lather to day..
 

Celcius666

Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Will try to do pm one of the mod later on, it's easier to do it on pc.
 

rolltidevaper

Still here! Just covered up with "life"
VU Donator
Silver Contributor
Member For 4 Years
ECF Refugee
Reddit Exile
This is probably super-inefficient code. It's been the better part of a decade since i've written anything at all. Feel free to tidy it up. I tried to comment the shit out of it for clarity; for best results, remove all that crap once you understand what you're doing.

Lastly, as evidenced in my original post on this thread, i'm clearly AWFUL at even the simplest math, so as the Department of Homeland Security might say, "if you see something, say something."

signature_bar.php
PHP:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
*                    PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
*                         This work is licensed under the
*     Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/New_York');

// set your quit date
$quitdate = "2010-08-16"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 5.00; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 2.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 30; // omit the dollar sign

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './trebuc.ttf';
$fontb = './trebucbd.ttf';

// number of pixels for the left margin
$left_margin = 5;

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
    $now = time(); // this is really NOW, for comparison to your quit date
    $your_date = strtotime($quitdate);
    $datediff = $now - $your_date;    // compare your quit date to right now (output in seconds)
    $datetime1 = new DateTime($quitdate);
    $datetime2 = new DateTime();
    $interval = date_diff($datetime1, $datetime2); // just another time comparison
    $howlong = $interval->format('%y years, %m months, %d days');
    $vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
    $vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
    $vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
    $vapesaved = $vapedays*$cigprice*$packsperday-$vapecost_ttl; // days x cost x ppd, minus vaping costs
    $cigsavoided = $packsperday*20*$vapedays;    // ppd x 20 smokes per pack x total days since quitting
    $packs = $cigsavoided/20;    // total number of packs avoided since quitting
// format numbers: decimal places, decimal separator, thousands separator
        $vapesaved = number_format($vapesaved, 2, '.', ',');
        $cigsavoided = number_format($cigsavoided, 0, '.', ',');
        $packs = number_format($packs, 0, '.', ',');
        $vapedays = number_format($vapedays, 0, '.', ',');

// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
    'The SubGenius must have SLACK! (B.Dobbs)',
    'Hail Eris! All Hail Discordia!',
    'How can I be free in the shadow of a chapel? (anon)',
    'Act like a dumbshit and they\'ll treat you like an equal (B.Dobbs)',
    'Nature abhors a moron. (HL Mencken)',
    'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
    'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = 'signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 140, 0);
$blue = imagecolorallocate($im, 216, 196, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, 18, $black, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin-2, 34, $black, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin-2, 50, $black, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin-1, 65, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, 16, $orange, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin, 32, $blue, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin, 48, $white, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin, 64, $yellow, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
Thank You
 

kelli

Vapid Vapetress
Platinum Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
You never know your own real age you know. You just have to take it on trust :p

nobody will know my real age anyhoo, cause i only put down my month and day.....no year. neener.gif
 
  • Like
Reactions: jae

kelli

Vapid Vapetress
Platinum Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
You don't look old enough to be on this forum ≧◔◡◔≦

i did just like you....now i love you.
hug.gif
 

havok333

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
In my profile it written that I'm from 1 January 1970 that's 44 years, but I'm from 20 June 1978 :) LoL Don't know what happened when I was putting up my account, but know for sure that I didn't write that in it. Hehehe :):)
Mine is set the same. Pretty sure it came from default Tapatalk settings when I first joined here, and joined through the Tapatalk interface.
 

Celcius666

Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Arrg crap.. I cant change it on the pc either..
Here is whats standing in the profile, but bet on that it allmost the same thing standig in your profile..
Date of Birth:
Jan 1, 1970
Once your birthday has been entered, it cannot be changed. Please contact an administrator if it is incorrect.
 

Saddletramp1200

Diamond Contributor
Member For 4 Years
Arrg crap.. I cant change it on the pc either..
Here is whats standing in the profile, but bet on that it allmost the same thing standig in your profile..
Date of Birth:
Jan 1, 1970
Once your birthday has been entered, it cannot be changed. Please contact an administrator if it is incorrect.
Lord I wish! Mine is 1955 and it's right.
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
This is probably super-inefficient code. It's been the better part of a decade since i've written anything at all. Feel free to tidy it up. I tried to comment the shit out of it for clarity; for best results, remove all that crap once you understand what you're doing.

Lastly, as evidenced in my original post on this thread, i'm clearly AWFUL at even the simplest math, so as the Department of Homeland Security might say, "if you see something, say something."

signature_bar.php
PHP:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
*                    PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
*                         This work is licensed under the
*     Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/New_York');

// set your quit date
$quitdate = "2010-08-16"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 5.00; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 2.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 30; // omit the dollar sign

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './trebuc.ttf';
$fontb = './trebucbd.ttf';

// number of pixels for the left margin
$left_margin = 5;

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
    $now = time(); // this is really NOW, for comparison to your quit date
    $your_date = strtotime($quitdate);
    $datediff = $now - $your_date;    // compare your quit date to right now (output in seconds)
    $datetime1 = new DateTime($quitdate);
    $datetime2 = new DateTime();
    $interval = date_diff($datetime1, $datetime2); // just another time comparison
    $howlong = $interval->format('%y years, %m months, %d days');
    $vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
    $vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
    $vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
    $vapesaved = $vapedays*$cigprice*$packsperday-$vapecost_ttl; // days x cost x ppd, minus vaping costs
    $cigsavoided = $packsperday*20*$vapedays;    // ppd x 20 smokes per pack x total days since quitting
    $packs = $cigsavoided/20;    // total number of packs avoided since quitting
// format numbers: decimal places, decimal separator, thousands separator
        $vapesaved = number_format($vapesaved, 2, '.', ',');
        $cigsavoided = number_format($cigsavoided, 0, '.', ',');
        $packs = number_format($packs, 0, '.', ',');
        $vapedays = number_format($vapedays, 0, '.', ',');

// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
    'The SubGenius must have SLACK! (B.Dobbs)',
    'Hail Eris! All Hail Discordia!',
    'How can I be free in the shadow of a chapel? (anon)',
    'Act like a dumbshit and they\'ll treat you like an equal (B.Dobbs)',
    'Nature abhors a moron. (HL Mencken)',
    'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
    'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = 'signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 140, 0);
$blue = imagecolorallocate($im, 216, 196, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, 18, $black, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin-2, 34, $black, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin-2, 50, $black, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin-1, 65, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, 16, $orange, $fontb, 'Vaping since 16 August 2010; '.$howlong);
imagettftext($im, 10, 0, $left_margin, 32, $blue, $font, 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs');
imagettftext($im, 10, 0, $left_margin, 48, $white, $font, 'Money spent on better things: $'.$vapesaved);
imagettftext($im, 8, 0, $left_margin, 64, $yellow, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>

I mentioned in another thread that I may have a couple of suggestions. Well, I really only have one, other than whatever other do-dads people want to add to their own banners: instead of typing the shadow and highlight lines individually and doubling up on all that keyboard time (and possibly introducing weirdnesses between the shadow and highlight), assign the individual line messages to variables and just type the variables into the imagettftext() functions. :)

If you need an example, I'd be happy to post mine. :)

Thank you again for actually doing the research on this! I had no idea of that function, which makes all this possible!
 
  • Like
Reactions: jae

jae

Silver Contributor
Member For 4 Years
I mentioned in another thread that I may have a couple of suggestions. Well, I really only have one, other than whatever other do-dads people want to add to their own banners: instead of typing the shadow and highlight lines individually and doubling up on all that keyboard time (and possibly introducing weirdnesses between the shadow and highlight), assign the individual line messages to variables and just type the variables into the imagettftext() functions. :)

If you need an example, I'd be happy to post mine. :)

Thank you again for actually doing the research on this! I had no idea of that function, which makes all this possible!
Thanks! I was going to tackle that very thing when i had the time. If you don't mind, i would love to see how you did it! I'm pretty sure i know exactly what you mean but i haven't actually tried it out yet.

[EDIT] here's my attempt, though i'm sure this could be done far more efficiently somehow. I'm usually only able to code late at night after my job, so my brain is usually fairly frizzle-fried by then.
Code:
// THE MESSAGE
$line1 = 'Vaping since 16 August 2010; '.$howlong;
$line2 = 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs';
$line3 = 'Money spent on better things: $'.$vapesaved.' + $'.$vapecost_ttl.' shamelessly vaporized';

// the spacing
$line1vert = 16;
$line2vert = 32;
$line3vert = 48;
$line4vert = 64;

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, $line1vert+2, $black, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin-2, $line2vert+2, $black, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin-2, $line3vert+2, $black, $font, $line3);
imagettftext($im, 8, 0, $left_margin-1, $line4vert+2, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, $line1vert, $blue, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin, $line2vert, -$cyan, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin, $line3vert, -$white, $font, $line3);
imagettftext($im, 8, 0, $left_margin, $line4vert, -$cyan2, $fontb, $quotation);
 
Last edited:

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Thanks! I was going to tackle that very thing when i had the time. If you don't mind, i would love to see how you did it! I'm pretty sure i know exactly what you mean but i haven't actually tried it out yet.

[EDIT] here's my attempt, though i'm sure this could be done far more efficiently somehow. I'm usually only able to code late at night after my job, so my brain is usually fairly frizzle-fried by then.
Code:
// THE MESSAGE
$line1 = 'Vaping since 16 August 2010; '.$howlong;
$line2 = 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs';
$line3 = 'Money spent on better things: $'.$vapesaved.' + $'.$vapecost_ttl.' shamelessly vaporized';

// the spacing
$line1vert = 16;
$line2vert = 32;
$line3vert = 48;
$line4vert = 64;

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, $line1vert+2, $black, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin-2, $line2vert+2, $black, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin-2, $line3vert+2, $black, $font, $line3);
imagettftext($im, 8, 0, $left_margin-1, $line4vert+2, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, $line1vert, $blue, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin, $line2vert, -$cyan, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin, $line3vert, -$white, $font, $line3);
imagettftext($im, 8, 0, $left_margin, $line4vert, -$cyan2, $fontb, $quotation);

Other than customizing mine to suit my needs, that's exactly what I did, minus the $line(x)vert declarations! Good idea! :)
 
  • Like
Reactions: jae

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
I'm sure I could learn, but I don't know any Javascript, if it's similar to that. I only know enough PHP to get me in trouble. ;)

Oh, and I played around with one that I could use over at that other place:
Sig_Bar_400.php
 
  • Like
Reactions: jae

jae

Silver Contributor
Member For 4 Years
Here's a newer version where the quit date isn't hard coded into the banner itself. Funny, i spent so many bits manipulating the damn thing, but i never bothered to format it nicely and just spit it out literally onto the actual banner.
Code:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
*  PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
*  This work is licensed under the
*  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/New_York');

// set your quit date
$quitdate = "2010-08-16"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 5.00; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 2.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 50; // omit the dollar sign

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './trebuc.ttf';
$fontb = './trebucbd.ttf';

// number of pixels for the left margin
$left_margin = 5;

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
   $prettydate = date_create_from_format("Y-m-j", $quitdate); // no, not a girl/boy. just a nicer-looking date format.
   $now = time(); // this is really NOW, for comparison to your quit date
  $your_date = strtotime($quitdate);
  $datediff = $now - $your_date;   // compare your quit date to right now (output in seconds)
   $datetime1 = new DateTime($quitdate);
   $datetime2 = new DateTime();
   $interval = date_diff($datetime1, $datetime2); // just another time comparison
   $howlong = $interval->format('%y years, %m months, %d days');
   $vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
   $vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
   $vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
   $vapesaved = $vapedays*$cigprice*$packsperday-$vapecost_ttl; // days x cost x ppd, minus vaping costs
   $cigsavoided = $packsperday*20*$vapedays;   // ppd x 20 smokes per pack x total days since quitting
   $packs = $cigsavoided/20;   // total number of packs avoided since quitting
// format numbers: decimal places, decimal separator, thousands separator
     $vapesaved = number_format($vapesaved, 2, '.', ',');
     $vapecost_ttl = number_format($vapecost_ttl, 2, '.', ',');
     $cigsavoided = number_format($cigsavoided, 0, '.', ',');
     $packs = number_format($packs, 0, '.', ',');
     $vapedays = number_format($vapedays, 0, '.', ',');

// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
   'How can I be free in the shadow of a chapel? (anon)',
   'We are a way for the cosmos to know itself. (C.Sagan)',
   'What can be asserted w/o evidence can also be dismissed w/o evidence. (C.Hitchens)',
   'I\'d take the awe of understanding over the awe of ignorance any day. (D.Adams)',
   'I love deadlines. I love the whooshing noise they make as they go by. (D.Adams)',
   'DON\'T PANIC (D.Adams)',
   'Nothing is true. Everything is permissible. (Hassan i Sabbah)',
   'We are made of starstuff. (C.Sagan)',
   'Curb Your Dogma. (Hill/Thornley)',
   'The Enlightened take things Lightly. (Hill/Thornley)',
   'Ideologies separate us. Dreams and anguish bring us together. (Ionesco)',
   'Anyone who isn\'t confused doesn\'t really understand the situation. (E.Murrow)',
   'As for me, all I know is that I know nothing. (Socrates)',
   'Only the madman is absolutely sure. (RA Wilson)',
   'A frog in a well cannot conceive of the ocean. (Zhuangzi)',
   'With our thoughts we make the world. (Gotama)',
   'Oppressive laws don\'t destroy minorities; they simply make bootleggers. (HL Mencken)',
   'Nature abhors a moron. (HL Mencken)',
   'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
   'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = 'signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 180, 90);
$blue = imagecolorallocate($im, 180, 200, 255);
$cyan = imagecolorallocate($im, 200, 215, 255);
$cyan2 = imagecolorallocate($im, 215, 235, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 235, 235, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

/* OUTPUT FOR TESTING/DEBUGGING - TO TEST, COMMENT OUT EVERYTHING BELOW THIS BLOCK TO THE END
echo "now = ".$now."<br>".
   "quitdate = ".$quitdate."<br>".
   "your_date = ".$your_date."<br>".
   "datediff = ".$datediff."<br>".
   "howlong = ".$howlong."<br>".
   "vapedays = ".$vapedays."<br>".
   "vapesaved = ".$vapesaved."<br>".
   "cigsavoided = ".$cigsavoided."<br>".
   "packs = ".$packs."<br>"
;
*/

// THE MESSAGE
$line1 = 'Vaping since '.$prettydate->format('j F Y').'; '.$howlong;
$line2 = 'Cigarettes avoided: '.$cigsavoided.' in '.$packs.' packs';
$line3 = 'Money spent on better things: $'.$vapesaved.' + $'.$vapecost_ttl.' shamelessly vaporized';

// the spacing
$line1vert = 16;
$line2vert = 32;
$line3vert = 48;
$line4vert = 64;

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 12, 0, $left_margin-2, $line1vert+2, $black, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin-2, $line2vert+2, $black, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin-2, $line3vert+2, $black, $font, $line3);
imagettftext($im, 8, 0, $left_margin-1, $line4vert+2, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 12, 0, $left_margin, $line1vert, $blue, $fontb, $line1);
imagettftext($im, 10, 0, $left_margin, $line2vert, -$cyan, $fontb, $line2);
imagettftext($im, 9, 0, $left_margin, $line3vert, -$white, $font, $line3);
imagettftext($im, 8, 0, $left_margin, $line4vert, -$cyan2, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
 

jae

Silver Contributor
Member For 4 Years
I'm sure I could learn, but I don't know any Javascript, if it's similar to that. I only know enough PHP to get me in trouble. ;)
Wow, i honestly thought i was the only person ever who knew a little bit of PHP yet didn't know any JavaScript! Now i don't feel quite so alone.
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Wow, i honestly thought i was the only person ever who knew a little bit of PHP yet didn't know any JavaScript! Now i don't feel quite so alone.

Funny!

I'm not quite finished with my first beginner's PHP & MySQL book, and I only knew what I did before that from running a bunch of phpBB and vBulletin fora.

I decided that I'd like to actually learn PHP and MySQL, so I picked up a couple of Kindle books. :)

I only made my initial suggestion because I made sure to check and double-check those lines before realizing I should combine them into one variable.
 
  • Like
Reactions: jae

jae

Silver Contributor
Member For 4 Years
Funny!

I'm not quite finished with my first beginner's PHP & MySQL book, and I only knew what I did before that from running a bunch of phpBB and vBulletin fora.

I decided that I'd like to actually learn PHP and MySQL, so I picked up a couple of Kindle books. :)

I only made my initial suggestion because I made sure to check and double-check those lines before realizing I should combine them into one variable.
phpBB - wow. That brings back some memories. I ran several boards with that, years back. Good stuff. I actually went to check up on them a little while back and they're apparently STILL on v2. Seems they've stalled or something, or maybe they've just been super micro-incremental for the past ten fucking years.

I coded for several years in the early noughts but i haven't touched it in about the same amount of time. Never did it for a living or anything. I've forgotten so much that PHP is nearly brand new for me now.

I think my next project will be to fix my broken WordPress install. I hacked it up so badly back in the day (adding bells and whistles:rolleyes:) that it just runs like shit and is downright broken in some spots now.
 

VU Sponsors

Top