MyAnimeList.net

Forums

Recent Posts | My Watched Topics | My Ignored Topics | Search

saka's minimal signature script (with merged anime/manga feeds)
MyAnimeList.net Forum »» Club Discussion »» Signature Scripters »» saka's minimal signature script (with merged anime/manga feeds)

Must be a Club Member to Reply
Pages (21) [1] 2 3 » ... Last »
#1
05-10-09, 11:13 AM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
After marveling at all the spaghetti code floating around, I decided to make a refined minimal script to compliment shiteiru/erhgeiz's script.

This script should work as a drop-in replacement for that script, except without all the obscure token nonsense that plagues it. The file is designed mostly as a learning excercise for people new to php, and because of that I have commented it heavily. I have tried to mark important areas with UPPERCASE comments, so look for those for configuration purposes.

For now I'm just giving you the files , but I plan to post a full tutorial soon. At minimum, you will need a background image ("background.png" default) and a font *.ttf file in the same directory as this script and upload them all to your webserver. You can find great custom fonts at http://dafont.com/

Here's the code:

Download saka's minimal script (with anime/manga merged and example files)
(last updated August 14, 2011 - v1.54)


Important Notes on image caching:
  • This script contains support for simple image caching. Your script will get accessed every time someone looks at a forum thread you posted in.... and that can mean thousands of hits in a short time period. Caching basically just makes it so the script doesn't have to build the signature from scratch every single time. Instead it just outputs a reasonably new copy of what it's created previously.

    In order to store that temporary image of your sig, the script will need a writable location to save it. I recommend making an empty directory named 'cache' and making sure it's writable on the server (chmod 777 or change file properties using an FTP client like FileZilla). I've put an empty directory in the zip for you, but you'll need to set the permissions on it after you upload.

    The caching greatly reduces stress on MAL and your server, and makes it much faster. Please use it! (see comments in the script to see how it works, or ask here if you're unsure how to set it up for your server)

  • Image displaying but not updating? By default, the image only updates at most every ten minutes, but for testing/building your sig you may want to set the cache time to 0 minutes so you can see your changes immediately. The script checks its own modification time so re-uploading the php file or deleting the cache image will force it to refresh... but if you are trying different fonts or background images it wouldn't be aware of that. Once your sig is working how you'd like, remember to put the cache time back to something reasonable! I recommend 10-15 minutes.


Where do I point my signature?
You can set your forum signature to use something like
[img]http://yourdomain/signature/sig.php[/img]

...and the file will output your signature image directly (make sure cache is enabled).

Alternatively, you can link to the saved image, for example...
[img]http://yourdomain/signature/cache/sig.png[/img]

...and have a cronjob visit the sig.php location every few minutes to keep the image current. Loading the cache image directly is faster, and is more resistent from 000webhost audits and other such errors, so I recommend this indirect method when possible. If you use MAL Updater, you can use the PHP Signature plugin instead of a cronjob (and your sig will update whenever you watch anime).
Modified by saka, 03-31-13, 1:00 PM
 
#2
05-10-09, 1:35 PM

Offline
Joined: Feb 2008
Posts: 4533
Looks good. Are you going to post this in the creative corner or allow shiteiru/'whatever his name is now' to update his post?
 
#3
05-10-09, 1:37 PM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
kuroshiroi said:
Looks good. Are you going to post this in the creative corner or allow shiteiru/'whatever his name is now' to update his post?

he knows about it... i don't really mind either way.
 
#4
05-10-09, 2:59 PM

Offline
Joined: May 2007
Posts: 4739
lol@people who change nicks frequently.
 
#5
05-10-09, 6:04 PM

Offline
Joined: Feb 2009
Posts: 174
I dont feel like learning more stuff so i'll keep my bombarding sig :)
 
#6
05-11-09, 12:40 AM

Offline
Joined: Sep 2007
Posts: 2285
Tried it out, really nice. Only things it is missing are transparency and title cutter I think :)

edit: just typo fix, I'm still half-asleep...
Modified by SunyiNyufi, 05-11-09, 12:50 AM
 
#7
05-11-09, 5:59 AM

Offline
Joined: Apr 2008
Posts: 91
lol@people who change nicks frequently.


Tell me...what's bad or funny about changing ones nick ? ^^ I don't get it.

Anyway, nearly every nick used online is self given and holds absolutely no meaning, so whats the point in "not changing it" ?

I don't really mind if people know me or not.
Who cares in the first place?

Btw. who cares which episodes have been watched by nick xyz in the last 4 or 5 hours (except you know him and want to know desperately what he was watching)...not me

The only purpose i made this sig thingie in the first place, was that custom sigs look a lot better than the mal generated ones. Besides that, there is absolutely no point (at least in my opinion) for creating self updating sigs.

Just my 2 cents.

Last not least: i don't want everyone to know what i'm doing where and why. So...in every community i'am i do indeed have a different nick.
Call it paranoia........who cares anyway ^^

Now go on and do something that matters like learning japanese or so :-D

>>MyList<< | >>Emilie Autumn<< | >>Bauer<<
 
#8
05-11-09, 6:52 AM

Offline
Joined: Dec 2008
Posts: 4503
Uh, it was screwing up on the transparencys for my sig, should add that
imagealphablending($sigimage,true);
imagesavealpha($sigimage,true);

thingy

Not that I know anything though, took me like 10 minutes to figure out where the heck to put it! lol
 
#9
05-11-09, 6:58 AM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
SunyiNyufi said:
Tried it out, really nice. Only things it is missing are transparency and title cutter I think :)


