[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> submitnews.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/submitnews.php,v $
  14  |     $Revision: 1.18 $
  15  |     $Date: 2007/02/13 23:36:01 $
  16  |     $Author: e107coders $
  17  +----------------------------------------------------------------------------+
  18  */
  19  require_once ("class2.php");
  20  require_once(HEADERF);
  21  
  22  if (!isset($pref['subnews_class']))
  23  {
  24      $pref['subnews_class'] = "0";
  25  }
  26  if (!check_class($pref['subnews_class']))
  27  {
  28      $ns->tablerender(NWSLAN_12, NWSLAN_11);
  29      require_once(FOOTERF);
  30      exit;
  31  }
  32  
  33  $author_name = $tp->toDB($_POST['author_name']);
  34  $author_email = $tp->toDB(check_email($_POST['author_email']));
  35  
  36  if (isset($_POST['submit']))
  37  {
  38      $user = (USER ? USERNAME : $author_name);
  39      $email = (USER ? USEREMAIL : $author_email);
  40  
  41      if ($user && $email)
  42      {
  43          $ip = $e107->getip();
  44          $fp = new floodprotect;
  45          if ($fp->flood("submitnews", "submitnews_datestamp") == false)
  46          {
  47              header("location:" . e_BASE . "index.php");
  48              exit;
  49          }
  50          $itemtitle = $tp->toDB($_POST['itemtitle']);
  51          $item = $tp->toDB($_POST['item']);
  52          $item = str_replace("src=&quot;e107_images", "src=&quot;" . SITEURL . "e107_images", $item);
  53          // Process File Upload    =================================================
  54          if ($_FILES['file_userfile'] && $pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS)
  55          {
  56              require_once(e_HANDLER . "upload_handler.php");
  57              $uploaded = file_upload(e_IMAGE . "newspost_images/");
  58              $file = $uploaded[0]['name'];
  59              $filetype = $uploaded[0]['type'];
  60              $filesize = $uploaded[0]['size'];
  61              $fileext = substr(strrchr($file, "."), 1);
  62  
  63              if (!$pref['upload_maxfilesize'])
  64              {
  65                  $pref['upload_maxfilesize'] = ini_get('upload_max_filesize') * 1048576;
  66              }
  67  
  68              if ($uploaded && $fileext != "jpg" && $fileext != "gif" && $fileext != "png")
  69              {
  70                  $message = SUBNEWSLAN_3;
  71                  $error = true;
  72              }
  73  
  74              if ($filesize > $pref['upload_maxfilesize'])
  75              {
  76                  $message = SUBNEWSLAN_4;
  77                  $error = true;
  78              }
  79  
  80              if (!$error)
  81              {
  82                  // $numberoffiles = count($uploaded);
  83                  $today = getdate();
  84                  $newname = USERID . "_" . $today[0] . "_" . str_replace(" ", "_", substr($itemtitle, 0, 6)) . "." . $fileext;
  85                  if ($file && $pref['subnews_resize'])
  86                  {
  87                      require_once(e_HANDLER . "resize_handler.php");
  88                      $rezwidth = $pref['subnews_resize'];
  89                      if (!resize_image(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname, $rezwidth))
  90                      {
  91                          rename(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname);
  92                      }
  93                  } elseif ($file)
  94                  {
  95                      rename(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname);
  96                  }
  97              }
  98          }
  99  
 100          if ($error == false)
 101          {
 102              if (!file_exists(e_IMAGE . "newspost_images/" . $newname))
 103              {
 104                  $newname = "";
 105              }
 106              $sql->db_Insert("submitnews", "0, '$user', '$email', '$itemtitle', '".intval($_POST['cat_id'])."','$item', '" . time() . "', '$ip', '0', '$newname' ");
 107              $edata_sn = array("user" => $user, "email" => $email, "itemtitle" => $itemtitle, "catid" => intval($_POST['cat_id']), "item" => $item, "ip" => $ip, "newname" => $newname);
 108              $e_event->trigger("subnews", $edata_sn);
 109              $ns->tablerender(LAN_133, "<div style='text-align:center'>" . LAN_134 . "</div>");
 110              require_once(FOOTERF);
 111              exit;
 112          }
 113          else
 114          {
 115              require_once(e_HANDLER . "message_handler.php");
 116              message_handler("P_ALERT", $message);
 117          }
 118      }
 119  }
 120  
 121  if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); }
 122  
 123  $text = "<div style='text-align:center'>
 124      <form id='dataform' method='post' action='" . e_SELF . "' enctype='multipart/form-data' onsubmit='return frmVerify()'>\n
 125      <table style='".USER_WIDTH."' class='fborder'>";
 126  if (!USER)
 127  {
 128      $text .= "<tr>\n<td style='width:20%' class='forumheader3'>" . LAN_7 . "</td>\n<td style='width:80%' class='forumheader3'>\n<input class='tbox' type='text' name='author_name' size='60' value='$author_name' maxlength='100' />\n</td>\n</tr>\n<tr>\n<td style='width:20%' class='forumheader3'>" . LAN_112 . "</td>\n<td style='width:80%' class='forumheader3'>\n<input class='tbox' type='text' name='author_email' size='60' value='$author_email' maxlength='100' />\n</td>\n</tr>";
 129  }
 130  $news_aj = new textparse();
 131  // Added by Barry
 132  if (!empty($pref['news_subheader']))
 133  {
 134      $text .= " <tr>
 135      <td colspan='2' class='forumheader3'>" . $news_aj->tpa($pref['news_subheader']) . "</td>
 136      </tr>";
 137  }
 138  // end barry
 139  $text .= " <tr>
 140      <td style='width:20%' class='forumheader3'>" . NWSLAN_6 . ": </td>
 141      <td style='width:80%' class='forumheader3'>";
 142  if (!$sql->db_Select("news_category"))
 143  {
 144      $text .= NWSLAN_10;
 145  }
 146  else
 147  {
 148      $text .= "
 149      <select name='cat_id' class='tbox'>";
 150      while (list($cat_id, $cat_name, $cat_icon) = $sql->db_Fetch())
 151      {
 152          $sel = ($_POST['cat_id'] == $cat_id) ? "selected='selected'" : "";
 153          $text .= "<option value='$cat_id' $sel>" . $tp->toHTML($cat_name,FALSE,"defs") . "</option>";
 154      }
 155      $text .= "</select>";
 156  }
 157  $text .= "</td>
 158      </tr><tr>
 159      <td style='width:20%' class='forumheader3'>" . LAN_62 . "</td>
 160      <td style='width:80%' class='forumheader3'>
 161      <input class='tbox' type='text' id='itemtitle' name='itemtitle' size='60' value='$itemtitle' maxlength='200' style='width:90%' />
 162      </td>
 163      </tr>";
 164  if ($pref['subnews_htmlarea'])
 165  {
 166      require_once(e_HANDLER . "tiny_mce/wysiwyg.php");
 167      echo wysiwyg("item");
 168  }
 169  else
 170  {
 171  require_once(e_HANDLER."ren_help.php");
 172  }
 173  
 174  $insertjs = (!$pref['subnews_htmlarea'])?"rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'" : "rows='25' ";
 175  $text .= "
 176  
 177      <tr>
 178      <td style='width:20%' class='forumheader3'>" . LAN_135 . "</td>
 179      <td style='width:80%' class='forumheader3'>
 180      <textarea class='tbox' id='item' name='item'  cols='80'  style='max-width:95%' $insertjs></textarea>";
 181  if (!$pref['subnews_htmlarea'])
 182  {
 183    $text .= display_help("helpb", 'news');
 184  }
 185  $text .= "    </td>
 186      </tr>\n";
 187  if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS)
 188  {
 189      $text .= "
 190          <tr>
 191          <td style='width:20%' class='forumheader3'>" . SUBNEWSLAN_5 . "<br /><span class='smalltext'>" . SUBNEWSLAN_6 . "</span></td>
 192          <td style='width:80%' class='forumheader3'>
 193          <input class='tbox' type='file' name='file_userfile[]' style='width:90%' />
 194          </td>
 195          </tr>\n";
 196  }
 197  
 198  $text .= "
 199      <tr>
 200      <td colspan='2' style='text-align:center' class='forumheader'>
 201      <input class='button' type='submit' name='submit' value='" . LAN_136 . "' />
 202      </td>
 203      </tr>
 204      </table>
 205      </form>
 206      </div>";
 207  $ns->tablerender(LAN_136, $text);
 208  require_once(FOOTERF);
 209  function headerjs()
 210  {
 211      $script = "<script type=\"text/javascript\">
 212  		function frmVerify()
 213          {
 214              if(document.getElementById('itemtitle').value == \"\")
 215              {
 216                  alert('" . SUBNEWSLAN_1 . "');
 217                  return false;
 218              }
 219              if(document.getElementById('item').value == \"\")
 220              {
 221                  alert('" . SUBNEWSLAN_2 . "');
 222                  return false;
 223              }
 224          }
 225          </script>";
 226      return $script;
 227  }
 228  
 229  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7