1513 lines
48 KiB
PHP
1513 lines
48 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board 2.1.7
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2005 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| http://www.ibresource.ru/products/invisionpowerboard/
|
|
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
|
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
| http://www.ibresource.ru/license
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
|
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
|
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
|
|
+---------------------------------------------------------------------------
|
|
| > $Date: 2006-02-01 18:16:26 +0000 (Wed, 01 Feb 2006) $
|
|
| > $Revision: 132 $
|
|
| > $Author: bfarber $
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > Administration Module
|
|
| > Module written by Matt Mecham
|
|
| > Date started: 27th January 2004
|
|
|
|
|
| > Module Version Number: 1.0.0
|
|
| > DBA Checked: Mon 24th May 2004
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
if ( ! defined( 'IN_ACP' ) )
|
|
{
|
|
print "<h1>Íåâåðíûé âõîä</h1> Ó Âàñ íåò äîñòóïà ê äèðåêòèâå ýòîãî ôàéëà. Åñëè Âû ïðîâîäèëè îáíîâëåíèÿ, óáåäèòåñü, ÷òî íå çàáûëè îáíîâèòü 'admin.php'.";
|
|
exit();
|
|
}
|
|
|
|
class ad_emoticons {
|
|
|
|
var $functions = "";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_main = "lookandfeel";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_child = "emoticons";
|
|
|
|
/**
|
|
* Allowed file types
|
|
*/
|
|
var $allowed_files = array( 'png', 'jpeg', 'jpg', 'gif' );
|
|
|
|
function auto_run()
|
|
{
|
|
//-----------------------------------------
|
|
// Require and RUN !! THERES A BOMB
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->admin->page_detail = "";
|
|
$this->ipsclass->admin->page_title = "Íàñòðîéêà ñìàéëèêîâ";
|
|
|
|
//-----------------------------------------
|
|
// Kill globals - globals bad, Homer good.
|
|
//-----------------------------------------
|
|
|
|
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
|
|
|
|
foreach ( $tmp_in as $k => $v )
|
|
{
|
|
unset($$k);
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// What to do...
|
|
//-----------------------------------------
|
|
|
|
switch($this->ipsclass->input['code'])
|
|
{
|
|
//-----------------------------------------
|
|
// Emu?
|
|
//-----------------------------------------
|
|
|
|
case 'emo':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->emoticon_start();
|
|
break;
|
|
|
|
case 'emo_packsplash':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':export' );
|
|
$this->emoticon_pack_splash();
|
|
break;
|
|
|
|
case 'emo_packexport':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':export' );
|
|
$this->emoticon_pack_export();
|
|
break;
|
|
|
|
case 'emo_packimport':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':import' );
|
|
$this->emoticon_pack_import();
|
|
break;
|
|
|
|
case 'emo_manage':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->emoticon_manage();
|
|
break;
|
|
|
|
case 'emo_doedit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->emoticon_edit();
|
|
break;
|
|
|
|
case 'emo_doadd':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
|
|
$this->emoticon_add();
|
|
break;
|
|
|
|
case 'emo_remove':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
|
|
$this->emoticon_remove();
|
|
break;
|
|
|
|
case 'emo_setadd':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
|
|
$this->emoticon_setalter($type='add');
|
|
break;
|
|
|
|
case 'emo_setedit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->emoticon_setalter($type='edit');
|
|
break;
|
|
|
|
case 'emo_setremove':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
|
|
$this->emoticon_setremove();
|
|
break;
|
|
|
|
case 'emo_upload':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':upload' );
|
|
$this->emoticon_upload();
|
|
|
|
default:
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->emoticon_start();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Set add
|
|
//-----------------------------------------
|
|
|
|
function emoticon_setalter($type='add')
|
|
{
|
|
$name = preg_replace( "/[^a-zA-Z0-9\-_]/", "", $this->ipsclass->input['emoset'] );
|
|
|
|
if ($name == "")
|
|
{
|
|
$this->ipsclass->main_msg = "Âû ââåëè íåäîïóñòèìîå èìÿ ïàêè, âåðíèòåñü íàçàä è ïðîâåðüòå âàøè ñèìâîëû (A-Z, a-z, 0-9)";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Safe mode?
|
|
//-----------------------------------------
|
|
|
|
if ( SAFE_MODE_ON )
|
|
{
|
|
$this->ipsclass->main_msg = "Áåçîïàñíûé ðåæèì: IPB íå ìîæåò ñîçäàòü èëè îòðåäàêòèðîâàòü ïàïêó çà âàñ, ïîæàëóéñòà, ñîçäàéòå ñàìè (èëè óäàëèòå) ïàïêó ïðè ïîìîùè FTP â 'style_emoticons'.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Directory exists?
|
|
//-----------------------------------------
|
|
|
|
if ( file_exists( CACHE_PATH.'style_emoticons/'.$name ) )
|
|
{
|
|
$this->ipsclass->main_msg = "'style_emoticons/$name' óæå ñóùåñòâóåò, ïîæàëóéñòà, âûáåðåòå äðóãèå èìÿ.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
if ( $type == 'add' )
|
|
{
|
|
//-----------------------------------------
|
|
// Create directory?
|
|
//-----------------------------------------
|
|
|
|
if ( @mkdir( CACHE_PATH.'style_emoticons/'.$name, 0777 ) )
|
|
{
|
|
@chmod( CACHE_PATH.'style_emoticons/'.$name, 0777 );
|
|
|
|
$this->ipsclass->main_msg = "Äèðåêîòîðèÿ íå ñîçäàíà";
|
|
$this->emoticon_start();
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->main_msg = "IPB íå ìîæåò ñîçäàòü èëè îòðåäàêòèðîâàòü ïàïêó çà âàñ, ïîæàëóéñòà, ñîçäàéòå ñàìè (èëè óäàëèòå) ïàïêó ïðè ïîìîùè FTP â 'style_emoticons'";
|
|
$this->emoticon_start();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( ! $this->ipsclass->input['id'] )
|
|
{
|
|
$this->ipsclass->main_msg = "Ïàïêè ñ òàêèì íàçâàíèåì íåò.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Rename directory?
|
|
//-----------------------------------------
|
|
|
|
if ( @rename( CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['id'], CACHE_PATH.'style_emoticons/'.$name ) )
|
|
{
|
|
if ( file_exists( CACHE_PATH.'style_emoticons/'.$name ) )
|
|
{
|
|
//-----------------------------------------
|
|
// Update the emos
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->do_update( 'emoticons', array( 'emo_set' => $name ), "emo_set='".$this->ipsclass->input['id']."'" );
|
|
}
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
//-----------------------------------------
|
|
// Update the skins using this set
|
|
//-----------------------------------------
|
|
|
|
$rebuild_sets = array();
|
|
|
|
$this->ipsclass->DB->build_query( array( 'select' => 'set_skin_set_id', 'from' => 'skin_sets', 'where' => "set_emoticon_folder='{$this->ipsclass->input['id']}'" ) );
|
|
$outer = $this->ipsclass->DB->exec_query();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row($outer) )
|
|
{
|
|
$this->ipsclass->DB->do_update( 'skin_sets', array( 'set_emoticon_folder' => $name ), 'set_skin_set_id='.$r['set_skin_set_id'] );
|
|
$rebuild_sets[] = $r['set_skin_set_id'];
|
|
}
|
|
|
|
if( count($rebuild_sets) )
|
|
{
|
|
$this->ipsclass->cache_func->_rebuild_all_caches( $rebuild_sets );
|
|
}
|
|
|
|
|
|
$this->ipsclass->main_msg = "Ïàïêà ïåðåèìåíîâàíà.";
|
|
$this->emoticon_start();
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->main_msg = "IPB íå ìîæåò ïåðåèìåíîâàòü ýòó ïàïêó çà Âàñ.";
|
|
$this->emoticon_start();
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Edit
|
|
//-----------------------------------------
|
|
|
|
function emoticon_edit()
|
|
{
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->main_msg = "Íå âûáðàí ID ãðóïïû ñìàéëèêîâ.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
foreach ($this->ipsclass->input as $key => $value)
|
|
{
|
|
if ( preg_match( "/^emo_type_(\d+)$/", $key, $match ) )
|
|
{
|
|
if ( isset( $this->ipsclass->input[$match[0]]) )
|
|
{
|
|
$typed = str_replace( '"', "", $this->ipsclass->input[$match[0]] );
|
|
$click = $this->ipsclass->input['emo_click_'.$match[1] ];
|
|
|
|
$typed = str_replace( '\', "", $typed );
|
|
|
|
if ( $typed and $match[1] )
|
|
{
|
|
$this->ipsclass->DB->do_update( 'emoticons', array( 'clickable' => intval($click), 'typed' => $typed ), 'id='.$match[1] );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
$this->ipsclass->main_msg = "Ñìàéëèêè îáíîâëåíû";
|
|
|
|
$this->emoticon_manage();
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Remove
|
|
//-----------------------------------------
|
|
|
|
function emoticon_remove()
|
|
{
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->main_msg = "Íå âûáðàí ID ãðóïïû ñìàéëèêîâ";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
if ($this->ipsclass->input['eid'] == "")
|
|
{
|
|
$this->ipsclass->main_msg = "Íå âûáðàí ID ñìàéëèêîâ";
|
|
$this->emoticon_manage();
|
|
}
|
|
|
|
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'emoticons', 'where' => "id=".intval($this->ipsclass->input['eid']) ) );
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
$this->ipsclass->main_msg = "Ñìàéëèê óäàëåí";
|
|
|
|
$this->emoticon_manage();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON ADD
|
|
//-----------------------------------------
|
|
|
|
function emoticon_add()
|
|
{
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->main_msg = "Íå âûáðàí ID ãðóïïû èêîíîê.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
foreach ($this->ipsclass->input as $key => $value)
|
|
{
|
|
if ( preg_match( "/^emo_type_(\d+)$/", $key, $match ) )
|
|
{
|
|
if ( isset( $this->ipsclass->input[$match[0]]) )
|
|
{
|
|
$typed = str_replace( '"', "", $this->ipsclass->input[$match[0]] );
|
|
$click = $this->ipsclass->input['emo_click_'.$match[1] ];
|
|
$add = $this->ipsclass->input['emo_add_'.$match[1] ];
|
|
$image = $this->ipsclass->input['emo_image_'.$match[1] ];
|
|
$set = trim($this->ipsclass->input['id']);
|
|
|
|
$typed = str_replace( '\', "", $typed );
|
|
|
|
if ( $this->ipsclass->input['addall'] )
|
|
{
|
|
$add = 1;
|
|
}
|
|
|
|
if ( $add and $typed and $image )
|
|
{
|
|
$this->ipsclass->DB->do_insert( 'emoticons', array( 'clickable' => intval($click), 'typed' => $typed, 'image' => $image, 'emo_set' => $set ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
$this->ipsclass->main_msg = "Ñìàéëèêè îáíîâëåíû";
|
|
|
|
$this->emoticon_manage();
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Upload
|
|
//-----------------------------------------
|
|
|
|
function emoticon_upload()
|
|
{
|
|
$overwrite = 1;
|
|
|
|
//-----------------------------------------
|
|
// Which folders?
|
|
//-----------------------------------------
|
|
|
|
$directories = array();
|
|
$first_dir = '';
|
|
|
|
foreach ($this->ipsclass->input as $key => $value)
|
|
{
|
|
if ( preg_match( "/^dir_(.*)$/", $key, $match ) )
|
|
{
|
|
if ( $this->ipsclass->input[$match[0]] == 1 )
|
|
{
|
|
$directories[] = $match[1];
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( ! count( $directories ) )
|
|
{
|
|
$this->ipsclass->main_msg = "Âû íå âûáðàëè ñìàéëèê ÷òîáû ïðîèçâåñòè çàãðóçêó!";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Excuse me, can you shift?
|
|
//-----------------------------------------
|
|
|
|
$first_dir = array_shift( $directories );
|
|
|
|
//-----------------------------------------
|
|
// Loopy loo?
|
|
//-----------------------------------------
|
|
|
|
foreach( array( 1,2,3,4 ) as $i )
|
|
{
|
|
$field = 'upload_'.$i;
|
|
|
|
$FILE_NAME = $_FILES[$field]['name'];
|
|
$FILE_SIZE = $_FILES[$field]['size'];
|
|
$FILE_TYPE = $_FILES[$field]['type'];
|
|
|
|
//-----------------------------------------
|
|
// Naughty Opera adds the filename on the end of the
|
|
// mime type - we don't want this.
|
|
//-----------------------------------------
|
|
|
|
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
|
|
|
|
//-----------------------------------------
|
|
// Naughty Mozilla likes to use "none" to indicate an empty upload field.
|
|
// I love universal languages that aren't universal.
|
|
//-----------------------------------------
|
|
|
|
if ( $_FILES[$field]['name'] == "" or ! $_FILES[$field]['name'] or ($_FILES[$field]['name'] == "none") )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Make sure it's not a NAUGHTY file
|
|
//-----------------------------------------
|
|
|
|
$file_extension = preg_replace( "#^.*\.(.+?)$#si", "\\1", strtolower( $_FILES[ $field ]['name'] ) );
|
|
|
|
if ( ! in_array( $file_extension, $this->allowed_files ) )
|
|
{
|
|
$this->ipsclass->main_msg = "You can only upload image files (jpeg, jpg, gif and png)";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Copy the upload to the uploads directory
|
|
//-----------------------------------------
|
|
|
|
if ( ! @move_uploaded_file( $_FILES[ $field ]['tmp_name'], CACHE_PATH.'style_emoticons/'.$first_dir."/".$FILE_NAME) )
|
|
{
|
|
$this->ipsclass->main_msg = "Íåâîçìîæíî çàãðóçèòü, èçâèíèòå óæ!";
|
|
$this->emoticon_start();
|
|
}
|
|
else
|
|
{
|
|
@chmod( CACHE_PATH.'style_emoticons/'.$first_dir."/".$FILE_NAME, 0777 );
|
|
|
|
//-----------------------------------------
|
|
// Copy to other folders
|
|
//-----------------------------------------
|
|
|
|
if ( is_array( $directories ) and count( $directories ) )
|
|
{
|
|
foreach ( $directories as $newdir )
|
|
{
|
|
if ( file_exists( CACHE_PATH.'style_emoticons/'.$newdir."/".$FILE_NAME ) )
|
|
{
|
|
if ( $overwrite != 1 )
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if( @copy( CACHE_PATH.'style_emoticons/'.$first_dir."/".$FILE_NAME, CACHE_PATH.'style_emoticons/'.$newdir."/".$FILE_NAME ) )
|
|
{
|
|
@chmod( CACHE_PATH.'style_emoticons/'.$newdir."/".$FILE_NAME, 0777 );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->ipsclass->main_msg = "Çàãðóçêà çàâåðøåíà!";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Start
|
|
//-----------------------------------------
|
|
|
|
function emoticon_start()
|
|
{
|
|
if ( ! is_dir( CACHE_PATH. 'style_emoticons') )
|
|
{
|
|
$this->ipsclass->admin->error("Íåëüçÿ íàéòè ïàïêó ñ èêîíêàìè - óáåäèòåñü, ÷òî ïóòü ê 'style_emoticons' âåðåí");
|
|
$this->ipsclass->admin->output();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Start table
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "1%" );
|
|
$this->ipsclass->adskin->td_header[] = array( "Ïàïêà" , "30%" );
|
|
$this->ipsclass->adskin->td_header[] = array( "Çàãðóçêà" , "5%" );
|
|
$this->ipsclass->adskin->td_header[] = array( "# ïàïêè" , "15%" );
|
|
$this->ipsclass->adskin->td_header[] = array( "# ãðóïïû ñìàéëèêîâ" , "15%" );
|
|
$this->ipsclass->adskin->td_header[] = array( "Îïöèè ãðóïïû" , "20%" );
|
|
|
|
//-----------------------------------------
|
|
// Get emoticon count
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->cache_add_query( 'admin_emo_count', array() );
|
|
$this->ipsclass->DB->cache_exec_query();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$emo_db[ $r['emo_set'] ] = $r;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get emoticon folders
|
|
//-----------------------------------------
|
|
|
|
$emodirs = array();
|
|
|
|
$dh = opendir( CACHE_PATH.'style_emoticons' );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if (($file != ".") && ($file != ".."))
|
|
{
|
|
if ( is_dir(CACHE_PATH.'style_emoticons/'.$file) )
|
|
{
|
|
$emodirs[] = $file;
|
|
}
|
|
}
|
|
}
|
|
closedir( $dh );
|
|
|
|
//-----------------------------------------
|
|
// Start output
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= "<script type='text/javascript'>
|
|
function addfolder()
|
|
{
|
|
document.macroform.emoset.value = '';
|
|
document.macroform.code.value = 'emo_setadd';
|
|
document.macroform.submitbutton.value = 'Ñîçäàòü ïàïêó';
|
|
scroll(0,0);
|
|
togglediv( 'popbox', 1 );
|
|
return false;
|
|
}
|
|
|
|
function editfolder(id)
|
|
{
|
|
document.macroform.submitbutton.value = 'Èçìåíèòü èìÿ ïàïêè';
|
|
document.macroform.id.value = id;
|
|
document.macroform.code.value = 'emo_setedit';
|
|
document.macroform.emoset.value = id;
|
|
scroll(0,0);
|
|
togglediv( 'popbox', 1 );
|
|
return false;
|
|
}
|
|
</script>
|
|
<div align='center' style='position:absolute;display:none;text-align:center' id='popbox'>
|
|
<form name='macroform' action='{$this->ipsclass->base_url}' method='post'>
|
|
<input type='hidden' name='act' value='emoticons' />
|
|
<input type='hidden' name='section' value='lookandfeel' />
|
|
<input type='hidden' name='code' value='emo_setadd' />
|
|
<input type='hidden' name='id' value='' />
|
|
<table cellspacing='0' width='500' align='center' cellpadding='6' style='background:#EEE;border:2px outset #555;'>
|
|
<tr>
|
|
<td width='1%' nowrap='nowrap' valign='top' align='center'>
|
|
<b>Íàçâàíèå ïàïêè (òîëüêî áóêâû)</b><br><input class='textinput' name='emoset' type='text' size='40' />
|
|
<br /><br />
|
|
<center><input type='submit' class='realbutton' value='Add Folder' name='submitbutton' /> <input type='button' class='realdarkbutton' value='Çàêðûòü' onclick=\"togglediv('popbox');\" /></center>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
</div>";
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'emo_upload' ),
|
|
2 => array( 'act' , 'emoticons' ),
|
|
3 => array( 'MAX_FILE_SIZE', '10000000000' ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
) , "uploadform", " enctype='multipart/form-data'" );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Òåêóùàÿ ïàïêà ñìàéëèêîâ" );
|
|
|
|
foreach( $emodirs as $dir )
|
|
{
|
|
$files = $this->emoticon_get_folder_contents( $dir );
|
|
$count = intval( count($files) );
|
|
|
|
if ( is_writeable( './style_emoticons/'.$dir ) )
|
|
{
|
|
$icon = 'icon_can_write.gif';
|
|
$title = 'Íîâûå ñìàéëèêè ìîãóò áûòü äîáàâëåíû: ýòà ïàïêà èìååò ðàçðåøåíèå íà çàïèñü';
|
|
$checkbox = "<input type='checkbox' name='dir_{$dir}' value='1' />";
|
|
}
|
|
else
|
|
{
|
|
$icon = 'icon_cannot_write.gif';
|
|
$title = 'Â ýòó ïàïêó íåëüçÿ ïðîèçâîäèòü çàïèñü è CHMOD äîëæåí áûòü èçìåíåí';
|
|
$checkbox = "-";
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<center><img src='{$this->ipsclass->skin_url}/images/emoticon_folder.gif' border='0'></center>",
|
|
"<table width='100%' border='0'>
|
|
<tr>
|
|
<td width='99%' align='left'><a href='{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=emo_manage&id={$dir}' title='Óïðàâëåíèå ñìàéëèêàìè'><b>{$dir}</b></a></td>
|
|
<td width='1%' align='right'><img src='{$this->ipsclass->skin_url}/images/{$icon}' title='{$title}' alt='$icon' /></td>
|
|
</tr>
|
|
</table>",
|
|
"<center>{$checkbox}</center>",
|
|
"<center>{$count}</center>",
|
|
"<center>".intval($emo_db[ $dir ]['count'])."</center>",
|
|
"<center><input type='button' class='realbutton' value='Èçìåíèòü' onclick=\"editfolder('$dir');\" /> ".
|
|
$this->ipsclass->adskin->js_make_button("Óïðàâëåíèå" , $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=emo_manage&id={$dir}").' '.
|
|
$this->ipsclass->adskin->js_make_button("Óäàëèòü" , $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=emo_setremove&id={$dir}")
|
|
."</center>"
|
|
) );
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( array( "<div align='center'><input type='button' class='realbutton' value='Ñîçäàòü íîâóþ ïàïêó' onclick=\"addfolder();\" /></div>", 6, 'pformstrip' ) ) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
$this->ipsclass->admin->page_detail = "Â ýòîé ñåêöèè âû ìîæåòå äîáàâëÿòü, èçìåíÿòü è óäàëÿòü ñìàéëèêè.";
|
|
$this->ipsclass->admin->page_title = "Óïðàâëåíèå ñìàéëèêàìè";
|
|
|
|
if ( SAFE_MODE_ON )
|
|
{
|
|
$this->ipsclass->admin->page_detail .= "<b>SAFE MODE ÂÊËÞ×ÅÍ:</b> Ôóíêöèè ïî çàãðóçêå ëþáûõ ôàéëîâ íå áóäóò ðàáîòàòü, ïîêà PHP íàõîäèòñÿ â safe mode.";
|
|
$this->ipsclass->html .= "</form>";
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->html .= "<div class='tableborder'>
|
|
<div class='maintitle'>Çàãðóçêà ñìàéëèêîâ</div>
|
|
<table width='100%' border='0' cellpadding='4' cellspacing='0'>
|
|
<tr>
|
|
<td width='50%' class='tdrow1' align='center'><input type='file' value='{$_POST['upload_1']}' class='realbutton' name='upload_1' size='30' /></td>
|
|
<td width='50%' class='tdrow2' align='center'><input type='file' class='realbutton' name='upload_2' size='30' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td width='50%' class='tdrow1' align='center'><input type='file' class='realbutton' name='upload_3' size='30' /></td>
|
|
<td width='50%' class='tdrow2' align='center'><input type='file' class='realbutton' name='upload_4' size='30' /></td>
|
|
</tr>
|
|
</table>
|
|
<div class='pformstrip' align='center'><input type='submit' value='Çàãðóçèòü ñìàéëèêè â âûáðàííûå ïàïêè' class='realdarkbutton' /></form></div>
|
|
</div>";
|
|
}
|
|
|
|
$this->ipsclass->admin->output();
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Remove set
|
|
//-----------------------------------------
|
|
|
|
function emoticon_setremove()
|
|
{
|
|
$this->ipsclass->admin->page_detail = "Óäàëèòü IPB ïàê ñìàéëèêîâ.";
|
|
$this->ipsclass->admin->page_title = "Óïðàâëåíèå ñìàéëèêàìè";
|
|
|
|
if ( ! $this->ipsclass->input['id'] )
|
|
{
|
|
$this->ipsclass->main_msg = "Íå âûáðàí íè îäèí ñìàéëèê.";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Splash or mash?
|
|
//-----------------------------------------
|
|
|
|
if ( $this->ipsclass->input['do'] )
|
|
{
|
|
//-----------------------------------------
|
|
// Do it
|
|
//-----------------------------------------
|
|
|
|
if ( $this->ipsclass->input['emo_set'] == 'd' )
|
|
{
|
|
$this->ipsclass->admin->rm_dir( CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['id'] );
|
|
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'emoticons', 'where' => "emo_set='{$this->ipsclass->input['id']}'" ) );
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->admin->copy_dir( CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['id'], CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['emo_set'] );
|
|
$this->ipsclass->admin->rm_dir( CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['id'] );
|
|
|
|
//-----------------------------------------
|
|
// Merge, don't overwrite
|
|
//-----------------------------------------
|
|
|
|
$old_emo_db = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='".$this->ipsclass->input['id']."'" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$old_emo_db[ $r['image'] ] = $r;
|
|
}
|
|
|
|
$new_emo_db = array();
|
|
$new_typed = array();
|
|
$new_image = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='".$this->ipsclass->input['emo_set']."'" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$new_emo_db[ $r['image'] ] = $r;
|
|
$new_typed[ $r['typed'] ] = 1;
|
|
$new_image[ $r['image'] ] = 1;
|
|
}
|
|
|
|
$keep_ids = array();
|
|
$delete_ids = array();
|
|
|
|
foreach( $old_emo_db as $image => $data )
|
|
{
|
|
if ( $new_image[ $image ] or $new_typed[ $data['typed'] ] )
|
|
{
|
|
$delete_ids[] = $data['id'];
|
|
}
|
|
else
|
|
{
|
|
$keep_ids[] = $data['id'];
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Delete...
|
|
//-----------------------------------------
|
|
|
|
if ( count($delete_ids) )
|
|
{
|
|
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'emoticons', 'where' => "id IN(".implode(",",$delete_ids).")" ) );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Keep...
|
|
//-----------------------------------------
|
|
|
|
if ( count($keep_ids) )
|
|
{
|
|
$this->ipsclass->DB->do_update( 'emoticons', array( 'emo_set' => $this->ipsclass->input['emo_set'] ), "id IN(".implode(",",$keep_ids).")" );
|
|
}
|
|
}
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
$this->ipsclass->main_msg = "Ïàïêà ñ ñìàéëèêàìè áûëî óäàëåíà.";
|
|
$this->emoticon_start();
|
|
}
|
|
else
|
|
{
|
|
//-----------------------------------------
|
|
// Get emoticon folders
|
|
//-----------------------------------------
|
|
|
|
$emodirs = array();
|
|
$emodd = array( 0=> array( 'd', "Íå ïåðåìåùàòü, òîëüêî óäàëÿòü" ) );
|
|
|
|
$dh = opendir( CACHE_PATH.'style_emoticons' );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if (($file != ".") && ($file != ".."))
|
|
{
|
|
if ( is_dir(CACHE_PATH.'style_emoticons/'.$file) )
|
|
{
|
|
if ( $file != $this->ipsclass->input['id'] )
|
|
{
|
|
$emodirs[] = $file;
|
|
$emodd[] = array( $file, "Ïåðåìåñòèòü â: ".$file );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
closedir( $dh );
|
|
|
|
if ( count ( $emodirs ) < 1 )
|
|
{
|
|
$this->ipsclass->main_msg = "ÍÅËÜÇß ÓÄÀËÈÒÜ: Ýòà ïîñëåäíÿÿ ãðóïïà ñìàéëèêîâ è åå íèêàê íåëüçÿ óäàëèòü";
|
|
$this->emoticon_start();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Show form
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
|
|
|
|
//-----------------------------------------
|
|
// EXPORT: Start output
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'emo_setremove' ),
|
|
2 => array( 'act' , 'emoticons' ),
|
|
3 => array( 'id' , $this->ipsclass->input['id'] ),
|
|
4 => array( 'do' , 1 ),
|
|
5 => array( 'section', $this->ipsclass->section_code ),
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "ÓÄÀËÅÍÈÅ ÍÀÁÎÐÀ ÑÌÀÉËÈÊÎÂ: ".$this->ipsclass->input['id'] );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Ïåðåìåñòèòü èëè óäàëèòü îñòàâøèåñÿ ñìàéëèêè â ýòîì íàáîðå?</b><div style='color:gray'>Åñëè Âû ïåðåìåñòèòå èõ â äðóãóþ ãðóïïó, òî íå äóáëèðóéòå èçîáðàæåíèÿ è àêòèâàöèîííûå ñëîâà íå èçìåíÿòñÿ.</div>",
|
|
$this->ipsclass->adskin->form_dropdown( 'emo_set', $emodd )
|
|
) );
|
|
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("ÓÄÀËÈÒÜ ÃÐÓÏÏÓ ÑÌÀÉËÈÊÎÂ");
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
|
|
$this->ipsclass->admin->output();
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Import/Export Pack Splash
|
|
//-----------------------------------------
|
|
|
|
function emoticon_pack_splash()
|
|
{
|
|
$this->ipsclass->admin->page_detail = "Èìïîðò/ýêñïîðò ñìàéëèêîâ.";
|
|
$this->ipsclass->admin->page_title = "Íàñòðîéêà ñìàéëèêîâ";
|
|
|
|
if ( ! is_dir( CACHE_PATH. 'style_emoticons') )
|
|
{
|
|
$this->ipsclass->admin->error("Íåëüçÿ íàéòè ìåñòîðàñïîëîæåíèå ïàïêè ñî ñìàéëèêàìè - óáåäèòåñü ÷òî ïóòü ê 'style_emoticons' ïðàâèëåí.");
|
|
$this->ipsclass->admin->output();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get emoticon count
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->cache_add_query( 'admin_emo_count', array() );
|
|
$this->ipsclass->DB->cache_exec_query();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$emo_db[ $r['emo_set'] ] = $r;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get emoticon folders
|
|
//-----------------------------------------
|
|
|
|
$emodirs = array();
|
|
$emodd = array();
|
|
|
|
$dh = opendir( CACHE_PATH.'style_emoticons' );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if (($file != ".") && ($file != ".."))
|
|
{
|
|
if ( is_dir(CACHE_PATH.'style_emoticons/'.$file) )
|
|
{
|
|
$emodirs[] = $file;
|
|
$emodd[] = array( $file, $file );
|
|
}
|
|
}
|
|
}
|
|
closedir( $dh );
|
|
|
|
//-----------------------------------------
|
|
// EXPORT: Start table
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
|
|
|
|
//-----------------------------------------
|
|
// EXPORT: Start output
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'emo_packexport' ),
|
|
2 => array( 'act' , 'emoticons' ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Ýêñïîðò ãðóïïû ñìàéëèêîâ" );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Êàêóþ ãðóïïó ñìàéëèêîâ ýêñïîðòèðîâàòü?</b><div style='color:gray'>Ãðóïïà ñàéëèêîâ áóäåò óïàêîâàíà â XML-àðõèâ ñ èçîáðàæåíèÿìè è ñëîâàìè âûçîâà ñìàéëèêîâ (íàïðèìåð :smile:)</div>",
|
|
$this->ipsclass->adskin->form_dropdown( 'emo_set', $emodd )
|
|
) );
|
|
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Ýêñïîðò");
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
//-----------------------------------------
|
|
// IMPORT: Start table
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
|
|
|
|
//-----------------------------------------
|
|
// IMPORT: Start output
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'emo_packimport' ),
|
|
2 => array( 'act' , 'emoticons' ),
|
|
3 => array( 'MAX_FILE_SIZE', '10000000000' ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
) , "uploadform", " enctype='multipart/form-data'" );
|
|
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Èìïîðò ãðóïïû ñìàéëèêîâ" );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Â êàêóþ ñóùåñòâóþùóþ ãðóïïó èìïîðòèðîâàòü ñìàéëèêè?</b><div style='color:gray'>Ãðóïïà ñàéëèêîâ äîëæíà áûòü óïàêîâàíà â XML-àðõèâ ñ èçîáðàæåíèÿìè è ñëîâàìè âûçîâà ñìàéëèêîâ (íàïðèìåð :smile:)</div>",
|
|
$this->ipsclass->adskin->form_dropdown( 'emo_set', $emodd )
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b><u>ÈËÈ</u> Èìïîðòèðîâàòü â íîâóþ ãðóïïó:</b><div style='color:gray'>Ââåäèòå íàçâàíèå íîâîé ãðóïïû ñìàéëèêîâ.</div>",
|
|
$this->ipsclass->adskin->form_input( 'new_emo_set' )
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Ïåðåçàïèñàòü ñóùåñòâóþùèå èçîáðàæåíèå è ñëîâà âûçîâà ñìàéëèêîâ?</b><div style='color:gray'>Åñëè âûáðàíî ÄÀ, íîâûå èçîáðàæåíèÿ çàìåíÿò ñòàðûå</div>",
|
|
$this->ipsclass->adskin->form_yes_no( 'overwrite' )
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Çàãðóçêà XML-àðõèâà ñìàéëèêîâ</b><div style='color:gray'>Âûáåðèòå ôàéë äëÿ çàãðóçêè ñ âàøåãî êîìïüþòåðà 'ipb_emoticons.xml' èëè 'ipb_emoticons.xml.gz'</div>",
|
|
$this->ipsclass->adskin->form_upload( )
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Èìïîðò");
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
|
|
$this->ipsclass->admin->output();
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON EXPORT! EXPORT! EX... oh, that's abort isn't it?
|
|
//-----------------------------------------
|
|
|
|
function emoticon_pack_export()
|
|
{
|
|
//-----------------------------------------
|
|
// Get xml mah-do-dah
|
|
//-----------------------------------------
|
|
|
|
require( KERNEL_PATH.'class_xml.php' );
|
|
|
|
$xml = new class_xml();
|
|
|
|
require( KERNEL_PATH.'class_xmlarchive.php' );
|
|
|
|
$xmlarchive = new class_xmlarchive();
|
|
|
|
//-----------------------------------------
|
|
// Checkdamoonah
|
|
//-----------------------------------------
|
|
|
|
if ( ! $this->ipsclass->input['emo_set'] )
|
|
{
|
|
$this->ibforums->msg = "Âû äîëæíû âûáðàòü, êàêóþ ãðóïïó ñìàéëèêîâ áóäåò ýêñïîðòèðîâàòü";
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get emowticuns
|
|
//-----------------------------------------
|
|
|
|
$emo_db = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='".$this->ipsclass->input['emo_set']."'" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$emo_db[ $r['image'] ] = $r;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get ;) :D folders
|
|
//-----------------------------------------
|
|
|
|
$emodirs = array();
|
|
$emodd = array();
|
|
|
|
$dh = opendir( CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['emo_set'] );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if (($file != ".") && ($file != ".."))
|
|
{
|
|
if ( $emo_db[ $file ] != "" )
|
|
{
|
|
$files_to_add[] = CACHE_PATH.'style_emoticons/'.$this->ipsclass->input['emo_set'].'/'.$file;
|
|
}
|
|
}
|
|
}
|
|
|
|
closedir( $dh );
|
|
|
|
//-----------------------------------------
|
|
// Add um into the ark-hive
|
|
//-----------------------------------------
|
|
|
|
foreach( $files_to_add as $f )
|
|
{
|
|
$xmlarchive->xml_add_file( $f );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Create the database archive...
|
|
//-----------------------------------------
|
|
|
|
$xml->xml_set_root( 'emoticonexport', array( 'exported' => time(), 'name' => $this->ipsclass->input['emo_set'] ) );
|
|
|
|
//-----------------------------------------
|
|
// Get emo group
|
|
//-----------------------------------------
|
|
|
|
$xml->xml_add_group( 'emogroup' );
|
|
|
|
foreach( $emo_db as $i => $r )
|
|
{
|
|
$content = array();
|
|
|
|
$content[] = $xml->xml_build_simple_tag( 'typed' , $r['typed'] );
|
|
$content[] = $xml->xml_build_simple_tag( 'image' , $r['image'] );
|
|
$content[] = $xml->xml_build_simple_tag( 'clickable', $r['clickable'] );
|
|
|
|
$entry[] = $xml->xml_build_entry( 'emoticon', $content );
|
|
}
|
|
|
|
$xml->xml_add_entry_to_group( 'emogroup', $entry );
|
|
|
|
$xml->xml_format_document();
|
|
|
|
//-----------------------------------------
|
|
// Add in emoticons doc to archive
|
|
//-----------------------------------------
|
|
|
|
$xmlarchive->xml_add_file_contents( $xml->xml_document, 'emoticon_data.xml' );
|
|
|
|
$xmlarchive->xml_create_archive();
|
|
|
|
//-----------------------------------------
|
|
// Create archive and send to
|
|
// browser.
|
|
//-----------------------------------------
|
|
|
|
$imagearchive = $xmlarchive->xml_get_contents();
|
|
|
|
$this->ipsclass->admin->show_download( $imagearchive, 'ipb_emoticons.xml' );
|
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// IMPORT THE EMOTICONS
|
|
//-----------------------------------------
|
|
|
|
function emoticon_pack_import()
|
|
{
|
|
$content = $this->ipsclass->admin->import_xml( 'ipb_emoticons.xml' );
|
|
|
|
//-----------------------------------------
|
|
// Got anything?
|
|
//-----------------------------------------
|
|
|
|
if ( ! $content )
|
|
{
|
|
$this->ipsclass->main_msg = "Íåóäà÷íàÿ çàãðóçêà, ipb_emoticons.xml ëèáî íå ñóùåñòâóåò, ëèáî ïóñò";
|
|
$this->emoticon_pack_splash();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get xml mah-do-dah
|
|
//-----------------------------------------
|
|
|
|
require( KERNEL_PATH.'class_xml.php' );
|
|
|
|
$xml = new class_xml();
|
|
|
|
require( KERNEL_PATH.'class_xmlarchive.php' );
|
|
|
|
$xmlarchive = new class_xmlarchive();
|
|
|
|
$xmlarchive->xml_read_archive_data( $content );
|
|
|
|
//-----------------------------------------
|
|
// Get the datafile
|
|
//-----------------------------------------
|
|
|
|
$emoticons = array();
|
|
$emoticon_data = array();
|
|
|
|
foreach( $xmlarchive->file_array as $f )
|
|
{
|
|
if ( $f['filename'] == 'emoticon_data.xml' )
|
|
{
|
|
$emoticon_data = $f['content'];
|
|
}
|
|
else
|
|
{
|
|
$emoticons[ $f['filename'] ] = $f['content'];
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Unpack the datafile
|
|
//-----------------------------------------
|
|
|
|
$xml->xml_parse_document( $emoticon_data );
|
|
|
|
//-----------------------------------------
|
|
// New set, old set - we're set!
|
|
//-----------------------------------------
|
|
|
|
if ( ! $this->ipsclass->input['emo_set'] and ! $this->ipsclass->input['new_emo_set'] )
|
|
{
|
|
$this->ibforums->msg = "Âû äîëæíû âûáðàòü, êàêóþ ãðóïïó ñìàéëèêîâ áóäåòå èñïîðòèðîâàòü";
|
|
}
|
|
|
|
$emo_set_dir = $this->ipsclass->input['emo_set'];
|
|
|
|
$this->ipsclass->input['new_emo_set'] = preg_replace( "/[^a-zA-Z0-9\-_]/", "",$this->ipsclass->input['new_emo_set'] );
|
|
|
|
if ( $this->ipsclass->input['new_emo_set'] )
|
|
{
|
|
$emo_set_dir = $this->ipsclass->input['new_emo_set'];
|
|
|
|
//-----------------------------------------
|
|
// Directory exists?
|
|
//-----------------------------------------
|
|
|
|
if ( file_exists( CACHE_PATH.'style_emoticons/'.$emo_set_dir ) )
|
|
{
|
|
$this->ipsclass->main_msg = "'style_emoticons/$emo_set_dir' óæå ñóùåñòâóåò, âûáåðèòå äðóãèå èìÿ.";
|
|
$this->emoticon_pack_splash();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Create directory?
|
|
//-----------------------------------------
|
|
|
|
if ( @mkdir( CACHE_PATH.'style_emoticons/'.$emo_set_dir, 0777 ) )
|
|
{
|
|
@chmod( CACHE_PATH.'style_emoticons/'.$emo_set_dir, 0777 );
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->main_msg = ": IPB íå ìîæåò ñîçäàòü èëè îòðåäàêòèðîâàòü ïàïêó çà âàñ, ïîæàëóéñòà, ñîçäàéòå ñàìè (èëè óäàëèòå) ïàïêó ïðè ïîìîùè FTP â 'style_emoticons'";
|
|
$this->emoticon_pack_splash();
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Are we over writing?
|
|
//-----------------------------------------
|
|
|
|
$emo_image = array();
|
|
$emo_typed = array();
|
|
|
|
if ( $this->ipsclass->input['overwrite'] != 1 )
|
|
{
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='".$emo_set_dir."'" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$emo_image[ $r['image'] ] = 1;
|
|
$emo_typed[ $r['typed'] ] = 1;
|
|
}
|
|
}
|
|
|
|
foreach( $xml->xml_array['emoticonexport']['emogroup']['emoticon'] as $idx => $entry )
|
|
{
|
|
$image = $entry['image']['VALUE'];
|
|
$typed = $entry['typed']['VALUE'];
|
|
$click = $entry['clickable']['VALUE'];
|
|
|
|
if ( $emo_image[ $image ] or $emo_typed[ $typed ] )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
$file_extension = preg_replace( "#^.*\.(.+?)$#si", "\\1", strtolower( $image ) );
|
|
|
|
if ( ! in_array( $file_extension, $this->allowed_files ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
@unlink( CACHE_PATH.'style_emoticons/'.$emo_set_dir.'/'.$image );
|
|
|
|
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'emoticons', 'where' => "typed='$typed' and image='$image' and emo_set='$emo_set_dir'" ) );
|
|
|
|
if ( $FH = fopen( CACHE_PATH.'style_emoticons/'.$emo_set_dir.'/'.$image, 'wb' ) )
|
|
{
|
|
if ( fwrite( $FH, $emoticons[ $image ] ) )
|
|
{
|
|
fclose( $FH );
|
|
|
|
$this->ipsclass->DB->do_insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'clickable' => $click, 'emo_set' => $emo_set_dir ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->emoticon_rebuildcache();
|
|
|
|
$this->ipsclass->main_msg = "Èìïîðòèðîâàíèå XML-àðõèâà ñìàéëèêîâ çàâåðøåí ";
|
|
|
|
$this->emoticon_start();
|
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Manage
|
|
//-----------------------------------------
|
|
|
|
function emoticon_manage()
|
|
{
|
|
$this->ipsclass->input['id'] = trim($this->ipsclass->input['id']);
|
|
|
|
$this->ipsclass->admin->nav[] = array( "{$this->ipsclass->form_code}&code=emo", 'Óïðàâëåíèå ñìàéëèêàìè' );
|
|
$this->ipsclass->admin->nav[] = array( '', 'Óïðàâëåíèå ãðóïïîé ñìàéëèêîâ '.$this->ipsclass->input['id'] );
|
|
|
|
$this->ipsclass->admin->page_detail = " ýòîé ñåêöèè âû ìîæåòå äîáàâëÿòü, èçìåíÿòü è óäàëÿòü ñìàéëèêè. Íàæèìàåìûå ñìàéëèêè — ýòî ñìàéëèêè, êîòîðûå áóäóò ïîêàçàíû â òàáëè÷êå ðÿäîì ñ ôîðìîé ñîîáùåíèÿ äëÿ áûñòðîãî âûáîðà ñìàéëèêà.<br /><strong>Âû íå ìîæåòå èñïîëüçîâàòü ñèìâîë " â êîäå âûçîâà.";
|
|
$this->ipsclass->admin->page_title = "Óïðàâëåíèå ñìàéëèêàìè";
|
|
|
|
//-----------------------------------------
|
|
// Get emoticons for this group
|
|
//-----------------------------------------
|
|
|
|
$emo_db = array();
|
|
$emo_file = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='".$this->ipsclass->input['id']."'", 'order' => 'clickable DESC' ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$emo_db[ $r['image'] ] = $r;
|
|
}
|
|
|
|
$emo_file = array();
|
|
$emo_rfile = $this->emoticon_get_folder_contents( $this->ipsclass->input['id'] );
|
|
|
|
foreach( $emo_rfile as $ef )
|
|
{
|
|
$emo_file[ $ef ] = $ef;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Start output
|
|
//-----------------------------------------
|
|
|
|
$per_row = 5;
|
|
$td_width = 100 / $per_row;
|
|
|
|
$this->ipsclass->html .= "<div class='tableborder'>
|
|
<div class='maintitle'>Óñòàíîâëåííûå ñìàéëèêè â ãðóïïå '{$this->ipsclass->input['id']}'</div>
|
|
<form action='{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=emo_doedit&id={$this->ipsclass->input['id']}' method='post'>
|
|
<table cellpadding='4' cellspacing='0' border='0' width='100%'>
|
|
";
|
|
|
|
$count = 0;
|
|
$smilies = "<tr align='center'>\n";
|
|
$poss_names = array();
|
|
|
|
foreach( $emo_db as $image => $data )
|
|
{
|
|
$count++;
|
|
|
|
unset( $emo_file[ $image ] );
|
|
|
|
if ( $data['clickable'] )
|
|
{
|
|
$click = 'checked="checked"';
|
|
$class = 'tdrow1';
|
|
}
|
|
else
|
|
{
|
|
$click = '';
|
|
$class = 'tdrow2';
|
|
}
|
|
|
|
$smilies .= "<td width='{$td_width}%' align='center' class='$class'>
|
|
<fieldset>
|
|
<legend><strong>{$image}</strong></legend>
|
|
<img src='style_emoticons/{$this->ipsclass->input['id']}/{$image}' border='0' /> <a href='{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=emo_remove&eid={$data['id']}&id={$this->ipsclass->input['id']}' title='Óäàëèòü ýòîò ñìàéëèê'><img src='{$this->ipsclass->skin_url}/images/emo_delete.gif' border='0' alt='Óäàëèòü' /></a>
|
|
<br />
|
|
<input type='textinput' class='realbutton' size='10' name='emo_type_{$data['id']}' value='{$data['typed']}' />
|
|
<br /><br />Íàæèìàåìûé? <input type='checkbox' name='emo_click_{$data['id']}' value='1' {$click} />
|
|
</fieldset>
|
|
</td>";
|
|
|
|
if ($count == $per_row )
|
|
{
|
|
$smilies .= "</tr>\n\n<tr align='center'>";
|
|
$count = 0;
|
|
}
|
|
|
|
$poss_names[$data['typed']] = $data['typed'];
|
|
}
|
|
|
|
if ( $count > 0 and $count != $per_row )
|
|
{
|
|
for ($i = $count ; $i < $per_row ; ++$i)
|
|
{
|
|
$smilies .= "<td class='tdrow2'> </td>\n";
|
|
}
|
|
|
|
$smilies .= "</tr>";
|
|
}
|
|
|
|
|
|
$this->ipsclass->html .= $smilies;
|
|
|
|
$this->ipsclass->html .= "</table>
|
|
<div class='pformstrip' align='center'><input type='submit' class='realbutton' value='Îáíîâèòü ñìàéëèêè' /></form></div></div><br />";
|
|
|
|
|
|
//-----------------------------------------
|
|
// Images left in the dir?
|
|
//-----------------------------------------
|
|
|
|
if ( count( $emo_file ) )
|
|
{
|
|
$this->ipsclass->html .= "<div class='tableborder'>
|
|
<div class='maintitle'>Íåóñòàíîâëåííûå ñìàéëèêè â ãðóïïå '{$this->ipsclass->input['id']}'</div>
|
|
<form action='{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=emo_doadd&id={$this->ipsclass->input['id']}' method='post'>
|
|
<table cellpadding='4' cellspacing='0' border='0' width='100%'>
|
|
";
|
|
|
|
$count = 0;
|
|
$smilies = "<tr align='center'>\n";
|
|
|
|
$master_count = 0;
|
|
|
|
foreach( $emo_file as $image )
|
|
{
|
|
$count++;
|
|
$master_count++;
|
|
|
|
$poss_name = ':'.preg_replace( "/(.*)(\..+?)$/", "\\1", $image ).':';
|
|
|
|
if ( $poss_names[ $poss_name ] )
|
|
{
|
|
$poss_name = preg_replace( "/:$/", "2:", $poss_name );
|
|
}
|
|
|
|
$smilies .= "<td width='{$td_width}%' align='center' class='tdrow1'>
|
|
<fieldset>
|
|
<legend><strong>{$image}</strong></legend>
|
|
<img src='style_emoticons/{$this->ipsclass->input['id']}/{$image}' border='0' /> <b>Äîáàâèòü</b> <input name='emo_add_{$master_count}' type='checkbox' value='1' />
|
|
<br />
|
|
Âûçîâ: <input type='textinput' class='realbutton' size='10' name='emo_type_{$master_count}' value='$poss_name' />
|
|
<br /><br />Íàæèìàåìûé? <input type='checkbox' name='emo_click_{$master_count}' value='1' />
|
|
<input type='hidden' name='emo_image_{$master_count}' value='{$image}' />
|
|
</fieldset>
|
|
</td>";
|
|
|
|
if ($count == $per_row )
|
|
{
|
|
$smilies .= "</tr>\n\n<tr align='center'>";
|
|
$count = 0;
|
|
}
|
|
}
|
|
|
|
if ( $count > 0 and $count != $per_row )
|
|
{
|
|
for ($i = $count ; $i < $per_row ; ++$i)
|
|
{
|
|
$smilies .= "<td class='tdrow1'> </td>\n";
|
|
}
|
|
|
|
$smilies .= "</tr>";
|
|
}
|
|
|
|
|
|
$this->ipsclass->html .= $smilies;
|
|
|
|
$this->ipsclass->html .= "</table>
|
|
<div class='pformstrip' align='center'><input type='submit' class='realbutton' value='Äîáàâèòü âûáðàííûå ñìàéëèêè' /> <input type='submit' name='addall' class='realbutton' value='Äîáàâèòü âñå ñìàéëèêè' /></form></div></div>";
|
|
}
|
|
|
|
$this->ipsclass->admin->output();
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Rebuild Cache
|
|
//-----------------------------------------
|
|
|
|
function emoticon_rebuildcache()
|
|
{
|
|
$this->ipsclass->cache['emoticons'] = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => 'typed,image,clickable,emo_set', 'from' => 'emoticons' ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->cache['emoticons'][] = $r;
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'emoticons', 'array' => 1, 'deletefirst' => 1 ) );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EMOTICON Get folder contents
|
|
//-----------------------------------------
|
|
|
|
function emoticon_get_folder_contents($folder='default')
|
|
{
|
|
$files = array();
|
|
|
|
//-----------------------------------------
|
|
// Get emoticon folders
|
|
//-----------------------------------------
|
|
|
|
$dh = opendir( CACHE_PATH.'style_emoticons/'.$folder );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if ( ($file != ".") && ($file != "..") )
|
|
{
|
|
if ( preg_match( "/\.(?:gif|jpg|jpeg|png|swf)$/i", $file ) )
|
|
{
|
|
$files[] = $file;
|
|
}
|
|
}
|
|
}
|
|
|
|
closedir( $dh );
|
|
|
|
return $files;
|
|
}
|
|
|
|
|
|
|
|
function perly_length_sort($a, $b)
|
|
{
|
|
if ( strlen($a['typed']) == strlen($b['typed']) )
|
|
{
|
|
return 0;
|
|
}
|
|
return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;
|
|
}
|
|
|
|
function perly_word_sort($a, $b)
|
|
{
|
|
if ( strlen($a['type']) == strlen($b['type']) )
|
|
{
|
|
return 0;
|
|
}
|
|
return ( strlen($a['type']) > strlen($b['type']) ) ? -1 : 1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|