Выберите файл для загрузки с вашего компьютера 'ipb_emoticons.xml' или 'ipb_emoticons.xml.gz'
",
$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 = "В этой секции вы можете добавлять, изменять и удалять смайлики. Нажимаемые смайлики — это смайлики, которые будут показаны в табличке рядом с формой сообщения для быстрого выбора смайлика. Вы не можете использовать символ " в коде вызова.";
$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 .= "
Установленные смайлики в группе '{$this->ipsclass->input['id']}'
";
//-----------------------------------------
// Images left in the dir?
//-----------------------------------------
if ( count( $emo_file ) )
{
$this->ipsclass->html .= "
Неустановленные смайлики в группе '{$this->ipsclass->input['id']}'