示例#1
0
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'wysiwyg':
        // update wysiwyg ++ state
        $wysiwyg = isset($_REQUEST['enable']) ? 'on' : 'off';
        $pommo->_session['state']['mailing']['wysiwyg'] = $wysiwyg;
        PommoAPI::configUpdate(array('list_wysiwyg' => $wysiwyg), true);
        break;
    case 'savebody':
        $pommo->_session['state']['mailing']['body'] = $_REQUEST['body'];
        $pommo->_session['state']['mailing']['altbody'] = $_REQUEST['altbody'];
        break;
    case 'altbody':
        Pommo::requireOnce($pommo->_baseDir . 'inc/lib/lib.html2txt.php');
        $h2t =& new html2text($_REQUEST['body']);
        $json->add('altbody', $h2t->get_text());
        break;
    case 'getTemplateDescription':
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/templates.php');
        $template = PommoMailingTemplate::getDescriptions(array('id' => $_REQUEST['id']));
        $msg = empty($template[$_REQUEST['id']]) ? 'Aucune' : $template[$_REQUEST['id']];
        die($msg);
    default:
        $json->fail();
        break;
}
$json->success();
示例#2
0
        case 'activate':
            $messages = PommoHelperMessages::resetDefault('activate');
            break;
        case 'unsubscribe':
            $messages = PommoHelperMessages::resetDefault('unsubscribe');
            break;
        case 'confirm':
            $messages = PommoHelperMessages::resetDefault('confirm');
            break;
        case 'update':
            $messages = PommoHelperMessages::resetDefault('update');
            break;
    }
    // reset _POST.
    $_POST = array();
    $json->add('callbackFunction', 'redirect');
    $json->add('callbackParams', $pommo->_baseUrl . 'admin/setup/setup_configure.php?tab=Messages');
    $json->serve();
}
// ADD CUSTOM VALIDATOR FOR CHARSET
function check_notifyMails($value, $empty, &$params, &$formvars)
{
    $mails = PommoHelper::trimArray(explode(',', $value));
    $ret = true;
    foreach ($mails as $mail) {
        if (!empty($mail) && !PommoHelper::isEmail($mail)) {
            $ret = false;
        }
    }
    return $ret;
}
示例#3
0
    $smarty->assign('vMsg', $vMsg);
    // populate _POST with info from database (fills in form values...)
    $dbVals = PommoAPI::configGet(array('admin_username'));
    $dbVals['admin_email'] = $pommo->_config['admin_email'];
    $smarty->assign($dbVals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if (SmartyValidate::is_valid($_POST, 'users')) {
        // __ FORM IS VALID
        // convert password to MD5 if given...
        if (!empty($_POST['admin_password'])) {
            $_POST['admin_password'] = md5($_POST['admin_password']);
        }
        PommoAPI::configUpdate($_POST);
        unset($_POST['admin_password'], $_POST['admin_password2']);
        $pommo->reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('users'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/users.tpl');
Pommo::kill();
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) {
    // ___ USER HAS NOT SENT FORM ___
    SmartyValidate::register_form('exchanger', true);
    SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger');
    $vMsg = array();
    $vMsg['email'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
    $dbvals = array('exchanger' => $exchanger, 'email' => $pommo->_config['admin_email']);
    $smarty->assign($dbvals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if (SmartyValidate::is_valid($_POST, 'exchanger')) {
        // __ FORM IS VALID
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php');
        $msg = PommoHelperMessages::testExchanger($_POST['email'], $exchanger) ? Pommo::_T('Mail Sent.') : Pommo::_T('Error Sending Mail');
        $json->success($msg);
    } else {
        // __ FORM NOT VALID
        $json->addMsg(Pommo::_T('Please review and correct errors with your submission.'));
        $json->add('fieldErrors', $smarty->getInvalidFields('exchanger'));
        $json->fail();
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/ajax.testexchanger.tpl');
Pommo::kill();
示例#5
0
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if ($state['tally'] > 0) {
        if ($state['ishtml'] == 'off') {
            $state['body'] = $state['altbody'];
            $state['altbody'] = '';
        }
        $mailing = PommoMailing::make(array(), TRUE);
        $state['status'] = 1;
        $state['current_status'] = 'stopped';
        $state['command'] = 'restart';
        $mailing = PommoHelper::arrayIntersect($state, $mailing);
        $code = PommoMailing::add($mailing);
        if (!PommoMailCtl::queueMake($group->_memberIDs)) {
            $json->fail('Unable to populate queue');
        }
        if (!PommoMailCtl::spawn($pommo->_baseUrl . 'admin/mailings/mailings_send4.php?code=' . $code)) {
            $json->fail('Unable to spawn background mailer');
        }
        // clear mailing composistion data from session
        PommoAPI::stateReset(array('mailing'));
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', $pommo->_baseUrl . 'admin/mailings/mailing_status.php');
    } else {
        $json->fail(Pommo::_T('Cannot send a mailing to 0 subscribers!'));
    }
    $json->serve();
}
$smarty->assign($state);
$smarty->display('admin/mailings/mailing/preview.tpl');
Pommo::kill();
示例#6
0
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'updateOrdering':
        $when = '';
        foreach ($_REQUEST['order'] as $order => $fieldID) {
            if (is_numeric($order)) {
                $when .= $dbo->prepare("WHEN %i THEN %i", array($fieldID, $order)) . ' ';
            }
        }
        $query = "\n\t\t\tUPDATE " . $dbo->table['fields'] . "\n\t\t\tSET field_ordering = \n\t\t\t\tCASE field_id " . $when . " ELSE field_ordering END";
        if (!$dbo->query($dbo->prepare($query))) {
            $json->fail('Error Updating Order');
        }
        $json->add('query', $query);
        $json->success(Pommo::_T('Order Updated.'));
        break;
    case 'addOption':
        // validate field ID
        $field = current(PommoField::get(array('id' => $_REQUEST['field_id'])));
        if ($field['id'] != $_REQUEST['field_id']) {
            die('bad field ID');
        }
        if (!empty($_REQUEST['options'])) {
            $options = PommoField::optionAdd($field, $_REQUEST['options']);
        }
        if (!options) {
            $json->fail(Pommo::_T('Error with addition.'));
        }
        $json->add('callbackFunction', 'updateOptions');
示例#7
0
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php');
$smarty = new PommoTemplate();
$smarty->prepareForForm();
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
$success = false;
if (isset($_POST['skip']) || isset($_POST['template']) && !is_numeric($_POST['template'])) {
    $success = true;
} elseif (isset($_POST['load'])) {
    $template = current(PommoMailingTemplate::get(array('id' => $_POST['template'])));
    $pommo->_session['state']['mailing']['body'] = $template['body'];
    $pommo->_session['state']['mailing']['altbody'] = $template['altbody'];
    $success = true;
} elseif (isset($_POST['delete'])) {
    $msg = PommoMailingTemplate::delete($_POST['template']) ? Pommo::_T('Template Deleted') : Pommo::_T('Error with deletion.');
    $json->add('callbackFunction', 'deleteTemplate');
    $json->add('callbackParams', array('id' => $_POST['template'], 'msg' => $msg));
} else {
    $smarty->assign('templates', PommoMailingTemplate::getNames());
    $smarty->display('admin/mailings/mailing/templates.tpl');
    Pommo::kill();
}
$json->serve($success);
示例#8
0
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        // __ FORM IS VALID
        // TODO -> Which below logic is better? the computed diff, or send all fields for update?
        /*
        // make a difference between updated & original field
        $update = array_diff_assoc(PommoField::makeDB($_POST),$field);
        // restore the ID
        $update['id'] = $field['id'];
        */
        // let MySQL do the difference processing
        $update = PommoField::makeDB($_POST);
        if (!PommoField::update($update)) {
            $json->fail('error updating field');
        }
        $json->add('callbackFunction', 'updateField');
        $json->add('callbackParams', $update);
        $json->success(Pommo::_T('Settings updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields());
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>');
$f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>');
$f_num = sprintf(Pommo::_T('%s - Only Numeric values will be accepted for number fields.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Number') . ')</strong>');
$f_date = sprintf(Pommo::_T('%s - Only calendar values will be accepted for this field. A date selector (calendar popup) will appear next to the field to aid the subscriber in selecting a date.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Date') . ')</strong>');
$f_mult = sprintf(Pommo::_T('%s - Subscribers will be able to select a value from the options you provide below. Multiple choice fields have reliable values for organizing, and are useful for collecting Country, Interests, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Multiple Choice') . ')</strong>');
$f_comm = sprintf(Pommo::_T('%s -. If a subscriber enters a value for a comment field, it will be mailed to the admin notification email.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Comment') . ')</strong>');
switch ($field['type']) {
示例#9
0
    SmartyValidate::register_validator('maxRuntime', 'maxRuntime', 'isInt', false, false, 'trim', 'mailings');
    $vMsg = array();
    $vMsg['maxRuntime'] = Pommo::_T('Enter a number.');
    $vMsg['list_fromname'] = Pommo::_T('Cannot be empty.');
    $vMsg['list_fromemail'] = $vMsg['list_frombounce'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
    // populate _POST with info from database (fills in form values...)
    $dbVals = PommoAPI::configGet(array('list_fromname', 'list_fromemail', 'list_frombounce', 'list_charset', 'public_history', 'maxRuntime'));
    $dbVals['demo_mode'] = !empty($pommo->_config['demo_mode']) && $pommo->_config['demo_mode'] == "on" ? 'on' : 'off';
    $smarty->assign($dbVals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if (SmartyValidate::is_valid($_POST, 'mailings')) {
        // __ FORM IS VALID
        PommoAPI::configUpdate($_POST);
        $pommo->reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('mailings'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/mailings.tpl');
Pommo::kill();
示例#10
0
if (!empty($_REQUEST['sord']) && ($_REQUEST['sord'] == 'asc' || $_REQUEST['sord'] == 'desc')) {
    $state['order'] = $_REQUEST['sord'];
}
// Calculate the offset
$start = $state['limit'] * $state['page'] - $state['limit'];
if ($start < 0) {
    $start = 0;
}
/**********************************
	RECORD RETREVIAL
*********************************/
// normalize sort to database column
if ($state['sort'] == 'start') {
    $state['sort'] = 'started';
}
// Fetch Mailings for this Page
$mailings = PommoMailing::get(array('noBody' => TRUE, 'sort' => $state['sort'], 'order' => $state['order'], 'limit' => $state['limit'], 'offset' => $start));
/**********************************
	OUTPUT FORMATTING
*********************************/
$records = array();
foreach ($mailings as $o) {
    $row = array('id' => $o['id'], 'subject' => $o['subject'], 'start' => $o['start']);
    if ($o['status'] == 0) {
        // only return "complete" mailings
        array_push($records, $row);
    }
}
// format for JSON output to jqGrid
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => PommoMailing::tally(), 'rows' => $records));
$json->serve();
示例#11
0
$output['statusText'] = $statusText[$output['status']];
// get last 50 unique notices
$mailingNotices = PommoMailing::getNotices($mailing['id'], 50, true);
$newNotices = array();
foreach ($mailingNotices as $time => $arr) {
    if (!isset($state['notices'][$time])) {
        $newNotices = array_merge($newNotices, $arr);
        continue;
    }
    foreach ($arr as $notice) {
        if (array_search($notice, $arr) === false) {
            $newNotices[] = $notice;
        }
    }
}
$state['notices'] = $mailingNotices;
$output['notices'] = array_reverse($newNotices);
// calculate sent
if ($output['status'] == 4) {
    $output['sent'] = PommoMailing::getSent($mailing['id']);
} else {
    $query = "SELECT count(subscriber_id) FROM {$dbo->table['queue']} WHERE status > 0";
    $output['sent'] = $dbo->query($query, 0);
}
// cleanup session if frozen or finished.
if ($output['status'] > 2) {
    PommoAPI::stateInit('subscribers_manage');
}
$output['percent'] = $output['status'] == 4 ? 100 : round($output['sent'] * (100 / $mailing['tally']));
$json->add($output);
$json->serve();
示例#12
0
    $vMsg = array();
    $vMsg['site_url'] = $vMsg['site_success'] = $vMsg['site_confirm'] = Pommo::_T('Must be a valid URL');
    $vMsg['list_name'] = $vMsg['site_name'] = Pommo::_T('Cannot be empty.');
    $smarty->assign('vMsg', $vMsg);
    // populate _POST with info from database (fills in form values...)
    $dbVals = PommoAPI::configGet(array('site_success', 'site_confirm', 'list_exchanger', 'list_confirm'));
    $dbVals['site_url'] = $pommo->_config['site_url'];
    $dbVals['site_name'] = $pommo->_config['site_name'];
    $dbVals['list_name'] = $pommo->_config['list_name'];
    $smarty->assign($dbVals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
    $json = new PommoJSON();
    if (SmartyValidate::is_valid($_POST, 'general')) {
        // __ FORM IS VALID
        PommoAPI::configUpdate($_POST);
        $pommo->reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('general'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/general.tpl');
Pommo::kill();
示例#13
0
         // 9 for "update"
     }
     $key = PommoSubscriber::add($subscriber);
     if (!$key) {
         $json->fail();
     }
     $json->addMsg(sprintf(Pommo::_T('Subscriber %s added!'), '<strong>' . $subscriber['email'] . '</strong>'));
     if ($flag) {
         $json->addErr(Pommo::_T('Subscriber has been flagged for update due to invalid or missing information.'));
     }
     // add the subscriber to JSON output
     $data = array('key' => $key, 'email' => $subscriber['email'], 'registered' => $subscriber['registered'], 'touched' => $subscriber['registered'], 'ip' => $subscriber['ip']);
     foreach ($subscriber['data'] as $k => $val) {
         $data['d' . $k] = htmlspecialchars($val);
     }
     $json->add('callbackFunction', 'addSubscriber');
     $json->add('callbackParams', $data);
     break;
 case 'delSubscriber':
     $emails = array();
     if (isset($_REQUEST['emails'])) {
         $in = array_unique(preg_split("/[\\s,]+/", $_REQUEST['emails']));
         foreach ($in as $email) {
             if (PommoHelper::isEmail($email)) {
                 array_push($emails, $email);
             }
         }
     }
     if (count($emails) > 0) {
         $ids = PommoSubscriber::getIDByEmail($emails, $_REQUEST['status']);
         $msg = sprintf(Pommo::_T('You have removed %s subscribers!'), PommoSubscriber::delete($ids));
示例#14
0
             PommoRules::addGroupRule($state['group'], $_REQUEST['field'], $_REQUEST['logic']);
             break;
         case 'true':
         case 'false':
             PommoRules::addBoolRule($state['group'], $_REQUEST['field'], $_REQUEST['logic']);
             break;
         case 'is':
         case 'not':
         case 'less':
         case 'greater':
             $values = array_unique($_REQUEST['match']);
             $type = $_REQUEST['type'] == 'or' ? 'or' : 'and';
             PommoRules::addFieldRule($state['group'], $_REQUEST['field'], $_REQUEST['logic'], $values, $type);
             break;
     }
     $json->add('callbackFunction', 'redirect');
     $json->add('callbackParams', $pommo->_baseUrl . 'admin/subscribers/groups_edit.php');
     $json->serve();
     break;
 case 'updateRule':
     Pommo::requireOnce($pommo->_baseDir . 'inc/classes/sql.gen.php');
     $group =& current(PommoGroup::get(array('id' => $state['group'])));
     $rules = PommoSQL::sortRules($group['rules']);
     switch ($_REQUEST['request']) {
         case 'update':
             if ($_REQUEST['type'] == 'or' && count($rules['and']) < 2) {
                 $json->add('callbackFunction', 'resume');
                 $json->success(Pommo::_T('At least 1 "and" rule must exist before an "or" rule takes effect.'));
             }
             PommoRules::changeType($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic'], $_REQUEST['type']);
             break;
示例#15
0
if ($start < 0) {
    $start = 0;
}
/**********************************
	RECORD RETREVIAL
*********************************/
// Normalize sort column to match DB column
if ($state['sort'] == 'registered' || $state['sort'] == 'touched') {
    $state['sort'] = 'time_' . $state['sort'];
} elseif (substr($state['sort'], 0, 1) == 'd') {
    $state['sort'] = substr($state['sort'], 1);
}
// fetch subscribers for this page
$subscribers = $group->members(array('sort' => $state['sort'], 'order' => $state['order'], 'limit' => $state['limit'], 'offset' => $start));
/**********************************
	OUTPUT FORMATTING
*********************************/
// format subscribers for JSON output to jqGrid
$subOut = array();
foreach ($subscribers as $s) {
    $sub = array('id' => $s['id'], 'email' => $s['email'], 'touched' => $s['touched'], 'registered' => $s['registered'], 'ip' => $s['ip']);
    foreach ($s['data'] as $key => $d) {
        $sub['d' . $key] = $d;
    }
    array_push($subOut, $sub);
}
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => $group->_tally, 'rows' => $subOut));
$json->serve();
?>