예제 #1
0
    function emailRegardingWrongBusiness($incoming, array $businesses)
    {
        $root_url = ROOT_URL;
        $businesses = implode(',', $businesses);
        $msg = <<<CUT
        Dear Admin,
    There is probably a problem with ePayph plugin coniguration in aMember Pro
    {$root_url}/admin/

    ePay.ph sent a payment record with primary email address:
       {$incoming}
    However, you have only the following e-mail addresses configured in
    aMember Pro CP -> Setup/Configuration -> ePayph
       {$businesses}

    If it is really your transaction and your primary ePay.ph email address
    is {$incoming}, go to aMember CP -> Setup -> ePayph
    and set ePay.ph email address as {$incoming}

    Once you have fixed the configuration, please visit Amember CP -> Invoice Log,
    find this transaction (invoice #{$this->request->invoice}), and press "Retry Processing".

    --
    Your aMember Pro script
    P.S. If you have any questions, resend this email to support@cgi-central.net
    with server access details.
CUT;
        $mail = new Am_Mail();
        $mail->toAdmin();
        $mail->setBodyText($msg);
        $mail->setSubject('*** ePayph plugin error in Amember ***');
        $mail->send();
    }
예제 #2
0
 function __get($name)
 {
     if ($name == 'unsubscribe_link') {
         return Am_Mail::getUnsubscribeLink($this->email, Am_Mail::LINK_USER);
     }
     return null;
 }
예제 #3
0
 function indexAction()
 {
     $e = $this->getParam('e');
     if (!$e) {
         throw new Am_Exception_InputError("Empty e-mail parameter passed - wrong url");
     }
     $s = $this->getFiltered('s');
     if (!Am_Mail::validateUnsubscribeLink($e, $s, Am_Mail::LINK_USER)) {
         throw new Am_Exception_InputError(___('Wrongly signed URL, please contact site admin'));
     }
     $this->view->user = $this->getDi()->userTable->findFirstByEmail($e);
     if (!$this->view->user) {
         throw new Am_Exception_InputError(___("Wrong parameters, error #1253"));
     }
     if ($this->_request->get('yes')) {
         $this->view->user->unsubscribed = 1;
         $this->view->user->update();
         $this->getDi()->hook->call(Am_Event::USER_UNSUBSCRIBED_CHANGED, array('user' => $this->view->user, 'unsubscribed' => 1));
         return $this->_redirect('member?' . http_build_query(array('_msg' => ___('Status of your subscription has been changed.')), '', '&'));
     } elseif ($this->_request->get('no')) {
         return $this->_redirect('member');
     }
     $this->view->e = $e;
     $this->view->s = $s;
     if (!$this->getDi()->blocks->get($this->view, 'unsubscribe')) {
         $this->getDi()->blocks->add(new Am_Block('unsubscribe', ___('Unsubscribe'), 'unsubscribe-std', null, 'unsubscribe-std.phtml'));
     }
     $this->view->display('unsubscribe.phtml');
 }
 function indexAction()
 {
     Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
     if ($this->_request->get('start')) {
         $this->getSession()->yourmembers_db = null;
         $this->getSession()->yourmembers_import = null;
     } elseif ($this->_request->get('import_settings')) {
         $this->getSession()->yourmembers_import = null;
     }
     if (!$this->getSession()->yourmembers_db) {
         return $this->askDbSettings();
     }
     $this->db_yourmembers = Am_Db::connect($this->getSession()->yourmembers_db);
     if (!$this->getSession()->yourmembers_import) {
         return $this->askImportSettings();
     }
     // disable ALL hooks
     $this->getDi()->hook = new Am_Hook($this->getDi());
     $done = $this->_request->getInt('done', 0);
     $importSettings = $this->getSession()->yourmembers_import;
     $import = $this->_request->getFiltered('i', $importSettings['import']);
     $class = "Am_Import_" . ucfirst($import) . "3";
     $importer = new $class($this->db_yourmembers, (array) @$importSettings[$import]);
     if ($importer->run($done) === true) {
         $this->view->title = ucfirst($import) . " Import Finished";
         $this->view->content = "{$done} records imported from Wordpress Your Members Plugin";
         $this->view->content .= "<br /><br/><a href='" . REL_ROOT_URL . "/admin-import-your-members'>Continue to import other information</a>";
         $this->view->content .= "<br /><br />Do not forget to <a href='" . REL_ROOT_URL . "/admin-rebuild'>Rebuild Db</a> after all import operations are done.";
         $this->view->display('admin/layout.phtml');
         $this->getSession()->yourmembers_import = null;
     } else {
         $this->redirectHtml(REL_ROOT_URL . "/admin-import-your-members?done={$done}&i={$import}", "{$done} records imported");
     }
 }
 /**
  * display signup page
  */
 function indexAction()
 {
     $e = $this->getParam('e');
     if (!$e) {
         throw new Am_Exception_InputError("Empty e-mail parameter passed - wrong url");
     }
     $s = $this->getFiltered('s');
     if (!Am_Mail::validateUnsubscribeLink($e, $s, Am_Mail::LINK_GUEST)) {
         throw new Am_Exception_InputError(___('Wrongly signed URL, please contact site admin'));
     }
     $this->view->guest = $this->getDi()->newsletterGuestTable->findFirstByEmail($e);
     if (!$this->view->guest) {
         throw new Am_Exception_InputError(___("Your e-mail address was not found in database"));
     }
     $this->view->e = $e;
     $this->view->s = $s;
     $this->lists = $this->getDi()->newsletterListTable->findGuests();
     if (!$this->lists) {
         throw new Am_Exception_InputError("Guest subscriptions disabled - no lists available");
     }
     $this->view->form = $this->createForm();
     if ($this->view->form->isSubmitted() && $this->view->form->validate()) {
         $this->changeSubscriptions($this->view->guest, $this->view->form->getValue());
         $this->_redirect('index');
     }
     $this->view->display('newsletter/unsubscribe.phtml');
 }
 function cronAction()
 {
     check_demo();
     if (!$this->getDi()->config->get('email_backup_frequency')) {
         throw new Am_Exception_InternalError("Email Backup feature is disabled at Setup/Configuration -> Advanced");
     }
     $key = $this->getParam('k');
     if ($key != $this->getDi()->app->getSiteHash('backup-cron', 10)) {
         throw new Am_Exception_AccessDenied("Incorrect access key");
     }
     $dat = date('Y_m_d');
     $stream = fopen('php://temp', 'w+b');
     if (!$stream) {
         throw new Am_Exception_InternalError("Could not open php://temp stream");
     }
     $bp = new Am_BackupProcessor();
     $stream = $bp->run($stream);
     rewind($stream);
     $filename = $bp->isGzip() ? "amember-{$dat}.sql.gz" : "amember-{$dat}.sql";
     $mimeType = $bp->isGzip() ? 'application/x-gzip' : 'text/sql';
     $m = new Am_Mail();
     $m->addTo($this->getDi()->config->get('email_backup_address'))->setSubject('Email Backup ' . $dat)->setFrom($this->getDi()->config->get('admin_email'));
     $m->setBodyText(sprintf("File with backup for %s is attached. Backup was done at %s", $this->getDi()->config->get('root_url'), $this->getDi()->sqlDate));
     $m->createAttachment($stream, $mimeType, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $filename);
     $m->setPeriodic(Am_Mail::ADMIN_REQUESTED);
     $m->send();
     $this->getDi()->adminLogTable->log('Email backup to ' . $this->getDi()->config->get('email_backup_address'));
 }
예제 #7
0
 function updateSubscriptionAction()
 {
     if (($s = $this->getFiltered('s')) && ($e = $this->getParam('e')) && Am_Mail::validateUnsubscribeLink($e, $s)) {
         $user = $this->getDi()->userTable->findFirstByEmail($e);
     } else {
         $user = $this->getDi()->user;
     }
     if (!$user) {
         throw new Am_Exception_InputError("You must be logged-in to use this function");
     }
     $allowed = array();
     foreach ($this->getDi()->newsletterListTable->getAllowed($user) as $r) {
         $allowed[$r->pk()] = $r;
     }
     $subs = array();
     foreach ($this->getDi()->newsletterUserSubscriptionTable->findByUserId($user->pk()) as $s) {
         $subs[$s->list_id] = $s;
     }
     $post = $this->getRequest()->getPost();
     $ret = array('status' => 'OK');
     foreach ($post as $k => $v) {
         if (!is_int($k)) {
             continue;
         }
         switch ($v) {
             case 0:
                 if (!empty($subs[$k])) {
                     $subs[$k]->unsubscribe();
                 }
                 $ret[(int) $k] = (int) $v;
                 break;
             case 1:
                 $this->getDi()->newsletterUserSubscriptionTable->add($user->pk(), $k, NewsletterUserSubscription::TYPE_USER);
                 $ret[(int) $k] = (int) $v;
                 break;
             default:
                 throw new Am_Exception_InputError("Wrong value submitted");
         }
     }
     $this->ajaxResponse($ret);
 }
예제 #8
0
 function unsubscribedAction()
 {
     $v = $this->_request->getPost('unsubscribed');
     if (strlen($v) != 1) {
         throw new Am_Exception_InputError("Wrong input");
     }
     $v = $v > 0 ? 1 : 0;
     if (($s = $this->getFiltered('s')) && ($e = $this->getParam('e')) && Am_Mail::validateUnsubscribeLink($e, $s)) {
         $user = $this->getDi()->userTable->findFirstByEmail($e);
     } else {
         $user = $this->getDi()->user;
     }
     if (!$user) {
         return $this->ajaxError("You must be logged-in to run this action");
     }
     if ($user->unsubscribed != $v) {
         $user->set('unsubscribed', $v)->update();
         $this->getDi()->hook->call(Am_Event::USER_UNSUBSCRIBED_CHANGED, array('user' => $user, 'unsubscribed' => $v));
     }
     $this->ajaxResponse(array('status' => 'OK', 'value' => $v));
 }
 public function preDispatch()
 {
     // Try to set any available english UTF-8 locale. Required for fgetcsv function to parse UTF-8 content.
     setlocale(LC_ALL, 'C.UTF-8', 'en_US.UTF-8', 'C');
     Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
 }
예제 #10
0
 public function batchSend(&$context, Am_BatchProcessor $batch)
 {
     if ($this->saved->count_users <= $this->saved->sent_users) {
         return true;
     }
     // we are done;
     $q = $this->searchUi->query($this->saved->sent_users, 10);
     $i = 0;
     $db = $this->getDi()->db;
     $foundrows = false;
     while ($r = $db->fetchRow($q)) {
         $foundrows = true;
         if (!$batch->checkLimits()) {
             return false;
         }
         $r['name'] = $r['name_f'] . ' ' . $r['name_l'];
         $this->saved->updateQuick(array('last_email' => $r['email'], 'sent_users' => $this->saved->sent_users + 1));
         if ($r['email'] == '') {
             continue;
         }
         $m = $this->getDi()->mail;
         $m->setPeriodic(Am_Mail::ADMIN_REQUESTED);
         $m->addHeader('X-Amember-Queue-Id', $this->_request->getFiltered('queue_id'));
         $m->addUnsubscribeLink(Am_Mail::LINK_USER);
         $m->addTo($r['email'], $r['name']);
         if ($reply_to = $this->getParam('reply_to')) {
             switch ($reply_to) {
                 case 'default':
                     $email = false;
                     break;
                 case 'other':
                     $email = $this->getParam('reply_to_other');
                     $name = null;
                     break;
                 default:
                     preg_match('/^admin-(\\d+)$/', $reply_to, $match);
                     $admin = $this->getDi()->adminTable->load($match[1], false);
                     if ($admin) {
                         $email = $admin->email;
                         $name = $admin->getName();
                     }
                     break;
             }
             if ($email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
                 $m->setReplyTo($email, $name);
             }
         }
         $subject = $this->getParam('subject');
         $body = $this->getParam('body');
         $tpl = new Am_SimpleTemplate();
         $tpl->assignStdVars();
         if (strpos($body, '%user.unsubscribe_link%') !== false || strpos($subject, '%user.unsubscribe_link%') !== false) {
             $r['unsubscribe_link'] = Am_Mail::getUnsubscribeLink($r['email'], Am_Mail::LINK_USER);
         }
         $tpl->user = $r;
         $this->getDi()->hook->call(Am_Event::MAIL_SIMPLE_TEMPLATE_BEFORE_PARSE, array('template' => $tpl, 'body' => $body, 'subject' => $subject, 'mail' => $m, 'request' => $this->getRequest()));
         $subject = $tpl->render($subject);
         $body = $tpl->render($body);
         if ($this->getParam('email_template_layout_id') && ($layout = $this->getDi()->emailTemplateLayoutTable->load($this->getParam('email_template_layout_id', false)))) {
             $tpl->assign('content', $body);
             $body = $tpl->render($layout->layout);
         }
         $m->setSubject($subject);
         if ($this->getParam('format') == 'text') {
             $m->setBodyText($body);
         } else {
             $text = strip_tags($body);
             $html = strpos($body, '<html') === false ? "<html><head><title>{$subject}</title></head><body>{$body}</body></html>" : $body;
             $m->setBodyHtml($html);
             $m->setBodyText($text);
         }
         foreach ($this->getAttachments() as $at) {
             $m->addAttachment($at);
         }
         try {
             $m->send();
         } catch (Zend_Mail_Exception $e) {
             trigger_error("Error happened while sending e-mail to {$r['email']} : " . $e->getMessage(), E_USER_WARNING);
         }
     }
     $this->getDi()->db->freeResult($q);
     if (!$foundrows) {
         return true;
     }
     if ($this->saved->count_users <= $this->saved->sent_users) {
         return true;
     }
     // we are done;
 }
 public function batchSend(&$context, Am_BatchProcessor $batch)
 {
     if ($this->saved->count_users <= $this->saved->sent_users) {
         return true;
     }
     // we are done;
     $q = $this->searchUi->query($this->saved->sent_users, 10);
     $t = new Am_View();
     $i = 0;
     $db = $this->getDi()->db;
     while ($r = $db->fetchRow($q)) {
         $r['name'] = $r['name_f'] . ' ' . $r['name_l'];
         if (!empty($r['user_id'])) {
             $isUser = true;
         } else {
             $isUser = false;
         }
         $this->saved->updateQuick(array('last_email' => $r['email'], 'sent_users' => $this->saved->sent_users + 1));
         if ($r['email'] == '') {
             continue;
         }
         $subject = $this->getParam('subject');
         $body = $this->getParam('body');
         // assign variables
         $tpl = new Am_SimpleTemplate();
         $tpl->assignStdVars();
         $tpl->user = $r;
         $subject = $tpl->render($subject);
         $body = $tpl->render($body);
         //
         $m = new Am_Mail();
         $m->addUnsubscribeLink($isUser ? Am_Mail::LINK_USER : Am_Mail::LINK_GUEST);
         $m->addTo($r['email'], $r['name'])->setSubject($subject);
         //->setFrom($this->getDi()->config->get('admin_email'), $this->getDi()->config->get('site_title') . ' Admin');
         if ($this->getParam('format') == 'text') {
             $m->setBodyText($body);
         } else {
             $m->setBodyHtml($body);
         }
         $m->setPeriodic(Am_Mail::ADMIN_REQUESTED);
         $m->addHeader('X-Amember-Queue-Id', $this->_request->getFiltered('queue_id'));
         foreach ($this->getAttachments() as $at) {
             $m->addAttachment($at);
         }
         try {
             $m->send();
         } catch (Zend_Mail_Exception $e) {
             trigger_error("Error happened while sending e-mail to {$r['email']} : " . $e->getMessage(), E_USER_WARNING);
         }
     }
     $this->getDi()->db->freeResult($q);
     if ($this->saved->count_users <= $this->saved->sent_users) {
         return true;
     }
     // we are done;
 }
예제 #12
0
 public function run()
 {
     if (!$this->getForm()->validate()) {
         echo $this->renderConfirmationForm();
     } else {
         $prefix = $this->grid->getId() . '_';
         foreach ($this->getForm()->getValue() as $k => $v) {
             if (strpos($k, $prefix) === 0) {
                 $this->_vars[substr($k, strlen($prefix))] = $v;
             }
         }
         // disable emailing
         Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
         return parent::run();
     }
 }
 public function doAction()
 {
     // disable all emails
     Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
     $payplugin = null;
     foreach ($this->getDi()->plugins_payment->getEnabled() as $pl) {
         if ($pl == 'free') {
             continue;
         }
         $payplugin = $this->getDi()->plugins_payment->loadGet($pl);
         break;
     }
     if (empty($payplugin)) {
         throw new Am_Exception_InputError("No payment plugins enabled. Visit [aMember Cp -> Setup/Configuration -> Plugins] and enable one");
     }
     $batch = new Am_BatchProcessor(array($this, 'generateUser'), 5);
     $context = array('payplugin' => $payplugin);
     if (!$batch->run($context)) {
         $this->sendRedirect();
     }
     $this->updateDemoHistory(true);
     $this->session->unsetAll();
     $this->_redirect('admin-build-demo');
 }
 function indexAction()
 {
     Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
     if ($this->_request->get('start')) {
         $this->getSession()->wordpress_db = null;
         $this->getSession()->wordpress_import = null;
     } elseif ($this->_request->get('import_settings')) {
         $this->getSession()->wordpress_import = null;
     }
     if (!$this->getSession()->wordpress_db) {
         return $this->askDbSettings();
     }
     $this->db_wordpress = Am_Db::connect($this->getSession()->wordpress_db);
     if (!$this->getSession()->wordpress_import) {
         return $this->askImportSettings();
     }
     // disable ALL hooks
     $this->getDi()->hook = new Am_Hook($this->getDi());
     $done = $this->_request->getInt('done', 0);
     $importSettings = $this->getSession()->wordpress_import;
     $import = $this->_request->getFiltered('i', $importSettings['import']);
     if ($import == 'product') {
         foreach ($importSettings['pr_link'] as $wom => $am) {
             if ($am) {
                 $this->getDi()->productTable->load($am)->data()->set('wom:id', $wom)->update();
                 $done++;
             }
         }
         $this->view->title = "Product Linking Finished";
         $this->view->content = "{$done} records linked from Wordpress Optimize Member Plugin";
         $this->view->content .= "<br /><br/><a href='" . REL_ROOT_URL . "/admin-import-wordpress-optimize-member'>Continue to import other information</a>";
         $this->view->display('admin/layout.phtml');
         $this->getSession()->wordpress_import = null;
         return;
     }
     $class = "Am_Import_" . ucfirst($import) . "3";
     $importer = new $class($this->db_wordpress, (array) @$importSettings[$import]);
     if ($importer->run($done) === true) {
         $this->view->title = ucfirst($import) . " Import Finished";
         $this->view->content = "{$done} records imported from Wordpress Optimize Member Plugin";
         $this->view->content .= "<br /><br/><a href='" . REL_ROOT_URL . "/admin-import-wordpress-optimize-member'>Continue to import other information</a>";
         $this->view->content .= "<br /><br />Do not forget to <a href='" . REL_ROOT_URL . "/admin-rebuild'>Rebuild Db</a> after all import operations are done.";
         $this->view->display('admin/layout.phtml');
         $this->getSession()->wordpress_import = null;
     } else {
         $this->redirectHtml(REL_ROOT_URL . "/admin-import-wordpress-optimize-member?done={$done}&i={$import}", "{$done} records imported");
     }
 }
예제 #15
0
 function indexAction()
 {
     $enabled = $this->getDi()->plugins_protect->loadEnabled()->getAllEnabled();
     foreach ($enabled as $k => $pl) {
         if ($pl->getId() == 'invision') {
             unset($enabled[$k]);
             break;
         }
     }
     $this->getDi()->plugins_protect->setEnabled($enabled);
     Am_Mail::setDefaultTransport(new Am_Mail_Transport_Null());
     if ($this->_request->get('start')) {
         $this->getSession()->ipb_nexus_db = null;
         $this->getSession()->ipb_nexus_import = null;
     } elseif ($this->_request->get('import_settings')) {
         $this->getSession()->ipb_nexus_import = null;
     }
     if (!$this->getSession()->ipb_nexus_db) {
         return $this->askDbSettings();
     }
     $this->db_ipb_nexus = Am_Db::connect($this->getSession()->ipb_nexus_db);
     if (!$this->getSession()->ipb_nexus_import) {
         return $this->askImportSettings();
     }
     // disable ALL hooks
     $this->getDi()->hook = new Am_Hook($this->getDi());
     $done = $this->_request->getInt('done', 0);
     $importSettings = $this->getSession()->ipb_nexus_import;
     $import = $this->_request->getFiltered('i', $importSettings['import']);
     $class = "Am_Import_" . ucfirst($import) . "3";
     $importer = new $class($this->db_ipb_nexus, (array) @$importSettings[$import]);
     if ($importer->run($done) === true) {
         $this->view->title = ucfirst($import) . " Import Finished";
         $this->view->content = "{$done} records imported from IPB Nexus";
         $this->view->content .= "<br /><br/><a href='" . REL_ROOT_URL . "/admin-import-ipb-nexus'>Continue to import other information</a>";
         $this->view->content .= "<br /><br />Do not forget to <a href='" . REL_ROOT_URL . "/admin-rebuild'>Rebuild Db</a> after all import operations are done.";
         $this->view->display('admin/layout.phtml');
         $this->getSession()->ipb_nexus_import = null;
     } else {
         $this->redirectHtml(REL_ROOT_URL . "/admin-import-ipb-nexus?done={$done}&i={$import}", "{$done} records imported");
     }
 }
예제 #16
0
 /**
  * @param string $content - will be modified
  * @param bool $isHtml
  * @return null
  */
 protected function _addUnsubscribeLink(&$content, $isHtml)
 {
     if (!$this->addUnsubscribeLink) {
         return;
     }
     if (Am_Di::getInstance()->config->get('disable_unsubscribe_link')) {
         return;
     }
     //disabled at all
     $e = @$this->_to[0];
     if ($e == "") {
         trigger_error("E-Mail address is empty in " . __METHOD__ . ", did you call addUnsubscribeLink before adding receipients?", E_USER_WARNING);
         return;
         // no email address
     }
     $link = Am_Mail::getUnsubscribeLink($e, $this->addUnsubscribeLink);
     if ($isHtml) {
         $out = Am_Di::getInstance()->config->get('unsubscribe_html', Am_Mail::UNSUBSCRIBE_HTML);
     } else {
         $out = Am_Di::getInstance()->config->get('unsubscribe_txt', Am_Mail::UNSUBSCRIBE_TXT);
     }
     $out = "\r\n" . str_replace('%link%', $isHtml ? Am_Controller::escape($link) : $link, $out);
     if (!$isHtml) {
         $content .= "\r\n" . $out;
     } else {
         $content = str_ireplace('</body>', $out . '</body>', $content, $replaced);
         if (!$replaced) {
             $content .= $out;
         }
     }
 }