1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 21:21:54 +02:00

Emoticons admin tidy up, including bugtracker ,

This commit is contained in:
e107steved 2007-05-24 21:07:21 +00:00
parent 009d56fce4
commit 734933399e
3 changed files with 235 additions and 92 deletions
e107_admin
e107_handlers
e107_languages/English/admin

@ -11,42 +11,51 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/emoticon.php,v $
| $Revision: 1.3 $
| $Date: 2006-12-18 22:25:16 $
| $Author: e107coders $
| $Revision: 1.4 $
| $Date: 2007-05-24 21:06:50 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
if (!getperms("F")) {
if (!getperms("F"))
{
header("location:".e_BASE."index.php");
exit;
}
$e_sub_cat = 'emoticon';
require_once("auth.php");
if(!$sql->db_Count("core", "(*)", "WHERE e107_name = 'emote_default'"))
{
{ // Set up the default emotes
$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) ;-)";}';
$sql->db_Insert("core", "'emote_default', '$tmp' ");
$sql->db_Insert("core", "'emote_default', '{$tmp}' ");
}
// Change the active emote pack
if (isset($_POST['active']))
{
if ($pref['smiley_activate'] != $_POST['smiley_activate']) {
$pref['smiley_activate'] = $_POST['smiley_activate'];
save_prefs();
$update = true;
}
admin_update($update);
if ($pref['smiley_activate'] != $_POST['smiley_activate'])
{
$pref['smiley_activate'] = $_POST['smiley_activate'];
save_prefs();
$update = true;
}
admin_update($update);
}
/* get packs */
/* get packs */
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
$emote = new emotec;
$one_pack = FALSE;
// Check for pack-related buttons pressed
foreach($_POST as $key => $value)
{
if(strstr($key, "subPack_"))
@ -56,24 +65,42 @@ foreach($_POST as $key => $value)
break;
}
if(strstr($key, "XMLPack_"))
{
$subpack = str_replace("XMLPack_", "", $key);
$emote -> emoteXML($subpack);
break;
}
if(strstr($key, "defPack_"))
{
$pref['emotepack'] = str_replace("defPack_", "", $key);
save_prefs();
break;
}
if(strstr($key, "scanPack_"))
{
$one_pack = str_replace("scanPack_", "", $key);
break;
}
}
$check = TRUE;
$check = $emote -> installCheck();
if($check!==FALSE){
//$check = $emote -> installCheck();
$check = $emote -> installCheck($one_pack);
if($check!==FALSE)
{
$emote -> listPacks();
}
class emotec
{
var $packArray;
var $packArray; // Stores an array of all available emote packs (as subdirectory names)
function emotec()
{
@ -82,14 +109,15 @@ class emotec
$this -> packArray = $fl -> get_dirs(e_IMAGE."emotes");
if(isset($_POST['sub_conf']))
{
$this -> saveConf();
{ // Update stored pack configuration
$this -> saveConf();
}
}
// List available emote packs
function listPacks()
{
global $ns, $fl, $pref;
$text = "<div style='text-align:center'>
@ -123,14 +151,14 @@ class emotec
<td class='forumheader' style='width: 20%;'>".EMOLAN_9."</td>
";
$reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*');
$reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '\.bak$');
foreach($this -> packArray as $pack)
{
$emoteArray = $fl -> get_files(e_IMAGE."emotes/".$pack, "", $reject);
$text .= "
<tr>
<td class='forumheader' style='width: 20%;'>$pack</td>
<td class='forumheader' style='width: 20%;'>{$pack}</td>
<td class='forumheader' style='width: 20%;'>
";
@ -141,9 +169,14 @@ class emotec
$text .= "</td>
<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>
<td class='forumheader3' style='width: 20%; text-align: center;'><input class='button' type='submit' name='subPack_".$pack."' value=\"".EMOLAN_12."\" /></td>
</tr>
";
<td class='forumheader3' style='width: 20%; text-align: center;'>
<input class='button' type='submit' name='subPack_".$pack."' value=\"".EMOLAN_12."\" />";
if ($pack != 'default')
{
$text .= "<br /><br /><input class='button' type='submit' name='scanPack_".$pack."' value=\"".EMOLAN_26."\" />";
}
$text .= "<br /><br /><input class='button' type='submit' name='XMLPack_".$pack."' value=\"".EMOLAN_28."\" />";
$text .= "</td></tr>";
}
$text .= "
@ -153,24 +186,29 @@ class emotec
$ns -> tablerender(EMOLAN_13, $text);
}
// Configure an individual emote pack
function emoteConf($packID)
{
global $ns, $fl, $pref, $sysprefs, $tp;
$corea = "emote_".$packID;
$emotecode = $sysprefs -> getArray($corea);
$reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore');
$reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$');
$emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, "", $reject);
$eArray = array();
foreach($emoteArray as $value)
{
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"))
{
$eArray[] = array('path' => $value['path'], 'fname' => $value['fname']);
}
if(!strstr($value['fname'], ".php")
&& !strstr($value['fname'], ".txt")
&& !strstr($value['fname'], ".pak") && !strstr($value['fname'], ".bak")
&& !strstr($value['fname'], ".xml")
&& !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html"))
{
$eArray[] = array('path' => $value['path'], 'fname' => $value['fname']);
}
}
$text = "
@ -187,57 +225,130 @@ class emotec
{
$ename = $emote['fname'];
$evalue = str_replace(".", "!", $ename);
$file_back = '';
$text_back = '';
if (!isset($emotecode[$evalue]))
{
$file_back = ' background-color: #FF8000;';
}
elseif (!$emotecode[$evalue])
{
$text_back = ' background-color: #FF8000';
}
$text .= "
<tr>
<td class='forumheader3' style='width: 20%;'>".$ename."</td>
<td class='forumheader3' style='width: 20%;{$file_back}'>".$ename."</td>
<td class='forumheader3' style='width: 20%; text-align: center;'><img src='".$emote['path'].$ename."' alt='' /></td>
<td class='forumheader3' style='width: 60%;'><input style='width: 80%' class='tbox' type='text' name='$evalue' value='".$tp -> toForm($emotecode[$evalue])."' maxlength='200' /></td>
<td class='forumheader3' style='width: 60%;{$text_back}'><input style='width: 80%' class='tbox' type='text' name='{$evalue}' value='".$tp -> toForm(varset($emotecode[$evalue],''))."' maxlength='200' /></td>
</tr>
";
}
$text .= "
<tr>
<td style='text-align: center;' colspan='3' class='forumheader'><input class='button' type='submit' name='sub_conf' value='".EMOLAN_14."' /></td>
<td class='forumheader'>".count($eArray)." files</td>
<td style='text-align: center;' colspan='2' class='forumheader'><input class='button' type='submit' name='sub_conf' value='".EMOLAN_14."' /></td>
</tr>
</table>
<input type='hidden' name='packID' value='$packID' />
<input type='hidden' name='packID' value='{$packID}' />
</form>";
$ns -> tablerender(EMOLAN_15.": '".$packID."'", $text);
}
// Generate an XML file - packname.xml in root emoticon directory
function emoteXML($packID)
{
global $fl, $pref, $sysprefs, $tp;
$fname = e_IMAGE."emotes/".$packID."/emoticons.xml";
$backname = e_IMAGE."emotes/".$packID."/emoticons.bak";
$corea = "emote_".$packID;
$emotecode = $sysprefs -> getArray($corea);
$reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$');
$emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, "", $reject);
$eArray = array();
foreach($emoteArray as $value)
{
if(!strstr($value['fname'], ".php")
&& !strstr($value['fname'], ".txt")
&& !strstr($value['fname'], ".pak") && !strstr($value['fname'], ".bak")
&& !strstr($value['fname'], ".xml")
&& !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html"))
{
$eArray[] = $value['fname'];
}
}
$f_string = "<?xml version=\"1.0\"?".">\n<messaging-emoticon-map >\n\n\n";
foreach($eArray as $emote)
{
// Strip file extension
$evalue = str_replace(".", "!", $emote);
$ename = substr($emote,0,strrpos($emote,'.'));
$f_string .= "<emoticon file=\"{$ename}\">\n";
foreach (explode(' ',$tp -> toForm($emotecode[$evalue])) as $v)
{
if (trim($v)) $f_string .= "\t<string>{$v}</string>\n";
}
$f_string .= "</emoticon>\n";
}
$f_string .= "\n</messaging-emoticon-map>\n";
if (is_file($backname)) unlink($backname); // Delete any old backup
if (is_file($fname)) rename($fname,$backname);
file_put_contents($fname,$f_string);
echo "<br /><div style='text-align: center;'>".EMOLAN_29."<b>".$fname."</b></div><br />";
}
// Save configuration for an emote pack that's been edited
function saveConf()
{
global $ns, $sql, $tp;
$packID = $_POST['packID'];
unset($_POST['sub_conf'], $_POST['packID']);
foreach($_POST as $key => $value)
/*
foreach($_POST as $key => $value) // $key is file name, with '.' already replaced by '!'
{
$key = str_replace("_", "!", $key);
$_POST[$key] = $value;
unset($_POST[$key]);
// $key = str_replace("_", "!", $key); // Why?
// $key = str_replace(".", "!", $key); // Don't think we need this, either
$_POST[$key] = $value;
}
*/
$encoded_emotes = $tp -> toDB($_POST);
$tmp = addslashes(serialize($encoded_emotes));
if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'")) {
admin_update($sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='emote_".$packID."' "), 'update', EMOLAN_16);
} else {
admin_update($sql->db_Insert("core", "'emote_".$packID."', '$tmp' "), 'insert', EMOLAN_16);
if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'"))
{
admin_update($sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='emote_".$packID."' "), 'update', EMOLAN_16);
}
else
{
admin_update($sql->db_Insert("core", "'emote_".$packID."', '$tmp' "), 'insert', EMOLAN_16);
}
}
function installCheck()
// Identify currently selected emote pack. Read in any new ones
// Return false to disable listing of packs
function installCheck($do_one = FALSE)
{
global $sql, $fl;
foreach($this -> packArray as $value)
{
if(strpos($value,' ')!==FALSE){
if(strpos($value,' ')!==FALSE)
{ // Highlight any directory names containing spaces - not allowed
global $ns;
$msg = "
<div style='text-align:center;'><b>".EMOLAN_17."<br />".EMOLAN_18."</b><br /><br />
@ -255,8 +366,12 @@ class emotec
$ns->tablerender(EMOLAN_21, $msg);
return FALSE;
}
if(!$sql -> db_Select("core", "*", "e107_name='emote_".$value."' "))
{
if (($do_one == $value) || !$do_one && (!$sql -> db_Select("core", "*", "e107_name='emote_".$value."' ")))
{ // Pack info not in DB, or to be re-scanned
$no_error = TRUE;
$File_type = 'Unknown';
// Array of all files in the directory of the selected emote pack
$fileArray = $fl -> get_files(e_IMAGE."emotes/".$value);
foreach($fileArray as $file)
{
@ -274,7 +389,7 @@ class emotec
}
}
/* .pak file ------------------------------------------------------------------------------------------------------------------------------------ */
/* .pak file */
if($confFile['type'] == "pak")
{
$filename = e_IMAGE."emotes/".$value."/".$confFile['file'];
@ -282,72 +397,95 @@ class emotec
$contentArray = array();
foreach($pakconf as $line)
{
if(trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) $contentArray[] = $line;
if(trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) $contentArray[] = $line;
}
$confArray = array();
foreach($contentArray as $pakline)
{
$tmp = explode("=+:", $pakline);
$confIC = str_replace(".", "!", $tmp[0]);
$confArray[$confIC] = trim($tmp[2]);
$tmp = explode("=+:", $pakline);
$confIC = str_replace(".", "!", $tmp[0]);
$confArray[$confIC] = trim($tmp[2]);
}
$tmp = addslashes(serialize($confArray));
$sql->db_Insert("core", "'emote_".$value."', '$tmp' ");
echo "<div style='text-align: center;'><b>".EMOLAN_22." '</b> ".$value."'</div>";
$File_type = EMOLAN_22;
}
/* end ----------------------------------------------------------------------------------------------------------------------------------------- */
/* end */
/* .xml file ------------------------------------------------------------------------------------------------------------------------------------ */
/* .xml file */
if($confFile['type'] == "xml")
{
$filename = e_IMAGE."emotes/".$value."/".$confFile['file'];
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = fread ($handle, filesize ($filename)); // Get the XML file for the emote pack
fclose ($handle);
preg_match_all("#\<emoticon file=\"(.*?)\"\>(.*?)\<\/emoticon\>#si", $contents, $match);
$confArray = array();
// $match[0] - complete emoticon entry
// $match[1] - filename (no file extension/suffix)
// $match[2] - match string(s) representing emote
for($a=0; $a<=(count($match[0])); $a++)
// Now pull out all the 'match' strings
for($a=0; $a < count($match[2]); $a++)
{
preg_match_all("#\<string\>(.*?)\<\/string\>#si", $match[0][$a], $match2);
preg_match_all("#\<string\>(.*?)\<\/string\>#si", $match[2][$a], $match2);
$codet = "";
foreach($match2[1] as $code)
{
$codet .= $code." ";
}
$codet = "";
foreach($match2[1] as $code)
{
$codet .= $code." ";
}
foreach($fileArray as $emote)
$file = '';
foreach($fileArray as $emote)
{ // Check that the file exists
if(strpos($emote['fname'], $match[1][$a].".") === 0)
{
if(strstr($emote['fname'], $match[1][$a]))
{
$file = str_replace(".", "!", $emote['fname']);
}
$file = str_replace(".", "!", $emote['fname']);
break;
}
$confArray[$file] = $codet;
}
// Only add if the file exists. OK if no definition - might want to be added
if ($file) $confArray[$file] = $codet;
}
// Save pack info in the database
$tmp = addslashes(serialize($confArray));
$sql->db_Insert("core", "'emote_".$value."', '$tmp' ");
echo "<div style='text-align: center;'><b>".EMOLAN_23." '</b> ".$value."'</div>";
$File_type = EMOLAN_23;
}
if($confFile['type'] == "php")
{
echo "<b>.conf file found</b>: installing '".$value."'<br />";
echo EMOLAN_25."'".$value."'<br />";
include_once(e_IMAGE."emotes/".$value."/".$confFile['file']);
$sql->db_Insert("core", "'emote_".$value."', '$_emoteconf' ");
echo "<div style='text-align: center;'><b>".EMOLAN_24." '</b> ".$value."'</div>";
$File_type = EMOLAN_24;
$tmp = $_emoteconf; // Use consistent name
}
if ($no_error)
{
if ($do_one)
{ // Assume existing pack
$sql->db_Update("core", "`e107_value`='{$tmp}' WHERE `e107_name`='emote_".$value."'");
}
else
{ // Assume new pack
$sql->db_Insert("core", "'emote_".$value."', '{$tmp}' ");
}
echo "<div style='text-align: center;'><b>".$File_type." '</b> ".$value."'</div>";
}
else
{ // Error occurred
echo "<div style='text-align: center;'><b>".EMOLAN_27." '</b> ".$value."'</div>";
}
/* end ----------------------------------------------------------------------------------------------------------------------------------------- */
}
}
return TRUE;
}
}
require_once("footer.php");
?>

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/emote.php,v $
| $Revision: 1.3 $
| $Date: 2007-04-15 16:07:39 $
| $Author: lisa_ $
| $Revision: 1.4 $
| $Date: 2007-05-24 21:06:50 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
@ -29,11 +29,11 @@ function r_emote()
}
$str = '';
foreach($tp->e_emote->emotes as $key => $value)
foreach($tp->e_emote->emotes as $key => $value) // filename => text code
{
$key = str_replace("!", "_", $key);
$key = preg_replace("#_(\w{3})$#", ".\\1", $key);
$key = e_IMAGE."emotes/" . $pref['emotepack'] . "/" .$key;
$key = str_replace("!", ".", $key); // Usually '.' was replaced by '!' when saving
$key = preg_replace("#_(\w{3})$#", ".\\1", $key); // '_' followed by exactly 3 chars is file extension
$key = e_IMAGE."emotes/" . $pref['emotepack'] . "/" .$key; // Add in the file path
$value2 = substr($value, 0, strpos($value, " "));
$value = ($value2 ? $value2 : $value);

@ -4,9 +4,9 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_emoticon.php,v $
| $Revision: 1.2 $
| $Date: 2006-12-02 11:31:18 $
| $Author: lisa_ $
| $Revision: 1.3 $
| $Date: 2007-05-24 21:06:57 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
define("EMOLAN_1", "Emote activation");
@ -21,7 +21,7 @@ define("EMOLAN_7", "separate multiple entries with spaces");
define("EMOLAN_8", "Status");
define("EMOLAN_9", "Options");
define("EMOLAN_10", "Active");
define("EMOLAN_11", "Activate pack'");
define("EMOLAN_11", "Activate pack");
define("EMOLAN_12", "Edit / configure this pack");
define("EMOLAN_13", "Installed packs");
@ -29,7 +29,7 @@ define("EMOLAN_13", "Installed packs");
define("EMOLAN_14", "Save configuration");
define("EMOLAN_15", "Edit / configure emotes");
define("EMOLAN_16", "Emote configuration saved");
define("EMOLAN_17", "You have an emoticon pack present that contains spaces, which are not allowed !");
define("EMOLAN_17", "You have an emoticon pack present that contains spaces in the name, which are not allowed !");
define("EMOLAN_18", "please rename the instances listed below so they no longer contain spaces:");
define("EMOLAN_19", "Name");
define("EMOLAN_20", "Location");
@ -38,4 +38,9 @@ define("EMOLAN_21", "Error");
define("EMOLAN_22", "New emote pak found:");
define("EMOLAN_23", "New emote xml pak found:");
define("EMOLAN_24", "New emote php found:");
define("EMOLAN_25", "Installing new PHP emotes: ");
define("EMOLAN_26", "Re-scan pack");
define("EMOLAN_27", "Error occurred processing pack: ");
define("EMOLAN_28", "Generate XML");
define("EMOLAN_29", "XML file generated: ");
?>