Location: PHPKode > projects > Esvon Personals > esvon-personals/modules/Extra_Pages/hw_admin.php
<?php

// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting, 
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds. 
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------

if(!defined('SITE_PATH') || !IsAdmin()) die('Access denied');
if(!function_exists('hwModVer') || !hwModVer(12)) die('This module is incompatible with '.EC_TITLE.' '.EC_VERSION);

require SITE_PATH.'inc/class.item_adm.php';

class ExpageAdm extends SiteItemAdm {
  
  function ExpageAdm(){ // constructor
  
    parent::SiteItemAdm();
    $this->TBL_ITEM = hwModTable(HW_MOD,'data');
    $this->ADM_TPL_PATH = HW_MOD_TPL.'ex_'; // with files prefix
    $this->PAGE_URL = HW_MOD_URL.'&'; //
    $this->FS_FILE = HW_MOD_TPL.'ex_fields.txt';
    if(!$_REQUEST['per_row']) $_REQUEST['per_row'] = 20;

  }
  
  function ListShow(){
  	parent::ListShow();
    $idx_extra = $this->db->one_data('SELECT COUNT(*) FROM '.$this->TBL_ITEM.' WHERE id="index"');
    if(EN_IDX_EXTRA <> $idx_extra){
      global $O_HW;
      $O_HW->Update( array('EN_IDX_EXTRA' => $idx_extra) );
    }
  }
  
  function ListSQLFieldsGet(){ 
    return '*,ROUND(LENGTH(content)/1024, 1) AS size_kb';
  }

  function ItemValidate(){
    $err_msg = parent::ItemValidate();
    if(!$err_msg){
      $col = 'id';
      $ql = $this->ID ? 'AND '.$this->IDX.'<>"'.$this->ID.'"' : '';
      $err_msg = hwIsDBUniqueTaken($this->TBL_ITEM,$col,$_POST[$col],$ql,'Page ID');
    }
    return $err_msg;
  }

  function ListRenderRow(&$v){
    $v['url'] = EN_SE_URLS ? "pg-$v[id].html" : 'index.php?page=extra&pg='.$v['id']; // HW_MOD_URL
  }

  function ItemsDelete() {
    //onExtraPageDelete
    if(hwModGetState('Multi_Lang')){
      $this->db->query('DELETE FROM '.hwModTable('Multi_Lang','extra_page').' WHERE id IN('.$this->ItemsDeleteSQLIds().')');
    }
    return parent::ItemsDelete();
  }

}

function Extra_Pages_main(){

// import old format data pages if available
  if(is_dir(TPL_PATH.'data')){
    if(rename(TPL_PATH.'data', TPL_PATH.'data_bak')){
      ExtraPagesImport(TPL_PATH.'data_bak/');
    }
  }

  $O_ADM = new ExpageAdm;
  $O_ADM->ShowPage();
}

// extra

function ExtraPagesImport($path){
  $buf = @file($path.'data.dat');
  if(!$buf) return;
  global $db;
  $tbl = hwModTable(HW_MOD,'data');
  foreach($buf as $line){
    list($p_id, $p_title) = explode("\t", rtrim($line));
    $p_body = @file_get_contents($path.$p_id);
    if(!$p_body) continue;
    $db->query('INSERT IGNORE INTO '.$tbl.' SET id=?, ptitle=?, content=?, wrap=1', 
      array($p_id, $p_title, $p_body) );
  }
}

?>
Return current item: Esvon Personals