due to the fact, that the scripts i found here were all way to heavy for the simple things i wanted it to do i made my own.
It's tiny and neat ^^ ( 70 lines of code...not more) and fits my needs.
The code is nothing special just a small parser, an information preparer and a part to generate the image.
Should overall be perfect for sig-scriping beginners.
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.
Well I tought it will be big failure, but just wanted to try it. On my suprise it works great, minimal code, easy to understand and only 4 files to include. Its really user friendly and does what it suppose to do. Anyway here is my outcome within only 15 min or less:
glad you like the script and am really more glad, that it is easy to handle and understand cause i aimed especially for this point
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.
Very easy to use, this was my first time with php but still managed to get the results I wanted. I only added a few extra lines to get rid of the '- TV' part, plus a limit for the length of the title.
Thanks a lot for the tutorial - I really found it useful!
However, I do have 1 question. I can get my sig to appear but it always seems to vanish after a short period of time. But if I re-update my forum settings in MAL, it re-appears, how do I get it so stop vanishing? It's a pain to have to keep re-updating all the time!
I am a complete doob (my new invention of a word- dumb+noob=doob XP) in PHP, and to tell you the truth this is my very first time actually working with PHP script or cronjobs. So I did my best and successfully got a sig ^_^
You can see it in my sig area (I know it is too big, it is just a trial).
Overall the tut is very easy and very nicely explained. Oh, and thanks for recommending 000webhost.com. I was so glad to see they actually offered cronjobs (coz the other site-cronjobs.com, requires you to pay :-( )
Well, thank you so so so much for this tut and the script <3
Problem, my status info always go under the title no matter how I do it...
I tried the concatenation as suggested by Saka, but same result
<?php
header("Content-Type: image/png");
//generate the image
$image = ImageCreateFromPng("New.png");
imagealphablending($image, true);
imagesavealpha($image, true);
//specify the url that shall be read
$url = "http://myanimelist.net/rss.php?type=rw&u=hiyonomay";
//generate a readable file out of the specified url for our parser to read
$file = @fopen ("$url","r");
//starting and ending strings needed to get the valuable information out of the file
//do not modify this unless you know what you are doing
$title = "<title>";
$ptw = "<description>Plan to Watch -";
$watching = "<description>Watching -";
$completed = "<description>Completed -";
$onhold = "<description>On-Hold -";
$dropped = "<description>Dropped -";
$titleend = "</title>";
$descend ="</description>";
//set variables
$t = 0;
$z = 0;
//rss-parser(Anime-Titles)
if (trim($file) == "") {
echo "Service out of order"; //if we can't create a file MAL is supposed to be down
} else {
$i=0;
//this while-loop will run until the end of the file and read it line per line
//every single read line will be save in an array (in this case $buffer[$i]
while (!feof($file)) {
//1024 bytes per line will be read until the end of file has been reached
//every single line will be saved in the array $buffer
//example: line 1 would be saved in $buffer[0]; line 2 would be saved in $buffer[1] and so on
$buffer[$i] = fgets($file,1024);
$i++;
}
fclose($file);//close the file
}
{
}
//now we have to prepare the information we cached in the $buffer array earlier
//for this we are going to use a for-loop
//this for-loop just extracts the anime_title information
for ($j=1;$j<$i;$j++) {
if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search')
//if the specified string has been found do...
//str_replace('found string', 'replace with', 'replace it in')
//and save it in the variable $ncnt
$ncnt = str_replace($title, "", $cnt);
$end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search')
//once again replace a part of the string and save the outcome in a new arrai
$cutter = str_replace($end,"",$ncnt);
$cutter = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special)$/', '', $cutter);
$titles[$t] = str_replace($end,"",$ncnt);
$t++;
}
}
//this for-loop just extracts the anime_episode information
for ($j=1;$j<$i;$j++) { //episodes
if ($cnt = strstr($buffer[$j],$ptw)) {
$status[$z] = "plan to watch";
$z++;
}
if ($cnt = strstr($buffer[$j],$completed)) {
$status[$z] = "completed";
$z++;
}
if ($cnt = strstr($buffer[$j],$onhold)) {
$status[$z] = "on hold";
$z++;
}
if ($cnt = strstr($buffer[$j],$dropped)) {
$status[$z] = "dropped";
$z++;
}
if ($cnt = strstr($buffer[$j],$watching)) {
$ncnt = str_replace($watching, "", $cnt);
$end2 = strstr($ncnt, $descend);
$status[$z] = str_replace($end2,"",$ncnt);
$z++;
}
}
//begin natemod - extract and format statuses
for ($j=1;$j<$i;$j++) { //episodes
foreach (array($ptw, $completed, $onhold, $dropped, $watching) as $thestatus) {
if ($cnt = strstr($buffer[$j],$thestatus)) {
$status[$z] = preg_replace("/${thestatus} - ([\d?]+) of ([\d?]+) episodes?/", strtolower($thestatus).' @ \1/\2', $cnt);
$z++;
}
}
}
//end natemod
//begin natemod - cut that crap off the end
for ($i = 0; $i < count($titles); $i++) {
$titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special)$/', '', $titles[$i]);
$mergedtitle[0] = $titles[0];
$mergedtitle[1] = $titles[1];
$font1 = 'Swatch.TTF';
//imagecolorexact(image, red(between 0 and 255), green, blue)
//imagecolorexact($image,0,0,0) = black font | imagecolorexact($image,255,255,255) = white font
$colour1 = imagecolorallocate($image,103,116,242);
$colour2 = imagecolorallocate($image,2,14,123);
//imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output)
imagefttext($image,20,-20,0,57,$colour1,$font1,$mergedtitle[1]);