New
May 10, 2009 11:13 AM
#1
After marveling at all the spaghetti code floating around, I decided to make a refined minimal script to complement 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 October 3rd, 2015 - v1.58) Important Notes on image caching:
Where do I point my signature? The full address to your signature script once you upload it will be something like: http://yourdomain/path/to/your/signature.png/index.php ...and that address will output your signature image directly (updating in real time if the cache time hasn't passed). The folder is confusingly named "signature.png" to satisfy security checks that the MAL forum uses to make certain attacks more difficult. To avoid incurring the wrath of the security gods, just leave the "/index.php" off the end of the address, giving you forum bbcode that looks like: [img]http://yourdomain/path/to/your/signature.png[/img] Alternatively, you can link to the saved image, for example... [img]http://yourdomain/path/to/your/signature.png/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 less likely to make some free hosts mad, 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). |
sakaOct 3, 2017 12:14 PM
May 10, 2009 1:35 PM
#2
Looks good. Are you going to post this in the creative corner or allow shiteiru/'whatever his name is now' to update his post? |
May 10, 2009 1:37 PM
#3
May 10, 2009 6:04 PM
#5
May 11, 2009 12:40 AM
#6
May 11, 2009 5:59 AM
#7
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 |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
May 11, 2009 6:52 AM
#8
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 |
May 11, 2009 6:58 AM
#9
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. |
May 11, 2009 7:09 AM
#10
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. |
123114334dMay 11, 2009 7:15 AM
May 18, 2009 12:51 AM
#11
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. |
May 18, 2009 5:44 AM
#12
I recently added this way-too-long code to my script:$replaceCharacters = array('/ä/','/~/','/☆/','/†/'); 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? |
May 18, 2009 7:05 AM
#13
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: ![]() |
sakaSep 10, 2009 6:54 PM
May 18, 2009 7:35 AM
#14
saka said: I hear you on that but it beats having boxes and shit in the sig.I don't really want to add anything more to this one |
Jun 2, 2009 10:12 PM
#15
Jun 2, 2009 10:49 PM
#16
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. |
Jun 19, 2009 12:18 PM
#18
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? |
Jun 19, 2009 12:25 PM
#19
Post the code again with the error. |
Jun 19, 2009 12:59 PM
#20
<?php 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. |
Jun 19, 2009 3:05 PM
#21
Okay, everything seems to go better way now, great thanks for help, but still I would use some more ^^ Sig is loading now, but there's no text on it, whatever I do. Here's the text-regarding code: $sigimage = open_image("background.png"); $font = 'DIST_Inking.ttf'; $colour = imagecolorallocate($sigimage,0,0,0); // draw the text - the template is imagettftext(image, font size, angle, x-pos, y-pos, font, color, fontfile, text output) imagettftext($sigimage,10,0,2,5,$colour,$font,$titles[0]); imagettftext($sigimage,20,0,20,20,$colour,$font,$status[0]); Changing font, color, position, doesn't do anything, sig is still empty |
Jun 19, 2009 3:12 PM
#22
Well, what color is your background, are you sure that's the correct position of the text and since fonts are very CaSe-SeNsItIvE, check that, including the ttf. |
Jun 19, 2009 5:03 PM
#23
one more thing that might be the culprit: the mal forums will strip backslashes on edit... it's right on my post now, but I had to edit it once to put the backslashes back in. Without them the regular expressions break and none of your RSS data is loaded... which might cause no text to appear. Make sure these three lines contain backslashes in your version: $buffer = strtr($buffer, array("\n" => '', "\r" => '', "\t" => '', '<' => '<', '>'=>'>', '&' => '&', '"' => '"', '''=>"'") ); You can check that your rss data is being matched by putting a line like this right before your text lines: var_dump($titles); exit(0); That will output what the titles array looks like and then stop the script.... so you should see some data when you try to run it. You should see a list of all the titles in your feed... If nothing is there, something is probably going wrong with parsing. You can just remove the test code if it is working, or use it to test other variables if you'd like. If that fails, just compare your code against my original since we know that works.... ;P |
Jun 20, 2009 5:16 AM
#24
Checked the code, it's exacly the same as Your original code, also that var_dump line doesn't work, nothing changes (at first time I got "NULL error", but later nothing changed). Changing font position, angle, size, doesn't do anything. Maybe something's with font file, it was .otf, I've changed it to ttf... |
Jun 20, 2009 6:32 AM
#25
Silmoren said: You changed the name of the font or the code?Checked the code, it's exacly the same as Your original code, also that var_dump line doesn't work, nothing changes (at first time I got "NULL error", but later nothing changed). Changing font position, angle, size, doesn't do anything. Maybe something's with font file, it was .otf, I've changed it to ttf... |
Jun 20, 2009 9:11 AM
#26
Silmoren said: Checked the code, it's exacly the same as Your original code, also that var_dump line doesn't work, nothing changes (at first time I got "NULL error", but later nothing changed). Changing font position, angle, size, doesn't do anything. ...which just further implies that something is wrong before the text stuff. There's probably nothing in the $titles array, so you're printing out a lot of nothing. An empty string prints just about the same when moved or rotated. ;) Silmoren said: Maybe something's with font file, it was .otf, I've changed it to ttf... *.otf should work just as well, as long as it matches the filename in your code... I still suspect something on one of the parsing lines is not correct, but I can't tell without looking at it. I've zipped up my test files and sent you a link via pm. Just replace with your background.png and ol.png and it should work just fine. |
Jun 20, 2009 11:08 AM
#27
Okay, as it can be seen the problem is out, it was the font file that generated errors, changed it and everything seems fine. Once more many thanks for all people, who helped me creating this sig ^^ |
Jun 22, 2009 10:39 AM
#29
Hey, I'm making a signature for a friend using the anime/manga merged feeds. Anime updates works great, but when manga is updated, it looks like this:![]() It doesn't show the read chapter. It also showed the manga type before, but I managed to remove that. This problem is out of my skills though :P This is what my code looks like:
|
Jun 22, 2009 11:21 AM
#30
I'm guessing you'll need to editif ($status[$i] == "Watching" or $status[$i] == "Re-Watching") if ($status[$i] == "Watching" or $status[$i] == "Re-Watching" or $status[$i] == "Reading") Basically, tell the script how it should format the reading manga entries. |
Jul 3, 2009 2:02 PM
#33
Hmmm recently I wanted to change script from Anime to Anime/Manga. Everything works just fine but 2 problems. Is it possible with this script to create signature that displays two titles with statuses, where one title is always for manga and other is always for anime? I've changed few things but that script always shows me my recent changes, so when I watch two animes, it displays changes about those two animes, when I read two mangas, it displayes changes about those two mangas. Second thing is, that script displayes how many anime episodes I've watched, but it doesn't display how many manga chapters I've read. Also made small change to the code, so that manga title won't be displayed with "- Manga" at the title end: $titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga)$/', '', $titles[$i]); |
Jul 3, 2009 2:57 PM
#34
Silmoren said: Is it possible with this script to create signature that displays two titles with statuses, where one title is always for manga and other is always for anime? I've changed few things but that script always shows me my recent changes, so when I watch two animes, it displays changes about those two animes, when I read two mangas, it displayes changes about those two mangas. I set it up like this intentionally, although since the status contains 'chapters' instead of 'episodes', you should be able to use this to determine whether an entry is anime or manga. You could duplicate the preg_match_all lines and parse the anime and manga buffers separately instead of the combined one... You'd need to make some new array names, or make the titles[], status[] etc arrays two dimensional. If that sounds odd to you, you can do this easier workaround... If you've got more than 15 anime in your list (most people), you can just comment out the line that sorts the combined entries by date: // array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units); ...and then the most recent manga entry should always be the 16th one (since the recent anime feeds list 15 entries). It's not as elegant, but it works. Silmoren said: Second thing is, that script displayes how many anime episodes I've watched, but it doesn't display how many manga chapters I've read. Also made small change to the code, so that manga title won't be displayed with "- Manga" at the title end: $titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga)$/', '', $titles[$i]); Strange, I thought I had fixed that already, but I guess i forgot to update the url. The full line to remove all types is this: $titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga|Manhwa|Manhua|Novel|One Shot|Doujin|OEL)$/', '', $titles[$i]); I'll fix this on the first page shortly. |
sakaJul 3, 2009 3:00 PM
Jul 4, 2009 5:44 AM
#35
Forgive me if I'm asking a lot, but is there a way to reposition text if the anime title has less then a certain amount of letters? |
![]() |
Jul 4, 2009 6:15 AM
#36
Roxkis said: Should be rather easy, if you know a little programming. You'd have to use http://php.net/manual/en/function.strlen.php and some kind of conditional statement like a switch or an if.Forgive me if I'm asking a lot, but is there a way to reposition text if the anime title has less then a certain amount of letters? There may be some errors there, but it should be something like this:
In this case, the first 2 lines will execute if the length is over 5 and the last 2 will execute if the length is below 5. Yes, I overuse white space, give me a break. |
kuroshiroiJul 4, 2009 6:20 AM
Jul 4, 2009 12:22 PM
#37
saka said: If that sounds odd to you, you can do this easier workaround... If you've got more than 15 anime in your list (most people), you can just comment out the line that sorts the combined entries by date: // array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units); ...and then the most recent manga entry should always be the 16th one (since the recent anime feeds list 15 entries). It's not as elegant, but it works. Nope, it doesn't work for me, when I use it, sig only displays anime entries. saka said: You could duplicate the preg_match_all lines and parse the anime and manga buffers separately instead of the combined one... You'd need to make some new array names, or make the titles[], status[] etc arrays two dimensional. Hmm I understand what what you mean, but my low PHP skill doesn't allow me to use that. Well I'll stick with what I've got now, still it's not so bad :P |
Jul 4, 2009 5:13 PM
#38
works for me... Try this code: http://pastebin.com/m361654e1 the titles array comes out like this, where 0-14 are anime and 15+ are manga: Array ( [0] => Dragon Ball Kai [1] => Hetalia Axis Powers [2] => Elemental Gelade [3] => Spice and Wolf II OVA [4] => Grenadier: Specials [5] => Grenadier [6] => Aria the Animation [7] => Code Geass - Hangyaku... [8] => Excel Saga [9] => Green Green Character DVD [10] => Green Green Thirteen:... [11] => Green Green OVA [12] => Green Green [13] => Kuroshitsuji - Tanaka... [14] => Kuroshitsuji [15] => Spice and Wolf [16] => Spice and Wolf [17] => School Rumble [18] => Great Teacher Onizuka [19] => Mahou Sensei Negima! [20] => Love Hina [21] => Cromartie High School [22] => School Rumble Z [23] => Time Stranger Kyoko ) these are the lines i changed, which might be helpful: http://pastebin.com/pastebin.php?diff=m361654e1 |
Jul 5, 2009 8:31 AM
#40
saka 1 - php 0 |
Jul 10, 2009 4:38 AM
#41
Small change in code: if ($status[$i] == "Watching" or $status[$i] == "Re-Watching" or $status[$i] == "Reading" or $status[$i] == "Re-Reading") { Without this, sig won't display amount of manga chapters |
SilmorenJul 16, 2009 2:53 AM
Jul 11, 2009 3:36 PM
#42
Thanks for mentioning that. This has been pointed out before so I've updated it in the code. Since with dual feeds its more likely people will list lots of statuses, I've changed it to an in_array() call so that you don't need to keep writing " or $status[$i] == " every time. I encourage people to change the formatting bits any way they'd like. Here's the diff: |
Jul 15, 2009 12:40 PM
#43
saka said: 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: ![]() is that how you did it? I tried to create a cron job exactly like that, but it doesn't update. I have to manually visit the php file to get my cache pic to update, so I know that is working. mine looks like this and yes, I added it (just in case anyone asked) ![]() any idea what I could be doing wrong? |
redlupineJul 15, 2009 12:45 PM
![]() |
Jul 15, 2009 2:46 PM
#44
Jul 15, 2009 9:22 PM
#45
saka said: make sure the second field starts with public_html since the path should contain that. I'm not sure how it was left out of my screenie from earlier, but it should be there. So the second field for you would be: public_html/myanimelist/sig_creator2.php it's still not updating, maybe that was just part of the problem I've tried playing around with the check_cache function, to see if that was the problem, but no luck there |
![]() |
Jul 15, 2009 11:26 PM
#46
check_cache() will just prevent the sig from updating more frequently than once every X minutes. If your cron job is set to visit it every ten minutes, then you should still see the updates after that 10 minutes (or the cache time, whichever is greater). The script seems to be generating it properly, so it must be a problem with the cronjob and not the script. The settings you showed should work though... are you sure it isn't working? Try making an anime update, then wait 20 mins and check the cache image. There are also alternatives to using cron, such as using MAL Updater's php signature plugin to visit the url. |
Jul 16, 2009 12:02 PM
#47
Jul 16, 2009 12:05 PM
#48
thanks for trying to help, but it's still not working I made a strange discovery though. I tried 3 other cron job sites and tried to point them to my php file url, but the all failed when I tried to set the cron. I think there's something about my php file that cron jobs don't like. Maybe I gotta make it not output an image, just save it to a the cache. Is there a way to do that? EDIT: Nevermind, I fixed it, that was exactly the problem I commented out the header("Content-type: image/png"); line and BAM, now it works EDIT2: False alarm, it still doesn't work. Either it was a one time deal that it updated or someone was messing with me and manually ran my php |
redlupineJul 16, 2009 9:18 PM
![]() |
Jul 16, 2009 12:07 PM
#49
V3gas said: I used the script posted on the first page (this), the anime and manga merged one. But I get this error: Parse error: parse error in C:xampphtdocssigindex4.php on line 62 Does anyone know what to do? in fact there is missing a ) if ( in_array($status[$i], array("Watching", "Re-Watching", "Reading", "Re-Reading") ) { if ( in_array($status[$i], array("Watching", "Re-Watching", "Reading", "Re-Reading") ) ) { |
Jul 16, 2009 12:23 PM
#50
Niroko said: ]should be changed to if ( in_array($status[$i], array("Watching", "Re-Watching", "Reading", "Re-Reading") ) ) { Oh. Hahaha, such a small mistake. I guess I didn't look closely enough. EDIT: Can anyone tell me how to not display Plan to Watch/- Read? |
V3gasJul 16, 2009 1:16 PM
More topics from this board
» Scripted Signature ShowcaseKHobbits - Jul 9, 2008 |
23 |
by KHobbits
»»
Oct 21, 2014 6:42 PM |
|
» MAL Signature DesignerApocist - Mar 11, 2014 |
10 |
by Apocist
»»
Aug 6, 2014 3:01 PM |
|
» iSignaturei906 - Dec 11, 2009 |
9 |
by USKurosaki
»»
Apr 10, 2013 8:40 PM |
|
» Animated Signatureskoleare - Jan 3, 2013 |
1 |
by Rezurrekt
»»
Jan 10, 2013 4:13 PM |
|
» List of Free PHP Hosts that meet script requirementssaka - Jun 8, 2010 |
31 |
by saka
»»
Oct 26, 2012 2:58 AM |