[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_admin/ -> emoticon.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/e107_admin/emoticon.php,v $
  14  |     $Revision: 1.37 $
  15  |     $Date: 2006/12/18 22:24:29 $
  16  |     $Author: e107coders $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  require_once ("../class2.php");
  21  if (!getperms("F")) {
  22      header("location:".e_BASE."index.php");
  23      exit;
  24  }
  25  $e_sub_cat = 'emoticon';
  26  
  27  require_once ("auth.php");
  28  
  29  if(!$sql->db_Count("core", "(*)", "WHERE e107_name = 'emote_default'"))
  30  {
  31      $tmp = 'a:28:{s:9:"alien!png";s:6:"!alien";s:10:"amazed!png";s:7:"!amazed";s:9:"angry!png";s:11:"!grr !angry";s:12:"biglaugh!png";s:4:"!lol";s:11:"cheesey!png";s:10:":D :oD :-D";s:12:"confused!png";s:10:":? :o? :-?";s:7:"cry!png";s:19:"&| &-| &o| :(( !cry";s:8:"dead!png";s:21:"x) xo) x-) x( xo( x-(";s:9:"dodge!png";s:6:"!dodge";s:9:"frown!png";s:10:":( :o( :-(";s:7:"gah!png";s:10:":@ :o@ :o@";s:8:"grin!png";s:10:":D :oD :-D";s:9:"heart!png";s:6:"!heart";s:8:"idea!png";s:10:":! :o! :-!";s:7:"ill!png";s:4:"!ill";s:7:"mad!png";s:13:"~:( ~:o( ~:-(";s:12:"mistrust!png";s:9:"!mistrust";s:11:"neutral!png";s:10:":| :o| :-|";s:12:"question!png";s:2:"?!";s:12:"rolleyes!png";s:10:"B) Bo) B-)";s:7:"sad!png";s:4:"!sad";s:10:"shades!png";s:10:"8) 8o) 8-)";s:7:"shy!png";s:4:"!shy";s:9:"smile!png";s:10:":) :o) :-)";s:11:"special!png";s:3:"%-6";s:12:"suprised!png";s:10:":O :oO :-O";s:10:"tongue!png";s:21:":p :op :-p :P :oP :-P";s:8:"wink!png";s:10:";) ;o) ;-)";}';
  32      $sql->db_Insert("core", "'emote_default', '$tmp' ");
  33  }
  34  
  35  if (isset($_POST['active']))
  36  {
  37      if ($pref['smiley_activate'] != $_POST['smiley_activate']) {
  38          $pref['smiley_activate'] = $_POST['smiley_activate'];
  39          save_prefs();
  40          $update = true;
  41      }
  42      admin_update($update);
  43  }
  44  
  45  /* get packs */
  46  
  47  require_once(e_HANDLER."file_class.php");
  48  $fl = new e_file;
  49  $emote = new emotec;
  50  foreach($_POST as $key => $value)
  51  {
  52      if(strstr($key, "subPack_"))
  53      {
  54          $subpack = str_replace("subPack_", "", $key);
  55          $emote -> emoteConf($subpack);
  56          break;
  57      }
  58  
  59      if(strstr($key, "defPack_"))
  60      {
  61          $pref['emotepack'] = str_replace("defPack_", "", $key);
  62          save_prefs();
  63          break;
  64      }
  65  }
  66  
  67  $check = TRUE;
  68  $check = $emote -> installCheck();
  69  if($check!==FALSE){
  70      $emote -> listPacks();
  71  }
  72  
  73  class emotec
  74  {
  75  
  76      var $packArray;
  77  
  78  	function emotec()
  79      {
  80          /* constructor */
  81          global $fl;
  82          $this -> packArray = $fl -> get_dirs(e_IMAGE."emotes");
  83  
  84          if(isset($_POST['sub_conf']))
  85          {
  86              $this -> saveConf();
  87          }
  88      }
  89  
  90  	function listPacks()
  91      {
  92  
  93          global $ns, $fl, $pref;
  94  
  95          $text = "<div style='text-align:center'>
  96          <form method='post' action='".e_SELF."'>
  97          <table style='".ADMIN_WIDTH."' class='fborder'>
  98          <tr>
  99          <td style='width:30%' class='forumheader3'>".EMOLAN_4.": </td>
 100          <td style='width:70%' class='forumheader3'>".($pref['smiley_activate'] ? "<input type='checkbox' name='smiley_activate' value='1'  checked='checked' />" : "<input type='checkbox' name='smiley_activate' value='1' />")."</td>
 101          </tr>
 102  
 103          <tr>
 104          <td colspan='2' style='text-align:center' class='forumheader'>
 105          <input class='button' type='submit' name='active' value='".LAN_UPDATE."' />
 106          </td>
 107          </tr>
 108          </table>
 109          </form>
 110          </div>
 111          ";
 112  
 113          $ns -> tablerender(EMOLAN_1, $text);
 114  
 115  
 116          $text = "
 117          <form method='post' action='".e_SELF."'>
 118          <table style='".ADMIN_WIDTH."' class='fborder'>
 119          <tr>
 120          <td class='forumheader' style='width: 20%;'>".EMOLAN_2."</td>
 121          <td class='forumheader' style='width: 50%;'>".EMOLAN_3."</td>
 122          <td class='forumheader' style='width: 10%; text-align: center;'>".EMOLAN_8."</td>
 123          <td class='forumheader' style='width: 20%;'>".EMOLAN_9."</td>
 124          ";
 125  
 126          $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*');
 127          foreach($this -> packArray as $pack)
 128          {
 129              $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$pack, "", $reject);
 130  
 131              $text .= "
 132              <tr>
 133              <td class='forumheader' style='width: 20%;'>$pack</td>
 134              <td class='forumheader' style='width: 20%;'>
 135              ";
 136  
 137              foreach($emoteArray as $emote)
 138              {
 139                  $text .= "<img src='".$emote['path'].$emote['fname']."' alt='' /> ";
 140              }
 141  
 142              $text .= "</td>
 143              <td class='forumheader3' style='width: 10%; text-align: center;'>".($pref['emotepack'] == $pack ? EMOLAN_10 : "<input class='button' type='submit' name='defPack_".$pack."' value=\"".EMOLAN_11."\" />")."</td>
 144              <td class='forumheader3' style='width: 20%; text-align: center;'><input class='button' type='submit' name='subPack_".$pack."' value=\"".EMOLAN_12."\" /></td>
 145              </tr>
 146              ";
 147          }
 148  
 149          $text .= "
 150          </table>
 151          </form>
 152          ";
 153          $ns -> tablerender(EMOLAN_13, $text);
 154      }
 155  
 156  	function emoteConf($packID)
 157      {
 158  
 159          global $ns, $fl, $pref, $sysprefs, $tp;
 160          $corea = "emote_".$packID;
 161  
 162          $emotecode = $sysprefs -> getArray($corea);
 163  
 164          $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore');
 165          $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, "", $reject);
 166  
 167          $eArray = array();
 168          foreach($emoteArray as $value)
 169          {
 170              if(!strstr($value['fname'], ".php") && !strstr($value['fname'], ".txt") && !strstr($value['fname'], ".pak") && !strstr($value['fname'], ".xml") && !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html"))
 171              {
 172                  $eArray[] = array('path' => $value['path'], 'fname' => $value['fname']);
 173              }
 174          }
 175  
 176          $text = "
 177          <form method='post' action='".e_SELF."'>
 178          <table style='".ADMIN_WIDTH."' class='fborder'>
 179          <tr>
 180          <td class='forumheader' style='width: 20%;'>".EMOLAN_2."</td>
 181          <td class='forumheader' style='width: 20%; text-align: center;'>".EMOLAN_5."</td>
 182          <td class='forumheader' style='width: 60%;'>".EMOLAN_6." <span class='smalltext'>( ".EMOLAN_7." )</a></td>
 183          </tr>
 184          ";
 185  
 186          foreach($eArray as $emote)
 187          {
 188              $ename = $emote['fname'];
 189              $evalue = str_replace(".", "!", $ename);
 190  
 191              $text .= "
 192              <tr>
 193              <td class='forumheader3' style='width: 20%;'>".$ename."</td>
 194              <td class='forumheader3' style='width: 20%; text-align: center;'><img src='".$emote['path'].$ename."' alt='' /></td>
 195              <td class='forumheader3' style='width: 60%;'><input style='width: 80%' class='tbox' type='text' name='$evalue' value='".$tp -> toForm($emotecode[$evalue])."' maxlength='200' /></td>
 196              </tr>
 197              ";
 198          }
 199  
 200          $text .= "
 201          <tr>
 202          <td style='text-align: center;' colspan='3' class='forumheader'><input class='button' type='submit' name='sub_conf' value='".EMOLAN_14."' /></td>
 203          </tr>
 204  
 205          </table>
 206          <input type='hidden' name='packID' value='$packID' />
 207          </form>";
 208          $ns -> tablerender(EMOLAN_15.": '".$packID."'", $text);
 209  
 210      }
 211  
 212  	function saveConf()
 213      {
 214          global $ns, $sql, $tp;
 215  
 216          $packID = $_POST['packID'];
 217          unset($_POST['sub_conf'], $_POST['packID']);
 218  
 219          foreach($_POST as $key => $value)
 220          {
 221              $key = str_replace("_", "!", $key);
 222              $_POST[$key] = $value;
 223          }
 224  
 225          $encoded_emotes = $tp -> toDB($_POST);
 226          $tmp = addslashes(serialize($encoded_emotes));
 227  
 228          if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'")) {
 229              admin_update($sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='emote_".$packID."' "), 'update', EMOLAN_16);
 230          } else {
 231              admin_update($sql->db_Insert("core", "'emote_".$packID."', '$tmp' "), 'insert', EMOLAN_16);
 232          }
 233      }
 234  
 235  	function installCheck()
 236      {
 237          global $sql, $fl;
 238          foreach($this -> packArray as $value)
 239          {
 240              if(strpos($value,' ')!==FALSE){
 241                  global $ns;
 242                  $msg = "
 243                  <div style='text-align:center;'><b>".EMOLAN_17."<br />".EMOLAN_18."</b><br /><br />
 244                      <table class='fborder'>
 245                      <tr>
 246                          <td class='fcaption'>".EMOLAN_19."</td>
 247                          <td class='fcaption'>".EMOLAN_20."</td>
 248                      </tr>
 249                      <tr>
 250                          <td class='forumheader3'>".$value."</td>
 251                          <td class='forumheader3'>".e_IMAGE."emotes/</td>
 252                      </tr>
 253                      </table>
 254                  </div>";
 255                  $ns->tablerender(EMOLAN_21, $msg);
 256                  return FALSE;
 257              }
 258              if(!$sql -> db_Select("core", "*", "e107_name='emote_".$value."' "))
 259              {
 260                  $fileArray = $fl -> get_files(e_IMAGE."emotes/".$value);
 261                  foreach($fileArray as $file)
 262                  {
 263                      if(strstr($file['fname'], ".xml"))
 264                      {
 265                          $confFile = array('file' => $file['fname'], 'type' => "xml");
 266                      }
 267                      else if(strstr($file['fname'], ".pak"))
 268                      {
 269                          $confFile = array('file' => $file['fname'], 'type' => "pak");
 270                      }
 271                      else if(strstr($file['fname'], ".php"))
 272                      {
 273                          $confFile = array('file' => $file['fname'], 'type' => "php");
 274                      }
 275                  }
 276  
 277                  /* .pak file ------------------------------------------------------------------------------------------------------------------------------------ */
 278                  if($confFile['type'] == "pak")
 279                  {
 280                      $filename = e_IMAGE."emotes/".$value."/".$confFile['file'];
 281                      $pakconf = file ($filename);
 282                      $contentArray = array();
 283                      foreach($pakconf as $line)
 284                      {
 285                          if(trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) $contentArray[] = $line;
 286                      }
 287                      $confArray = array();
 288                      foreach($contentArray as $pakline)
 289                      {
 290                          $tmp = explode("=+:", $pakline);
 291                          $confIC = str_replace(".", "!", $tmp[0]);
 292                          $confArray[$confIC] = trim($tmp[2]);
 293                      }
 294                      $tmp = addslashes(serialize($confArray));
 295                      $sql->db_Insert("core", "'emote_".$value."', '$tmp' ");
 296                      echo "<div style='text-align: center;'><b>".EMOLAN_22." '</b> ".$value."'</div>";
 297                  }
 298                  /* end ----------------------------------------------------------------------------------------------------------------------------------------- */
 299  
 300                  /* .xml file ------------------------------------------------------------------------------------------------------------------------------------ */
 301                  if($confFile['type'] == "xml")
 302                  {
 303                      $filename = e_IMAGE."emotes/".$value."/".$confFile['file'];
 304  
 305                      $handle = fopen ($filename, "r");
 306                      $contents = fread ($handle, filesize ($filename));
 307                      fclose ($handle);
 308  
 309                      preg_match_all("#\<emoticon file=\"(.*?)\"\>(.*?)\<\/emoticon\>#si", $contents, $match);
 310                      $confArray = array();
 311  
 312                      for($a=0; $a<=(count($match[0])); $a++)
 313                      {
 314                          preg_match_all("#\<string\>(.*?)\<\/string\>#si", $match[0][$a], $match2);
 315  
 316                          $codet = "";
 317                          foreach($match2[1] as $code)
 318                          {
 319                              $codet .= $code." ";
 320                          }
 321  
 322                          foreach($fileArray as $emote)
 323                          {
 324                              if(strstr($emote['fname'], $match[1][$a]))
 325                              {
 326                                  $file = str_replace(".", "!", $emote['fname']);
 327                              }
 328                          }
 329                          $confArray[$file] = $codet;
 330                      }
 331  
 332                      $tmp = addslashes(serialize($confArray));
 333                      $sql->db_Insert("core", "'emote_".$value."', '$tmp' ");
 334                      echo "<div style='text-align: center;'><b>".EMOLAN_23." '</b> ".$value."'</div>";
 335                  }
 336  
 337                  if($confFile['type'] == "php")
 338                  {
 339                      echo "<b>.conf file found</b>: installing '".$value."'<br />";
 340                      include_once(e_IMAGE."emotes/".$value."/".$confFile['file']);
 341                      $sql->db_Insert("core", "'emote_".$value."', '$_emoteconf' ");
 342                      echo "<div style='text-align: center;'><b>".EMOLAN_24." '</b> ".$value."'</div>";
 343                  }
 344                  /* end ----------------------------------------------------------------------------------------------------------------------------------------- */
 345  
 346              }
 347          }
 348      }
 349  }
 350  
 351  require_once ("footer.php");
 352  
 353  ?>


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