zombie1982
Member
Hello,
I modified a php script for my RL and want to share it here as a Tut:
This button converts all .nfo files in "/files" directory to .png to "/files"
Add 2 .php files and this Fontfile to root of RL:
nfo2png.php
Zippyshare.com - nfo2png.php
nfotest.php
Zippyshare.com - nfotest.php
* for LastLine you can add your nic or what ever you want...or leave it blanck like :
buildNFO($f, "", "000000", basename($Images[$i]));
Then create a button in RL to run it in new window:
Add in "\templates\plugmod\main.php":
Hope this is usefull for someone :fly:
I modified a php script for my RL and want to share it here as a Tut:
This button converts all .nfo files in "/files" directory to .png to "/files"
Add 2 .php files and this Fontfile to root of RL:
nfo2png.php
Zippyshare.com - nfo2png.php
Code:
<?php
function buildNFO($nfotext, $footer = "", $fg = "000000", $file_name = 'new_image', $path = 'files/') {
// Write Headers for PNG
header("Content-Type: image/png");
header("Content-Disposition: inline; filename=\"nfo2png.sf.net.png\"");
if(!strlen($nfotext)) $nfotext = "Empty String submitted.";
$nfo = explode("\n", $nfotext);
// Load the Bitmap-Font
$fnt = imageloadfont("nfo2pngfont");
// Check for empty lines
$fillers = strlen($nfo[1])+strlen($nfo[3])+strlen($nfo[5])+strlen($nfo[7])<9?1:0;
$nxo = array();
$xmax = 0;
// Reformat each line
foreach($nfo as $key=>$line){
$line = chop($line);
if($xmax < strlen($line)) $xmax = strlen($line);
if($fillers and ($key & 1)) continue;
array_push($nxo,$line);
}
// Show footer
if(strlen($footer)) {
array_push($nxo,"");
$fill = str_repeat(" ",($xmax - strlen($footer)>>1));
array_push($nxo,$fill.$footer);
}
// Linecount
$ymax = count($nxo);
// Set foreground color
$color = array(0, 0, 0);
if(strlen($fg) == 6) {
$color[0] = intval(substr($fg,0,2), 16);
$color[1] = intval(substr($fg,2,2), 16);
$color[2] = intval(substr($fg,4,2), 16);
}
// Render NFO
$im = ImageCreate($xmax*8,$ymax*16);
ImageInterlace($im,1);
$background_color = ImageColorTransparent($im, ImageColorAllocate ($im, 254, 254, 126));
$text_color = ImageColorAllocate ($im, $color[0], $color[1], $color[2]);
foreach($nxo as $y=>$line)
ImageString($im, $fnt, 0, $y*16, $line, $text_color);
ImagePNG($im, $path . $file_name . '.png' );
}
?>
nfotest.php
Zippyshare.com - nfotest.php
Code:
<?php
$Images=glob("files/*.nfo");
print_r($Images);
$pagestr=$_SERVER['SERVER_ADDR'];
if($pagestr)
{
include("nfo2png.php");
for($i=0;$i<count($Images);$i++)
{ print_r($Images[$i]);
$f = file($Images[$i]);
$f = implode("",$f);
buildNFO($f, "[COLOR=#ff0000][B]LastLine[/B][/COLOR]", "000000", basename($Images[$i]));
}
}
else echo "No Result";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NFO-Test</title>
</head>
<body bgcolor="white">
<img src="nfotest.php?1">
</body>
</html>
buildNFO($f, "", "000000", basename($Images[$i]));
Then create a button in RL to run it in new window:
Add in "\templates\plugmod\main.php":
Code:
<input class="button-auto" type="button" value="<?php echo lang(334); ?>" onclick="window.open('audl.php');return false;" />
<?php
}
?>
<br />
<?php
if (!$options['auto_upload_disable']) {
?>
<input class="button-auto" type="button" value="<?php echo lang(335); ?>" onclick="window.open('auul.php');return false;" />
<?php
}
?>
<br />
<input class="button-auto" type="button" value="MTN" onclick="window.open('mtn.php');return false;" />
<br />
[COLOR=#ff0000]<input class="button-auto" type="button" value="NFO2PNG" onclick="window.open('nfotest.php');return false;" /> [/COLOR]
<br />
Hope this is usefull for someone :fly: