Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Seeking applications ...
Author Message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Tue May 24, 2005 11:48 pm Reply with quote

Anyone help converting the code below into a block?
I have read the 'How To' and can understand the basic principle but it's just not working for me.
Here's the raw code;
Code:


<scr ipt language="JavaScri pt1.1" src="http://www.sophos.com/virusinfo/infofeed/tenalerts.js"></scr ipt>
<scr ipt type="text/javascr ipt" language="JavaScr ipt1.1">

var bgcolour_main     = '#cccccc'
var bgcolour_heading  = '#99cccc'
var text_colour       = '#000000'
var link_colour       = '#000099'
var font_size         = '1'
var font_face         = 'verdana, arial, helvetica, sans-serif'
var count             =  10   // number should be between 1 and 10
var first_column      = 'yes' // 'yes' or 'no'
var cellspacing       = 'yes' // 'yes' or 'no'
var target            = '_new' // '_self' or 'new'

var htmltxt = "";
var font_desc = '<font face="' + font_face + '" size="'
  + font_size + '" color="' + text_colour + '">';
var tmp_count = 0;
   
if (first_column == "no") {
  colspan = 1;
} else {
  colspan = 2;
}

if (cellspacing == "no") {
  cellspacing = 0;
} else {
  cellspacing = 2;


if (count > 0) {
  if (count > 10) {count = 10}
  htmltxt += '\n<table cellpadding="6" cellspacing="'
  + cellspacing + '" border="0" bgcolor="#ffffff">';
  if (count == 1) {
    htmltxt += '\n<tr><td colspan="' + colspan + '" bgcolor="'
    + bgcolour_heading + '">' + font_desc
    + '<b>Latest virus alert</b></font></td></tr>';
  } else {
    htmltxt += '\n<tr><td colspan="' + colspan + '" bgcolor="'
    + bgcolour_heading + '">' + font_desc + '<b>Latest '
    + count + ' virus alerts</b></font></td></tr>';
  }

  for (var i=0; i<tenalerts.length; i+=3) {
    tmp_count++;
    if (tmp_count > count) {
      break;
    } else {
      if (first_column == "no") {
        htmltxt += '\n<tr><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<a href="' + tenalerts[i+2] + '" target="'
        + target + '"><font color="'
        + link_colour + '"><nobr>' + tenalerts[i+1]
        + '</nobr></font></a></font></td></tr>';
      } else { 
        htmltxt += '\n<tr><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<nobr>' + tenalerts[i+0]
        + '</nobr></font></td><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<a href="' + tenalerts[i+2] + '" target="'
        + target + '"><font color="'
        + link_colour + '"><nobr>' + tenalerts[i+1]
        + '</nobr></font></a></font></td></tr>';
      }
    } 
  }
} else {
  document.write
  ("=== Sophos info feed error: Specify value of count > 0 ==="); }


htmltxt += '\n<tr><td colspan="' + colspan + '" bgcolor="'
+ bgcolour_heading + '">' + font_desc
+ 'Source: <a href="http://www.sophos.com" target="'
+ target + '"><font color="' + link_colour
+ '">Sophos</font></a></td></tr>';
htmltxt += '\n<tr><td colspan="' + colspan + '" bgcolor="'
+ bgcolour_heading + '">' + font_desc
+ '<a href="http://www.sophos.com/virusinfo/infofeed/" target="'
+ target + '"><font color="' + link_colour
+ '">Add this info to your website</font></a></td></tr>';
htmltxt += '\n</table>';

document.write(htmltxt);
</scr ipt>
 
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Wed May 25, 2005 7:05 am Reply with quote

Here is one already converted. See if it helps. If not, I can convert this one for you. Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
Guardian2003
PostPosted: Wed May 25, 2005 9:02 am Reply with quote

Downloaded it and had a quick peek at the code - it is simiar to the block I had tried to use so I'll let you know after I upload and try it out - then I can do a compare to see where I went wrong with my 'effort' - thanks mate.
 
Raven
PostPosted: Wed May 25, 2005 9:52 am Reply with quote

This is your original code made into a block
Code:
<?

if ( !defined('NUKE_FILE') ) {
    Header("Location: index.php");
    die();
}

$content = <<<_SOPHOS_
<scr ipt type="text/javascript" language="JavaScript1.1" src="http://www.sophos.com/virusinfo/infofeed/tenalerts.js"></scr ipt>
<scr ipt type="text/javascript" language="JavaScript1.1">

var bgcolour_main     = '#cccccc'
var bgcolour_heading  = '#99cccc'
var text_colour       = '#000000'
var link_colour       = '#000099'

var font_size         = '1'
var font_face         = 'verdana, arial, helvetica, sans-serif'
var count             =  10   // number should be between 1 and 10
var first_column      = 'yes' // 'yes' or 'no'
var cellspacing       = 'yes' // 'yes' or 'no'
var target            = '_new' // '_self' or 'new'

var htmltxt = "";
var font_desc = '<font face="' + font_face + '" size="'
  + font_size + '" color="' + text_colour + '">';
var tmp_count = 0;

if (first_column == "no") {
  colspan = 1;
} else {
  colspan = 2;
}

if (cellspacing == "no") {
  cellspacing = 0;
} else {
  cellspacing = 2;
}

if (count > 0) {
  if (count > 10) {count = 10}
  htmltxt += '<table cellpadding="6" cellspacing="'
  + cellspacing + '" border="0" bgcolor="#ffffff">';
  if (count == 1) {
    htmltxt += '<tr><td colspan="' + colspan + '" bgcolor="'
    + bgcolour_heading + '">' + font_desc
    + '<b>Latest virus alert<\/b><\/font><\/td><\/tr>';
  } else {
    htmltxt += '<tr><td colspan="' + colspan + '" bgcolor="'
    + bgcolour_heading + '">' + font_desc + '<b>Latest '
    + count + ' virus alerts<\/b><\/font><\/td><\/tr>';
  }

  for (var i=0; i<tenalerts.length; i+=3) {
    tmp_count++;
    if (tmp_count > count) {
      break;
    } else {
      if (first_column == "no") {
        htmltxt += '<tr><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<a href="' + tenalerts[i+2] + '" target="'
        + target + '"><font color="'
        + link_colour + '"><nobr>' + tenalerts[i+1]
        + '<\/nobr><\/font><\/a><\/font><\/td><\/tr>';
      } else {
        htmltxt += '<tr><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<nobr>' + tenalerts[i+0]
        + '<\/nobr><\/font><\/td><td bgcolor="' + bgcolour_main + '">'
        + font_desc + '<a href="' + tenalerts[i+2] + '" target="'
        + target + '"><font color="'
        + link_colour + '"><nobr>' + tenalerts[i+1]
        + '<\/nobr><\/font><\/a><\/font><\/td><\/tr>';
      }
    }
  }
} else {
  document.write("=== Sophos info feed error: Specify value of count > 0 ==="); }


htmltxt += '<tr><td colspan="' + colspan + '" bgcolor="'
+ bgcolour_heading + '">' + font_desc
+ 'Source: <a href="http://www.sophos.com" target="'
+ target + '"><font color="' + link_colour
+ '">Sophos<\/font><\/a><\/td><\/tr>';
htmltxt += '<tr><td colspan="' + colspan + '" bgcolor="'
+ bgcolour_heading + '">' + font_desc
+ '<a href="http://www.sophos.com/virusinfo/infofeed/" target="'
+ target + '"><font color="' + link_colour
+ '">Add this info to your website<\/font><\/a><\/td><\/tr>';
htmltxt += '<\/table>';

document.write(htmltxt);
</scr ipt>
_SOPHOS_;
?>
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Seeking applications ...

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©