New
Oct 6, 2009 8:27 AM
#101
well, all these scripts will automatically download one or more of the rss feeds from the bottom left of your profile: ...and then they will parse out the relevant information to get things like the titles, episode numbers, and status... then it's just a matter of taking that info and putting it into an image. I've tried to divide my script into these three major tasks, where each line is heavily commented to explain what each line does. For example, to get the watching statuses formatted the same as yours ("watching X of X episodes") you would look for the area marked "FORMAT THE STATUS VALUES" and change it to something like this: // FORMAT THE STATUS VALUES - you can change the format as you like ...or if you're using the anime/manga merged version, substitute episodes in that red line with $units[$i] and it will display 'episodes' or 'chapters' depending on the type. ;) If you have a question about a specific area, don't hesitate to ask in this thread. |
Oct 6, 2009 9:48 AM
#102
Oct 13, 2009 9:08 AM
#103
made a very minor update... just a wording change on the error message in check_cache when the cache folder is not configured properly. die("Could not write to cache; please make sure the cache directory exists and is writable by all (777 permissions).\n\$cachedpath = {$cachedpath}"); |
Oct 14, 2009 1:50 PM
#104
cailoli said: Hmmm... did you comment out the two lines of the cache thing? //$cachedpath = "cache/sig.png"; // a temporary copy of your signature will be stored here at the end //check_cache(10); // time to cache signature in minutes, comment out this line for testing but put it back afterward! Or made a directory called cache. nonono. Just the check cache line, and btw I have something to help you!!!! :D saka said: made a very minor update... just a wording change on the error message in check_cache when the cache folder is not configured properly. die("Could not write to cache; please make sure the cache directory exists and is writable by all (777 permissions).n$cachedpath = {$cachedpath}"); I have a better way ;) Just replace the whole function check_cache with this: http://pastebin.com/f299efd57 quick view function check_cache($minutes) { global $cachedpath; if ( !( is_writable($cachedpath) or is_writable(dirname($cachedpath)) and !file_exists($cachedpath) ) ) { $rs = @mkdir( cache, '0777' ); @handleError(); if(!$rs) { echo("Folder May have been created. Please refresh"); echo($php_errormsg); die(); } } if ( time() - @filemtime($cachedpath) < 60*$minutes ) { header("Content-type: image/png"); echo file_get_contents($cachedpath); exit(0); } } function handleError() { trigger_error('MY ERROR'); } This will automatically create the directory with 777 chmods and purge errors if it exists. I have tested it. --------------- IF YOU CANT GET YOUR SIG TO DISPLAY THE TEXT!!!! DO THIS comment out this line near the top for testing your signature. check_cache(10); // time to cache signature in minutes, comment out this line for testing but put it back afterward! change to //check_cache(10); // time to cache signature in minutes, comment out this line for testing but put it back afterward! ----------------------- Good luck, if you have questions feel free to ask saka or I. |
Caprica6Oct 15, 2009 5:45 PM
Oct 16, 2009 10:24 PM
#105
mushwars said: Just replace the whole function check_cache with... I don't think this is any more likely to work, since mkdir() will also fail if the current directory is not writable (which is about 95% certain not to be since the user would have to do this). It will only work if suPHP is enabled (the minority of *nix servers) or if you're using a shitty windows box since they disregard user permissions by default. |
Nov 17, 2009 10:29 AM
#106
Ehehe...As a php-noob, I have a minor problem... I'm pretty sure I basically set all chmods to 777 and I still get : 'The cache is not writable; please change it to 777 permissions using FTP. $cachedpath = signature/Miku/cache/' as output any idea how to fix this? >.< (I'm using the merged version btw) |
Nov 17, 2009 11:22 AM
#107
I'm not sure how your folder structure is, but the path is relative to where the script is.... so if the script is in the 'signature/Miku' folder, the $cachedpath should just be $cachedpath = 'cache/sig.png'; the filename needs to be in there like above, not just the folder (also don't worry... sig.png will be created by the script as long as the cache folder is writable). |
Nov 17, 2009 11:30 AM
#108
...Omg, thanks x3 ...Next problem is... I can't see text >.< I've put everything on 0 to see if I could see it, but I can't ='( looks like this, atm // draw the text - the template is imagettftext(image, font size, angle, x-pos, y-pos, font color, fontfile, text output, 'c' or 'l' or 'r') imagettftextalign($image,18,0,0,0,$colour,$font,$titles[0],'l'); imagettftextalign($image,18,0,0,0,$colour,$font,$status[0],'l'); imagettftextalign($image,18,0,0,0,$colour,$font,$titles[1],'l'); imagettftextalign($image,18,0,0,0,$colour,$font,$status[1],'l'); ...I feel so noob >.< sorry to bother you! You still rock btw |
kurootetsurooNov 17, 2009 12:09 PM
Nov 17, 2009 12:52 PM
#109
KokoroChan said: I've put everything on 0 to see if I could see it, but I can't ='( if you put the text at 0,0, you probably won't see anything... maybe 1 pixel or two at the top left. Did you see anything with the default values, which are closer to the center? imagettftextalign($sigimage,14,0,250,36,$colour,$font,$titles[0],'c'); imagettftextalign($sigimage,11,0,250,50,$colour2,$font,$status[0],'c'); imagettftextalign($sigimage,14,0,250,76,$colour,$font,$titles[1],'c'); imagettftextalign($sigimage,11,0,250,90,$colour2,$font,$status[1],'c'); The coordinates start with (0,0) on the top left of the image, and increase the farther right and down you go. The text is oriented with the coordinates as the bottom left corner of the text..... so most likely the text is just off-screen, but there are other things that can cause text not to appear. edit: the default looks something like this: |
sakaNov 17, 2009 12:56 PM
Nov 17, 2009 1:30 PM
#110
Eh. I tried with the default settings and still couldn't see anything. >.< EDIT: I rescripted it and now it works =D Thanks for your help saka ^^ |
kurootetsurooNov 17, 2009 2:06 PM
Dec 2, 2009 4:06 PM
#111
Nice script. I lost my script files for bard's script so I'll be using this now. Thanks ^^ |
Dec 3, 2009 2:39 AM
#112
i actually have a little problem, my overlay images won't show up how many times i tried to ;w; i was double checking the names but it was the right name so my sig became like this now: and here's my code: http://pastebin.com/f296193d5 please see it if i do something wrong, thanks in advance |
Dec 3, 2009 2:47 AM
#113
@suzuka_pew find this part // OVERLAY ANOTHER IMAGE over the font and background (optional) //overlay_image("overlay.PNG"); and remove those lines I've put in red. Your overlay image should also have this name : overlay.PNG And the right thread for this question is here ;) http://myanimelist.net/forum/?topicid=7256&show=0 |
Dec 3, 2009 11:37 AM
#114
actually, if the question is about my script specifically, I do prefer it's posted here. Meri is correct about the // ... I commented it out because it isn't needed most times. Perhaps I should make a note there since others have gotten confused. also, be carefuly with CAPITAL and lowercase in your filenames.... on unix systems (which most webservers are) the case is very important as 'image.png' and 'image.PNG' can be completely different files. The script will stop with an error if it can't find the file, though. |
Dec 3, 2009 4:25 PM
#115
The cache wasn't generated properly even after few reloads. Here's the generated sig |
Dec 3, 2009 6:11 PM
#116
Sylpheed said: The cache wasn't generated properly can you be more specific? ...just that the image was not generated? there does seem to be a generated image but maybe you're having other troubles... make sure the cache directory is writable by the server (777) as well as the file, if it exists. Also, make sure the path in $cachedpath matches to the file (case sEnSiTiVe). The cache will update if the php is loaded and 10 minutes has passed since the cache image was modified. if that doesn't fix it, then post your code to pastebin or codepad so I can peek at it. |
Dec 3, 2009 9:11 PM
#117
Meri said: @suzuka_pew find this part // OVERLAY ANOTHER IMAGE over the font and background (optional) //overlay_image("overlay.PNG"); and remove those lines I've put in red. Your overlay image should also have this name : overlay.PNG And the right thread for this question is here ;) http://myanimelist.net/forum/?topicid=7256&show=0 okay, i have tried it and it works :D thanks meri :3 saka said: also, be carefuly with CAPITAL and lowercase in your filenames.... on unix systems (which most webservers are) the case is very important as 'image.png' and 'image.PNG' can be completely different files. The script will stop with an error if it can't find the file, though. yep, i already aware about that CAPITAL and lowercase filenames :) but thanks for telling it again. |
Dec 4, 2009 9:14 AM
#118
@saka I've already set up the cron and everything. Cache seems fine since it worked. I think this script won't work if cache is not in 777. Anyway, I made sure I did the right thing. I mean the sig is generating without problems. I assume the cache is separated from the generated sig itself since it's in a different directory. Those I posted above were the "cached" one and the one is tagged in www/sig/sig_creator.php It worked after reloading it XD Does this script have other features? I have some free space below XD The one with the php extension is working. |
SylpheedDec 4, 2009 9:17 AM
Dec 4, 2009 10:45 AM
#119
well, whenever the php one is loaded, it will update the cache copy. It might have updated only because you linked to the php one on this page, and when I or other people loaded this forum page, it updated your cache. ;) It could be that your cron job is what isn't configured properly. There is no harm linking directly to the php version of your sig; you just gain 1-3 seconds of speed by using cron and linking to the cached version. |
Dec 5, 2009 8:15 PM
#120
saka said: well, whenever the php one is loaded, it will update the cache copy. It might have updated only because you linked to the php one on this page, and when I or other people loaded this forum page, it updated your cache. ;) It could be that your cron job is what isn't configured properly. There is no harm linking directly to the php version of your sig; you just gain 1-3 seconds of speed by using cron and linking to the cached version. I thought it affects the server load both here and on my site. I have this in my cron: http://etherune.net/sig/auu/sig_creator.php and it's set to 15minutes Should I just set my sig to the php one? |
Dec 5, 2009 11:25 PM
#121
Sylpheed said: I thought it affects the server load both here and on my site. not having a cache at all can be problematic, but it's not setup that way. If you load the php, it will use the modification time of the cached image to know whether it needs a new one or not. Basically it handles it for you... it's just a warning not to comment it out except maybe during testing. ;) Using cron is a separate issue, and not required at all.... if you just point to the php without using cron and your script isn't loaded for a while, then the first person who loads it will have to wait for your server to generate it from scratch which might take a second or two..... where if you were using cron it would have been refreshing the image every X minutes so a copy was always ready. Also, using the cache image directly is more resilient to errors -- like if mal is having rss trouble or your server's php stops working (like 000webhost does when your account is audited). It's handy, but not needed. |
Dec 10, 2009 3:46 AM
#123
What should I do to make this output posible? on-hold at 8 of 50 episodes or dropped at 8 of 50 episodes. Basically I want to add to the status, currents, units & totals. Can this be done with a if statement? something like } else if ($status[$i] == "On Hold") { $status[$i] = "on-hold at $current[$i] of $totals[$i] $units[$i]"; |
Dec 10, 2009 8:22 AM
#124
I think that my comment in the script is incorrect; it is actually "On-Hold" in the rss and not "On Hold", so the only thing you need to do is convert to lowercase, and strtolower() is already in my example script. You can certainly use if statements like that also, and that's exactly how you want to work with different statuses. Here's how I would do it: // FORMAT THE STATUS VALUES - you can change the format as you like ...or if you want completed to not show episodes/chapters either: // FORMAT THE STATUS VALUES - you can change the format as you like |
Dec 10, 2009 9:04 AM
#125
Thank you saka. You really are amaze <3 I tried it and as you can see it works just great. The second version is if I'm getting this correctly is to make the output just: ''completed'' and not ''completed x number of x episodes'' right? I think that's even better, since you really dont need for numbers of episodes to show when you have finished something. Thanks again <3 |
Dec 11, 2009 12:00 AM
#127
Meri said: The second version is if I'm getting this correctly is to make the output just: ''completed'' and not ''completed x number of x episodes'' right? yep Sylpheed said: How bout "Update xx [time] ago?" hmm... well, use the anime/manga merged version (since it parses the timestamps). You'll need a function to generate a nice human-readable string, so put this somewhere near the bottom before ?>.... function nicetime($date) ...and now you can put something like this into your format loop: // let's go through the whole list and format it how we want If you copy and paste the above function and replace that section, you should get output kinda like this: It's not necessary to put the "time ago" in the status either like I did here... you can just put $ago[$i] into imagettftextalign() lower in the code. It might need a little tweaking if time zones on the server are an issue, but I hope that the idea isn't too difficult to follow... the script parses the timestamps from mal out of the rss feed, and then the nicetime() function above compares to the current server time to make something readable. Also, keep in mind that the "time ago" is from whatever time the image was last updated, which isn't always immediate. I think it's just fine to be accurate to within five minutes or so though. ;) |
Dec 11, 2009 8:37 AM
#129
Dec 12, 2009 1:02 PM
#130
Dec 12, 2009 7:16 PM
#131
Dec 12, 2009 8:46 PM
#132
saka said: find the section of code that looks similar to the gray parts, and copy/paste the green bits to overwrite the rest. It's around line 70 or so. It says Bad data in my sig >< I overwrote all the green one after the line: $titles[$i] = textlimit($titles[$i],20); and before the lowercase/uppercase function $titles[$i] = textlimit($titles[$i],20); // calculate time passed since each update $ago[$i] = nicetime($timestamps[$i]); // remove 's' from end of units for display $units[$i] = preg_replace('/s$/', '', $units[$i]); // replace 'ing' with 'ed' and generally fix up all the statuses to word them properly $status[$i] = strtr($status[$i], array('Plan to Watch'=>'Planning to watch since','Plan to Read'=>'Planning to read since','Watching'=>'Watched','Reading'=>'Read','Rewatching'=>'Rewatched','On-Hold'=>'Put on hold','Reading On Hold'=>'Put on hold') ); // FORMAT THE STATUS VALUES - you can change the format as you like if ( preg_match('/(Plan|Completed|Hold)/i',$status[$i]) ) { // these statuses don't need episode numbers $status[$i] = "$status[$i] $ago[$i]"; } else { $status[$i] = "$status[$i] $units[$i] $current[$i] $ago[$i]"; } //$status[$i] = strtolower($status[$i]); // make all the statuses lowercase } I've also added the ago function before ?> |
SylpheedDec 12, 2009 8:50 PM
Dec 12, 2009 8:55 PM
#133
there's probably some small mistake that's making php generate a warning before or after the image data (and hence corrupting the image). post the full code to pastebin or codepad and i'll have a look at it... can be as simple as a stray space after the ?> or sometimes it happens if you switch to utf-8 instead of ansi in your text editor. |
Dec 14, 2009 9:24 AM
#134
Sorry for the delay...here it is http://codepad.org/2MlPSR3Z |
Dec 14, 2009 12:14 PM
#135
just got a chance to test this. I'm not getting any warnings or corrupt data.... though I did forget to post the modified version of the nicetime() function from before. It was always returning "Bad date". I've modified it and put it into your code and i get this: Here's the code, only modified a line and removed the empty lines: http://pastebin.com/m4ffa5402 since you're getting that weird bug in yours, most likely it's a text encoding issue. Make sure it's ANSI and not UTF-8 since sometimes that causes issues. In Notepad++ it can be selected under Format > Encode in ANSI then save again. If you use the Download link on pastebin it will also give it to you as ANSI text. |
Dec 15, 2009 8:33 AM
#136
Thanks it's working now ^^ Can I move it on the next line so it won't collide with the episode update...or that would be another recoding of that block? |
Dec 15, 2009 11:31 AM
#137
sure thing... just download this code and overwrite: http://pastebin.com/m20179ee2 the lines i changed: http://pastebin.com/pastebin.php?diff=m20179ee2 (basically i just took the $ago[$i] out of the status, and made a new imagettftextalign() below the others) |
Dec 17, 2009 8:15 PM
#138
I found a few useful things in your script. In particular, your use of imagettfbox is brilliant. But I couldn't help but notice a few strange things. First and foremost, why use regex on the XML? html_entity_decode or htmlspecialchars_decode might be a better choice here. // now we have to sanitize the information we saved to the buffer (no newlines/tabs and replace xml entities) Seeing "or" is just weird. // FORMAT THE STATUS VALUES - you can change the format as you like Saving it this way saves a lot of space. Echoing the image we just saved as opposed to letting imagepng generate it again trades disk access for generation time. Most likely, both are cached. However, I trust my OS's disk I/O driver to cache it more than I trust PHP/GD. // finally, let's output our pretty signature image to the browser Shaved off a trim and made it less confusing. "strlen($a) > $b ? ...$a... : $a" should never really exist. // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) Also, there's a silly forum bug that makes me lose my slashes when I preview my message. |
Dec 17, 2009 9:34 PM
#139
raylu said: I found a few useful things in your script. In particular, your use of imagettfbox is brilliant. But I couldn't help but notice a few strange things. First and foremost, why use regex on the XML? html_entity_decode or htmlspecialchars_decode might be a better choice here. I would have used html_entity_decode but strtr is faster, and it saves me a line of code without added confusion. I know that I cannot expect more than these entities, since those are the only ones xml requires encoded, and I was actually the one who told Xinil to encode them so I don't expect that to change. raylu said: Seeing "or" is just weird. I'm more used to || too, but part of this is to get users new to php exposed to it so might as well use the plain english boolean operators. Doesn't really matter... it's only preference. raylu said: Saving it this way saves a lot of space. Echoing the image we just saved as opposed to letting imagepng generate it again trades disk access for generation time. Most likely, both are cached. However, I trust my OS's disk I/O driver to cache it more than I trust PHP/GD. // finally, let's output our pretty signature image to the browser The image should still be in memory, where the one we "saved" may have failed because many people setting these up don't know how to chmod... which is the reason for the @. I know it's setup to fail now anyway when you do check_cache() but I don't see a big difference. raylu said: Shaved off a trim and made it less confusing. "strlen($a) > $b ? ...$a... : $a" should never really exist. // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) yeah, I used a bit of magic there and stuck it in one line... guess I was just trying to reduce line count. raylu said: Also, there's a silly forum bug that makes me lose my slashes when I preview my message. there's an overaggressive content filter on the edit boxes... mal uses a really broken custom bbcode implementation. I've yelled at it many times when posting code. I thought it only strips slashes on edit, though... but maybe not. I've complained about the bbcode and broken post filter before.... you can go post a bug in the support forum though and maybe Xinil will actually pay attention. I suspect strip_slashes is enabled on a server somewhere. |
Dec 17, 2009 10:44 PM
#140
saka said: The image should still be in memory, where the one we "saved" may have failed because many people setting these up don't know how to chmod... which is the reason for the @. I know it's setup to fail now anyway when you do check_cache() but I don't see a big difference. The image is in memory, but that doesn't mean GD is guaranteed to use it instead of regenerating it. The disk cache on a standard webserver environment will, though. It still irks me that regex is being used on XML. |
Dec 17, 2009 10:47 PM
#141
Dec 18, 2009 1:12 PM
#143
oh right lol.... yeah it's poor style I guess but it does the job. Also, I don't really trust mal's xml generation since it tends to occasionally miss entities that break xml_parse(). If it's any consolation, the code I wrote for myself uses xml_parse and grabs the data from an associative array. |
Dec 20, 2009 6:40 PM
#144
Is there a way to change the "completed" status to something like "24/24"? A new sig I'm working on doesn't have space for it :< |
[ |
Dec 20, 2009 6:47 PM
#145
https://pastee.org/sddk8 I'm assuming you don't have room for the other statuses either ("Plan to Watch", "Dropped", "On Hold", etc.) so I just took them out. |
Dec 27, 2009 5:49 AM
#147
Dec 27, 2009 8:17 AM
#148
it looks right aligned to me. It right aligns to the x,y you give.... so that means that x,y will be the bottom right corner of the text. Since it was centered before you'll need to increase the x value to the right side of wherever you want it. Looks like adding about 175px to the x values should work. |
Dec 27, 2009 8:21 AM
#149
That was stupid...I think I'm just sleepy XD I forgot about the x y positioning and thought it was the same as a word processor XD |
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 |