New
May 10, 2011 12:22 PM
#351
May 15, 2011 4:09 PM
#352
saka said: Is there perhaps a sig.png in the directory already, that is not writable? If there is a sig.png there then just delete it and try again. nope. the dir is completely empty. i've never had a successful sig yet. technically i have two servers i'm trying to work this on, but the other one gives me a server error (500) without putting anything in the log, so i figured the one where it's saying cache isn't writable (when it is) is the one i'll be more likely to get working. |
May 15, 2011 5:06 PM
#353
Not sure then... perhaps if you zip up the whole directory and upload it for me I can try to troubleshoot. It sounds server dependent though. I try to make the code as portable as possible, but there are always cases that slip by. Some servers do not compile php with GD or FreeType and will therefore throw errors when trying to work with images at all. The one with the "not writable" error should have those at least, so I hope it can be resolved. Make sure the $cachedpath variable has the correct path, and that the path is writable by the webserver. Some servers will run su_exec so the server actually runs with your username, and I've seen them error out if you chmod the directory (for example justhost.com). Perhaps setting the directory back to the default 755 is worth trying. |
May 18, 2011 3:37 PM
#354
How do I put the anime/manga text in upper case? >: |
May 18, 2011 3:59 PM
#355
Jul 11, 2011 1:28 AM
#356
Jul 11, 2011 1:39 AM
#357
Jul 11, 2011 4:25 AM
#358
Jul 11, 2011 10:46 AM
#359
Well it's too big to use on mal first of all.... so you'll need to make it smaller first (600x140 is the max). I've posted my thumbnail functions in this topic (second post): http://myanimelist.net/forum/?topicid=209829 You'll need to add a bit more logic for each thumbnail to rotate it using imagerotate(). What you'll want to do is make your image above transparent in the thumbnail areas. In the script open or make a blank image just large enough to overlay all three thumbnails, generate and overlay the thumbnails, rotate that whole image 10 degrees or whatever it is, overlay all the thumbnails onto a blank image the same size as your final image, and then finally overlay your hinagiku and film with the transparency over all that so that the thumbnails peek through them. Resize your image first to be 140px high and I can help you with the rest. I've done some very similar signatures before. Somebody made one with the tilted film idea too some time ago. |
Jul 22, 2011 11:35 AM
#360
Jul 22, 2011 12:12 PM
#361
Most people have been using niroko's glow/effect library here: http://myanimelist.net/forum/?topicid=104246 You can just download that file to the same directory, add require('imagettf.adv.php'); at the top, and then follow the example there providing each value the imagettfstroke function needs. If you just need stroke, I can probably whip up a fast function for you. I was also working on an improved glow library a while back that I never quite finished, but works better in some situations. Give me a bit and I'll post some nice stroke code here. |
Jul 22, 2011 12:26 PM
#362
Jul 22, 2011 12:52 PM
#363
alrighty, here ya go: http://codepad.org/jVRTd8QE ^ copy and paste the above function to the bottom of your signature script just before the ?> ...and then just replace your imagettftextalign lines with imagettfstrokealign, adding a stroke color and radius onto the end: imagettftextalign($sigimage,18,0,250,40,$color,$font,$titles[0],'c'); ...becomes... imagettfstrokealign($sigimage,18,0,250,40,$color,$font,$titles[0],'c',0xff0000,10); I didn't feel like doing $strokecolor = imagecolorallocate($sigimage,255,0,0); so I just entered the hex color directly. You can use a variable for it if you wish. |
Jul 22, 2011 3:27 PM
#364
Jul 24, 2011 12:01 AM
#365
Heya. I'm having some problems with your script Saka. I've uploaded all my files and I've updated my user, font name etc but when i try and open the sig.php in my browser it outputs the following errors: Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /home/a1016241/public_html/signature/sig.php on line 191 Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a1016241/public_html/signature/sig.php on line 198 If it's easier i can upload a .zip of my files. Thanks! |
Jul 24, 2011 12:25 AM
#366
Jul 24, 2011 12:32 AM
#367
Jul 24, 2011 12:58 AM
#368
Works fine for me: Try reuploading the font -- maybe it only uploaded partially or something. Otherwise it may be an issue on the server that you cannot fix (php+gd may not have been compiled with freetype support). You might also try using a different font to see if it works on that server. I'm going to bed now but I'll be back in ~8 hours. |
Jul 24, 2011 1:24 AM
#369
Aug 3, 2011 4:29 AM
#370
Dec 28, 2011 4:47 PM
#373
I had to add ./ before font name. Dunno why. |
Jan 10, 2012 11:53 PM
#374
I'm having a problem. I'm using the random signature codes you posted, but I keep getting this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/vhosts/9-k.freeoda.com/signature/randsig.php on line 9 Line 9 said: header('Content-type: image/png'); I'm not sure what's wrong there.. Okay, for some reason it wasn't working earlier, but it works now. I figured it out. Thanks for the codes (and all the help you've indirectly given me!) |
mzkmkbJan 12, 2012 6:35 AM
Jan 11, 2012 12:00 AM
#375
EDIT: Read through the whole thread and found my answer, sorry about that. EDIT @Saka: Could I have a link to the perspective warping/rotation, web2.0-style reflections + photoshop-style blending modes .zip? (Sent you a PM about it too.) EDIT: Oh and Niroko's Glow Effect Library with alignment if you still have that. |
YanofliesJan 11, 2012 1:26 AM
Signature removed. Please follow the signature rules, as defined in the Site & Forum Guidelines. |
Mar 3, 2012 6:18 PM
#376
Does it work with gif images? I changed the output to gif: However, the gif is frozen. Again, it appears sometimes, but mostly I get it: What do I do? Btw, I use freewebhostingarea. |
lihmaoMar 3, 2012 7:34 PM
Jul 3, 2012 12:58 PM
#377
Haven't made a sig in over 3 years... i heard about something about 000webhost... so are they blocking these php scripts now or something? b/c i reactivated my acct and everytime i try to run it 404's. Its the same script i've had before (thank god i kept it zipped)... is it the host thats giving me issues? |
Jul 8, 2012 8:53 AM
#378
I can't get it to work... I get these errors, apparently, it can't load the font. http://ozland.mareko.webatu.com/sig.php <?php /************************************************************************ * saka's minimal signature script - v1.52 (anime/manga merged) * http://myanimelist.net/forum/?topicid=84446 * * 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 3 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, see <http://www.gnu.org/licenses/>. *************************************************************************/ ob_start(); // buffer output to catch php warnings @chdir(dirname(__FILE__)); // corrects environment path (ignore this) // ENTER YOUR USERNAME $user = "Ozland"; // let's configure the cache $cachedpath = "cache/sig.png"; // a temporary copy of your signature will be stored here at the end check_cache(0); // time to cache signature in minutes, you can comment out this line for testing but put it back afterward! // IMPORTANT: YOUR 'cache' DIRECTORY MUST EXIST AND BE WRITABLE ON THE SERVER!!! (chmod 777 or change file properties using FTP) // * By default, the image only updates at most every ten minutes or when you make a change to this script, but there are // times when you might want it to always update (perhaps when trying different backgrounds, fonts or overlays). To disable // the cache, simply set the time to 0 instead of 10 in the check_cache(...) line above. Once your sig is working how you'd // like, MAKE SURE TO PUT IT BACK TO SOMETHING REASONABLE. I do not recommend leaving the cache disabled or setting it for // less than 7 minutes, since too low a setting can bombard MAL with lots of RSS requests and may also piss off your host. // * When you are done, you can set your forum signature to use , and this file // will output your signature image, or you can alternatively link to and // have a cronjob visit the php url occasionally. /////////////////////////////////////////////////////////////////////////////////////////// // LET'S DOWNLOAD THE RSS FEED AND PARSE THE DATA - you should not have to change anything here $animebuffer = download("http://myanimelist.net/rss.php?type=rw&u={$user}"); $mangabuffer = download("http://myanimelist.net/rss.php?type=rm&u={$user}"); if ( !$animebuffer or !$mangabuffer ) die("Could not download RSS feed"); // lets fix the status in the manga feeds so they make sense, and so we can differentiate from anime (silly Xinil) $mangabuffer = strtr($mangabuffer, array('>Plan to Watch'=>'>Plan to Read','>Watching'=>'>Reading','>Rewatching'=>'>Re-Reading','>On-Hold'=>'>Reading On Hold','>Completed'=>'>Finished Reading') ); // easiest to parse if we just merge the feeds together and parse all at once $buffer = $animebuffer . $mangabuffer; // sanitize the information we saved to the buffer (no newlines/tabs and replace xml entities) $buffer = strtr($buffer, array("n" => '', "r" => '', "t" => '', '<' => '<', '>'=>'>', '&' => '&', '"' => '"', '''=>"'") ); // these lines just extract the anime title and status information into $titles[] and $status[] arrays, plus other info preg_match_all("/<item><title>([^<]*) - ([^<]*?)</title>/i", $buffer, $titlematches); preg_match_all("/<description>([^<]*) - ([d?]+) of ([d?]+) ([^<]*)</description>/i", $buffer, $statusmatches); preg_match_all("/<pubDate>([^<]*)</pubDate>/i", $buffer, $timematches); preg_match_all("@<link>https?://(?:www.)?myanimelist.net/(anime|manga)/(d+)/[^<]*</link>@i", $buffer, $linkmatches); $titles = $titlematches[1]; // $titles is now an array of titles $status = $statusmatches[1]; // $status is now an array of statuses $current = $statusmatches[2]; // $current is now an array of all the current episodes/chapters $totals = $statusmatches[3]; // $totals is now an array of the total number of episodes in each series $units = $statusmatches[4]; // $units is now an array of 'episode(s)' or 'chapter(s)' $timestamps = $timematches[1]; // $timestamps is now an array of dates watched/read $types = $linkmatches[1]; // $types is now an array containing the type ('anime' or 'manga') $subtypes = $titlematches[2]; // $subtypes now has the detailed type if you want it ('TV','Movie','Manga','Novel',...) $ids = $linkmatches[2]; // $ids is now an array containing the unique numeric mal series id // sort all of the arrays by the timestamps, so that the most recent entries are first $timestamps = array_map('strtotime',$timestamps); // converts to numeric unix timestamps array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units,$types,$subtypes,$ids); // LET'S FORMAT EACH UPDATE ONE AT A TIME HOWEVER WE WANT for($i = 0; $i < count($titles); $i++) { // FORMAT THE TITLE VALUES // limit the titles to 35 characters; adjust this to your needs $titles[$i] = textlimit($titles[$i],35); // FORMAT THE TIME VALUES // Default is something like 'Mon 12:00pm' - see http://php.net/manual/en/function.date.php $times[$i] = date('D h:ia',$timestamps[$i]); // FORMAT THE UNITS (episodes/chapters/volumes) $units[$i] = strtr( $units[$i], array( 'episodes' => 'ep.', 'chapters' => 'ch.', 'volumes' => 'vol.' )); // FORMAT THE STATUS VALUES - you can change the format as you like for each // do not change the values on the left, only put your desired status on the right // you can add special array values as desired (for example "$current[$i]/$totals[$i] $units[$i]" becomes "2/13 episodes") // be careful of unclosed quotes, and every substitution needs a comma except the last! $status[$i] = strtr( $status[$i], array( "Plan to Watch" => "Plan to Watch", "Plan to Read" => "Plan to Read", "Watching" => "Just watched $units[$i] $current[$i]", "Reading" => "Reading at $units[$i] $current[$i]/$totals[$i]", "Rewatching" => "Rewatched $units[$i] $current[$i]", "Re-Reading" => "Re-reading $units[$i] $current[$i]", "On-Hold" => "On Hold at $units[$i] $current[$i]/$totals[$i]", "Reading On Hold" => "Reading On Hold", "Completed" => "Completed", "Finished Reading" => "Finished Reading", "Dropped" => "Dropped" )); } /////////////////////////////////////////////////////////////////////////////////////////// // LET'S START GENERATING THE SIGNATURE IMAGE $sigimage = open_image("background.png"); // load your background image // WRITE THE TEXT ONTO THE IMAGE $font = 'font.ttf'; // if you use another font, make sure you copy the *.ttf file into the same directory // let's define a font color - the last four arguments are the red, green, blue, and alpha // (so 0,0,0,0 = solid black and 255,255,255,70 = semi-transparent white) $color = imagecolorallocatealpha($sigimage,255,255,0,0); $color2 = imagecolorallocatealpha($sigimage,230,230,230,0); // draw the text - the template is imagettftextalign(image, font size, angle, x-pos, y-pos, font color, fontfile, text output, 'c' or 'l' or 'r') imagettftextalign($sigimage,18,0,250,40,$color,$font,$titles[0],'c'); imagettftextalign($sigimage,14,0,250,55,$color2,$font,$status[0],'c'); imagettftextalign($sigimage,18,0,250,83,$color,$font,$titles[1],'c'); imagettftextalign($sigimage,14,0,250,99,$color2,$font,$status[1],'c'); // OVERLAY ANOTHER IMAGE over the font and background (optional); remove the // at the beginning of the line below //overlay_image("overlay.png"); // finally, let's output our pretty signature image to the browser $error = ob_get_clean(); if( !$error ) { // if no errors/warnings header("Content-type: image/png"); imagepng($sigimage); imagepng($sigimage, $cachedpath); // try to save a copy of our signature to the cache location we set earlier } else echo $error; /////////////////////////////////////////////////////////////////////////////////////////// // Don't modify below here... just a few helping functions that can be called in the above code // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) function textlimit($string, $length=25) { return ( strlen(trim($string)) > $length ? trim( substr(trim($string),0,$length-3) )."..." : $string ); } // textlimitpx($string, $pixels, $font, $size) returns the shortened $string that fits within exactly $pixels width horizontally when using $font and $size function textlimitpx($string, $pixels, $font, $size) { for($k = strlen(trim($string)); $k > 0; $k--) { if (textwidth(textlimit($string,$k), $font, $size) <= $pixels) break; } return textlimit($string,$k); } // textwidth($string, $font, $size) returns the pixel width of the final text with those parameters function textwidth($string, $font, $size) { $box = imagettfbbox($size,0,$font,$string); return $box[2] - $box[0]; } // overlay_image($baseimage,$overlaypath,$x,$y) opens the image at $imagepath and overlays it onto $sigimage at position ($x, $y) // most image types should work, but 24-bit/true color PNG is recommended if you need transparency function overlay_image($overlaypath,$x=0,$y=0) { global $sigimage; $overlay = is_string($overlaypath)?open_image($overlaypath):$overlaypath; // open, or assume opened if non-string imagecopy($sigimage, $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay)); // overlay onto our base image @imagedestroy($overlay); // clean up memory, since we don't need the overlay image anymore } // open_image($path) will load an image into memory so we can work with it, and die with an error if we fail function open_image($path) { $image = @imagecreatefromstring(file_get_contents($path)); if (!$image) die("could not open image ($path) make sure it exists"); imagealphablending($image,true); imagesavealpha($image,true); // preserve transparency return $image; } // check_cache($minutes) returns a cached image and stops execution if $minutes has not passed since the last update function check_cache($minutes) { global $cachedpath; if ( !( is_writable($cachedpath) or is_writable(dirname($cachedpath)) and !file_exists($cachedpath) ) ) die("The cache is not writable; please change it to 777 permissions using FTP.n<br />$cachedpath = {$cachedpath}"); if ( time() - @filemtime($cachedpath) < 60*$minutes and @filemtime(basename($_SERVER['SCRIPT_NAME'])) < @filemtime($cachedpath) ) { header("Content-type: image/png"); echo file_get_contents($cachedpath); exit(0); } } // imagettftextalign() is basically a wrapper for imagettftext() to add the ability to center/right-align text to a point // the $align argument can be 'c' for center, 'r' for right align, or 'l' for left align (default) function imagettftextalign(&$img,$size,$angle,$x,$y,&$c,$font,$string,$align='l') { $box = imagettfbbox($size,$angle,$font,$string); $w = $box[2] - $box[0]; $h = $box[3] - $box[1]; switch (strtolower($align)) { case 'r': $x -= $w; $y -= $h; break; case 'c': $x -= $w/2; $y -= $h/2; break; } imagettftext($img,$size,$angle,$x,$y,$c,$font,$string); } // download() downloads the content at $url and returns the raw string, not including the http header function download($url) { if(function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch,CURLOPT_HEADER,false); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $results = curl_exec($ch); // download! curl_close($ch); } if (!$results) $results = file_get_contents($url); // curl failed, try url_fopen if (!$results) die("Could not download from $url"); // give up return $results; } ?> Edit: Nevermind, it was 000webhost acting again. Thanks for the script :) Edit 2: Is there a way that I can only show the anime updates and not the "Plan To Watch", "Dropped", etc. ? |
OzlandJul 8, 2012 9:26 AM
Jul 8, 2012 9:47 AM
#379
Ranivus said: Yeah 000webhost decided to declare war on signatures, since poorly configured scripts were using a significant amount of their resources. I made a topic with a list of free web hosts, although as you'll see almost all of them are unusable now. The remaining ones are either badly limited or difficult to register. If anybody finds new free hosts that work, please post them there.Haven't made a sig in over 3 years... i heard about something about 000webhost... so are they blocking these php scripts now or something? b/c i reactivated my acct and everytime i try to run it 404's. Its the same script i've had before (thank god i kept it zipped)... is it the host thats giving me issues? Ozland said: Yes, you can remove them from the update array(s) though be careful because the rss feed goes back only 15 updates, and that can cause issues if you have no allowed statuses in those updates. For example, if you add 15 new titles under Plan to Watch, and your script is set to remove them, it will find no updates and fail.Edit 2: Is there a way that I can only show the anime updates and not the "Plan To Watch", "Dropped", etc. ? Understanding this, you can remove it like this.... Find line 72 which looks like this: array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units,$types,$subtypes,$ids); ...and add the code from this post beneath it:http://myanimelist.net/forum/?topicid=84446&show=240#msg8576208 It's actually a hackish way to do it, since you have to make sure every array is included in your lists. It would have been better if I had made all the statuses in a structured way. At the time it seemed better to make them easy to reference (If they were objects or nested arrays you would have $updates[0]->title instead of just $titles[0]). |
sakaJul 9, 2012 9:14 AM
Jul 8, 2012 10:19 AM
#380
Amazing, thank you very much for your anwer, I got it working now. :) |
Jul 16, 2012 5:20 AM
#381
Hello..Today i wanted to create my own Signature and use the custom text and such without Mal standard.i stated working on this 5 hours ago and finaly nearly finished...but now ive given up and thought of asking for help..Ok firstly i am actually completed But when i try get the signature to comeup or generate,it wont show..The webhost i use is Freewebhosting.com and i can view my sig.php and my png file on the browser but when i try add it to my Signature it tells me that it cant find it..Any help would be greatly apreaciated Thank you. Edit: ok well i managed to show an Image but i am abit lost on puting the Information of the List onto the image i have provided.. Edit: The only problem i have is my Sig.php wont generate a picture with the font.. <?php /************************************************************************ * saka's minimal signature script - v1.52 (anime/manga merged) * http://myanimelist.net/forum/?topicid=84446 * * 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 3 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, see <http://www.gnu.org/licenses/>. *************************************************************************/ ob_start(); // buffer output to catch php warnings @chdir(dirname(__FILE__)); // corrects environment path (ignore this) // ENTER YOUR USERNAME $user = "Arcuied"; // let's configure the cache $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, you can comment out this line for testing but put it back afterward! // IMPORTANT: YOUR 'cache' DIRECTORY MUST EXIST AND BE WRITABLE ON THE SERVER!!! (chmod 777 or change file properties using FTP) // * By default, the image only updates at most every ten minutes or when you make a change to this script, but there are // times when you might want it to always update (perhaps when trying different backgrounds, fonts or overlays). To disable // the cache, simply set the time to 0 instead of 10 in the check_cache(...) line above. Once your sig is working how you'd // like, MAKE SURE TO PUT IT BACK TO SOMETHING REASONABLE. I do not recommend leaving the cache disabled or setting it for // less than 7 minutes, since too low a setting can bombard MAL with lots of RSS requests and may also piss off your host. // * When you are done, you can set your forum signature to use , and this file // will output your signature image, or you can alternatively link to and // have a cronjob visit the php url occasionally. /////////////////////////////////////////////////////////////////////////////////////////// // LET'S DOWNLOAD THE RSS FEED AND PARSE THE DATA - you should not have to change anything here $animebuffer = download("http://myanimelist.net/rss.php?type=rw&u={$user}"); $mangabuffer = download("http://myanimelist.net/rss.php?type=rm&u={$user}"); if ( !$animebuffer or !$mangabuffer ) die("Could not download RSS feed"); // lets fix the status in the manga feeds so they make sense, and so we can differentiate from anime (silly Xinil) $mangabuffer = strtr($mangabuffer, array('>Plan to Watch'=>'>Plan to Read','>Watching'=>'>Reading','>Rewatching'=>'>Re-Reading','>On-Hold'=>'>Reading On Hold','>Completed'=>'>Finished Reading') ); // easiest to parse if we just merge the feeds together and parse all at once $buffer = $animebuffer . $mangabuffer; // sanitize the information we saved to the buffer (no newlines/tabs and replace xml entities) $buffer = strtr($buffer, array("\n" => '', "\r" => '', "\t" => '', '<' => '<', '>'=>'>', '&' => '&', '"' => '"', '''=>"'") ); // these lines just extract the anime title and status information into $titles[] and $status[] arrays, plus other info preg_match_all("/<item><title>([^<]*) - ([^<]*?)<\/title>/i", $buffer, $titlematches); preg_match_all("/<description>([^<]*) - ([\d?]+) of ([\d?]+) ([^<]*)<\/description>/i", $buffer, $statusmatches); preg_match_all("/<pubDate>([^<]*)<\/pubDate>/i", $buffer, $timematches); preg_match_all("@<link>https?://(?:www\.)?myanimelist.net/(anime|manga)/(\d+)/[^<]*</link>@i", $buffer, $linkmatches); $titles = $titlematches[1]; // $titles is now an array of titles $status = $statusmatches[1]; // $status is now an array of statuses $current = $statusmatches[2]; // $current is now an array of all the current episodes/chapters $totals = $statusmatches[3]; // $totals is now an array of the total number of episodes in each series $units = $statusmatches[4]; // $units is now an array of 'episode(s)' or 'chapter(s)' $timestamps = $timematches[1]; // $timestamps is now an array of dates watched/read $types = $linkmatches[1]; // $types is now an array containing the type ('anime' or 'manga') $subtypes = $titlematches[2]; // $subtypes now has the detailed type if you want it ('TV','Movie','Manga','Novel',...) $ids = $linkmatches[2]; // $ids is now an array containing the unique numeric mal series id // sort all of the arrays by the timestamps, so that the most recent entries are first $timestamps = array_map('strtotime',$timestamps); // converts to numeric unix timestamps array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units,$types,$subtypes,$ids); // LET'S FORMAT EACH UPDATE ONE AT A TIME HOWEVER WE WANT for($i = 0; $i < count($titles); $i++) { // FORMAT THE TITLE VALUES // limit the titles to 35 characters; adjust this to your needs $titles[$i] = textlimit($titles[$i],35); // FORMAT THE TIME VALUES // Default is something like 'Mon 12:00pm' - see http://php.net/manual/en/function.date.php $times[$i] = date('D h:ia',$timestamps[$i]); // FORMAT THE UNITS (episodes/chapters/volumes) $units[$i] = strtr( $units[$i], array( 'episodes' => 'ep.', 'chapters' => 'ch.', 'volumes' => 'vol.' )); // FORMAT THE STATUS VALUES - you can change the format as you like for each // do not change the values on the left, only put your desired status on the right // you can add special array values as desired (for example "$current[$i]/$totals[$i] $units[$i]" becomes "2/13 episodes") // be careful of unclosed quotes, and every substitution needs a comma except the last! $status[$i] = strtr( $status[$i], array( "Plan to Watch" => "Plan to Watch", "Plan to Read" => "Plan to Read", "Watching" => "Just watched $units[$i] $current[$i]", "Reading" => "Reading at $units[$i] $current[$i]/$totals[$i]", "Rewatching" => "Rewatched $units[$i] $current[$i]", "Re-Reading" => "Re-reading $units[$i] $current[$i]", "On-Hold" => "On Hold at $units[$i] $current[$i]/$totals[$i]", "Reading On Hold" => "Reading On Hold", "Completed" => "Completed", "Finished Reading" => "Finished Reading", "Dropped" => "Dropped" )); } /////////////////////////////////////////////////////////////////////////////////////////// // LET'S START GENERATING THE SIGNATURE IMAGE $sigimage = open_image("Arturia Sig 1a.png"); // load your background image // WRITE THE TEXT ONTO THE IMAGE $font = 'stonehen.ttf'; // if you use another font, make sure you copy the *.ttf file into the same directory // let's define a font color - the last four arguments are the red, green, blue, and alpha // (so 0,0,0,0 = solid black and 255,255,255,70 = semi-transparent white) $color = imagecolorallocatealpha($sigimage,255,255,0,0); $color2 = imagecolorallocatealpha($sigimage,230,230,230,0); // draw the text - the template is imagettftextalign(image, font size, angle, x-pos, y-pos, font color, fontfile, text output, 'c' or 'l' or 'r') imagettftextalign($sigimage,18,0,250,40,$color,$font,$titles[0],'c'); imagettftextalign($sigimage,14,0,250,55,$color2,$font,$status[0],'c'); imagettftextalign($sigimage,18,0,250,83,$color,$font,$titles[1],'c'); imagettftextalign($sigimage,14,0,250,99,$color2,$font,$status[1],'c'); // OVERLAY ANOTHER IMAGE over the font and background (optional); remove the // at the beginning of the line below //overlay_image("overlay.png"); // finally, let's output our pretty signature image to the browser $error = ob_get_clean(); if( !$error ) { // if no errors/warnings header("Content-type: image/png"); imagepng($sigimage); imagepng($sigimage, $cachedpath); // try to save a copy of our signature to the cache location we set earlier } else echo $error; /////////////////////////////////////////////////////////////////////////////////////////// // Don't modify below here... just a few helping functions that can be called in the above code // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) function textlimit($string, $length=25) { return ( strlen(trim($string)) > $length ? trim( substr(trim($string),0,$length-3) )."..." : $string ); } // textlimitpx($string, $pixels, $font, $size) returns the shortened $string that fits within exactly $pixels width horizontally when using $font and $size function textlimitpx($string, $pixels, $font, $size) { for($k = strlen(trim($string)); $k > 0; $k--) { if (textwidth(textlimit($string,$k), $font, $size) <= $pixels) break; } return textlimit($string,$k); } // textwidth($string, $font, $size) returns the pixel width of the final text with those parameters function textwidth($string, $font, $size) { $box = imagettfbbox($size,0,$font,$string); return $box[2] - $box[0]; } // overlay_image($baseimage,$overlaypath,$x,$y) opens the image at $imagepath and overlays it onto $sigimage at position ($x, $y) // most image types should work, but 24-bit/true color PNG is recommended if you need transparency function overlay_image($overlaypath,$x=0,$y=0) { global $sigimage; $overlay = is_string($overlaypath)?open_image($overlaypath):$overlaypath; // open, or assume opened if non-string imagecopy($sigimage, $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay)); // overlay onto our base image @imagedestroy($overlay); // clean up memory, since we don't need the overlay image anymore } // open_image($path) will load an image into memory so we can work with it, and die with an error if we fail function open_image($path) { $image = @imagecreatefromstring(file_get_contents($path)); if (!$image) die("could not open image ($path) make sure it exists"); imagealphablending($image,true); imagesavealpha($image,true); // preserve transparency return $image; } // check_cache($minutes) returns a cached image and stops execution if $minutes has not passed since the last update function check_cache($minutes) { global $cachedpath; if ( !( is_writable($cachedpath) or is_writable(dirname($cachedpath)) and !file_exists($cachedpath) ) ) die("The cache is not writable; please change it to 777 permissions using FTP.\n<br />\$cachedpath = {$cachedpath}"); if ( time() - @filemtime($cachedpath) < 60*$minutes and @filemtime(basename($_SERVER['SCRIPT_NAME'])) < @filemtime($cachedpath) ) { header("Content-type: image/png"); echo file_get_contents($cachedpath); exit(0); } } // imagettftextalign() is basically a wrapper for imagettftext() to add the ability to center/right-align text to a point // the $align argument can be 'c' for center, 'r' for right align, or 'l' for left align (default) function imagettftextalign(&$img,$size,$angle,$x,$y,&$c,$font,$string,$align='l') { $box = imagettfbbox($size,$angle,$font,$string); $w = $box[2] - $box[0]; $h = $box[3] - $box[1]; switch (strtolower($align)) { case 'r': $x -= $w; $y -= $h; break; case 'c': $x -= $w/2; $y -= $h/2; break; } imagettftext($img,$size,$angle,$x,$y,$c,$font,$string); } // download() downloads the content at $url and returns the raw string, not including the http header function download($url) { if(function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch,CURLOPT_HEADER,false); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $results = curl_exec($ch); // download! curl_close($ch); } if (!$results) $results = file_get_contents($url); // curl failed, try url_fopen if (!$results) die("Could not download from $url"); // give up return $results; } ?> |
ArcuiedJul 16, 2012 7:14 AM
Jul 17, 2012 11:55 PM
#382
Um... you should not be using FTP to reference your signature. Even if it weren't password-protected, the PHP environment runs under the HTTP side so the script would only be accessed and not run. The public link to access your script is here, and the error is pretty self-explanatory: http://arturia.orgfree.com/Signature/sig.PHP ...Try to avoid using spaces and special charaters in your image names. Make sure the file names match exactly, and they are case-sensitive. |
Jul 18, 2012 12:21 AM
#383
Ok Thanks ill try it now Edit : Thanks Saka i got it to show..all i got to do is Edit my font and colour and size then im all good...Thanks again |
ArcuiedJul 18, 2012 12:28 AM
Oct 24, 2012 5:40 PM
#384
Small issue here with the script. I realized today it doesn't work anymore. Nothing changed on the server, permissions are still 755, but it doesn't work. No error is given out either, aside from the 504 of the browser. I checked all error logs, but absolutely nothing from the script. Any way to see why isn't it working? |
Oct 24, 2012 7:32 PM
#385
If php doesn't like anything in the script then the script should output a descriptive text error instead of the image. It sounds like your web server's software is complaining instead. A 504 error generally means there is a networking issue with the web server. It's more likely an issue with the server configuration than the script. This script requires there to be open outgoing ports on the server's gateway (router) and depending on how it is configured that could cause a 504 error. Your host may have recently started blocking outgoing traffic (which means the script will fail to download mal's rss feed). There are legitimate reasons to do this to prevent people from using their servers for unsavory stuff (botnets, spam, password harvesting, etc). If you pm me the link to your script and a copy of the source, I can take a look at it to be sure. You might also want to try uploading the script I have in the spoiler here: http://myanimelist.net/forum/?topicid=217409 |
Oct 26, 2012 8:11 AM
#386
saka said: If php doesn't like anything in the script then the script should output a descriptive text error instead of the image. It sounds like your web server's software is complaining instead. A 504 error generally means there is a networking issue with the web server. It's more likely an issue with the server configuration than the script. This script requires there to be open outgoing ports on the server's gateway (router) and depending on how it is configured that could cause a 504 error. Your host may have recently started blocking outgoing traffic (which means the script will fail to download mal's rss feed). There are legitimate reasons to do this to prevent people from using their servers for unsavory stuff (botnets, spam, password harvesting, etc). If you pm me the link to your script and a copy of the source, I can take a look at it to be sure. You might also want to try uploading the script I have in the spoiler here: http://myanimelist.net/forum/?topicid=217409 It was indeed a firewall blocking outbound connections. I sent them a ticket and they added MAL RSS to allowed IPs, so now the script is working properly. Thanks. ^^ |
Feb 27, 2013 7:01 PM
#387
now http://saka.sorams.com/signature.zip can't download. |
Nov 4, 2013 8:14 AM
#388
Heya Again Been awhile since I last needed help haha. Any way I have had smooth sailing for my Sig all this time until now..For some reason it isn't showing my Updates on the Sig anymore..I am aunsure what to do.. If you want details like the Scripts I can Message them afterwards.. Any help would be appreciated thank you. |
Nov 4, 2013 10:19 PM
#389
Crave implemented a new intrusion detection system that is blocking a lot of automated traffic, including not just scripts but services like Taiga and MAL Updater. Until Crave can find some middle ground between security and accessibility, I'm afraid that a lot of signatures and other programs that rely on the API will continue to have these problems. Changes to the code may be required to keep things running smoothly, but I won't post any changes until I verify that next week. |
Nov 5, 2013 3:11 PM
#391
saka said: Crave implemented a new intrusion detection system that is blocking a lot of automated traffic, including not just scripts but services like Taiga and MAL Updater. Until Crave can find some middle ground between security and accessibility, I'm afraid that a lot of signatures and other programs that rely on the API will continue to have these problems. Changes to the code may be required to keep things running smoothly, but I won't post any changes until I verify that next week. So this was the problem. I noticed all of a sudden that my signature was only showing the image, without the list, and was wondering what's wrong. Please keep us updated. |
Dec 14, 2013 2:26 PM
#393
Yeah, I have the same problem. I thought it was a problem on my FTP server, but seems not... Wish I knew how to solve it. My great thanks to saka, who is trying to solve it. :) |
Dec 14, 2013 6:34 PM
#394
There is a whitelist feature implemented now, though I've had some continuing trouble with it. Essentially you set a fixed user agent in the cURL header and it should allow you to get the RSS feeds from MAL. Problem is there is no user agent by default on my script so everyone will require an update. I'll post the needed code changes once it's approved by Crave. |
Dec 28, 2013 8:02 AM
#395
saka said: There is a whitelist feature implemented now, though I've had some continuing trouble with it. Essentially you set a fixed user agent in the cURL header and it should allow you to get the RSS feeds from MAL. Problem is there is no user agent by default on my script so everyone will require an update. I'll post the needed code changes once it's approved by Crave. Hey saka, Any update. I just noticed this was happening to me. I tried updating the script to include the CURL User Agent, but no go. This whitelisting stuff appears to be generally annoying. It looks like they made a poor choice in vendors DDoS protection. Regardless, I'd love to get this working again. I'll assume you submitted your script to their whitelisting form? I'm about to start building my own MAL because of all this BS. |
Jan 4, 2014 3:03 AM
#396
Jan 5, 2014 2:43 AM
#397
Jan 5, 2014 5:14 PM
#398
Jan 21, 2014 9:15 AM
#399
Ok got a little tired of waiting. The issue doesn't just to appear to be with the userAgent, the header seems to try to add cookies as well, if the cookies aren't provided you get redirected to a invalid location.
The 2 cookies seems to be generated each time as well incap_ses_32_81958 = 72dMW7OxwTqD2usirbBxAC2p3lIAAAAAuQtkRU4XDPlxg5dnpUGIlw== and visid_incap_81958 = WQFIoKoISzWPuvUK/Np /i2p3lIAAAAAQUIPAAAAAADARdiAKNpg9OoI0POYtC98 You set a cookie ahead of time to cUrl with curl_setopt($ch, CURLOPT_COOKIE, $cookie'); , but the issue Apo's seeing is if it's possible to grab the cookies first to allow the cUrl to process correctly. |
Jan 21, 2014 7:34 PM
#400
You're not going to have any luck with cookies. It's funny because yesterday I did manage to get it working successfully, though not as Crave advertised it. I requested a whitelisted user agent from Crave to use the API, and tried setting the user agent but had no success in three attempts of contacting them. I did try adding fields as if I was various browsers and also was getting frustrated by the cookies. If you set the appropriate headers with the whitelisted user agent, it does seem to work. I work long hours during the week but I'll post some code as soon as I can. |
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 |