boastMachine PHP Cross Reference Blogging Systems

Source: /bmc/shout.php - 165 lines - 4284 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*

   4    ===========================

   5  

   6    boastMachine v3.1

   7    Released : Sunday, June 5th 2005 ( 06/05/2005 )

   8    http://boastology.com

   9  

  10    Developed by Kailash Nadh

  11    Email   : mail@kailashnadh.name

  12    Website : http://kailashnadh.name, http://bnsoft.net

  13    Blog    : http://boastology.com/blog

  14  

  15    boastMachine is a free software licensed under GPL (General public license)

  16  

  17    ===========================

  18  */
  19  
  20  
  21  //======================== SHOUT BOX MODULE

  22  
  23      $shout=true; // Enable shout box?

  24  
  25      $shout_blog=false;    // Separate shoutboxes for different blogs?

  26  
  27      $max_posts=10; // Maximum number of posts

  28  
  29      $max_chars=100; // Mazimum number of characters to be allowed in the message

  30      
  31      $smile=true; // Allow smilies?

  32  
  33      $width=140; // Frame width

  34  
  35      $height=200; // Frame height

  36  
  37      $border=1; // Frame border

  38  
  39      $border_color="#AAAAAA";
  40  
  41  
  42  //==================================

  43  
  44      include_once dirname(__FILE__)."/main.php";
  45  
  46      // Check whether shout box is enabled

  47      if(!$shout) {
  48          die($lang['no_shout']);
  49      }
  50  
  51      $shout_file="shout.dat";    // Default shoutbox data file

  52  
  53  
  54      if(defined('BLOG')) {
  55          $the_blog=BLOG;
  56      } else {
  57          if(isset($_REQUEST['blog']) && is_numeric($_REQUEST['blog'])) {
  58              $the_blog=$_REQUEST['blog'];
  59          }
  60      }
  61  
  62  
  63      if($shout_blog) {    // Different shout boxes for different blogs
  64          $shout_file="shout_{$the_blog}.dat";
  65      }
  66  
  67  
  68  // Save a post

  69  if(isset($_POST['action']) && $_POST['action'] == "save" && !empty($_POST['name']) && !empty($_POST['msg'])) {
  70  
  71      $data=@fread(fopen(CFG_ROOT."/inc/vars/$shout_file","r"), filesize(CFG_ROOT."/inc/vars/$shout_file"));
  72      $data=trim($data);
  73      $data=explode("\n",$data);
  74  
  75      $num=count($data);
  76  
  77      // Cut out || from the posted data

  78      $name=trim(str_replace("||","|",$_POST['name']));
  79      $url=trim(str_replace("||","|",$_POST['url']));
  80      $msg=trim(str_replace("||","|",$_POST['msg']));
  81  
  82      $date=time();
  83      $ip=$_SERVER['REMOTE_ADDR']; // The poster's ip

  84  
  85      $msg=str_replace("\n"," ",$msg); // Strip the line breaks

  86  
  87      // Formatted data

  88      $str="$name||$url||$date||$ip||$msg";
  89  
  90      if($num >= $max_posts) {
  91          // If the number of entries exceed the max allowed, remove the oldest entry

  92          unset($data[0]);
  93          $data[]=$str;
  94          $data=implode("\n",$data);
  95      } else {
  96          $data=implode("\n",$data);
  97          $data.="\n".$str;
  98      }
  99  
 100  
 101      // Save the data

 102      $f=fopen(CFG_ROOT."/inc/vars/$shout_file", "w+");
 103      fputs($f,$data);
 104      fclose($f);
 105  
 106  
 107      bmc_Go("shout.php?action=show&blog={$the_blog}"); // Redirect

 108  }
 109  
 110  // ========================

 111  
 112  if(isset($_GET['action']) && $_GET['action']=="add") {
 113      // Show the 'ADD SHOUT' form

 114      include CFG_PARENT."/templates/".CFG_THEME."/shout_box.php";
 115      exit;
 116  }
 117  
 118  
 119  if(isset($_GET['action']) && $_GET['action'] == "show") {
 120  
 121  
 122      $fdata=@fread(fopen(CFG_ROOT."/inc/vars/$shout_file","r"), filesize(CFG_ROOT."/inc/vars/$shout_file"));
 123  
 124      if(!$fdata) { exit; } // no data

 125  
 126      $data=explode("\n",$fdata);
 127      $data=array_reverse($data); // Reverse the order of entries

 128  
 129  
 130      if(!count($data)) { exit; } // there are no posts

 131  
 132  
 133      // Collect the data and parse into an array

 134      for($n=0;$n<=count($data);$n++) {
 135          if(!empty($data[$n])) {
 136  
 137              list($name,$url,$date,$ip,$msg)=explode("||",$data[$n]);
 138              $msg=str_replace("\\n","\n",$msg);
 139  
 140              if(trim($name)) {
 141                  $posts['name'][$n]=bmc_htmlentities($name);
 142                  $posts['url'][$n]=bmc_htmlentities($url);
 143                  $posts['msg'][$n]=bmc_htmlentities(noSlash($msg));
 144                  $posts['date'][$n]=$date;
 145                  $posts['ip'][$n]=$ip;
 146              }
 147          }
 148      }
 149  
 150      include CFG_PARENT."/templates/".CFG_THEME."/shout_box.php";
 151  }
 152  
 153  else {
 154      ?>
 155  
 156      <script type="text/javascript">
 157      <!--
 158          document.writeln("<iframe src=\"<?php echo $bmc_vars['site_url']."/".BMC_DIR; ?>/shout.php?action=show&amp;blog=<?php echo $the_blog; ?>\" name=\"shout\" style=\"border-width: <?php echo $border; ?>px; border-style:solid;  border-color: <?php echo $border_color; ?>;\" frameborder=\"0\" height=\"<?php echo $height; ?>\" width=\"<?php echo $width; ?>\"></iframe>\n");
 159          document.writeln("<br /><a href=\"<?php echo $bmc_vars['site_url']."/".BMC_DIR; ?>/shout.php?action=add&amp;blog=<?php echo $the_blog; ?>\" target=\"shout\"><strong><?php echo $lang['post_post_but']; ?></strong></a><br /><br />\n");
 160      //-->

 161      </script>
 162  
 163      <?php
 164  }
 165      ?>

title

Description

title

Description

title

Description

title

title

Body