transparent overlays should work without imagealphablending() as long as only 24-bit png is used. I guess I could add an overlay by default or something, but I figured that had been covered enough already elsewhere. I might be wrong though.

I'll add in a title truncation line when I get back tonight.

ehrgeiz said:
The only purpose i made this sig thingie in the first place, was that custom sigs look a lot better than the mal generated ones. Besides that, there is absolutely no point (at least in my opinion) for creating self updating sigs.

Just my 2 cents.

yeah that's pretty much my opinion also... but there should be easier ways to make them look nice. It would be best if Xinil might get to expanding the existing sig system to have at least a few different fonts.

I just wanted to give people some options in the hosted php department.
 
05-11-09, 7:09 AM

Offline
Joined: Dec 2008
Posts: 4503
Cutting after however many characters would be nice to add too, cause I'm sure it'll come up

edit: love this code lol, theres barely anything with it so its easy for me to figure out how to add all the stuff like cutting on my own. Nice to have options, thanks for it.
Modified by Yuruku, 05-11-09, 7:15 AM
 
05-18-09, 12:51 AM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
Text 'cutting' and image overlays are now supported by default in the script. You can use the textlimit() and overlay_image() functions as defined in the script. You can use the new open_image() function to open any type of image that GD supports, although I recommend sticking with PNG.

Here's an example of limiting the string length to 25 characters:
$titles[0] = textlimit($titles[0], 25);

Here's an example of image overlay:
// open an image
$sigimage = open_image("background.png");

// put my png overlay on it
overlay_image("overlay.png");

...easy right? ^^

I've also added basic image caching by using a check_cache() function and tried to make it as simple as possible to understand. This still requires permission changes, but hopefully it's not too much for people.
 
05-18-09, 5:44 AM

Offline
Joined: Feb 2008
Posts: 4533
I recently added this way-too-long code to my script:
$replaceCharacters =     array('/ä/','/~/','/☆/','/†/');
$replaceWithCharacters = array('a','-','*','+');
$animeTitle = preg_replace($replaceCharacters,$replaceWithCharacters,$animeTitle);
It takes care of the characters (that I know of from MAL) that a lot of fonts don't include. Of course, * and + are no ☆ and † but you get the point.

I'm considering switching over to your script, I'd need to incorporate some minor changes but overall, it does what I need. I'm assuming it actually works with 000webhost's cron jobs?
 
05-18-09, 7:05 AM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
hmmm...It would be nice to compile a more comprehensive replacement method, or even better to have a fall-back font and let it switch to a unicode font only for writing those characters. I considered doing this in my own (non-minimal) script at one point... but since I no longer use the text I didn't bother. I don't really want to add anything more to this one, but it should be easy to add basic replacements using strtr(), near the other character replaces...

$buffer = strtr($buffer, array('ä' => 'a',...) );

kuroshiroi said:
I'm considering switching over to your script, I'd need to incorporate some minor changes but overall, it does what I need. I'm assuming it actually works with 000webhost's cron jobs?

there shouldn't be any problem. something like this should do it:
Modified by saka, 09-10-09, 6:54 PM
 
05-18-09, 7:35 AM

Offline
Joined: Feb 2008
Posts: 4533
saka said:
I don't really want to add anything more to this one
I hear you on that but it beats having boxes and shit in the sig.
 
06-02-09, 10:12 PM

Offline
Joined: May 2009
Posts: 56
Looks like i've learnt how to script, thanks alot.
Can you put JPEG pictures instead of png? or it doesnt work with JPEG?
 
06-02-09, 10:49 PM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609
ryuK- said:
Looks like i've learnt how to script, thanks alot.
Can you put JPEG pictures instead of png? or it doesnt work with JPEG?


jpeg images should work just fine ...it should even work with GIF (not animated) and a host of other formats like BMP, XPM, and GD raw images.

By default, it still converts the output to PNG, though. If you don't want this, you can change the imagepng(...) lines at the end to imagejpeg() instead just to avoid extra conversion and/or reduce filesize if you don't need transparency. Remember to change the header(...) lines accordingly also.
 
06-02-09, 11:38 PM

Offline
Joined: May 2009
Posts: 56
Thanks, i got it working
 
06-19-09, 12:18 PM

Offline
Joined: Apr 2008
Posts: 262
saka said:
erm... it's filled with #'s possibly?

you're probably getting a parsing error.... just remove all the #'s in your code if they are actually there (global replace in your text editor should handle it).
btw... it's better to just ask in the thread for my script if you have questions.

Okay I done that, but still it isn't working. Maybe let's start from begging. That whole code must be put in one php file (ex. sig_creator), then I must have background, overlay (I'm using it), font file and cache folder, right? I got that all, cache folder chmod is set 777, server is 000webhost.com and the code is like in other topic (but without #'s), still it isn't working. What could be the problem?
 
06-19-09, 12:25 PM

Offline
Joined: Feb 2008
Posts: 4533
Post the code again with the error.
 
06-19-09, 12:59 PM
Forum Moderator
Offline
Joined: May 2008
Posts: 4609


Fixed the errors, Silmoren...

make sure you have the url set like i have done above, and that the $font is the path to an actual *.ttf font file.

not sure why you wanted to strip out all the comments... nor exactly exactly what is wrong... but I'll look later tonight if I have time.
 
Top
Pages (21) [1] 2 3 » ... Last »
Help     FAQ     About     Contact     Terms     Privacy     AdChoices