function start()
 {
     global $lC_Database, $lC_MessageStack;
     $Qcounter = $lC_Database->query('select startdate, counter from :table_counter');
     $Qcounter->bindTable(':table_counter', TABLE_COUNTER);
     $Qcounter->execute();
     if ($Qcounter->numberOfRows()) {
         $counter_startdate = $Qcounter->value('startdate');
         $counter_now = $Qcounter->valueInt('counter') + 1;
         $Qcounterupdate = $lC_Database->query('update :table_counter set counter = counter+1');
         $Qcounterupdate->bindTable(':table_counter', TABLE_COUNTER);
         $Qcounterupdate->execute();
         $Qcounterupdate->freeResult();
     } else {
         $counter_startdate = lC_DateTime::getNow();
         $counter_now = 1;
         $Qcounterupdate = $lC_Database->query('insert into :table_counter (startdate, counter) values (:start_date, 1)');
         $Qcounterupdate->bindTable(':table_counter', TABLE_COUNTER);
         $Qcounterupdate->bindValue(':start_date', $counter_startdate);
         $Qcounterupdate->execute();
         $Qcounterupdate->freeResult();
     }
     $Qcounter->freeResult();
     return true;
 }
Exemple #2
0
 public static function formData($id = null)
 {
     global $lC_Database, $lC_Language;
     $lC_Language->loadIniFile('reviews.php');
     $result = array();
     if ($id != null) {
         $result['rData'] = lC_Reviews_Admin::getData($id);
         $result['dateShort'] = lC_DateTime::getShort($result['rData']['date_added']);
         switch ($result['rData']['reviews_status']) {
             case 1:
                 // approved
                 $result['rData']['reviews_status_text'] = $lC_Language->get('review_status_approved');
                 break;
             case 2:
                 // rejected
                 $result['rData']['reviews_status_text'] = $lC_Language->get('review_status_rejected');
                 break;
             default:
                 //new
                 $result['rData']['reviews_status_text'] = $lC_Language->get('review_status_pending');
                 break;
         }
         $result['ratingRadio'] = '';
         for ($i = 1; $i <= 5; $i++) {
             $checked = $result['rData']['reviews_rating'] == $i ? 'checked' : NULL;
             $result['ratingRadio'] .= '<label for="reviews_rating-' . $i . '" class="button blue-active"><input type="radio" name="reviews_rating" id="reviews_rating-' . $i . '" value="' . $i . '" ' . $checked . '>' . $i . '</label>';
         }
         $result['ratingStars'] = lc_image('../images/stars_' . $result['rData']['reviews_rating'] . '.png', sprintf($lC_Language->get('rating_from_5_stars'), $result['rData']['reviews_rating'])) . '&nbsp;[' . sprintf($lC_Language->get('rating_from_5_stars'), $result['rData']['reviews_rating']) . ']';
     }
     return $result;
 }
 public static function getAll()
 {
     global $lC_Language;
     if (!defined('LC_ADMIN_FILE_MANAGER_ROOT_PATH')) {
         define('LC_ADMIN_FILE_MANAGER_ROOT_PATH', substr(DIR_FS_CATALOG, 0, -1));
     }
     $media = $_GET['media'];
     $goto_array = array(array('id' => '', 'text' => $lC_Language->get('top_level')));
     if ($_SESSION['fm_directory'] != LC_ADMIN_FILE_MANAGER_ROOT_PATH) {
         $path_array = explode('/', substr($_SESSION['fm_directory'], strlen(LC_ADMIN_FILE_MANAGER_ROOT_PATH) + 1));
         foreach ($path_array as $value) {
             if (sizeof($goto_array) < 2) {
                 $goto_array[] = array('id' => $value, 'text' => $value);
             } else {
                 $parent = end($goto_array);
                 $goto_array[] = array('id' => $parent['id'] . '/' . $value, 'text' => $parent['id'] . '/' . $value);
             }
         }
     }
     $lC_DirectoryListing = new lC_DirectoryListing($_SESSION['fm_directory']);
     $lC_DirectoryListing->setStats(true);
     $result = array('aaData' => array());
     if ($_SESSION['fm_directory'] != LC_ADMIN_FILE_MANAGER_ROOT_PATH) {
         $files = '<td>' . lc_link_object(lc_href_link_admin(FILENAME_DEFAULT, 'file_manager&goto=' . $goto_array[sizeof($goto_array) - 2]['id']), '<span class="icon-up-fat icon-blue">&nbsp;' . $lC_Language->get('parent_level')) . '</td>';
         $result['aaData'][] = array("{$files}", "", "", "", "", "", "", "");
     }
     $cnt = 0;
     foreach ($lC_DirectoryListing->getFiles() as $file) {
         $file_owner = posix_getpwuid($file['user_id']);
         $group_owner = posix_getgrgid($file['group_id']);
         if ($file['is_directory'] === true) {
             $entry_url = lc_href_link_admin(FILENAME_DEFAULT, 'file_manager&directory=' . $file['name']);
             $files = '<td>' . lc_link_object($entry_url, '<span class="icon-folder icon-orange">&nbsp;' . $file['name']) . '</td>';
         } else {
             $entry_url = lc_href_link_admin(FILENAME_DEFAULT, 'file_manager&entry=' . $file['name'] . '&action=save');
             $files = '<td><a href="javascript:void(0);" onclick="editEntry(\'' . $file['name'] . '\')">' . '<span class="icon-page-list icon-blue">&nbsp;' . $file['name'] . '</a></td>';
         }
         $size = '<td>' . number_format($file['size']) . '</td>';
         $perms = '<td>' . lc_get_file_permissions($file['permissions']) . '</td>';
         $user = '******' . $file_owner['name'] . '</td>';
         $group = '<td>' . $group_owner['name'] . '</td>';
         $write = '<td>' . is_writable($lC_DirectoryListing->getDirectory() . '/' . $file['name']) ? '<span class="icon-tick icon-green">' : '<span class="icon-cross icon-red">' . '</td>';
         $last = '<td>' . lC_DateTime::getShort(@date('Y-m-d H:i:s', $file['last_modified']), true) . '</td>';
         if ($file['is_directory'] === false) {
             $action_links = '<a href="' . ((int) ($_SESSION['admin']['access']['file_manager'] < 3) ? '#' : 'javascript://" onclick="editEntry(\'' . $file['name'] . '\')') . '" class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['file_manager'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_edit')) . '</a>' . '<a href="' . ((int) ($_SESSION['admin']['access']['file_manager'] < 2) ? '#' : lc_href_link_admin(FILENAME_DEFAULT, 'file_manager&entry=' . $file['name'] . '&action=download')) . '" class="button icon-download with-tooltip' . ((int) ($_SESSION['admin']['access']['file_manager'] < 2) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_download') . '"></a>' . '<a href="' . ((int) ($_SESSION['admin']['access']['file_manager'] < 4) ? '#' : 'javascript://" onclick="deleteEntry(\'' . $file['name'] . '\', \'' . urlencode($file['name']) . '\')"') . '" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access']['file_manager'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a>';
         } else {
             $action_links = '<a href="' . ((int) ($_SESSION['admin']['access']['file_manager'] < 4) ? '#' : 'javascript://" onclick="deleteEntry(\'' . $file['name'] . '\', \'' . urlencode($file['name']) . '\')"') . '" class="button icon-trash' . ((int) ($_SESSION['admin']['access']['file_manager'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a>';
         }
         $action = '<td class="align-right vertical-center"><span class="button-group compact">
                ' . $action_links . '
              </span></td>';
         $result['aaData'][] = array("{$files}", "{$size}", "{$perms}", "{$user}", "{$group}", "{$write}", "{$last}", "{$action}");
         $cnt++;
     }
     $result['total'] = $cnt;
     return $result;
 }
Exemple #4
0
/**
* Retrieve web server and database server information
*
* @access public
*/
function lc_get_system_information()
{
    global $lC_Database;
    $Qdb_date = $lC_Database->query('select now() as datetime');
    $Qdb_uptime = $lC_Database->query('show status like "Uptime"');
    @(list($system, $host, $kernel) = preg_split('/[\\s,]+/', @exec('uname -a'), 5));
    $db_uptime = intval($Qdb_uptime->valueInt('Value') / 3600) . ':' . str_pad(intval($Qdb_uptime->valueInt('Value') / 60 % 60), 2, '0', STR_PAD_LEFT);
    return array('date' => lC_DateTime::getShort(null, true), 'system' => $system, 'kernel' => $kernel, 'host' => $host, 'ip' => gethostbyname($host), 'uptime' => @exec('uptime'), 'http_server' => $_SERVER['SERVER_SOFTWARE'], 'php' => PHP_VERSION, 'zend' => function_exists('zend_version') ? zend_version() : '', 'db_server' => DB_SERVER, 'db_ip' => gethostbyname(DB_SERVER), 'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? @mysql_get_server_info() : ''), 'db_date' => lC_DateTime::getShort($Qdb_date->value('datetime'), true), 'db_uptime' => $db_uptime);
}
 public static function save($id, $data)
 {
     global $lC_DateTime;
     $update = array('date_available' => strstr($data['products_date_available'], '/') ? lC_DateTime::toDateTime($data['products_date_available']) : $data['products_date_available']);
     if (lC_Products_Admin::setDateAvailable($id, $update)) {
         return true;
     } else {
         return false;
     }
 }
Exemple #6
0
 protected function _setData()
 {
     global $lC_Database, $lC_Language, $lC_Template;
     if (!$this->enabled) {
         $this->_data = '';
     } else {
         $this->_data = '<div class="four-columns six-columns-tablet twelve-columns-mobile">' . '  <h2 class="relative thin">' . $this->_title . '</h2>' . '  <ul class="list spaced">';
         $Qcustomers = $lC_Database->query('select customers_id, customers_gender, customers_lastname, customers_firstname, customers_status, date_account_created from :table_customers order by date_account_created desc limit 7');
         $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomers->execute();
         while ($Qcustomers->next()) {
             $full = $Qcustomers->valueProtected('customers_firstname') . ' ' . $Qcustomers->valueProtected('customers_lastname');
             $this->_data .= '    <li>' . '      <span class="list-link icon-user icon-blue" title="' . $lC_Language->get('edit') . '">' . '        <strong>' . $Qcustomers->value('customers_firstname') . ' ' . $Qcustomers->value('customers_lastname') . '</strong> &nbsp; <span class="anthracite">' . lC_DateTime::getShort($Qcustomers->value('date_account_created')) . '</span>' . '      </span>' . '      <div class="absolute-right compact show-on-parent-hover">' . '        <a href="' . ((int) ($_SESSION['admin']['access']['customers'] < 3) ? '#' : 'javascript://" onclick="editCustomer(\'' . $Qcustomers->valueInt('customers_id') . '\')') . ';" class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['customers'] < 3) ? ' disabled' : NULL) . '">' . $lC_Language->get('icon_view') . '</a>' . '        <a href="' . ((int) ($_SESSION['admin']['access']['customers'] < 2) ? '#' : lc_href_link_admin(FILENAME_DEFAULT, 'orders&cID=' . $Qcustomers->valueInt('customers_id'))) . '" class="button icon-price-tag with-tooltip' . ((int) ($_SESSION['admin']['access']['customers'] < 2) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_orders') . '"></a>' . '        <!-- a href="' . ((int) ($_SESSION['admin']['access']['customers'] < 4) ? '#' : 'javascript://" onclick="deleteCustomer(\'' . $Qcustomers->valueInt('customers_id') . '\', \'' . urlencode($full) . '\')') . ';" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access']['customers'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a -->' . '      </div>' . '    </li>';
         }
         $this->_data .= '  </ul>' . '</div>';
         $Qcustomers->freeResult();
         $this->_data .= $this->loadModal();
     }
 }
Exemple #7
0
 public function toDatetime($date = '', $delimiter = '/')
 {
     if (empty($date)) {
         $date = lC_DateTime::getNow();
         $dateArr = explode('-', $date);
         $dateString = $dateArr[0] . '-' . $dateArr[1] . '-' . $dateArr[2];
     } else {
         $dateArr = explode($delimiter, $date);
         $dateString = '';
         if (!empty($dateArr[2])) {
             $dateString .= $dateArr[2] . '-';
         }
         $dateString .= ($dateArr[0] < 10 ? '0' : '') . $dateArr[0];
         if (!empty($dateArr[1])) {
             $dateString .= '-' . ($dateArr[1] < 10 ? '0' : '') . $dateArr[1];
         }
         //$dateString = $dateArr[2] . '-' . $dateArr[0] . '-' . $dateArr[1];
     }
     return $dateString;
 }
Exemple #8
0
 protected function _setData()
 {
     global $lC_Database, $lC_Language;
     if (!$this->enabled) {
         $this->_data = '';
     } else {
         $this->_data = '<div class="four-columns six-columns-tablet twelve-columns-mobile">' . '  <h2 class="relative thin">' . $this->_title . '</h2>' . '  <ul class="list spaced">';
         $Qorders = $lC_Database->query('select o.orders_id, o.customers_name, o.date_purchased, s.orders_status_name, ot.text as order_total from :table_orders o, :table_orders_total ot, :table_orders_status s where o.orders_id = ot.orders_id and ot.class = "total" and o.orders_status = s.orders_status_id and s.language_id = :language_id order by o.date_purchased desc limit 7');
         $Qorders->bindTable(':table_orders', TABLE_ORDERS);
         $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
         $Qorders->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qorders->bindInt(':language_id', $lC_Language->getID());
         $Qorders->execute();
         while ($Qorders->next()) {
             $this->_data .= '    <li>' . '      <a href="' . ((int) ($_SESSION['admin']['access']['orders'] < 3) ? '#' : lc_href_link_admin(FILENAME_DEFAULT, 'orders=' . $Qorders->valueInt('orders_id') . '&action=save')) . '"' . '        <span class="list-link icon-price-tag icon-green" title="oID[' . $Qorders->value('orders_id') . ']">' . '          <strong><span class="tag green-bg"><small class="white">' . strip_tags($Qorders->value('order_total')) . '</small></span></strong> &nbsp; <span class="anthracite"><strong>' . $Qorders->value('customers_name') . '</strong> &nbsp; ' . lC_DateTime::getShort($Qorders->value('date_purchased')) . '</span>' . '        </span>' . '        <div class="absolute-right compact show-on-parent-hover">' . '          <span class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['orders'] < 3) ? ' disabled' : NULL) . '">' . $lC_Language->get('icon_view') . '</span>' . '          <!-- a href="' . ((int) ($_SESSION['admin']['access']['orders'] < 4) ? '#' : lc_href_link_admin(FILENAME_DEFAULT, 'orders=' . $Qorders->valueInt('orders_id') . '&action=save')) . '" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access']['orders'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a -->' . '        </div>' . '      </a>' . '    </li>';
         }
         $this->_data .= '  </ul>' . '</div>';
         $Qorders->freeResult();
         $this->_data .= $this->loadModal();
     }
 }
Exemple #9
0
 public static function getAll()
 {
     global $lC_Language, $_module;
     $media = $_GET['media'];
     $lC_DirectoryListing = new lC_DirectoryListing(DIR_FS_WORK . 'cache/');
     $lC_DirectoryListing->setIncludeDirectories(false);
     $lC_DirectoryListing->setCheckExtension('cache');
     $cached_files = array();
     foreach ($lC_DirectoryListing->getFiles() as $file) {
         $last_modified = filemtime(DIR_FS_WORK . 'cache/' . $file['name']);
         if (strpos($file['name'], '-') !== false) {
             $code = substr($file['name'], 0, strpos($file['name'], '-'));
         } else {
             $code = substr($file['name'], 0, strpos($file['name'], '.'));
         }
         if (isset($cached_files[$code])) {
             $cached_files[$code]['total']++;
             if ($last_modified > $cached_files[$code]['last_modified']) {
                 $cached_files[$code]['last_modified'] = $last_modified;
             }
         } else {
             $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified);
         }
     }
     $result = array('aaData' => array());
     foreach ($cached_files as $cache => $stats) {
         $check = '<td><input class="batch" type="checkbox" name="batch[]" value="' . $cache . '" id="' . $cache . '"></td>';
         $block = '<td>' . $cache . '</td>';
         $total = '<td>' . $stats['total'] . '</td>';
         $last = '<td>' . lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp($stats['last_modified']), true) . '</td>';
         $action = '<td><span class="button-group compact">
                <a href="' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? '#' : 'javascript://" onclick="deleteEntry(\'' . $cache . '\', \'' . urlencode($cache) . '\')') . '" class="button icon-trash' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_delete')) . '</a>
              </span></td>';
         $result['aaData'][] = array("{$check}", "{$block}", "{$total}", "{$last}", "{$action}");
     }
     return $result;
 }
 public static function save($id = null, $data)
 {
     global $lC_Database;
     $error = false;
     if (empty($data['html_text']) && empty($data['image_local']) && !empty($data['image'])) {
         if (!file_exists(realpath('../images/' . $data['image_target']))) {
             mkdir('../images/' . $data['image_target'] . '/', 0777);
             $path = realpath('../images/' . $data['image_target']);
             $insert_path = $data['image_target'] . '/';
         } else {
             $path = realpath('../images/banners/');
             $insert_path = 'banners/';
         }
         // Remove existing image with the same name.
         if (file_exists($path . '/' . $data['image']['name'])) {
             unlink($path . '/' . $data['image']['name']);
         }
         $image = new upload($data['image'], $path);
         if (!$image->exists() || !$image->parse() || !$image->save()) {
             $error = true;
         }
     }
     if ($error === false) {
         $image_location = !empty($data['image_local']) ? $data['image_local'] : (isset($image) ? $insert_path . $image->filename : null);
         if (is_numeric($id)) {
             $Qbanner = $lC_Database->query('update :table_banners set banners_title = :banners_title, banners_url = :banners_url, banners_target = :banners_target, banners_image = :banners_image, banners_group = :banners_group, banners_html_text = :banners_html_text, expires_date = :expires_date, expires_impressions = :expires_impressions, date_scheduled = :date_scheduled, status = :status where banners_id = :banners_id');
             $Qbanner->bindInt(':banners_id', $id);
         } else {
             $Qbanner = $lC_Database->query('insert into :table_banners (banners_title, banners_url, banners_target, banners_image, banners_group, banners_html_text, expires_date, expires_impressions, date_scheduled, status, date_added) values (:banners_title, :banners_url, :banners_target, :banners_image, :banners_group, :banners_html_text, :expires_date, :expires_impressions, :date_scheduled, :status, now())');
         }
         $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
         $Qbanner->bindValue(':banners_title', $data['title']);
         $Qbanner->bindValue(':banners_url', $data['url']);
         $Qbanner->bindInt(':banners_target', $data['target'] === true ? 1 : 0);
         $Qbanner->bindValue(':banners_image', $image_location);
         $Qbanner->bindValue(':banners_group', !empty($data['group_new']) ? $data['group_new'] : $data['group']);
         $Qbanner->bindValue(':banners_html_text', $data['html_text']);
         if (empty($data['date_expires'])) {
             $Qbanner->bindRaw(':expires_date', 'null');
             $Qbanner->bindInt(':expires_impressions', $data['expires_impressions']);
         } else {
             $Qbanner->bindValue(':expires_date', lC_DateTime::toDateTime($data['date_expires']));
             $Qbanner->bindInt(':expires_impressions', 0);
         }
         if (empty($data['date_scheduled'])) {
             $Qbanner->bindRaw(':date_scheduled', 'null');
             $Qbanner->bindInt(':status', $data['status'] === true ? 1 : 0);
         } else {
             $Qbanner->bindValue(':date_scheduled', lC_DateTime::toDateTime($data['date_scheduled']));
             $Qbanner->bindInt(':status', lC_DateTime::toDateTime($data['date_scheduled']) > @date('Y-m-d') ? 0 : ($data['status'] === true ? 1 : 0));
         }
         $Qbanner->setLogging($_SESSION['module'], $id);
         $Qbanner->execute();
         if (!$lC_Database->isError()) {
             return true;
         }
     }
     return false;
 }
Exemple #11
0
       </address>
    </div>
    <div class="col-sm-6 col-lg-6">
      <div class="well text-right">
        <h3 class="no-margin-top"><?php 
echo $lC_Language->get('receipt_order_number_title');
?>
 <?php 
echo $_GET['receipt'];
?>
</h3>
        <div><strong><?php 
echo $lC_Language->get('receipt_order_date_title');
?>
</strong> <?php 
echo lC_DateTime::getShort($order->info['date_purchased']);
?>
</div>
        <div><strong><?php 
echo $lC_Language->get('receipt_order_status_title');
?>
</strong> <?php 
echo $order->info['orders_status'];
?>
</div>
        <div><strong><?php 
echo $lC_Language->get('receipt_payment_method_title');
?>
</strong> <?php 
echo $order->info['payment_method'];
?>
Exemple #12
0
         <!-- left box -->
         <?php 
       // The link will appear only if:
       // - Download remaining count is > 0, AND
       // - The file is present in the DOWNLOAD directory, AND EITHER
       // - No expiry date is enforced (maxdays == 0), OR
       // - The expiry date is not reached
       if ($Qdownloads->valueInt('download_count') > 0 && file_exists(DIR_FS_DOWNLOAD . $Qdownloads->value('orders_products_filename')) && ($Qdownloads->value('download_maxdays') == 0 || $download_timestamp > time())) {
           echo '            <td>' . lc_link_object(lc_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $Qdownloads->valueInt('orders_products_download_id')), $Qdownloads->value('products_name')) . '</td>' . "\n";
       } else {
           echo '            <td>' . $Qdownloads->value('products_name') . '</td>' . "\n";
       }
       ?>
         <!-- right box -->
         <?php 
       echo '            <td>' . sprintf($lC_Language->get('download_link_expires'), lC_DateTime::getLong($download_expiry)) . '</td>' . "\n" . '            <td align="right">' . sprintf($lC_Language->get('download_counter_remaining'), $Qdownloads->valueInt('download_count')) . '</td>' . "\n" . '          </tr>' . "\n";
   }
   ?>
     </tr>
   </table></td>
 </tr>
 <?php 
   if (!strstr($_SERVER['SCRIPT_FILENAME'], 'receipt')) {
       ?>
   <tr>
     <td width="10">&nbsp;</td>
   </tr>
   <tr>
     <td class="smalltext" colspan="4"><p><?php 
       sprintf($lC_Language->get('download_footer'), lc_link_object(lc_href_link(FILENAME_ACCOUNT, null, 'SSL'), $lC_Language->get('my_account')));
       ?>
 /**
  * Save the coupons information
  *
  * @param integer $id The coupons id used on update, null on insert
  * @param array $data An array containing the coupons information
  * @access public
  * @return array
  */
 public static function save($id = null, $data)
 {
     global $lC_Database, $lC_Language;
     $error = false;
     $lC_Database->startTransaction();
     if (is_numeric($id)) {
         $Qfeatured = $lC_Database->query('update :table_featured_products set expires_date = :expires_date, status = :status, last_modified = now() where id = :id');
         $Qfeatured->bindInt(':id', $id);
     } else {
         $Qfeatured = $lC_Database->query('insert into :table_featured_products (products_id, date_added, last_modified, expires_date, status) values (:products_id, now(), now(), :expires_date, :status)');
         $Qfeatured->bindInt(':products_id', $data['products_id']);
     }
     // insert/update the featured products table
     $Qfeatured->bindTable(':table_featured_products', TABLE_FEATURED_PRODUCTS);
     //$Qfeatured->bindDate(':expires_date', (($data['expires_date'] != '0000-00-00 00:00:00') ? ((strstr($data['expires_date'], '/')) ? lC_DateTime::toDateTime($data['expires_date']) : $data['expires_date']) : '0000-00-00 00:00:00'));
     $Qfeatured->bindDate(':expires_date', $data['expires_date'] != '0000-00-00 00:00:00' ? lC_DateTime::toDateTime($data['expires_date']) : $data['expires_date']);
     $Qfeatured->bindInt(':status', $data['status']);
     $Qfeatured->setLogging($_SESSION['module'], $id);
     $Qfeatured->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('featured_products');
         if (is_numeric($id)) {
             return $id;
         } else {
             return $lC_Database->nextID();
         }
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
Exemple #14
0
 public function sendEmail($id)
 {
     global $lC_Database, $lC_Language, $lC_Currencies, $lC_ShoppingCart;
     $Qorder = $lC_Database->query('select * from :table_orders where orders_id = :orders_id limit 1');
     $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     $Qorder->bindInt(':orders_id', $id);
     $Qorder->execute();
     if ($Qorder->numberOfRows() === 1) {
         $email_order = STORE_NAME . "\n" . $lC_Language->get('email_order_separator') . "\n" . sprintf($lC_Language->get('email_order_order_number'), $id) . "\n" . sprintf($lC_Language->get('email_order_invoice_url'), lc_href_link(FILENAME_ACCOUNT, 'receipt=' . $id, 'SSL', false, true, true)) . "\n" . sprintf($lC_Language->get('email_order_date_ordered'), lC_DateTime::getLong()) . "\n\n" . $lC_Language->get('email_order_products') . "\n" . $lC_Language->get('email_order_separator') . "\n";
         $Qproducts = $lC_Database->query('select orders_products_id, products_model, products_sku, products_name, products_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id');
         $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
         $Qproducts->bindInt(':orders_id', $id);
         $Qproducts->execute();
         while ($Qproducts->next()) {
             $skuModel = $Qproducts->value('products_model') != NULL ? $Qproducts->value('products_model') : NULL;
             if ($skuModel == NULL) {
                 $skuModel == ($Qproducts->value('products_sku') != NULL) ? $Qproducts->value('products_sku') : NULL;
             }
             $email_order .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $skuModel . ') = ' . $lC_Currencies->displayPriceWithTaxRate($Qproducts->value('products_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), false, $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n";
             $Qvariants = $lC_Database->query('select group_title, value_title from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id order by id');
             $Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
             $Qvariants->bindInt(':orders_id', $id);
             $Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));
             $Qvariants->execute();
             while ($Qvariants->next()) {
                 $email_order .= "\t" . $Qvariants->value('group_title') . ': ' . $Qvariants->value('value_title') . "\n";
             }
         }
         unset($Qproducts);
         unset($Qvariants);
         $email_order .= $lC_Language->get('email_order_separator') . "\n";
         $Qtotals = $lC_Database->query('select title, text from :table_orders_total where orders_id = :orders_id order by sort_order');
         $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
         $Qtotals->bindInt(':orders_id', $id);
         $Qtotals->execute();
         while ($Qtotals->next()) {
             $email_order .= strip_tags($Qtotals->value('title') . ' ' . $Qtotals->value('text')) . "\n";
         }
         unset($Qtotals);
         if (lc_empty($Qorder->value('delivery_name')) === false && lc_empty($Qorder->value('delivery_street_address')) === false) {
             $address = array('name' => $Qorder->value('delivery_name'), 'company' => $Qorder->value('delivery_company'), 'street_address' => $Qorder->value('delivery_street_address'), 'suburb' => $Qorder->value('delivery_suburb'), 'city' => $Qorder->value('delivery_city'), 'state' => $Qorder->value('delivery_state'), 'zone_code' => $Qorder->value('delivery_state_code'), 'country_title' => $Qorder->value('delivery_country'), 'country_iso2' => $Qorder->value('delivery_country_iso2'), 'country_iso3' => $Qorder->value('delivery_country_iso3'), 'postcode' => $Qorder->value('delivery_postcode'), 'format' => $Qorder->value('delivery_address_format'));
             $email_order .= "\n" . $lC_Language->get('email_order_delivery_address') . "\n" . $lC_Language->get('email_order_separator') . "\n" . lC_Address::format($address) . "\n";
             unset($address);
         }
         $address = array('name' => $Qorder->value('billing_name'), 'company' => $Qorder->value('billing_company'), 'street_address' => $Qorder->value('billing_street_address'), 'suburb' => $Qorder->value('billing_suburb'), 'city' => $Qorder->value('billing_city'), 'state' => $Qorder->value('billing_state'), 'zone_code' => $Qorder->value('billing_state_code'), 'country_title' => $Qorder->value('billing_country'), 'country_iso2' => $Qorder->value('billing_country_iso2'), 'country_iso3' => $Qorder->value('billing_country_iso3'), 'postcode' => $Qorder->value('billing_postcode'), 'format' => $Qorder->value('billing_address_format'));
         $email_order .= "\n" . $lC_Language->get('email_order_billing_address') . "\n" . $lC_Language->get('email_order_separator') . "\n" . lC_Address::format($address) . "\n\n";
         unset($address);
         $Qstatus = $lC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
         $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qstatus->bindInt(':orders_status_id', $Qorder->valueInt('orders_status'));
         $Qstatus->bindInt(':language_id', $lC_Language->getID());
         $Qstatus->execute();
         $email_order .= sprintf($lC_Language->get('email_order_status'), $Qstatus->value('orders_status_name')) . "\n" . $lC_Language->get('email_order_separator') . "\n";
         unset($Qstatus);
         $Qstatuses = $lC_Database->query('select date_added, comments from :table_orders_status_history where orders_id = :orders_id and comments != "" order by orders_status_history_id');
         $Qstatuses->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
         $Qstatuses->bindInt(':orders_id', $id);
         $Qstatuses->execute();
         while ($Qstatuses->next()) {
             $email_order .= lC_DateTime::getLong($Qstatuses->value('date_added')) . "\n\t" . wordwrap(str_replace("\n", "\n\t", $Qstatuses->value('comments')), 60, "\n\t", 1) . "\n\n";
         }
         unset($Qstatuses);
         if (is_object($lC_ShoppingCart)) {
             $email_order .= $lC_Language->get('email_order_payment_method') . "\n" . $lC_Language->get('email_order_separator') . "\n";
             $email_order .= $Qorder->value('payment_method') . "\n\n";
             /*if (isset($this->email_footer)) {
                 $email_order .= $this->email_footer . "\n\n";
               }*/
         }
         lc_email($Qorder->value('customers_name'), $Qorder->value('customers_email_address'), $lC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         // send emails to other people
         if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
             lc_email('', SEND_EXTRA_ORDER_EMAILS_TO, $lC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         }
     }
     unset($Qorder);
 }
 public function add($product_id, $quantity = null)
 {
     global $lC_Database, $lC_Services, $lC_Language, $lC_Customer, $lC_Product;
     if (!is_numeric($product_id)) {
         return false;
     }
     $Qproduct = $lC_Database->query('select p.*, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag) where p.products_id = :products_id');
     $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproduct->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
     $Qproduct->bindInt(':default_flag', 1);
     $Qproduct->bindInt(':products_id', $product_id);
     $Qproduct->execute();
     if ($Qproduct->value('image') == null) {
         // check for parent image
         $Qimage = $lC_Database->query('select image from :table_products_images where products_id = :parent_id');
         $Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
         $Qimage->bindInt(':default_flag', 1);
         $Qimage->bindInt(':parent_id', $Qproduct->valueInt('parent_id'));
         $Qimage->execute();
         $image = $Qimage->value('image');
     } else {
         $image = $Qproduct->value('image');
     }
     if ($Qproduct->valueInt('products_status') === 1) {
         if ($this->exists($product_id)) {
             $item_id = $this->getBasketID($product_id);
             if (is_numeric($quantity)) {
                 $quantity = $this->getQuantity($item_id) + 1;
             }
             $this->_contents[$item_id]['quantity'] = $quantity;
             if ($lC_Customer->isLoggedOn()) {
                 $Qupdate = $lC_Database->query('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id');
                 $Qupdate->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
                 $Qupdate->bindInt(':quantity', $quantity);
                 $Qupdate->bindInt(':customers_id', $lC_Customer->getID());
                 $Qupdate->bindInt(':item_id', $item_id);
                 $Qupdate->execute();
             }
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             $Qdescription = $lC_Database->query('select products_name, products_keyword, products_description, products_tags, products_url from :table_products_description where products_id = :products_id and language_id = :language_id');
             $Qdescription->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qdescription->bindInt(':products_id', $product_id);
             $Qdescription->bindInt(':language_id', $lC_Language->getID());
             $Qdescription->execute();
             $desc = $Qdescription->toArray();
             if ($Qproduct->valueInt('parent_id') > 0) {
                 $Qmaster = $lC_Database->query('select products_name as parent_name, products_description as description, products_keyword as keyword, products_tags as tags, products_url as url from :table_products_description where products_id = :products_id and language_id = :language_id limit 1');
                 $Qmaster->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
                 $Qmaster->bindInt(':products_id', $Qproduct->valueInt('parent_id'));
                 $Qmaster->bindInt(':language_id', $lC_Language->getID());
                 $Qmaster->execute();
                 if ($Qproduct->valueInt('is_subproduct') > 0) {
                     $desc['products_name'] = $Qmaster->value('parent_name') . ' - ' . $desc['products_name'];
                 } else {
                     $desc['products_name'] = $Qmaster->value('parent_name');
                 }
                 $desc['products_description'] = $Qmaster->value('description');
                 $desc['products_keyword'] = $Qmaster->value('keyword');
                 $desc['products_tags'] = $Qmaster->value('tags');
                 $desc['products_url'] = $Qmaster->value('url');
             }
             // we get the product price from the product class - price already includes options, etc.
             if (!isset($lC_Product)) {
                 $lC_Product = new lC_Product($product_id);
             }
             $price = $lC_Product->getPrice($product_id, $lC_Customer->getCustomerGroup(), $_POST);
             if ($lC_Customer->isLoggedOn()) {
                 $Qid = $lC_Database->query('select max(item_id) as item_id from :table_shopping_carts where customers_id = :customers_id');
                 $Qid->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
                 $Qid->bindInt(':customers_id', $lC_Customer->getID());
                 $Qid->execute();
                 $item_id = $Qid->valueInt('item_id') + 1;
             } else {
                 if (empty($this->_contents)) {
                     $item_id = 1;
                 } else {
                     $item_id = max(array_keys($this->_contents)) + 1;
                 }
             }
             $this->_contents[$item_id] = array('item_id' => $item_id, 'id' => $product_id, 'parent_id' => $Qproduct->valueInt('parent_id'), 'name' => $desc['products_name'], 'model' => $Qproduct->value('products_model'), 'sku' => $Qproduct->value('products_sku'), 'keyword' => $desc['products_keyword'], 'tags' => $desc['products_tags'], 'url' => $desc['products_url'], 'description' => $desc['products_description'], 'image' => $image, 'price' => $price, 'quantity' => $quantity, 'weight' => $Qproduct->value('products_weight'), 'tax_class_id' => $Qproduct->valueInt('products_tax_class_id'), 'date_added' => lC_DateTime::getShort(lC_DateTime::getNow()), 'weight_class_id' => $Qproduct->valueInt('products_weight_class'));
             // simple options
             if (isset($_POST['simple_options']) && empty($_POST['simple_options']) === false) {
                 foreach ($_POST['simple_options'] as $options_id => $values_id) {
                     if (is_array($values_id)) {
                         $text_value = current($values_id);
                         // for text fields
                         $values_id = key($values_id);
                     }
                     $QsimpleOptionsValues = $lC_Database->query('select price_modifier from :table_products_simple_options_values where options_id = :options_id and values_id = :values_id and customers_group_id = :customers_group_id');
                     $QsimpleOptionsValues->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES);
                     $QsimpleOptionsValues->bindInt(':options_id', $options_id);
                     $QsimpleOptionsValues->bindInt(':values_id', $values_id);
                     $QsimpleOptionsValues->bindInt(':customers_group_id', '1');
                     $QsimpleOptionsValues->execute();
                     $Qvariants = $lC_Database->query('select pvg.title as group_title, pvg.module, pvv.title as value_title from :table_products_variants_groups pvg, :table_products_variants_values pvv where pvg.id = :options_id and pvv.id = :values_id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id limit 1');
                     $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
                     $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
                     $Qvariants->bindInt(':options_id', $options_id);
                     $Qvariants->bindInt(':values_id', $values_id);
                     $Qvariants->bindInt(':languages_id', $lC_Language->getID());
                     $Qvariants->bindInt(':languages_id', $lC_Language->getID());
                     $Qvariants->execute();
                     if (strstr($Qvariants->value('module'), 'file_upload')) {
                         $group_title = is_array($_FILES['simple_options_upload']['name']) && count($_FILES['simple_options_upload']['name']) > 2 ? $lC_Language->get('text_label_files') : $lC_Language->get('text_label_file');
                         $value_title = is_array($_FILES['simple_options_upload']['name']) ? implode(', ', $_FILES['simple_options_upload']['name']) : $_FILES['simple_options_upload']['name'];
                         if (substr($value_title, -2) == ', ') {
                             $value_title = substr($value_title, 0, -2);
                         }
                         $value_title = str_replace(', ,', ', ', $value_title);
                         if ($value_title == '') {
                             $group_title = '';
                         }
                         if (is_array($_FILES['simple_options_upload']['name'])) {
                             $filesArr = $_FILES;
                             $_SESSION['file_upload'] = $_FILES['simple_options_upload'];
                             foreach ($filesArr['simple_options_upload']['name'] as $key => $file) {
                                 $_FILES = array('simple_options_upload' => array('name' => $file, 'type' => $filesArr['simple_options_upload']['type'][$key], 'tmp_name' => $filesArr['simple_options_upload']['tmp_name'][$key], 'error' => $filesArr['simple_options_upload']['error'][$key], 'size' => $filesArr['simple_options_upload']['size'][$key]));
                                 // upload the file
                                 $image = new upload('simple_options_upload', realpath('pub'));
                                 if ($image->exists()) {
                                     if ($image->parse() && $image->save()) {
                                         // success
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($Qvariants->value('module') == 'text_field') {
                             $group_title = $Qvariants->value('group_title');
                             $value_title = $text_value;
                         } else {
                             $group_title = $Qvariants->value('group_title');
                             $value_title = $Qvariants->value('value_title');
                         }
                     }
                     $this->_contents[$item_id]['simple_options'][] = array('value_id' => $values_id, 'group_id' => $options_id, 'group_title' => $group_title, 'value_title' => $value_title, 'price_modifier' => $QsimpleOptionsValues->valueDecimal('price_modifier'));
                     $QsimpleOptionsValues->freeResult();
                     $Qvariants->freeResult();
                 }
             }
             if ($lC_Customer->isLoggedOn()) {
                 $Qnew = $lC_Database->query('insert into :table_shopping_carts (customers_id, item_id, products_id, quantity, meta_data, date_added) values (:customers_id, :item_id, :products_id, :quantity, :meta_data, :date_added)');
                 $Qnew->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
                 $Qnew->bindInt(':customers_id', $lC_Customer->getID());
                 $Qnew->bindInt(':item_id', $item_id);
                 $Qnew->bindInt(':products_id', $product_id);
                 $Qnew->bindInt(':quantity', $quantity);
                 $Qnew->bindValue(':meta_data', serialize($this->_contents[$item_id]['simple_options']));
                 $Qnew->bindRaw(':date_added', 'now()');
                 $Qnew->execute();
             }
             if ($Qproduct->valueInt('parent_id') > 0) {
                 $Qvariant = $lC_Database->query('select pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title from :table_products_variants pv, :table_products_variants_values pvv, :table_products_variants_groups pvg where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id');
                 $Qvariant->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                 $Qvariant->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
                 $Qvariant->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
                 $Qvariant->bindInt(':products_id', $product_id);
                 $Qvariant->bindInt(':languages_id', $lC_Language->getID());
                 $Qvariant->bindInt(':languages_id', $lC_Language->getID());
                 $Qvariant->execute();
                 while ($Qvariant->next()) {
                     $group_title = lC_Variants::getGroupTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $value_title = lC_Variants::getValueTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $has_custom_value = lC_Variants::hasCustomValue($Qvariant->value('module'));
                     if (strstr($Qvariant->value('module'), 'file_upload')) {
                         $group_title = is_array($_FILES['variants_upload']['name']) && count($_FILES['variants_upload']['name']) > 2 ? $lC_Language->get('text_label_files') : $lC_Language->get('text_label_file');
                         $value_title = is_array($_FILES['variants_upload']['name']) ? implode(', ', $_FILES['variants_upload']['name']) : $_FILES['variants_upload']['name'];
                         if (substr($value_title, -2) == ', ') {
                             $value_title = substr($value_title, 0, -2);
                         }
                         if (is_array($_FILES['variants_upload']['name'])) {
                             $filesArr = $_FILES;
                             $_SESSION['file_upload'] = $_FILES['variants_upload'];
                             foreach ($filesArr['variants_upload']['name'] as $key => $file) {
                                 $_FILES = array('variants_upload' => array('name' => $file, 'type' => $filesArr['variants_upload']['type'][$key], 'tmp_name' => $filesArr['variants_upload']['tmp_name'][$key], 'error' => $filesArr['variants_upload']['error'][$key], 'size' => $filesArr['variants_upload']['size'][$key]));
                                 // upload the file
                                 $image = new upload('variants_upload', realpath('pub'));
                                 if ($image->exists()) {
                                     if ($image->parse() && $image->save()) {
                                         // success
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($Qvariant->value('module') == 'text_field') {
                             $group_title = $Qvariant->value('group_title');
                         } else {
                             $group_title = $Qvariant->value('group_title');
                             $value_title = $Qvariant->value('value_title');
                         }
                     }
                     $this->_contents[$item_id]['variants'][] = array('group_id' => $Qvariant->valueInt('group_id'), 'value_id' => $Qvariant->valueInt('value_id'), 'group_title' => $group_title, 'value_title' => $value_title, 'has_custom_value' => $has_custom_value);
                     if ($lC_Customer->isLoggedOn() && $has_custom_value === true) {
                         $Qnew = $lC_Database->query('insert into :table_shopping_carts_custom_variants_values (shopping_carts_item_id, customers_id, products_id, products_variants_values_id, products_variants_values_text) values (:shopping_carts_item_id, :customers_id, :products_id, :products_variants_values_id, :products_variants_values_text)');
                         $Qnew->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES);
                         $Qnew->bindInt(':shopping_carts_item_id', $item_id);
                         $Qnew->bindInt(':customers_id', $lC_Customer->getID());
                         $Qnew->bindInt(':products_id', $product_id);
                         $Qnew->bindInt(':products_variants_values_id', $Qvariant->valueInt('value_id'));
                         $Qnew->bindValue(':products_variants_values_text', $value_title);
                         $Qnew->execute();
                     }
                 }
             }
         }
         $this->_cleanUp();
         $this->_calculate();
     }
 }
Exemple #16
0
 /**
  * Save the coupons information
  *
  * @param integer $id The coupons id used on update, null on insert
  * @param array $data An array containing the coupons information
  * @access public
  * @return array
  */
 public static function save($id = null, $data)
 {
     global $lC_Database, $lC_Language;
     $coupon_id = '';
     $error = false;
     $lC_Database->startTransaction();
     if (is_numeric($id)) {
         $Qcoupon = $lC_Database->query('update :table_coupons set type = :type, mode = :mode, code = :code, reward = :reward, purchase_over = :purchase_over, start_date = :start_date, expires_date = :expires_date, uses_per_coupon = :uses_per_coupon, uses_per_customer = :uses_per_customer, restrict_to_products = :restrict_to_products, restrict_to_categories = :restrict_to_categories, restrict_to_customers = :restrict_to_customers, status = :status, date_modified = now(), sale_exclude = :sale_exclude, notes = :notes where coupons_id = :coupons_id');
         $Qcoupon->bindInt(':coupons_id', $id);
     } else {
         $Qcoupon = $lC_Database->query('insert into :table_coupons (type, mode, code, reward, purchase_over, start_date, expires_date, uses_per_coupon, uses_per_customer, restrict_to_products, restrict_to_categories, restrict_to_customers, status, date_created, date_modified, sale_exclude, notes) values (:type, :mode, :code, :reward, :purchase_over, :start_date, :expires_date, :uses_per_coupon, :uses_per_customer, :restrict_to_products, :restrict_to_categories, :restrict_to_customers, :status, now(), now(), :sale_exclude, :notes)');
     }
     // insert/update the coupons table
     $Qcoupon->bindTable(':table_coupons', TABLE_COUPONS);
     $Qcoupon->bindValue(':type', $data['type']);
     $Qcoupon->bindValue(':mode', $data['mode']);
     $Qcoupon->bindValue(':code', $data['code']);
     $Qcoupon->bindValue(':reward', $data['reward']);
     $Qcoupon->bindInt(':purchase_over', $data['purchase_over'] > 0 ? str_replace('$', '', $data['purchase_over']) : 0.0);
     $Qcoupon->bindDate(':start_date', $data['start_date'] != '' ? strstr($data['start_date'], '/') ? lC_DateTime::toDateTime($data['start_date']) : $data['start_date'] : null);
     $Qcoupon->bindDate(':expires_date', $data['expires_date'] != '' ? strstr($data['expires_date'], '/') ? lC_DateTime::toDateTime($data['expires_date']) : $data['expires_date'] : null);
     $Qcoupon->bindInt(':uses_per_coupon', $data['uses_per_coupon']);
     $Qcoupon->bindInt(':uses_per_customer', $data['uses_per_customer']);
     $Qcoupon->bindValue(':restrict_to_products', $data['restrict_to_products']);
     $Qcoupon->bindValue(':restrict_to_categories', $data['restrict_to_categories']);
     $Qcoupon->bindValue(':restrict_to_customers', $data['restrict_to_customers']);
     $Qcoupon->bindInt(':status', $data['status']);
     $Qcoupon->bindInt(':sale_exclude', $data['sale_exclude']);
     $Qcoupon->bindValue(':notes', $data['notes']);
     $Qcoupon->setLogging($_SESSION['module'], $id);
     $Qcoupon->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     // insert/update the coupons description table
     if (!$lC_Database->isError()) {
         $coupon_id = is_numeric($id) ? $id : $lC_Database->nextID();
         foreach ($lC_Language->getAll() as $l) {
             if (is_numeric($id)) {
                 $Qcoupondescription = $lC_Database->query('update :table_coupons_description set name = :name where coupons_id = :coupons_id and language_id = :language_id');
                 $Qcoupondescription->bindInt(':coupons_id', $coupon_id);
             } else {
                 $Qcoupondescription = $lC_Database->query('insert into :table_coupons_description (coupons_id, language_id, name) values (:coupons_id, :language_id, :name)');
                 $Qcoupondescription->bindInt(':coupons_id', $coupon_id);
             }
             $Qcoupondescription->bindTable(':table_coupons_description', TABLE_COUPONS_DESCRIPTION);
             $Qcoupondescription->bindInt(':language_id', $l['id']);
             $Qcoupondescription->bindValue(':name', $data['name'][$l['id']]);
             $Qcoupondescription->execute();
             if ($lC_Database->isError()) {
                 $error = true;
                 break;
             }
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         return $coupon_id;
         // Return the coupon ID to with the save_close button
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
Exemple #17
0
 private function _isValid($cInfo)
 {
     global $lC_ShoppingCart, $lC_Customer, $lC_Currencies;
     $valid = array('status' => true, 'rpcStatus' => 1, 'msg' => '');
     // check status
     if (isset($cInfo['status']) && $cInfo['status'] != '1') {
         $valid = array('status' => false, 'rpcStatus' => -3);
     }
     // check purchase over
     $total = (double) $lC_ShoppingCart->getTotal();
     if (isset($cInfo['purchase_over']) && (double) $cInfo['purchase_over'] > $total) {
         $valid = array('status' => false, 'rpcStatus' => -4, 'msg' => $lC_Currencies->format($cInfo['purchase_over']));
     }
     // check start/end dates
     $today = lC_DateTime::getShort(lC_DateTime::getNow());
     $start = isset($cInfo['start_date']) && $cInfo['start_date'] != NULL ? lC_DateTime::getShort($cInfo['start_date']) : NULL;
     $expires = isset($cInfo['expires_date']) && $cInfo['expires_date'] != NULL ? lC_DateTime::getShort($cInfo['expires_date']) : NULL;
     if ($start != NULL) {
         if ($start <= $today) {
         } else {
             $valid = array('status' => false, 'rpcStatus' => -5, 'msg' => $start);
         }
     }
     if ($expires != NULL) {
         if ($today <= $expires) {
         } else {
             $valid = array('status' => false, 'rpcStatus' => -6, 'msg' => $expires);
         }
     }
     // check uses per coupon and uses per customer
     $uses = $this->_getUses($cInfo['coupons_id']);
     if ((int) $cInfo['uses_per_coupon'] > 0 && (int) $cInfo['uses_per_coupon'] <= (int) $uses['per_coupon']) {
         $valid = array('status' => false, 'rpcStatus' => -7, 'msg' => $cInfo['uses_per_coupon']);
     }
     if ((int) $cInfo['uses_per_customer'] > 0 && (int) $cInfo['uses_per_customer'] <= (int) $uses['per_customer']) {
         $valid = array('status' => false, 'rpcStatus' => -8, 'msg' => $cInfo['uses_per_customer']);
     }
     return $valid;
 }
Exemple #18
0
                    break;
                default:
                    $file_array['compression'] = TEXT_NO_EXTENSION;
                    break;
            }
            $buInfo = new objectInfo($file_array);
        }
        ?>

      <tr onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">
        <td><?php 
        echo lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&action=download&file=' . $entry), lc_icon_admin('save.png', ICON_FILE_DOWNLOAD) . '&nbsp;' . $entry);
        ?>
</td>
        <td><?php 
        echo lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(filemtime(DIR_FS_BACKUP . $entry)), true);
        ?>
</td>
        <td><?php 
        echo number_format(filesize(DIR_FS_BACKUP . $entry));
        ?>
 bytes</td>
        <td align="right">

<?php 
        if (isset($buInfo) && $entry == $buInfo->file) {
            echo lc_link_object('#', lc_icon_admin('tape.png', IMAGE_RESTORE), 'onclick="toggleInfoBox(\'bRestore\');"') . '&nbsp;' . lc_link_object('#', lc_icon_admin('trash.png', IMAGE_DELETE), 'onclick="toggleInfoBox(\'bDelete\');"');
        } else {
            echo lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&file=' . $entry . '&action=bRestore'), lc_icon_admin('tape.png', IMAGE_RESTORE)) . '&nbsp;' . lc_link_object(lc_href_link(FILENAME_DEFAULT, $lC_Template->getModule() . '&file=' . $entry . '&action=bDelete'), lc_icon_admin('trash.png', IMAGE_DELETE));
        }
        ?>
 protected function _setData()
 {
     global $lC_Database, $lC_Language, $lC_Currencies;
     $this->_data = array();
     $orderDate_qry = $lC_Database->query('select o.date_purchased , count(*) as orderCount from :table_orders o where 1 ');
     if (isset($_GET['statusID'])) {
         switch ($_GET['statusID']) {
             case 'Pending':
             case 'Approved':
             case 'Rejected':
                 $query = $lC_Database->query('select orders_status_id, orders_status_name from :table_orders_status where orders_status_type = "' . $_GET['statusID'] . '"');
                 $query->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
                 $query->bindInt(':language_id', $lC_Language->getID());
                 $query->execute();
                 $ids = '';
                 while ($query->next()) {
                     $ids .= $query->value('orders_status_id') . ",";
                 }
                 $ids = substr($ids, 0, -1);
                 $orderDate_qry->appendQuery(' and o.orders_status IN ( :orders_status )');
                 $orderDate_qry->bindValue(':orders_status', $ids);
                 break;
             default:
                 if ((int) $_GET['statusID'] > 0) {
                     $orderDate_qry->appendQuery(' and o.orders_status = :orders_status ');
                     $orderDate_qry->bindInt(':orders_status', $_GET['statusID']);
                 }
         }
     }
     $s_date_arr = explode('/', $_GET['startDate']);
     $start = $s_date_arr['2'] . "-" . $s_date_arr['0'] . "-" . $s_date_arr['1'];
     $e_date_arr = explode('/', $_GET['expiresDate']);
     $end = $e_date_arr['2'] . "-" . $e_date_arr['0'] . "-" . $e_date_arr['1'];
     if (isset($_GET['startDate']) && !empty($_GET['startDate'])) {
         $orderDate_qry->appendQuery(' and o.date_purchased >= :start ');
         $orderDate_qry->bindvalue(':start', $start);
     }
     if (isset($_GET['expiresDate']) && !empty($_GET['expiresDate'])) {
         $orderDate_qry->appendQuery(' and o.date_purchased <= :end');
         $orderDate_qry->bindvalue(':end', $end);
     }
     $orderDate_qry->appendQuery(' group by o.date_purchased ');
     $orderDate_qry->bindTable(':table_orders', TABLE_ORDERS);
     $orderDate_qry->execute();
     while ($orderDate_qry->next()) {
         $orderCount = 0;
         $itemCount = 0;
         $revenueTotal = 0;
         $shippingTotal = 0;
         $couponTotal = 0;
         $datePurchased = lC_DateTime::getShort($orderDate_qry->value('date_purchased'));
         $orderCount = $orderDate_qry->value('orderCount');
         $order_qry = $lC_Database->query('select orders_id from :table_orders where date_purchased = :date_purchased ');
         $order_qry->bindTable(':table_orders', TABLE_ORDERS);
         $order_qry->bindValue(':date_purchased', $orderDate_qry->value('date_purchased'));
         $order_qry->setBatchLimit($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS);
         $order_qry->execute();
         while ($order_qry->next()) {
             $tmp_arry = $this->_getOrdersProductsDetails_sales($order_qry->value('orders_id'));
             foreach ($tmp_arry as $k => $v) {
                 switch ($k) {
                     case 'itemCount':
                         $itemCount += $v;
                         break;
                     case 'revenueTotal':
                         $revenueTotal += $v;
                         break;
                     case 'shippingTotal':
                         $shippingTotal += $v;
                         break;
                     case 'couponTotal':
                         $couponTotal += $v;
                         break;
                 }
             }
         }
         $this->_data[] = array($datePurchased, $orderCount, $itemCount, $lC_Currencies->format($revenueTotal), $lC_Currencies->format($shippingTotal), $lC_Currencies->format($couponTotal));
     }
 }
Exemple #20
0
 public static function save($id = null, $data, $send_email = true)
 {
     global $lC_Database, $lC_Language, $lC_DateTime;
     $lC_Language->loadIniFile('customers.php');
     $error = false;
     $result = array();
     if (!is_numeric($id) || is_numeric($id)) {
         // check that email doesnt exist
         $Qcheck = $lC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address');
         if (isset($id) && is_numeric($id)) {
             $Qcheck->appendQuery('and customers_id != :customers_id');
             $Qcheck->bindInt(':customers_id', $id);
         }
         $Qcheck->appendQuery('limit 1');
         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcheck->bindValue(':customers_email_address', $data['email_address']);
         $Qcheck->execute();
         if ($Qcheck->numberOfRows() > 0) {
             $error = true;
             $result['rpcStatus'] = -2;
         }
         $Qcheck->freeResult();
         if (trim($data['password']) != null) {
             // check that passwords match
             if (trim($data['password']) != trim($data['confirmation'])) {
                 $error = true;
                 $result['rpcStatus'] = -3;
             }
         }
     } else {
         // check that passwords match
         if (trim($data['password']) != trim($data['confirmation'])) {
             $error = true;
             $result['rpcStatus'] = -3;
         }
     }
     if ($error === false) {
         $lC_Database->startTransaction();
         if (is_numeric($id)) {
             $Qcustomer = $lC_Database->query('update :table_customers set customers_group_id = :customers_group_id, customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob, customers_newsletter = :customers_newsletter, customers_status = :customers_status, date_account_last_modified = :date_account_last_modified where customers_id = :customers_id');
             $Qcustomer->bindRaw(':date_account_last_modified', 'now()');
             $Qcustomer->bindInt(':customers_id', $id);
         } else {
             $Qcustomer = $lC_Database->query('insert into :table_customers (customers_group_id, customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_dob, customers_newsletter, customers_status, number_of_logons, date_account_created) values (:customers_group_id, :customers_gender, :customers_firstname, :customers_lastname, :customers_email_address, :customers_dob, :customers_newsletter, :customers_status, :number_of_logons, :date_account_created)');
             $Qcustomer->bindInt(':number_of_logons', 0);
             $Qcustomer->bindRaw(':date_account_created', 'now()');
         }
         $dob = isset($data['dob']) && !empty($data['dob']) ? lC_DateTime::toDateTime($data['dob']) : '0000-00-00 00:00:00';
         $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
         $Qcustomer->bindValue(':customers_gender', $data['gender']);
         $Qcustomer->bindValue(':customers_firstname', $data['firstname']);
         $Qcustomer->bindValue(':customers_lastname', $data['lastname']);
         $Qcustomer->bindValue(':customers_email_address', $data['email_address']);
         $Qcustomer->bindValue(':customers_dob', $dob);
         $Qcustomer->bindInt(':customers_newsletter', $data['newsletter']);
         $Qcustomer->bindInt(':customers_status', $data['status']);
         $Qcustomer->bindInt(':customers_group_id', $data['group']);
         $Qcustomer->setLogging($_SESSION['module'], $id);
         $Qcustomer->execute();
         if (!$lC_Database->isError()) {
             if (!empty($data['password'])) {
                 $customer_id = !empty($id) ? $id : $lC_Database->nextID();
                 $result['new_customer_id'] = $customer_id;
                 $Qpassword = $lC_Database->query('update :table_customers set customers_password = :customers_password where customers_id = :customers_id');
                 $Qpassword->bindTable(':table_customers', TABLE_CUSTOMERS);
                 $Qpassword->bindValue(':customers_password', lc_encrypt_string(trim($data['password'])));
                 $Qpassword->bindInt(':customers_id', $customer_id);
                 $Qpassword->setLogging($_SESSION['module'], $customer_id);
                 $Qpassword->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                     $result['rpcStatus'] = -1;
                 }
             }
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         if ($send_email === true) {
             if (empty($id)) {
                 $full_name = trim($data['firstname'] . ' ' . $data['lastname']);
                 $email_text = '';
                 if (ACCOUNT_GENDER > -1) {
                     if ($data['gender'] == 'm') {
                         $email_text .= sprintf($lC_Language->get('email_greet_mr'), trim($data['lastname'])) . "\n\n";
                     } else {
                         $email_text .= sprintf($lC_Language->get('email_greet_ms'), trim($data['lastname'])) . "\n\n";
                     }
                 } else {
                     $email_text .= sprintf($lC_Language->get('email_greet_general'), $full_name) . "\n\n";
                 }
                 $email_text .= sprintf($lC_Language->get('email_text'), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, trim($data['password']));
                 $email_subject = sprintf($lC_Language->get('email_subject'), STORE_NAME);
                 lc_email($full_name, $data['email_address'], $email_subject, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             }
         }
         return $result;
     }
     $lC_Database->rollbackTransaction();
     return $result;
 }
Exemple #21
0
 /**
  * Deactivate all banners that have passed their schedule
  *
  * @access public
  */
 public function expireAll()
 {
     global $lC_Database;
     $Qbanner = $lC_Database->query('select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from :table_banners b, :table_banners_history bh where b.status = 1 and b.banners_id = bh.banners_id group by b.banners_id');
     $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
     $Qbanner->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
     $Qbanner->execute();
     while ($Qbanner->next()) {
         if (!lc_empty($Qbanner->value('expires_date'))) {
             if (lC_DateTime::getNow() >= $Qbanner->value('expires_date')) {
                 $this->expire($Qbanner->valueInt('banners_id'));
             }
         } elseif (!lc_empty($Qbanner->valueInt('expires_impressions'))) {
             if ($Qbanner->valueInt('expires_impressions') > 0 && $Qbanner->valueInt('banners_shown') >= $Qbanner->valueInt('expires_impressions')) {
                 $this->expire($Qbanner->valueInt('banners_id'));
             }
         }
     }
 }
        echo lc_href_link(FILENAME_ACCOUNT, 'receipt=' . $Qhistory->valueInt('orders_id'), 'SSL');
        ?>
"><?php 
        echo lc_image(DIR_WS_TEMPLATE_IMAGES . 'icons/16/search.png', $lC_Language->get('text_view'));
        ?>
</a></td>
            <td><?php 
        echo $Qhistory->valueInt('orders_id');
        ?>
</td>                
            <td><?php 
        echo lc_output_string_protected($order_name);
        ?>
</td> 
            <td><?php 
        echo lC_DateTime::getShort($Qhistory->value('date_purchased'));
        ?>
</td>
            <td><?php 
        echo $Qhistory->value('orders_status_name');
        ?>
</td> 
            <td><?php 
        echo lC_Order::numberOfProducts($Qhistory->valueInt('orders_id'));
        ?>
</td>
            <td><?php 
        echo strip_tags($Qhistory->value('order_total'));
        ?>
</td>
          </tr>
Exemple #23
0
 public function getListingOutput($id = null)
 {
     global $lC_Database, $lC_Language, $lC_Image;
     if (is_numeric($id)) {
         $Qreviews = $lC_Database->query('select reviews_id, reviews_text, reviews_rating, date_added, customers_name from :table_reviews where products_id = :products_id and languages_id = :languages_id and reviews_status = 1 order by reviews_id desc');
         $Qreviews->bindInt(':products_id', $id);
         $Qreviews->bindInt(':languages_id', $lC_Language->getID());
     } else {
         $Qreviews = $lC_Database->query('select r.reviews_id, left(r.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name, p.products_id, p.products_price, p.products_tax_class_id, pd.products_name, pd.products_keyword, i.image from :table_reviews r, :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where r.reviews_status = 1 and r.languages_id = :languages_id and r.products_id = p.products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by r.reviews_id desc');
         $Qreviews->bindTable(':table_products', TABLE_PRODUCTS);
         $Qreviews->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
         $Qreviews->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
         $Qreviews->bindInt(':default_flag', 1);
         $Qreviews->bindInt(':languages_id', $lC_Language->getID());
         $Qreviews->bindInt(':language_id', $lC_Language->getID());
     }
     $Qreviews->bindTable(':table_reviews', TABLE_REVIEWS);
     $Qreviews->setBatchLimit(isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1, MAX_DISPLAY_NEW_REVIEWS);
     $Qreviews->execute();
     $counter = 0;
     $output = '';
     if ($Qreviews->numberOfRows() > 0) {
         while ($Qreviews->next()) {
             $counter++;
             if ($counter > 1) {
                 $output .= '<br />' . "\n";
             }
             $text = strlen($Qreviews->valueProtected('reviews_text')) > 60 ? substr($Qreviews->valueProtected('reviews_text'), 0, 360) . '...' : $Qreviews->valueProtected('reviews_text');
             $output .= '<div class="content-reviews-stars">' . lc_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $Qreviews->valueInt('reviews_rating') . '.png', sprintf($lC_Language->get('rating_of_5_stars'), $Qreviews->valueInt('reviews_rating'))) . '&nbsp;' . sprintf($lC_Language->get('reviewed_by'), $Qreviews->valueProtected('customers_name')) . '; ' . lC_DateTime::getLong($Qreviews->value('date_added')) . '</div>' . "\n";
             $output .= '<div class="content-reviews-text"><em>' . nl2br($text) . '</em></div>' . "\n";
         }
     } else {
         $output = '<div>' . $lC_Language->get('no_reviews_available') . '</div>' . "\n";
     }
     return $output;
 }
Exemple #24
0
        <?php 
if ($lC_MessageStack->size('reviews') > 0) {
    echo '<div class="message-stack-container alert alert-error">' . $lC_MessageStack->get('reviews') . '</div>' . "\n";
}
?>

        <div class="content-product-reviews-container">  
          <h3 class="no-margin-top"><?php 
echo $lC_Template->getPageTitle();
?>
</h3>  
          <?php 
if ($lC_Product->getData('reviews_average_rating') > 0) {
    ?>
            <div class="content-reviews-info-stars"><?php 
    echo lc_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $Qreviews->valueInt('reviews_rating') . '.png', sprintf($lC_Language->get('rating_of_5_stars'), $Qreviews->valueInt('reviews_rating'))) . '&nbsp;' . sprintf($lC_Language->get('reviewed_by'), $Qreviews->valueProtected('customers_name')) . '; ' . lC_DateTime::getLong($Qreviews->value('date_added'));
    ?>
</div>
            <div class="content-reviews-info-text"><?php 
    echo nl2br(wordwrap($Qreviews->valueProtected('reviews_text'), 60, '&shy;'));
    ?>
</div>
            <?php 
}
?>
  
        </div>
      </div>
    </div>
  </div>   
  <div class="col-sm-12 col-lg-12 clearfix">
Exemple #25
0
 public static function save($id = null, $data)
 {
     global $lC_Database, $lC_DateTime;
     $error = false;
     $Qproduct = $lC_Database->query('select products_price from :table_products where products_id = :products_id limit 1');
     $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproduct->bindInt(':products_id', $data['products_id']);
     $Qproduct->execute();
     $specials_price = $data['specials_price'];
     if (substr($specials_price, -1) == '%') {
         $specials_price = $Qproduct->valueDecimal('products_price') - (double) $specials_price / 100 * $Qproduct->valueDecimal('products_price');
     }
     if ($specials_price < '0.00' || $specials_price >= $Qproduct->valueDecimal('products_price')) {
         $result['rpcStatus'] = -1;
         $error = true;
     }
     if (strtotime($data['specials_expires_date']) < strtotime($data['specials_start_date'])) {
         $result['rpcStatus'] = -2;
         $error = true;
     }
     if ($error === false) {
         if ($id > 0) {
             $Qspecial = $lC_Database->query('update :table_specials set specials_new_products_price = :specials_new_products_price, specials_last_modified = now(), expires_date = :expires_date, start_date = :start_date, status = :status where specials_id = :specials_id');
             $Qspecial->bindInt(':specials_id', $id);
         } else {
             $Qspecial = $lC_Database->query('insert into :table_specials (products_id, specials_new_products_price, specials_date_added, expires_date, start_date, status) values (:products_id, :specials_new_products_price, now(), :expires_date, :start_date, :status)');
             $Qspecial->bindInt(':products_id', $data['products_id']);
         }
         $Qspecial->bindTable(':table_specials', TABLE_SPECIALS);
         $Qspecial->bindValue(':specials_new_products_price', $specials_price);
         $Qspecial->bindDate(':expires_date', strstr($data['specials_expires_date'], '/') ? lC_DateTime::toDateTime($data['specials_expires_date']) : $data['specials_expires_date']);
         $Qspecial->bindDate(':start_date', strstr($data['specials_start_date'], '/') ? lC_DateTime::toDateTime($data['specials_start_date']) : $data['specials_start_date']);
         $Qspecial->bindInt(':status', $data['specials_status']);
         $Qspecial->setLogging($_SESSION['module'], $id);
         $Qspecial->execute();
         if ($lC_Database->isError()) {
             $result['rpcStatus'] = -3;
         }
     }
     return $result;
 }
Exemple #26
0
 public static function getHistory()
 {
     global $lC_Language, $lC_Database, $_module;
     $media = $_GET['media'];
     $Qhistory = $lC_Database->query('select * from :table_updates_log order by dateCreated');
     $Qhistory->bindTable(':table_updates_log', TABLE_UPDATES_LOG);
     $Qhistory->execute();
     $result = array('aaData' => array());
     while ($Qhistory->next()) {
         $uAction = '<th scope"row">' . $Qhistory->value('action') . '</th>';
         $uResult = '<td>' . $Qhistory->value('result') . '</td>';
         $uUser = '******' . $Qhistory->value('user') . '</td>';
         $uDate = '<td>' . lC_DateTime::getShort($Qhistory->value('dateCreated'), true) . '</td>';
         //    $log = '<td class="align-right vertical-center"><span class="button-group compact">
         //                 <a href="' . ((int)($_SESSION['admin']['access']['definitions'] < 3) ? '#' : 'javascript://" onclick="editGroup(\'' . $Qgroups->valueInt('customers_group_id') . '\')') . '" class="button icon-pencil' . ((int)($_SESSION['admin']['access']['definitions'] < 3) ? ' disabled' : NULL) . '">' .  (($media === 'mobile-portrait' || $media === 'mobile-landscape') ? NULL : $lC_Language->get('icon_edit')) . '</a>
         //                 <a href="' . ((int)($_SESSION['admin']['access']['definitions'] < 4 || $Qgroups->valueInt('customers_group_id') == DEFAULT_CUSTOMERS_GROUP_ID) ? '#' : 'javascript://" onclick="deleteGroup(\'' . $Qgroups->valueInt('customers_group_id') . '\', \'' . urlencode($Qgroups->valueProtected('title')) . '\')') . '" class="button icon-trash with-tooltip' . ((int)($_SESSION['admin']['access']['definitions'] < 4 || $Qgroups->valueInt('customers_group_id') == DEFAULT_CUSTOMERS_GROUP_ID ) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a>
         //               </span></td>';
         $result['aaData'][] = array("{$uAction}", "{$uResult}", "{$uUser}", "{$uDate}");
         $result['entries'][] = $Qhistory->toArray();
     }
     $Qhistory->freeResult();
     return $result;
 }
Exemple #27
0
 /**
  * Make a log entry
  *  
  * @param string $message  The message to log
  * @access protected      
  * @return void
  */
 protected static function log($message)
 {
     if (is_writable(DIR_FS_WORK . 'logs')) {
         file_put_contents(DIR_FS_WORK . 'logs/curl_errors.txt', '[' . lC_DateTime::getNow('d-M-Y H:i:s') . '] ' . $message . "\n", FILE_APPEND);
     }
 }
Exemple #28
0
 public static function backup($compression = null, $download_only = false)
 {
     global $lC_Database;
     if (lc_empty(DIR_FS_BACKUP) || !@is_dir(DIR_FS_BACKUP) || !@is_writeable(DIR_FS_BACKUP)) {
         return false;
     }
     lc_set_time_limit(0);
     $backup_file = 'db_' . DB_DATABASE . '-' . @date('YmdHis') . '.sql';
     $fp = @fopen(DIR_FS_BACKUP . $backup_file, 'w');
     $schema = '# LoadedCommerce, Innovative eCommerce Solutions' . "\n" . '# http://www.loadedcommerce.com' . "\n" . '#' . "\n" . '# Database Backup For ' . STORE_NAME . "\n" . '# Copyright (c) ' . @date('Y') . ' ' . STORE_OWNER . "\n" . '#' . "\n" . '# Database: ' . DB_DATABASE . "\n" . '# Database Server: ' . DB_SERVER . "\n" . '#' . "\n" . '# Backup Date: ' . lC_DateTime::getShort(null, true) . "\n\n";
     @fputs($fp, $schema);
     $Qtables = $lC_Database->query('show tables');
     while ($Qtables->next()) {
         $table = $Qtables->value('Tables_in_' . DB_DATABASE);
         $schema = 'drop table if exists ' . $table . ';' . "\n" . 'create table ' . $table . ' (' . "\n";
         $table_list = array();
         $Qfields = $lC_Database->query('show fields from :table');
         $Qfields->bindTable(':table', $table);
         $Qfields->execute();
         while ($Qfields->next()) {
             $table_list[] = $Qfields->value('Field');
             $schema .= '  ' . $Qfields->value('Field') . ' ' . $Qfields->value('Type');
             if (!lc_empty($Qfields->value('Default'))) {
                 $schema .= ' default \'' . $Qfields->value('Default') . '\'';
             }
             if ($Qfields->value('Null') != 'YES') {
                 $schema .= ' not null';
             }
             if (!lc_empty($Qfields->value('Extra'))) {
                 $schema .= ' ' . $Qfields->value('Extra');
             }
             $schema .= ',' . "\n";
         }
         $schema = substr($schema, 0, -2);
         // add the keys
         $Qkeys = $lC_Database->query('show keys from :table');
         $Qkeys->bindTable(':table', $table);
         $Qkeys->execute();
         $index = array();
         while ($Qkeys->next()) {
             $kname = $Qkeys->value('Key_name');
             if (!isset($index[$kname])) {
                 $index[$kname] = array('unique' => !$Qkeys->value('Non_unique'), 'fulltext' => $Qkeys->value('Index_type') == 'FULLTEXT' ? true : false, 'columns' => array());
             }
             $index[$kname]['columns'][] = $Qkeys->value('Column_name');
         }
         foreach ($index as $kname => $info) {
             $schema .= ',' . "\n";
             $columns = implode($info['columns'], ', ');
             if ($kname == 'PRIMARY') {
                 $schema .= '  PRIMARY KEY (' . $columns . ')';
             } elseif ($info['fulltext'] === true) {
                 $schema .= '  FULLTEXT ' . $kname . ' (' . $columns . ')';
             } elseif ($info['unique']) {
                 $schema .= '  UNIQUE ' . $kname . ' (' . $columns . ')';
             } else {
                 $schema .= '  KEY ' . $kname . ' (' . $columns . ')';
             }
         }
         $schema .= "\n" . ');' . "\n\n";
         @fputs($fp, $schema);
         // dump the data from the tables except from the sessions table and the who's online table
         if ($table != TABLE_SESSIONS && $table != TABLE_WHOS_ONLINE) {
             $Qrows = $lC_Database->query('select :columns from :table');
             $Qrows->bindRaw(':columns', implode(', ', $table_list));
             $Qrows->bindTable(':table', $table);
             $Qrows->execute();
             while ($Qrows->next()) {
                 $rows = $Qrows->toArray();
                 $schema = 'insert into ' . $table . ' (' . implode(', ', $table_list) . ') values (';
                 foreach ($table_list as $i) {
                     if (!isset($rows[$i])) {
                         $schema .= 'NULL, ';
                     } elseif (strlen($rows[$i]) > 0) {
                         $row = addslashes($rows[$i]);
                         $row = str_replace("\n#", "\n" . '\\#', $row);
                         $schema .= '\'' . $row . '\', ';
                     } else {
                         $schema .= '\'\', ';
                     }
                 }
                 $schema = substr($schema, 0, -2) . ');' . "\n";
                 fputs($fp, $schema);
             }
         }
     }
     fclose($fp);
     unset($schema);
     switch ($compression) {
         case 'gzip':
             exec(CFG_APP_GZIP . ' ' . DIR_FS_BACKUP . $backup_file);
             $backup_file .= '.gz';
             break;
         case 'zip':
             exec(CFG_APP_ZIP . ' -j ' . DIR_FS_BACKUP . $backup_file . '.zip ' . DIR_FS_BACKUP . $backup_file);
             if (file_exists(DIR_FS_BACKUP . $backup_file)) {
                 unlink(DIR_FS_BACKUP . $backup_file);
             }
             $backup_file .= '.zip';
             break;
     }
     if ($download_only === true) {
         header('Content-type: application/x-octet-stream');
         header('Content-disposition: attachment; filename=' . $backup_file);
         readfile(DIR_FS_BACKUP . $backup_file);
         if (file_exists(DIR_FS_BACKUP . $backup_file)) {
             unlink(DIR_FS_BACKUP . $backup_file);
         }
         exit;
     }
     if (file_exists(DIR_FS_BACKUP . $backup_file)) {
         return true;
     }
     return false;
 }
Exemple #29
0
 public static function get($id)
 {
     global $lC_Database, $lC_Language, $lC_Currencies;
     $Qproducts = $lC_Database->query('select p.*, pd.* from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':products_id', $id);
     $Qproducts->bindInt(':language_id', $lC_Language->getID());
     $Qproducts->execute();
     $data = array_merge(array('products_id' => $id), (array) $Qproducts->toArray());
     $Qproducts->freeResult();
     $Qspecials = $lC_Database->query('select * from :table_specials where products_id = :products_id');
     $Qspecials->bindTable(':table_specials', TABLE_SPECIALS);
     $Qspecials->bindInt(':products_id', $id);
     $Qspecials->execute();
     $data['products_special_status'] = $Qspecials->valueInt('status');
     $data['products_special_price'] = $Qspecials->valueDecimal('specials_new_products_price');
     if ($Qspecials->value('start_date') != null) {
         $data['products_special_start_date'] = lC_DateTime::getShort($Qspecials->value('start_date'));
     }
     if ($Qspecials->value('expires_date') != null) {
         $data['products_special_expires_date'] = lC_DateTime::getShort($Qspecials->value('expires_date'));
     }
     $Qspecials->freeResult();
     $Qfeatured = $lC_Database->query('select status from :table_featured_products where products_id = :products_id limit 1');
     $Qfeatured->bindTable(':table_featured_products', TABLE_FEATURED_PRODUCTS);
     $Qfeatured->bindInt(':products_id', $id);
     $Qfeatured->execute();
     $data['products_featured'] = $Qfeatured->valueInt('status');
     $Qfeatured->freeResult();
     $variants_array = array();
     if ($data['has_children'] == '1') {
         $QmultiSKUProducts = $lC_Database->query('select * from :table_products where parent_id = :parent_id');
         $QmultiSKUProducts->bindTable(':table_products', TABLE_PRODUCTS);
         $QmultiSKUProducts->bindInt(':parent_id', $data['products_id']);
         $QmultiSKUProducts->execute();
         while ($QmultiSKUProducts->next()) {
             $variants_array[$QmultiSKUProducts->valueInt('products_id')]['data'] = array('cost' => $QmultiSKUProducts->value('products_cost'), 'price' => $QmultiSKUProducts->value('products_price'), 'msrp' => $QmultiSKUProducts->value('products_msrp'), 'tax_class_id' => $QmultiSKUProducts->valueInt('products_tax_class_id'), 'model' => $QmultiSKUProducts->value('products_model'), 'sku' => $QmultiSKUProducts->value('products_sku'), 'quantity' => $QmultiSKUProducts->value('products_quantity'), 'weight' => $QmultiSKUProducts->value('products_weight'), 'weight_class_id' => $QmultiSKUProducts->valueInt('products_weight_class'), 'availability_shipping' => 1, 'status' => $QmultiSKUProducts->valueInt('products_status'));
             $Qvariants = $lC_Database->query('select pv.default_combo, pv.default_visual, pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.visual as visual, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id order by pvg.sort_order, pvg.title');
             $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
             $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
             $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
             $Qvariants->bindInt(':products_id', $QmultiSKUProducts->valueInt('products_id'));
             $Qvariants->bindInt(':languages_id', $lC_Language->getID());
             $Qvariants->bindInt(':languages_id', $lC_Language->getID());
             $Qvariants->execute();
             while ($Qvariants->next()) {
                 $variants_array[$QmultiSKUProducts->valueInt('products_id')]['values'][$Qvariants->valueInt('group_id')][$Qvariants->valueInt('value_id')] = array('value_id' => $Qvariants->valueInt('value_id'), 'group_title' => $Qvariants->value('group_title'), 'value_title' => $Qvariants->value('value_title'), 'sort_order' => $Qvariants->value('value_sort_order'), 'default' => (bool) $Qvariants->valueInt('default_combo'), 'default_visual' => $Qvariants->valueInt('default_visual'), 'module' => $Qvariants->value('module'), 'visual' => $Qvariants->value('visual'));
             }
         }
         $QmultiSKUProducts->freeResult();
     }
     $data['variants'] = $variants_array;
     $Qattributes = $lC_Database->query('select id, value, value2 from :table_product_attributes where products_id = :products_id and languages_id in (0, :languages_id)');
     $Qattributes->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
     $Qattributes->bindInt(':products_id', $id);
     $Qattributes->bindInt(':languages_id', $lC_Language->getID());
     $Qattributes->execute();
     $attributes_array = array();
     $data['attributes2'] = array();
     while ($Qattributes->next()) {
         // if the value is date, reformat for datepicker
         $value = substr($Qattributes->value('value'), 4, 1) == '-' ? lC_DateTime::getShort($Qattributes->value('value')) : $Qattributes->value('value');
         $attributes_array[$Qattributes->valueInt('id')] = $value;
         // check for value2
         if ($Qattributes->value('value2') != null) {
             $data['attributes2'][$Qattributes->valueInt('id')] = $Qattributes->value('value2');
         }
     }
     $data['attributes'] = $attributes_array;
     $Qattributes->freeResult();
     $Qimages = $lC_Database->query('select id, image, default_flag from :table_products_images where products_id = :products_id order by sort_order');
     $Qimages->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
     $Qimages->bindInt(':products_id', $id);
     $Qimages->execute();
     while ($Qimages->next()) {
         if ($Qimages->valueInt('default_flag') == '1') {
             $data['image'] = $Qimages->value('image');
         }
     }
     $Qimages->freeResult();
     // load subproducts
     $Qsubproducts = $lC_Database->query('select p.*, pd.* from :table_products p, :table_products_description pd where p.parent_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id');
     $Qsubproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qsubproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qsubproducts->bindInt(':products_id', $id);
     $Qsubproducts->bindInt(':language_id', $lC_Language->getID());
     $Qsubproducts->execute();
     $subproducts_array = array();
     while ($Qsubproducts->next()) {
         // subproduct images
         $Qimages = $lC_Database->query('select id, image, default_flag from :table_products_images where products_id = :sub_products_id order by sort_order');
         $Qimages->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
         $Qimages->bindInt(':sub_products_id', $Qsubproducts->valueInt('products_id'));
         $Qimages->execute();
         $subproducts_array[] = array_merge((array) $Qsubproducts->toArray(), array('image' => $Qimages->value('image')));
         $Qimages->freeResult();
     }
     $data['subproducts'] = $subproducts_array;
     if (sizeof($data['subproducts']) > 0) {
         $data['has_subproducts'] = 1;
     }
     $Qsubproducts->freeResult();
     // load simple options
     $Qoptions = $lC_Database->query('select so.options_id, so.products_id, so.sort_order, so.status, vg.title, vg.module from :table_products_simple_options so left join :table_products_variants_groups vg on (so.options_id = vg.id) where so.products_id = :products_id and vg.languages_id = :languages_id order by so.sort_order');
     $Qoptions->bindTable(':table_products_simple_options', TABLE_PRODUCTS_SIMPLE_OPTIONS);
     $Qoptions->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
     $Qoptions->bindInt(':products_id', $id);
     $Qoptions->bindInt(':languages_id', $lC_Language->getID());
     $Qoptions->execute();
     $cnt = 0;
     while ($Qoptions->next()) {
         $data['simple_options'][$cnt] = $Qoptions->toArray();
         $Qvalues = $lC_Database->query('select sov.products_id, sov.options_id, sov.values_id, sov.price_modifier, sov.customers_group_id, vv.title from :table_products_simple_options_values sov left join :table_products_variants_values vv on (sov.values_id = vv.id) where sov.options_id = :options_id and vv.languages_id = :languages_id order by sov.sort_order');
         $Qvalues->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES);
         $Qvalues->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
         $Qvalues->bindInt(':options_id', $Qoptions->valueInt('options_id'));
         $Qvalues->bindInt(':products_id', $id);
         $Qvalues->bindInt(':languages_id', $lC_Language->getID());
         $Qvalues->execute();
         while ($Qvalues->next()) {
             $data['simple_options'][$cnt]['values'][] = $Qvalues->toArray();
         }
         $Qvalues->freeResult();
         $cnt++;
     }
     $Qoptions->freeResult();
     if (DISPLAY_PRICE_WITH_TAX == 1 || $_SESSION['localization']['show_tax'] == 1) {
         $tax_data = lC_Tax_classes_Admin::getEntry($data['products_tax_class_id']);
         $data['products_price_with_tax'] = $data['products_price'] + $tax_data['tax_rate'] / 100 * $data['products_price'];
         //$data['products_cost_with_tax'] = $data['products_cost'] + ($tax_data['tax_rate']/100)*$data['products_cost'];
         $data['products_msrp_with_tax'] = $data['products_msrp'] + $tax_data['tax_rate'] / 100 * $data['products_msrp'];
     }
     return $data;
 }
Exemple #30
0
 /**
  * Display all banners based on banners_group.
  *
  * @access public
  * @return array
  */
 public function getAllByGroup($banners_group = null)
 {
     global $lC_Database;
     $Qbanner = $lC_Database->query('select * from :table_banners where banners_group = :banners_group and status = "1"');
     $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
     $Qbanner->bindValue(':banners_group', $banners_group);
     $Qbanner->execute();
     if ($Qbanner->numberOfRows() > 0) {
         while ($Qbanner->next()) {
             if (strtotime(lC_DateTime::getNow()) <= strtotime($Qbanner->value('expires_date'))) {
                 $banners[] = $Qbanner->toArray();
             }
         }
     }
     return $banners;
 }