Location: PHPKode > projects > Esvon Personals > esvon-personals/modules/Mailing_Lists/admin/ml_log.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')) die('Access denied');

define('ML_DISP_ROWS',10);

if($_POST['submdel']) GoDelete();
elseif($_POST['mail_now']) GoMail();

if($_REQUEST['pg']=='view') ShowFormList();
else ListItems();

// sub area

function ShowFormList() {
  global $db;

  $v = $db->one_assoc('SELECT ml.*,m.name FROM '.TBL_ML_LOG.' ml,'.TBL_ML_IDX.' m where ml.list_id=m.id AND ml.id='.(int)$_GET['id']);
  if(!$v) return;

  if(!$v['is_html']) $v['content'] = str_replace("\n",'<br>',$v['content']);
  $v['is_html'] = $v['is_html'] ? 'Yes' : 'No';

  EvalAdvTpl(HW_MOD_TPL.'ml_log_form.htm',$v,1);
}

function ListItems() {
 global $db;

 $tpl = new HawkTpl;
 $tpl->InitArray('row');

 $off = (ctype_digit($_GET['off']) && $_SERVER['REQUEST_METHOD']=='GET') ? $_GET['off'] : 0;
 $num = $off*ML_DISP_ROWS;

$mlist_id = (int)$_REQUEST['mlist_id'];
$sql_addon = ($mlist_id!=0?" AND m.id='$mlist_id'":'');

$num_rows = $db->one_data('SELECT count(*) FROM '.TBL_ML_LOG.' ml,'.TBL_ML_IDX.' m where ml.list_id=m.id'.$sql_addon);

$res = $db->query("SELECT ml.*,m.name FROM ".TBL_ML_LOG." ml,".TBL_ML_IDX." m WHERE ml.list_id=m.id $sql_addon".
                " ORDER BY date DESC,id DESC LIMIT $num,".ML_DISP_ROWS);

 while($v = mysql_fetch_assoc($res)) {
    $v['number']=++$num;
    if($v['status']==0) $v['status'] = 'pending';
    elseif($v['status']==1) $v['status'] = 'in progress';
    elseif($v['status']) $v['status'] = 'sent';
    $v['is_html'] = $v['is_html'] ? 'Yes' : 'No';
    $tpl->AddCell('row',$v);
  }

 $tpl_v = array();
 $tpl_v['nav'] = GetNavigation($_SERVER['PHP_SELF'],ML_DISP_ROWS,10,$num_rows,$off,'&mod='.HW_MOD.'&file=ml_log&mlist_id='.$mlist_id);
 $tpl_v['mlist'] = get_mail_lists(1,'OnChange="document.location=\''.HW_MOD_URL.'&file=ml_log&mlist_id=\'+document.frm.mlist_id.options[document.frm.mlist_id.selectedIndex].value"');

 $tpl->Parse(HW_MOD_TPL.'ml_log.htm', $tpl_v, 1);

}

function GoDelete() {
  global $db;
  if($_POST['chk_id'] && is_array($_POST['chk_id'])) {
    $s_id = '"'.implode('","', array_map('intval', $_POST['chk_id'])).'"';
    $db->query('DELETE FROM '.TBL_ML_TEMP.' WHERE log_id IN ('.$s_id.')');
    $db->query('DELETE FROM '.TBL_ML_LOG.' WHERE id IN ('.$s_id.')');
  }
}

function GoMail(){
global $err_msg;

  $fn = 'modules/Mailing_Lists/run.php';
  
  $is_executed = false;
  /*do {
    
    if($disabled_funcs = ini_get('disable_functions')){ // if "exec" is disabled
      if(preg_match('/[\s,]exec[\s,]/i',' '.$disabled_funcs.' ')) break;
    }

    $cmd = SITE_PATH.$fn;
//die('z:/webdev/php '.$cmd);
    if(defined('PHP_BINDIR')) $cmd = PHP_BINDIR.DIRECTORY_SEPARATOR.'php '.$cmd;
    elseif(!function_exists('is_executable') || !is_executable($cmd)) break;
    
    if(HW_IS_WINDOWS){
      
      // Give %system32%\cmd.exe read/execute permissions to IUSR account.
      break;

      $WshShell = new COM("WScript.Shell");
      $oExec = $WshShell->Run($cmd.' /C '.dirname($cmd).' /S %windir%', 0, false);
      // or this way
      if($oExec != 0) pclose(popen('start /B '. $cmd, 'r'));
    }
    else{
      
      exec("$cmd > /dev/null 2>&1 &",$ex_out,$ex_ret);
      
      if($ex_ret>0){
        $err_msg = $ex_out[0];
        if(!$err_msg && ini_get('safe_mode')) $err_msg = 'Safe mode is ON';
        die("ERROR: exec() error: $err_msg");
      }
    }

    $is_executed = true;

  } while(0);*/

  // some protection from incorrectly specified SITE_URL
  if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTPS']!='on'){
    $_dir = dirname($_SERVER['PHP_SELF']);
    $SITE_URL = 'http://'.$_SERVER['HTTP_HOST'].substr($_dir, 0, strrpos($_dir, '/')).'/';
  }
  else $SITE_URL = SITE_URL;

  if(!$is_executed) hwCURL( array(
        'url' => $SITE_URL.$fn,
        'nobody' => 1,
        'method' => 'socket',
  ) );

  sleep(2);

}

?>
Return current item: Esvon Personals