• 0

Dynamic Signatures


Question

How would I make a signature that allows users to put a piece of text into my signature? I know you can use PHP, but I don't have the slightest clue about PHP

(Apart from Cutenews stuff)

Could someone make me a saple signature, very plain, and show me how to allow users to imput text into it thru my website?

Edited by TimRogers
Link to comment
https://www.neowin.net/forum/topic/301987-dynamic-signatures/
Share on other sites

Recommended Posts

  • 0

Hey,

I just went through a whole learning process about this.

The result are my two signature images.

One conjurs up data output by an iTunes plugin, and the other is a random quotes.

I will post the sourece for the latter:

<?php

// tell the user's browser that it is an image
header("Content-type: image/png");

// load the background
$image = imagecreatefrompng("quote.png");

// define the color black (the colour of the text)
$clr_black = imagecolorallocate($image, 0, 0, 0);
$clr_white = imagecolorallocate($image, 255, 255, 255);

// Now let's add the text

// define the font, x_position
// how much the y_position changes (increments)
$line_number = 1;

//Get a random number
$num = rand(1,3);

//Start the switch function
switch ($num) {
//First Quote
case 1:
$quote = "Nothing strengthens authority so much as silence.";
$author = "Leonardo Da Vinci";
break;
//Second Quote
case 2:
$quote = "My life is one long curve, full of turning points.";
$author = "Pierre Elliott Trudeau";
break;
case 3:
$quote = "It\'s amazing what you can accomplish if you do not care who gets the credit. This is a test";
$author = "Leonardo Da Vinci";
break;
}
//Add text to image (img, size, angle, x,y, colour, .ttf, text)
ImageTTFText($image, 8, 0, 10, 50, $clr_black, "verdanai.TTF", stripslashes($author));
ImageTTFText($image, 9, 0, 10, 15, $clr_black, "verdana.TTF", wordwrap(stripslashes($quote), 80));

// and now... we display the image
imagepng($image);
imagedestroy($image);
?>

If your understanding PHP is average, you should be able to pick this apart, and use what you need.

If you need more detailed instructions on how to use this, reply accordingly and I will post a description of the script.

-Ax

  • 0

Try these:

Random Banner:

<script LANGUAGE="Javascript"><!--

// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************

function banner() {
};

banner = new banner();
number = 0;

// bannerArray
banner[number++] = "<a href='http://www.url1.com' target='_blank'><img src='images/banner-1.gif' border='0'></a>"
banner[number++] = "<a href='http://www.url2.com' target='_blank'><img src='images/banner-2.gif' border='0'></a>"
banner[number++] = "<a href='http://www.url3.com' target='_blank'><img src='images/banner-3.gif' border='0'></a>"
banner[number++] = "<a href='http://www.url4.com' target='_blank'><img src='images/banner-4.gif' border='0'></a>"
banner[number++] = "<a href='http://www.url5.com' target='_blank'><img src='images/banner-5.gif' border='0'></a>"
// keep adding items here...

increment = Math.floor(Math.random() * number);

document.write(banner[increment]);

//--></SCRIPT>

Random Avatar:

<?php
header('Content-type: image/jpeg');

//URL of the folder where the avatar images are
//The avatar images and php file can be in different places
$url = "http://homepage.ntlworld.com/frank.cox/damon/images/avatars/";

//List of filenames you wish to randomize, currently only jpegs are supported
//Note the last filename does not need a comma after it
$avatar = array (
"phpone.jpg",
"phptwo.jpg",
"phpthree.jpg"
);

//Select a random image from the list
$size = (count($avatar) - 1);
if (!isset($id) || ($size < 0) || ($id > $size)) {
$id = rand (0, ($size - 1));
}

//Output the image
$img = imagecreatefromjpeg($url . $avatar[$id]);
imagejpeg($img);
imagedestroy($img);
?> 

For that, you might want to try Tim Dorr: http://home.timdorr.com/scripts/sig/

If you get the script for that - see if you can post it here?

Hope they help,

Pete

  • 0

It's pretty easy :-

