Location: PHPKode > projects > Esvon Personals > esvon-personals/modules/Mailing_Lists/hw_api.php

function Mod_ML_Capture($a_emails){
  global $db;

  $HW_MOD = 'Mailing_Lists';
  $TBL_ML = hwModTable($HW_MOD,'list');
  $TBL_ML_IDX = hwModTable($HW_MOD,'idx');
  if(!is_array($a_emails)) $a_emails = array($a_emails);

  $a_id = $db->one_col_array('SELECT id FROM '.$TBL_ML_IDX.' WHERE capture="1"');
  if(empty($a_id)) return;

  foreach($a_emails as $email){
    $email = $db->quote($email);
    foreach($a_id as $ml_id){
      $db->query('INSERT IGNORE INTO '.$TBL_ML.' (list_id,email,date) VALUES ('.$ml_id.', "'.$email.'", '.SQL_NOW.')');

function ML_getEmailsAmountSQL($mid){
  global $db;
  if($mid == -1) $ql = 'SELECT COUNT(*) FROM '.TBL_USER.' u WHERE 1';
  elseif($mid == -2) $ql = 'SELECT COUNT(DISTINCT(id)) FROM '.TBL_USER.' u LEFT JOIN '.TBL_AD.' l ON u.id=l.userid WHERE l.userid IS NOT NULL';
  else { die("Bad List ID"); }
  $TBL_ML_UNSUB = hwModTable('Mailing_Lists','unsub');
  /*$amt = $db->one_data('SELECT COUNT(*) FROM '.$TBL_ML_UNSUB.' WHERE list_id="'.$mid.'"');
  if($amt > 0){
      $ql.=' AND email NOT IN(SELECT email FROM '.$TBL_ML_UNSUB.' WHERE list_id="'.$mid.'")';
      $em = $db->one_col_array('SELECT email FROM '.$TBL_ML_UNSUB.' WHERE list_id="'.$mid.'"');
      $em = '"'.implode('","', array_map(array($db,'quote'), $em)).'"';
      $ql.=' AND email NOT IN('.$em.')';
  return $ql;
Return current item: Esvon Personals