$Date: 2005-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $ | > $Revision: 23 $ | > $Author: matt $ +--------------------------------------------------------------------------- | | > Help Control functions | > Module written by Matt Mecham | > Date started: 2nd April 2002 | | > Module Version Number: 1.0.0 | > DBA Checked: Mon 24th May 2004 +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_ACP' ) ) { print "

Неверный вход

У Вас нет доступа к директиве этого файла. Если Вы проводили обновления, убедитесь, что не забыли обновить 'admin.php'."; exit(); } class ad_help { var $base_url; /** * Section title name * * @var string */ var $perm_main = "tools"; /** * Section title name * * @var string */ var $perm_child = "help"; function auto_run() { //----------------------------------------- // Kill globals - globals bad, Homer good. //----------------------------------------- $tmp_in = array_merge( $_GET, $_POST, $_COOKIE ); foreach ( $tmp_in as $k => $v ) { unset($$k); } //----------------------------------------- switch($this->ipsclass->input['code']) { case 'edit': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' ); $this->show_form('edit'); break; case 'new': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' ); $this->show_form('new'); break; case 'doedit': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' ); $this->doedit(); break; case 'donew': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' ); $this->doadd(); break; case 'remove': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' ); $this->remove(); break; //----------------------------------------- default: $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' ); $this->list_files(); break; } } //----------------------------------------- // HELP FILE FUNCTIONS //----------------------------------------- function doedit() { if ($this->ipsclass->input['id'] == "") { $this->ipsclass->admin->error("Вы должны ввести правильный ID файла помощи!"); } $text = preg_replace( "/\n/", "
", stripslashes($_POST['text'] ) ); //$title = preg_replace( "/\n/", "
", stripslashes($_POST['title'] ) ); $desc = preg_replace( "/\n/", "
", stripslashes($_POST['description'] ) ); $text = preg_replace( "/\\\/", "\", $text ); $this->ipsclass->DB->do_update( 'faq', array( 'title' => $this->ipsclass->input['title'], 'text' => $text, 'description' => $desc, ) , "id=".intval($this->ipsclass->input['id']) ); $this->ipsclass->admin->save_log("Изменен файл помощи"); $this->ipsclass->boink_it($this->ipsclass->base_url."&{$this->ipsclass->form_code}"); exit(); } //===================================================== function show_form($type='new') { $this->ipsclass->admin->page_detail = "В этой секции вы можете добавлять, изменять и удалять файлы помощи."; $this->ipsclass->admin->page_title = "Управление файлами помощи"; //----------------------------------------- if ($type != 'new') { if ($this->ipsclass->input['id'] == "") { $this->ipsclass->admin->error("Вы должны ввести правильный ID файла помощи!"); } //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'faq', 'where' => "id=".intval($this->ipsclass->input['id']) ) ); $this->ipsclass->DB->simple_exec(); if ( ! $r = $this->ipsclass->DB->fetch_row() ) { $this->ipsclass->admin->error("Невозможно найти в базе данных файл помощи с таким ID"); } //----------------------------------------- $button = 'Изменить этот файл помощи'; $code = 'doedit'; } else { $r = array(); $button = 'Добавить этот файл помощи'; $code = 'donew'; } $this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , $code ), 2 => array( 'act' , 'help' ), 3 => array( 'id' , $this->ipsclass->input['id'] ), 4 => array( 'section', $this->ipsclass->section_code ), ) ); $this->ipsclass->adskin->td_header[] = array( " " , "20%" ); $this->ipsclass->adskin->td_header[] = array( " " , "80%" ); $r['text'] = preg_replace( "/
/i", "\n", stripslashes($r['text']) ); //----------------------------------------- $this->ipsclass->html .= $this->ipsclass->adskin->start_table( $button ); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Название файла помощи", $this->ipsclass->adskin->form_input('title' , stripslashes($r['title']) ), ) ); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Описание", $this->ipsclass->adskin->form_textarea('description', stripslashes($r['description']) ), ) ); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Текст", $this->ipsclass->adskin->form_textarea('text', $r['text'], "60", "10" ), ) ); $this->ipsclass->html .= $this->ipsclass->adskin->end_form($button); $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); $this->ipsclass->admin->output(); } //===================================================== function remove() { if ($this->ipsclass->input['id'] == "") { $this->ipsclass->admin->error("Вы должны ввести правильный ID файла помощи!"); } $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'faq', 'where' => "id=".$this->ipsclass->input['id'] ) ); $this->ipsclass->admin->save_log("Removed a help file"); $this->ipsclass->boink_it($this->ipsclass->base_url."&{$this->ipsclass->form_code}"); exit(); } //===================================================== function doadd() { if ($this->ipsclass->input['title'] == "") { $this->ipsclass->admin->error("Вы должны ввести название файла помощи!"); } $text = preg_replace( "/\n/", "
", stripslashes($_POST['text'] ) ); $title = preg_replace( "/\n/", "
", stripslashes($_POST['title'] ) ); $desc = preg_replace( "/\n/", "
", stripslashes($_POST['description'] ) ); $text = preg_replace( "/\\\/", "\", $text ); $this->ipsclass->DB->do_insert( 'faq', array( 'title' => $title, 'text' => $text, 'description' => $desc, ) ); $this->ipsclass->admin->save_log("Добавлен файл помощи"); $this->ipsclass->boink_it($this->ipsclass->base_url."&{$this->ipsclass->form_code}"); exit(); } //===================================================== function list_files() { $this->ipsclass->admin->page_detail = "В этой секции вы можете добавлять, изменять и удалять файлы помощи"; $this->ipsclass->admin->page_title = "Управление файлами помощи"; //----------------------------------------- $this->ipsclass->adskin->td_header[] = array( "Название" , "50%" ); $this->ipsclass->adskin->td_header[] = array( "Изменить" , "30%" ); $this->ipsclass->adskin->td_header[] = array( "Удалить" , "20%" ); //----------------------------------------- $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Текущие файлы помощи" ); $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'faq', 'order' => "id" ) ); $this->ipsclass->DB->simple_exec(); if ( $this->ipsclass->DB->get_num_rows() ) { while ( $r = $this->ipsclass->DB->fetch_row() ) { $this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "".stripslashes($r['title'])."
".stripslashes($r['description']), "
Изменить
", "
Удалить
", ) ); } } $this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Добавить новый файл помощи", "center", "pformstrip" ); $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); //----------------------------------------- $this->ipsclass->admin->output(); } } ?>