コード例 #1
0
ファイル: user.class.php プロジェクト: Dirty-Butter/v6
 protected final function __construct()
 {
     //If there is a login attempt
     if (isset($_POST['username']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['password'])) {
         //Did they check the remember me box
         $remember = isset($_POST['remember']) && !empty($_POST['remember']) ? true : false;
         $this->authenticate($_POST['username'], $_POST['password'], $remember);
     } else {
         //If there is a cookie for the username and they are not logged in
         if (isset($_COOKIE['username']) && !empty($_COOKIE['username']) && !$this->is()) {
             //If we haven't pushed the user to the login
             if (!$GLOBALS['session']->get('login_push')) {
                 $GLOBALS['session']->set('login_push', true);
                 //Try to have them login
                 if (!isset($_GET['_a']) || $_GET['_a'] != 'login') {
                     httpredir('index.php?_a=login');
                 }
             }
         }
         $this->_load();
         //IS_USER defines if a the user is a valid user on the template
         $GLOBALS['smarty']->assign('IS_USER', $this->is());
         if ($this->is() && isset($_POST['mailing_list'])) {
             Newsletter::getInstance()->subscribe($this->get('email'), $this->getId());
         }
         $this->isBot();
     }
 }
コード例 #2
0
ファイル: customers.email.inc.php プロジェクト: kblok/v6
            } else {
                $file_data .= str_replace($find, $replace, $GLOBALS['RAW']['POST']['maillist_format']) . "\n";
            }
            /* End Fixing Bug 2884 */
            unset($customer, $replace, $member, $long_name, $short_name);
        }
        $GLOBALS['debug']->supress(true);
        deliverFile(false, false, $file_data, $lang['email']['export_filename'] . '.' . $_POST['maillist_extension']);
        exit;
    } else {
        $GLOBALS['main']->setACPWarning($lang['email']['error_news_export_empty']);
    }
}
$GLOBALS['gui']->addBreadcrumb($lang['email']['title_newsletters'], currentPage(array('action', 'newsletter_id')));
$seo = SEO::getInstance();
$newsletter = Newsletter::getInstance();
if (isset($_POST['newsletter']) && !empty($_POST['newsletter'])) {
    $redirect = false;
    $proceed = true;
    if (empty($_POST['newsletter']['subject'])) {
        $proceed = false;
        $GLOBALS['main']->setACPWarning($lang['email']['error_no_subject']);
    }
    if (empty($_POST['newsletter']['content_html']) && empty($_POST['newsletter']['content_text'])) {
        $proceed = false;
        $GLOBALS['main']->setACPWarning($lang['email']['error_no_message']);
    }
    if ($proceed) {
        $_POST['newsletter']['content_html'] = $GLOBALS['RAW']['POST']['newsletter']['content_html'];
        if ($newsletter->saveNewsletter($_POST['newsletter'])) {
            $redirect = true;
コード例 #3
0
ファイル: ajax.class.php プロジェクト: kblok/v6
 /**
  * Admin search function
  *
  * @param string $type
  * @param string $search_string
  * @return data/false
  */
 public static function search($type, $search_string)
 {
     $data = false;
     if (!empty($type) && !empty($search_string)) {
         switch (strtolower($type)) {
             case 'user':
                 if (($results = $GLOBALS['db']->select('CubeCart_customer', false, array('~' . $search_string => array('last_name', 'first_name', 'email')), false, false, false, false)) !== false) {
                     foreach ($results as $result) {
                         $data[] = array('value' => $result['customer_id'], 'display' => $result['first_name'] . ' ' . $result['last_name'], 'info' => $result['email'], 'data' => $result);
                     }
                 }
                 break;
             case 'address':
                 if (($results = $GLOBALS['db']->select('CubeCart_addressbook', false, array('customer_id' => (int) $search_string), false, false, false, false)) !== false) {
                     foreach ($results as $result) {
                         $result['state'] = getStateFormat($result['state']);
                         $result['country'] = getCountryFormat($result['country']);
                         $data[] = $result;
                     }
                 }
                 break;
             case 'product':
                 // Limited to a maximum of 15 results, in order to prevent it going mental
                 if (($results = $GLOBALS['db']->select('CubeCart_inventory', false, array('~' . $search_string => array('name', 'product_code')), false, 15, false, false)) !== false) {
                     foreach ($results as $result) {
                         $lower_price = Tax::getInstance()->salePrice($result['price'], $result['sale_price'], false);
                         if ($lower_price && $lower_price < $result['price']) {
                             $result['price'] = $lower_price;
                         }
                         $data[] = array('value' => $result['product_id'], 'display' => $result['name'], 'info' => Tax::getInstance()->priceFormat($result['price']), 'data' => $result);
                     }
                 }
                 break;
             case 'newsletter':
                 $newsletter = Newsletter::getInstance();
                 $status = $newsletter->sendNewsletter($_GET['q'], $_GET['page']);
                 if (is_array($status)) {
                     $data = $status;
                 } else {
                     $data = $status ? array('complete' => 'true', 'percent' => 100) : array('error' => 'true');
                 }
                 break;
             case 'files':
                 if ($_GET['dir'] == '/') {
                     $dir = false;
                 } elseif ($_GET['dir'] == '/') {
                     $dir = false;
                 } else {
                     $dir = $_GET['dir'];
                 }
                 $filemanager = new FileManager($_GET['group'], $dir);
                 // Directories
                 if (($dirs = $filemanager->findDirectories()) !== false) {
                     foreach ($dirs[$filemanager->formatPath($dir)] as $parent => $folder) {
                         $path = !empty($dir) ? '/' : '';
                         $json[] = array('type' => 'directory', 'path' => urldecode($dir . basename($folder) . '/'), 'name' => basename($folder));
                     }
                 }
                 if (($files = $filemanager->listFiles()) !== false) {
                     $catalogue = new Catalogue();
                     foreach ($files as $result) {
                         if ($filemanager->getMode() == FileManager::FM_FILETYPE_IMG) {
                             $fetch = $catalogue->imagePath($result['file_id'], 'medium');
                             $path = $name = $fetch;
                         } else {
                             $path = $result['filepath'];
                             $name = $result['filename'];
                         }
                         $json[] = array('type' => 'file', 'path' => dirname($path) . '/', 'file' => basename($result['filename']), 'name' => basename($name), 'id' => $result['file_id'], 'description' => $result['description'], 'mime' => $result['mimetype']);
                     }
                 }
                 $data = isset($json) && is_array($json) ? $json : false;
                 break;
             default:
                 return false;
                 break;
         }
         if (!$data) {
             $data = array();
         }
         return json_encode($data);
     }
     return false;
 }
コード例 #4
0
ファイル: gui.class.php プロジェクト: briansandall/v6
 /**
  * Display mailing list box
  */
 private function _displayMailingList()
 {
     if (!$GLOBALS['smarty']->templateExists('templates/box.newsletter.php')) {
         return false;
     }
     if ($GLOBALS['user']->is()) {
         $GLOBALS['smarty']->assign('CTRL_SUBSCRIBED', (bool) $GLOBALS['db']->select('CubeCart_newsletter_subscriber', false, array('email' => $GLOBALS['user']->get('email')), false, 1));
     }
     if (isset($_POST['subscribe'])) {
         $newsletter = Newsletter::getInstance();
         if ($newsletter->subscribe($_POST['subscribe'])) {
             $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_subscribed']);
             httpredir(currentPage(null, array('subscribed' => 'true')));
         } else {
             $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_unsubscribed']);
             httpredir(currentPage(null, array('_a' => 'newsletter', 'subscribed' => 'false')));
         }
     }
     foreach ($GLOBALS['hooks']->load('class.gui.display_mailing_list') as $hook) {
         include $hook;
     }
     $content = $GLOBALS['smarty']->fetch('templates/box.newsletter.php');
     $GLOBALS['smarty']->assign('MAIL_LIST', $content);
 }
コード例 #5
0
 /**
  * Newsletter
  */
 private function _newsletter()
 {
     // Newsletters
     $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['your_account'], 'index.php?_a=account');
     $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->newsletter['newsletters'], '?_a=newsletter');
     $newsletter = Newsletter::getInstance();
     // Display Newsletter archive
     if (isset($_GET['newsletter_id']) && is_numeric($_GET['newsletter_id'])) {
         // Show a newsletter from the archive
         if (($content = $GLOBALS['db']->select('CubeCart_newsletter', false, array('newsletter_id' => (int) $_GET['newsletter_id'], 'status' => 1))) !== false) {
             $GLOBALS['gui']->addBreadcrumb($content[0]['subject'], '?_a=newsletter&newsletter_id=' . (int) $_GET['newsletter_id']);
             $GLOBALS['smarty']->assign('NEWSLETTER', $content[0]);
             $GLOBALS['smarty']->assign('CTRL_VIEW', true);
         } else {
             httpredir(currentPage(array('newsletter_id')));
         }
     } else {
         if (isset($_POST['subscribe'])) {
             if ($newsletter->subscribe($_POST['subscribe'])) {
                 $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_subscribed']);
             } else {
                 if ($GLOBALS['user']->is()) {
                     $GLOBALS['gui']->setError($GLOBALS['language']->common['error_email_invalid']);
                 } else {
                     if ($newsletter->unsubscribe($_POST['subscribe'])) {
                         $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_unsubscribed']);
                     } else {
                         $GLOBALS['gui']->setError($GLOBALS['language']->common['error_email_invalid']);
                     }
                 }
             }
             httpredir(currentPage());
         }
         if (isset($_GET['unsubscribe']) && filter_var($_GET['unsubscribe'], FILTER_VALIDATE_EMAIL)) {
             if ($newsletter->unsubscribe($_GET['unsubscribe'])) {
                 $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_unsubscribed']);
                 httpredir(currentPage(array('unsubscribe')));
             }
         }
         if (isset($_GET['verify'])) {
             if ($newsletter->verify($_GET['verify'])) {
                 $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_email_verified']);
             } else {
                 $GLOBALS['gui']->setError($GLOBALS['language']->common['error_email_verified']);
             }
             httpredir(currentPage(array('verify')));
         }
         if ($GLOBALS['user']->is()) {
             if (isset($_GET['action'])) {
                 switch (strtolower($_GET['action'])) {
                     case 'subscribe':
                         $GLOBALS['db']->insert('CubeCart_newsletter_subscriber', array('customer_id' => $GLOBALS['user']->get('customer_id'), 'email' => $GLOBALS['user']->get('email'), 'status' => '1'));
                         $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_subscribed']);
                         break;
                     case 'unsubscribe':
                         $GLOBALS['db']->delete('CubeCart_newsletter_subscriber', array('customer_id' => $GLOBALS['user']->get('customer_id')));
                         $GLOBALS['db']->delete('CubeCart_newsletter_subscriber', array('email' => $GLOBALS['user']->get('email')));
                         $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_unsubscribed']);
                         break;
                 }
                 httpredir(currentPage(array('action')));
             }
             $GLOBALS['smarty']->assign('URL', array('subscribe' => $GLOBALS['storeURL'] . '/index.php?_a=newsletter&action=subscribe', 'unsubscribe' => $GLOBALS['storeURL'] . '/index.php?_a=newsletter&action=unsubscribe'));
             $GLOBALS['smarty']->assign('SUBSCRIBED', (bool) $GLOBALS['db']->select('CubeCart_newsletter_subscriber', false, array('email' => $GLOBALS['user']->get('email')), false, false, false, false));
         }
         // Show list of publicly visible newsletters
         if (($archive = $GLOBALS['db']->select('CubeCart_newsletter', false, array('status' => 1))) !== false) {
             foreach ($archive as $content) {
                 $content['view'] = currentPage(array('subscribed'), array('newsletter_id' => $content['newsletter_id']));
                 $content['date_sent'] = formatTime(strtotime($content['date_sent']));
                 $vars['newsletters'][] = $content;
             }
             $GLOBALS['smarty']->assign('NEWSLETTERS', $vars['newsletters']);
         }
     }
     $content = $GLOBALS['smarty']->fetch('templates/content.newsletter.php');
     $GLOBALS['smarty']->assign('SECTION_NAME', 'account');
     $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
 }