1. Make a page with a form, a textbox and a button on. Make this script submit to something like action.php

2. In action.php make it check to see if something was entered (also badwords, if you feel so inclined). If everything checks out allright then write the text to a .txt file.

3. In your image script use file_get_contents to get the data from inside the textfile and load it to a variable. Write this variable to the image using imagettftext or whatever you're using.

Done !

  • 0

Alright, I'll take a couple mins to fire this one out!

1. We'll be using two files for this. form.html and genimg.php (generate image).

form.html will simply have the form that a user can fill out to have the image display.

genimg.php will then take that information and using it to build the image you want!

Here's the form you can put on your site:

<form action="genimg.php" method="post" name="genimg">
<input type="text" name="text"><br>
<input type="submit" value="Make Image!">
</form>

And here's GenImg.php

<?php

if(isset($_POST['text'])) {
	//generate image
	header("Content-type: image/png");

	$image = imagecreatefrompng("image.png");

	//Colour Black
	$clr_black = imagecolorallocate($image, 0, 0, 0);

	//Add the text! REMEMBER TO ADJUST the number 90 at the end of this line for the length of your image.
	//Simply keep changing it till it works well for your site. (It makes the text not spill off the image).
	ImageTTFText($image, 9, 0, 5, 14, $clr_black, "arial.TTF", wordwrap(stripslashes($_POST['text']), 90));

	imagepng($image);
	imagedestroy($image);
} else {
	?>
	Sorry, you forgot to fill out the form!<br>
	<form action="genimg.php" method="post" name="genimg">
	<input type="text" name="text"><br>
	<input type="submit" value="Make Image!">
	</form>
	<?php

}
?>

This is a VERY basic code. I thought making it complicated would just confuse you :p.

You'll also need to put arial.TTF in the same directory as this file (You can find this file in: C:\Windows\Fonts\) and you'll also need an existing image named image.png.

The command:

ImageTTFText($image, 9, 0, 5, 14, $clr_black, "arial.TTF", wordwrap(stripslashes($_POST['text']), 90));

Has to be modified to make the text fit where you want it on your image. you can do this by adjusting the numbers 5 and 14. 5 sets the VERTICAL adjustment (up and down) and 14 adjusts the HORIZONTAL adjustment (LEFT and RIGHT). the number 9 is the font size, and the 0 is the angle.

I'd be glad to answer any questions.

EDIT**

Crud, I just relized you are wanting something a little different... You want people on your site to be able to Adjust YOUR signature image. Never mind this script then, it's not what you're looking for...

-Ax

  • 0

Ok, sorry totally forgot about this thread :rolleyes: ..

This is all in one block, this is the really old one..

<?php

/* Kings mooodi's PHP-GD powered Signature for use on forums
Orginaly made for my personal use on http://forums.ithium.net
Hope you enjoy : simple config bellow easy, simple, clear and commented.
note: thread name is currently supported by IPB only.

Now heres the crappy part:
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


*/

$commentfile = "comments.dat"; //Must be Chmod'd 777
$thisfile = "neowin.jpg"; //this file

//End of Config

if($go == "") {

header ("Content-type: image/png");


// Various Color and image creation Stuff
$im = imagecreate(400, 130);    	// Create Image
$white = imagecolorallocate ($im, 255, 255, 255); // Colours 
$black = imagecolorallocate ($im, 0, 0, 0);
$grey = imagecolorallocate ($im, 226, 215, 215);
imagerectangle ($im, 1, 1, 399, 129, $black);  // Border

//Find and read the comment
$commentopen = fopen($commentfile, "r"); //Open file
$comments = fread($commentopen, filesize($commentfile)); // Read file
$showcomments = explode(":", $comments); //separate comments
fclose($commentopen); //clost file

// Final stage, Print everything on to the image

imagettftext($im, 10, 0, 5, 25, $black, "./trebuc.ttf",  '-> IP : ' .$strIP);                    // Viewer IP
imagettftext($im, 10, 0, 5, 40, $black, "./trebuc.ttf",  '-> Date : ' .$strTIME);           // Date
imagettftext($im, 10, 0, 5, 55, $black, "./trebuc.ttf",  '-> Uptime : ' .$strUP);           // Server Uptime
imagettftext($im, 10, 0, 5, 70, $black, "./trebuc.ttf",  '-> Exec. in : ' .$strGEN);       // Generated in...     
imagettftext($im, 10, 0, 5, 85, $black, "./trebuc.ttf",  '-> Script Update: ' .$strMOD);   // Modified time
imagettftext($im, 10, 0, 20, 115, $black,"./trebuc.ttf",  '' .$showcomments[0]);           // Quote

imagettftext($im, 25, 0, 287, 32, $black, "./bord.ttf",  "mooodi");    // Name
imagestring ($im, 1, 375, 120,  ''.$strVER, $black);                       // Print Script Version


imagepng ($im);
imagedestroy ($im);


}elseif($go == "change") {
//Add comments..//
echo "<body><center>";
echo "<h1>Change Comment</h1>";
echo "<form action=$thisfile><input type=hidden name=go value=gochange>";
echo "New message: <input type=text name=newcomment maxlength=150><br>";
echo "<input type=submit value=\"Update commentwall\">";
echo "<br><br><a href=?go=list>Show Archives</a>";
echo "</center></form></html>";
} elseif($go == "list") {
if(!$commentflag) { $commentflag = "a"; }
// You can edit the archives page here. //
echo "<body><center>";
echo "<table width=70%>";
$commentopen = fopen($commentfile, "r");
$comments = fread($commentopen, filesize($commentfile));
$showcomments = explode(":", $comments);
foreach($showcomments as $s) {
	if($commentflag == "a") {
  echo "<tr><td bgcolor=#F1F3E5>";
  echo "$s<br>";
  echo "</td></tr>";
  $commentflag = "b";
	} elseif($commentflag == "b") {
  echo "<tr><td bgcolor=lightgrey>";
  echo "$s<br>";
  echo "</td></tr>";
  $commentflag = "a";
}
}
fclose($commentopen);
echo "</table></body></html>";
} elseif($go == "gochange") {
if(!$newcomment) {
echo "no comment";
die();
} else {
$newcomment = str_replace("<", "[html] ", $newcomment);
$newcomment = str_replace(">", " [!html]", $newcomment);
$newcomment = str_replace(":", " - ", $newcomment);

$newcommentz = stripslashes("$newcomment");
$commentopen = fopen($commentfile, "r");
$rottencomments = fread($commentopen, filesize($commentfile));
fclose($commentopen);
$commentwrite = fopen($commentfile, "w+");
	if(!fwrite($commentwrite, "$newcommentz:$rottencomments"))
	{ echo "File Write error"; }	
	fclose($commentwrite);
	echo "Comment added, done.";
}
} else {
echo "crap! invalid page...";
die();
}

?>

Notes:

Don't just copy paste the whole thing because its more than likely that you don't have fonts named trhe way I named them.

Make sure you have comments.dat (or whatever you specified your comments file to be) chomd'd to 777.

This is quite old so it is'nt the neatest work ever, and the pages are NOT what my usual stuff looks like.

The code above isn't the whole thing I cut out as much as possible (whilst keeping it error free) so that the comment thing is as clear as possible.

Pages :

filename.ext?go=list : will show all the comments.

filename.ext?go=change : will bring up the add comment change.

Preview :

This is what the above code should output.

neowin.jpg

Test: Add Comment and Archives.

Hope this is what you wanted ;) and umm sorry for the delay.. :rofl: ,

mooodi

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • One of the strangest galaxies in our Universe could help answer some long overdue questions by Sayan Sen Image by Pixabay via Pexels | Not representative An international team of astronomers led by the Department of Astronomy at Tsinghua University has discovered an unusually metal-poor galaxy that may contain signs of first-generation star formation. The galaxy, named Metal-Pristine Galaxy COSMOS Redshift 3 (MPG-CR3), or CR3, was identified using observations from the James Webb Space Telescope (JWST), the Very Large Telescope (VLT), and the Subaru Telescope. The findings, published in The Astrophysical Journal Letters, describe CR3 as the most metal-poor galaxy known from the period known as "cosmic noon," around 11.5 billion years ago. Cosmic noon refers to a period when the universe was producing stars at its highest rate and galaxies were growing rapidly. In astronomy, "metals" refers to all elements heavier than helium, including oxygen, carbon, and iron. Because CR3 contains so few of these heavier elements, researchers say it closely resembles what scientists expect the earliest galaxies in the universe may have looked like. The discovery is significant because it could offer clues about Population III (Pop III) stars, the first generation of stars thought to have formed after the Big Bang. These stars are believed to have formed from gas made almost entirely of hydrogen and helium, before heavier elements were created inside stars and spread across the universe through supernova explosions. Hence this is why CR3 has been referred to as a "living fossil." Scientists have long believed that Population III stars existed only in the very early universe. As more generations of stars formed and died, they enriched surrounding gas with heavier elements, making the conditions needed for metal-free star formation increasingly rare. Because of this, researchers expected the formation of such stars to have largely ended after the epoch of reionization, a period when radiation from the first stars and galaxies transformed the neutral hydrogen filling the universe and made it largely transparent to ultraviolet light. CR3 appears to challenge that idea. The galaxy was observed at a redshift of z = 3.193 ± 0.016. Redshift measures how much light from a distant object has been stretched as the universe expands and helps astronomers determine how far back in time they are looking. In this case, the redshift corresponds to roughly 11.5 billion years ago during cosmic noon. Although the universe was already several billion years old by that point, CR3 shows characteristics more commonly associated with much earlier galaxies. Observations revealed exceptionally strong emissions from hydrogen and helium, including Lyα, Hα, and He I λ10830. Lyα, or Lyman-alpha emission, is a specific wavelength of light produced by hydrogen and is widely used to study distant galaxies. Hα emission is another hydrogen signature commonly used to trace active star formation, while He I λ10830 is produced by helium and can indicate the presence of very hot, young stars. The measured equivalent widths of EW₀(Lyα) = 822 ± 101 Å and EW₀(Hα) = 2814 ± 327 Å are among the highest ever observed in star-forming galaxies. Equivalent width is a measure of the strength of an emission line relative to the surrounding light, and such large values are typically associated with intense and very recent star formation. At the same time, researchers found no statistically significant detections of metal emission lines, including [O III] λλ4959, 5007 and C IV λλ1548, 1550. Emission lines act as chemical fingerprints that reveal which elements are present in a galaxy. Oxygen and carbon lines are commonly seen in galaxies that have already undergone significant chemical enrichment. Their absence in CR3 suggests an unusually pristine environment. Using abundance calibration methods developed with JWST observations, the team placed a 2σ upper limit on the galaxy's gas-phase metallicity of 12+log(O/H)<6.52, corresponding to less than 0.7% of the Sun's metallicity (Z < 7 × 10⁻³ Z⊙). Gas-phase metallicity measures the abundance of heavy elements in a galaxy's gas. A 2σ upper limit indicates that the true value is very unlikely to be higher than the quoted threshold. Even when accounting for uncertainties in the calibration methods, the most conservative limit remains 12+log(O/H)<6.95, making CR3 the most metal-poor galaxy identified at cosmic noon. The galaxy also appears to contain very little dust. Researchers measured a Lyα/Hα flux ratio of 13.9 ± 2.5, a result that suggests negligible dust attenuation, meaning very little of the galaxy's light is being absorbed or scattered by cosmic dust. Because dust is usually produced by earlier generations of stars, this finding further supports the idea that CR3 has experienced very little chemical enrichment. Further analysis using spectral energy distribution modelling, a technique that compares observed light with theoretical models, suggests that CR3 contains an extremely young stellar population only around 2 million years old. The modelling, which used Population III stellar templates, also indicates the galaxy has a stellar mass of approximately 6.1 × 10⁵ M⊙. The symbol M⊙ represents one solar mass, or the mass of the Sun. One of the key questions raised by the discovery is how such a chemically primitive galaxy could exist in a universe that had already spent billions of years producing heavier elements. To investigate this, the researchers examined CR3's surroundings. Their analysis suggests the galaxy may lie in a slightly underdense environment, with a density contrast of roughly δ ≈ −0.12. An underdense region contains less matter and fewer galaxies than average. The team suggests that this relative isolation may have helped preserve pockets of pristine gas. Metal-rich material expelled from nearby galaxies may never have reached CR3, while the lower rate of galaxy mergers and interactions could have slowed the mixing of enriched gas into the system. If future observations confirm these findings, CR3 could provide some of the strongest evidence yet that first-generation star formation continued well after the epoch of reionization. Such a result would challenge the conventional view that pristine star formation ended by z ≳ 6 and suggest that small pockets of metal-free gas survived much longer than previously thought. Researchers stress that more observations will be needed to determine the galaxy's true nature. Future spectroscopic studies with higher resolution and better signal quality could help confirm whether CR3 is genuinely hosting Population III star formation. The discovery is also expected to encourage searches for other similar galaxies, which could help astronomers better understand how the first stars formed and how galaxies evolved in the early universe. Source: Tsinghua University, IOPscience This article was generated with some help from AI and reviewed by an editor. Under Section 107 of the Copyright Act 1976, this material is used for the purpose of news reporting. Fair use is a use permitted by copyright statute that might otherwise be infringing.
    • "I think in the immediate absence of a partner to apply relief" In the words of Sterling Archer... "Phrasing!"
    • For me, the fundamental problems with these "smartglasses" is that they really don't work well for people with significant prescriptions and massively up the price if you use attached lenses if they have displays, and if they don't, then they're not actually "smart" anything, rather just connecting to your phone and relaying voice to an AI. In a few cases like this, they throw in small cameras to feed video to the AI. All around, these feel like both a solution looking for a problem, and the problems it tries to solve seem more easily solved by different approaches and designs. Oddly, if the rumours are true, Apple may actually have invented something for once and it kind of does this right: put cameras in ear buds and manage the interface to AI exactly as most of us do: tapping on an ear bud and saying "Hey Google" or "Hey Siri." That makes them compatible with almost everyone, can double up as a hearing assist device, an impaired vision assist device, a "smart" device... and answer your phone and play music. That just seems like a better solution all around.
    • Usually the bigger ones with many fixes/changes take a few, theyre an exception to the rule most likely
    • If you don’t get lucky with Valve’s Steam Machine reservation system, you can make your own Steam Machine instead. Valve says that “starting with the SteamOS 3.8 release, you can put together your own Steam Machine using whatever PC parts you want.” SteamOS 3.8.10 launched last week with a slew of updates, including “improved compatibility with recent Intel and AMD platforms.” Alongside that improved compatibility, Valve is giving gamers the green light to install SteamOS on their own desktops. In an interview with The Verge, Valve’s Pierre-Loup Griffais said Valve has been “rolling out improvements to [SteamOS] so it’s more compatible with desktop hardware,” including eventual support for Nvidia graphics. Griffais says Valve has “a growing team” working on Nvidia driver support for SteamOS, adding, “We’re collaborating with Nvidia very closely.” While he mentioned that Nvidia support might not come this year, Griffais emphasized that “it’s certainly something that we’re working on in the background.”     Subscription not needed: https://archive.fo/Tssfc Subscription needed: https://www.theverge.com/games/953411/valve-steamos-desktop-nvidia
  • Recent Achievements

    • Dedicated
      HidekoYamamoto94 earned a badge
      Dedicated
    • One Month Later
      timbobit earned a badge
      One Month Later
    • One Month Later
      nates earned a badge
      One Month Later
    • Week One Done
      Almohandis earned a badge
      Week One Done
    • Rookie
      dorf went up a rank
      Rookie
  • Popular Contributors

    1. 1
      +primortal
      454
    2. 2
      +Edouard
      162
    3. 3
      PsYcHoKiLLa
      107
    4. 4
      Michael Scrip
      84
    5. 5
      Steven P.
      70
  • Tell a friend

    Love Neowin? Tell a friend!