Guest User

admin_class.php

a guest
Dec 30th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 37.68 KB | None | 0 0
  1. <?php
  2.   /**
  3.    * Digishop Class
  4.    *
  5.    * @package CMS Pro
  6.    * @author wojoscripts.com
  7.    * @copyright 2014
  8.    * @version $Id: class_admin.php, v4.00 2014-10-01 16:10:25 gewa Exp $
  9.    */
  10.  
  11.   if (!defined("_VALID_PHP"))
  12.       die('Direct access to this location is not allowed.');
  13.  
  14.   class Digishop
  15.   {
  16.      
  17.       const mTable = "mod_digishop";
  18.       const ctTable = "mod_digishop_categories";
  19.       const rTable = "mod_digishop_related_categories";
  20.       const trTable = "mod_digishop_transactions";
  21.       const xTable = "mod_digishop_cart";
  22.  
  23.       private $cattree = array();
  24.       private $catlist = array();
  25.      
  26.       const imagepath = "modules/digishop/dataimages/";
  27.      
  28.       private static $db;
  29.  
  30.  
  31.       /**
  32.        * Digishop::__construct()
  33.        *
  34.        * @return
  35.        */
  36.       function __construct($ctree = true, $item = false, $cat = false)
  37.       {
  38.           self::$db = Registry::get("Database");
  39.           $this->getConfig();
  40.          
  41.           $this->cattree = ($ctree) ? $this->getCatTree() : null;
  42.          
  43.           ($item) ? $this->renderSingleProduct() : null;
  44.           ($cat) ? $this->renderSingleCategory() : null;
  45.       }
  46.  
  47.          
  48.       /**
  49.        * Digishop::getConfig()
  50.        *
  51.        * @return
  52.        */
  53.       private function getConfig()
  54.       {
  55.  
  56.           $row = INI::read(MODPATH . 'digishop/config.ini');
  57.  
  58.           $this->filedir = base64_decode($row->ds_config->filedir);
  59.           $this->allow_free = $row->ds_config->allow_free;
  60.           $this->cols = $row->ds_config->cols;
  61.           $this->ipp = $row->ds_config->ipp;
  62.           $this->fpp = $row->ds_config->fpp;
  63.           $this->like = $row->ds_config->like;
  64.           $this->layout = $row->ds_config->layout;
  65.           $this->show_counter = $row->ds_config->show_counter;
  66.           $this->template = base64_decode($row->ds_config->template);
  67.  
  68.           return ($row) ? $row : 0;
  69.          
  70.  
  71.       }
  72.  
  73.       /**
  74.        * Digishop::getCatTree()
  75.        *
  76.        * @return
  77.        */
  78.       protected function getCatTree()
  79.       {
  80.           $query = self::$db->query("SELECT * FROM " . self::ctTable . " ORDER BY parent_id, sorting");
  81.          
  82.           while ($row = self::$db->fetch($query)) {
  83.               $this->cattree[$row->id] = array(
  84.                     'id' => $row->id,
  85.                     'name'.Lang::$lang => $row->{'name'.Lang::$lang},
  86.                     'parent_id' => $row->parent_id
  87.               );
  88.           }
  89.           return $this->cattree;
  90.       }
  91.  
  92.       /**
  93.        * Digishop::getCatList()
  94.        *
  95.        * @return
  96.        */
  97.       public function getCatList()
  98.       {
  99.  
  100.           $query = self::$db->query("SELECT *, (SELECT COUNT(p.id) FROM " . self::mTable . " p"
  101.           . "\n INNER JOIN " . self::rTable . " rc on p.id = rc.pid"
  102.           . "\n WHERE rc.cid = " . self::ctTable . ".id AND p.active = 1) as totalitems"
  103.           . "\n FROM " . self::ctTable
  104.           . "\n ORDER BY parent_id, sorting");
  105.          
  106.           $res = self::$db->numrows($query);
  107.           while ($row = self::$db->fetch($query)) {
  108.               $catlist[$row->id] = array(
  109.                     'id' => $row->id,
  110.                     'slug' => $row->slug,
  111.                     'name'.Lang::$lang => $row->{'name'.Lang::$lang},
  112.                     'parent_id' => $row->parent_id,
  113.                     'totalitems'=> $row->totalitems
  114.               );
  115.           }
  116.           return ($res) ? $catlist : null;
  117.       }
  118.  
  119.       /**
  120.        * Digishop::getCatCheckList()
  121.        *
  122.        * @param mixed $parent_id
  123.        * @param integer $level
  124.        * @param mixed $spacer
  125.        * @param bool $selected
  126.        * @return
  127.        */
  128.       public function getCatCheckList($parent_id, $level = 0, $spacer, $selected = false)
  129.       {
  130.          
  131.           if($this->cattree) {
  132.               $class = 'odd';
  133.  
  134.               if($selected) {
  135.                 $arr = explode(",",$selected);
  136.                 reset($arr);
  137.               }
  138.  
  139.               foreach ($this->cattree as $key => $row) {
  140.                   if($selected) {
  141.                     $sel =  (in_array($row['id'], $arr))  ? " checked=\"checked\"" : "";
  142.                     $hsel = (in_array($row['id'], $arr)) ? " sel" : "";
  143.                   } else {
  144.                       $sel = '';
  145.                       $hsel = '';
  146.                   }
  147.                   $class = ($class == 'even' ? 'odd' : 'even');
  148.                  
  149.                   if ($parent_id == $row['parent_id']) {
  150.                       print "<div class=\"" . $class . $hsel . "\"> <label class=\"checkbox\"><input type=\"checkbox\" name=\"cid[]\" class=\"checkbox\" value=\"" . $row['id'] . "\"".$sel." />";
  151.                       for ($i = 0; $i < $level; $i++)
  152.                           print $spacer;
  153.                          
  154.                       print "<i></i>".$row['name'.Lang::$lang] . "</label></div>\n";
  155.                       $level++;
  156.                       $this->getCatCheckList($key, $level, $spacer, $selected);
  157.                       $level--;
  158.                   }
  159.               }
  160.               unset($row);
  161.           }
  162.       }
  163.  
  164.       /**
  165.        * Digishop::fetchProductCategories()
  166.        *
  167.        * @return
  168.        */
  169.       public function fetchProductCategories()
  170.       {
  171.  
  172.           if ($result = self::$db->fetch_all("SELECT cid FROM " . self::rTable . " WHERE pid = ".Filter::$id)) {
  173.               $cids = array();
  174.               foreach ($result as $row) {
  175.                   $cids[] = $row->cid;
  176.               }
  177.               unset($row);
  178.               $cids = implode(",", $cids);
  179.           } else {
  180.               $cids = "";
  181.           }
  182.           return $cids;
  183.  
  184.       }
  185.  
  186.       /**
  187.        * Digishop::getSortCatList()
  188.        *
  189.        * @param integer $parent_id
  190.        * @return
  191.        */
  192.       public function getSortCatList($parent_id = 0)
  193.       {
  194.          
  195.           $submenu = false;
  196.           $class = ($parent_id == 0) ? "parent" : "child";
  197.  
  198.           foreach ($this->cattree as $key => $row) {
  199.               if ($row['parent_id'] == $parent_id) {
  200.                   if ($submenu === false) {
  201.                       $submenu = true;
  202.                      
  203.                       print "<ul class=\"sortMenu\">\n";
  204.                   }
  205.  
  206.                   print '<li class="dd-item" id="list_' . $row['id'] . '">'
  207.                   . '<div class="dd-handle"><a data-id="' . $row['id'] . '" data-name="' . $row['name' . Lang::$lang] . '"'
  208.                   . ' data-title="' . Lang::$word->_DELETE . '" data-option="deleteCategory" class="delete">'
  209.                   . '<i class="icon red remove sign"></i></a><i class="icon reorder"></i>'
  210.                   . '<a href="' . Core::url("modules", "catedit", $row['id']) . '" class="' . $class . '">' . $row['name' . Lang::$lang] . '</a></div>';
  211.                   $this->getSortCatList($key);
  212.                   print "</li>\n";
  213.  
  214.               }
  215.           }
  216.           unset($row);
  217.          
  218.           if ($submenu === true)
  219.               print "</ul>\n";
  220.       }
  221.      
  222.       /**
  223.        * Digishop::processConfig()
  224.        *
  225.        * @return
  226.        */
  227.       public function processConfig()
  228.       {
  229.    
  230.           Filter::checkPost('filedir', Lang::$word->_MOD_DS_FILEDIR);
  231.    
  232.           if (empty(Filter::$msgs)) {
  233.               $data = array('ds_config' => array(
  234.                       'cols' => intval($_POST['cols']),
  235.                       'ipp' => intval($_POST['ipp']),
  236.                       'fpp' => intval($_POST['fpp']),
  237.                       'like' => intval($_POST['like']),
  238.                       'show_counter' => intval($_POST['show_counter']),
  239.                       'filedir' => '"' . base64_encode($_POST['filedir']) . '"',
  240.                       'allow_free' => intval($_POST['allow_free']),
  241.                       'layout' => intval($_POST['layout']),
  242.                       'template' => '"' . base64_encode($_POST['template']) . '"')
  243.                       );
  244.    
  245.               if (INI::write(MODPATH . 'digishop/config.ini', $data)) {
  246.                   $json['type'] = 'success';
  247.                   $json['message'] = Filter::msgOk(Lang::$word->_MOD_DS_CGFUPDATED, false);
  248.                   Security::writeLog(Lang::$word->_MOD_DS_CGFUPDATED, "", "no", "module");
  249.               } else {
  250.                   $json['type'] = 'info';
  251.                   $json['message'] = Filter::msgAlert(Lang::$word->_PROCCESS_C_ERR . '{admin/modules/digishop/config.ini}', false);
  252.               }
  253.               print json_encode($json);
  254.    
  255.           } else {
  256.               $json['message'] = Filter::msgStatus();
  257.               print json_encode($json);
  258.           }
  259.       }
  260.      
  261.       /**
  262.        * Digishop::getProducts()
  263.        *
  264.        * @return
  265.        */
  266.       public function getProducts()
  267.       {
  268.    
  269.           if (Filter::$id) {
  270.               $where = "WHERE p.cid = " . Filter::$id;
  271.               $counter = countEntries(self::mTable, 'cid', Filter::$id);
  272.           } else {
  273.               $where = null;
  274.               $counter = countEntries(self::mTable);
  275.           }
  276.  
  277.           if (isset($_POST['fromdate_submit']) && $_POST['fromdate_submit'] <> "" || isset($from) && $from != '') {
  278.               $enddate = date("Y-m-d");
  279.               $fromdate = (empty($from)) ? $_POST['fromdate_submit'] : $from;
  280.               if (isset($_POST['enddate_submit']) && $_POST['enddate_submit'] <> "") {
  281.                   $enddate = $_POST['enddate_submit'];
  282.               }
  283.               $where = " WHERE p.created BETWEEN '" . trim($fromdate) . "' AND '" . trim($enddate) . " 23:59:59'";
  284.    
  285.               $q = "SELECT COUNT(*) FROM " . self::mTable . " WHERE created BETWEEN '" . trim($fromdate) . "' AND '" . trim($enddate) . " 23:59:59' LIMIT 1";
  286.               $record = Registry::get("Database")->query($q);
  287.               $total = Registry::get("Database")->fetchrow($record);
  288.               $counter = $total[0];
  289.           }
  290.          
  291.           $pager = Paginator::instance();
  292.           $pager->items_total = $counter;
  293.           $pager->default_ipp = Registry::get("Core")->perpage;
  294.           $pager->paginate();
  295.    
  296.           $sql = "SELECT p.*, c.id as cid, c.name" . Lang::$lang . " as catname,"
  297.           . "\n (SELECT COUNT(pid) FROM " . self::trTable . " WHERE pid = p.id) as sales"
  298.           . "\n FROM " . self::mTable . " as p"
  299.           . "\n LEFT JOIN " . self::ctTable . " as c ON c.id = p.cid"
  300.           . "\n $where"
  301.           . "\n ORDER BY p.created DESC" . $pager->limit;
  302.           $row = self::$db->fetch_all($sql);
  303.    
  304.           return ($row) ? $row : 0;
  305.       }
  306.  
  307.       /**
  308.        * Digishop::processProduct()
  309.        *
  310.        * @return
  311.        */
  312.       public function processProduct()
  313.       {
  314.    
  315.           Filter::checkPost('title' . Lang::$lang, Lang::$word->_MOD_DS_NAME);
  316.           Filter::checkPost('cid', Lang::$word->_MOD_DS_CATEGORY);
  317.           Filter::checkPost('price', Lang::$word->_MOD_DS_PRODPRICE);
  318.  
  319.           if (!Filter::$id) {
  320.               if (empty($_FILES['thumb']['name']))
  321.                   Filter::$msgs['thumb'] = Lang::$word->_MOD_DS_PRODIMG;
  322.  
  323.               if (empty($_FILES['filename']['name']))
  324.                   Filter::$msgs['filename'] = Lang::$word->_MOD_DS_PRODFILE;
  325.              
  326.                if (empty($_FILES['filename2']['name']))
  327.                   Filter::$msgs['filename2'] = Lang::$word->_MOD_DS_PRODFILE2;
  328.           }
  329.          
  330.           if (!empty($_FILES['filename']['name'])) {
  331.               if (!preg_match("/(\.zip|\.rar|\.pdf)$/i", $_FILES['filename']['name']))
  332.                   Filter::$msgs['filename'] = Lang::$word->_MOD_DS_PRODFILE_R;
  333.           }
  334.           if (!empty($_FILES['filename2']['name'])) {
  335.               if (!preg_match("/(\.zip|\.rar|\.pdf)$/i", $_FILES['filename2']['name']))
  336.                   Filter::$msgs['filename2'] = Lang::$word->_MOD_DS_PRODFILE2_R;
  337.           }
  338.           if (!empty($_FILES['thumb']['name'])) {
  339.               if (!preg_match("/(\.jpg|\.png)$/i", $_FILES['thumb']['name'])) {
  340.                   Filter::$msgs['thumb'] = Lang::$word->_CG_LOGO_R;
  341.               }
  342.               $file_info = getimagesize($_FILES['thumb']['tmp_name']);
  343.               if (empty($file_info))
  344.                   Filter::$msgs['thumb'] = Lang::$word->_CG_LOGO_R;
  345.           }
  346.    
  347.           if (empty(Filter::$msgs)) {
  348.               $data = array(
  349.                   'title' . Lang::$lang => sanitize($_POST['title' . Lang::$lang]),
  350.                   'slug' => (empty($_POST['slug'])) ? doSeo($_POST['title' . Lang::$lang]) : doSeo($_POST['slug']),
  351.                   'cid' => intval($_POST['cid'][0]),
  352.                   'price' => floatval($_POST['price']),
  353.                   'token' => md5(time()),
  354.                                   'token2' => md5(time()),
  355.  
  356.                   'active' => intval($_POST['active']),
  357.                   'gallery' => intval($_POST['module_data']),
  358.                   'metakey' . Lang::$lang => sanitize($_POST['metakey' . Lang::$lang]),
  359.                   'metadesc' . Lang::$lang => sanitize($_POST['metadesc' . Lang::$lang]),
  360.                   'body' . Lang::$lang => Filter::in_url($_POST['body' . Lang::$lang]),
  361.                   'active' => 1
  362.                   );
  363.    
  364.               if (empty($_POST['metakey' . Lang::$lang]) or empty($_POST['metadesc' . Lang::$lang])) {
  365.                   include (BASEPATH . 'lib/class_meta.php');
  366.                   parseMeta::instance($_POST['body' . Lang::$lang]);
  367.                   if (empty($_POST['metakey' . Lang::$lang])) {
  368.                       $data['metakey' . Lang::$lang] = parseMeta::get_keywords();
  369.                   }
  370.                   if (empty($_POST['metadesc'])) {
  371.                       $data['metadesc' . Lang::$lang] = parseMeta::metaText($_POST['body' . Lang::$lang]);
  372.                   }
  373.               }
  374.    
  375.               if (!Filter::$id) {
  376.                   $data['created'] = "NOW()";
  377.               }
  378.    
  379.               if (isset($_POST['membership_id'])) {
  380.                   $data['membership_id'] = Core::_implodeFields($_POST['membership_id']);
  381.               } else
  382.                   $data['membership_id'] = 0;
  383.    
  384.    
  385.               // Procces Image
  386.               if (!empty($_FILES['thumb']['name'])) {
  387.                   $filedir = BASEPATH . self::imagepath;
  388.                   $newName = "IMG_" . randName();
  389.                   $ext = substr($_FILES['thumb']['name'], strrpos($_FILES['thumb']['name'], '.') + 1);
  390.                   $fullname = $filedir . $newName . "." . strtolower($ext);
  391.    
  392.                   if (Filter::$id and $file = getValueById("thumb", self::mTable, Filter::$id)) {
  393.                       @unlink($filedir . $file);
  394.                   }
  395.    
  396.                   if (!move_uploaded_file($_FILES['thumb']['tmp_name'], $fullname)) {
  397.                       die(Filter::msgError(Lang::$word->_FILE_ERR, false));
  398.                   }
  399.                   $data['thumb'] = $newName . "." . strtolower($ext);
  400.               }
  401.    
  402.               // Procces File
  403.               if (!empty($_FILES['filename']['name'])) {
  404.                   $filedir = $this->filedir;
  405.                   $newName = "FILE_" . randName();
  406.                   $ext = substr($_FILES['filename']['name'], strrpos($_FILES['filename']['name'], '.') + 1);
  407.                   $fullname = $filedir . $newName . "." . strtolower($ext);
  408.    
  409.                   if (Filter::$id and $file = getValueById("filename", self::mTable, Filter::$id)) {
  410.                       @unlink($filedir . $file);
  411.                   }
  412.    
  413.                   if (!move_uploaded_file($_FILES['filename']['tmp_name'], $fullname)) {
  414.                       die(Filter::msgError(Lang::$word->_FILE_ERR, false));
  415.                   }
  416.                   $data['filename'] = $newName . "." . strtolower($ext);
  417.                   $data['filesize'] = filesize($fullname);
  418.               }
  419.               // Procces File2
  420.  
  421.                   if (!empty($_FILES['filename2']['name'])) {
  422.                   $filedir = $this->filedir;
  423.                   $newName = "FILE_" . randName();
  424.                   $ext = substr($_FILES['filename2']['name'], strrpos($_FILES['filename2']['name'], '.') + 1);
  425.                   $fullname2 = $filedir . $newName . "." . strtolower($ext);
  426.    
  427.                   if (Filter::$id and $file = getValueById("filename2", self::mTable, Filter::$id)) {
  428.                       @unlink($filedir . $file);
  429.                   }
  430.    
  431.                   if (!move_uploaded_file($_FILES['filename2']['tmp_name'], $fullname2)) {
  432.                       die(Filter::msgError(Lang::$word->_FILE_ERR, false));
  433.                   }
  434.                   $data['filename2'] = $newName . "." . strtolower($ext);
  435.                   $data['filesize2'] = filesize($fullname2);
  436.               }
  437.  
  438.               (Filter::$id) ? self::$db->update(self::mTable, $data, "id=" . Filter::$id) : $lastid = self::$db->insert(self::mTable, $data);
  439.              
  440.               if (Filter::$id) {
  441.                   // Process Categories
  442.                   if (isset($_POST['cid'])) {
  443.                       self::$db->delete(self::rTable, "pid = " . Filter::$id);
  444.                       foreach ($_POST['cid'] as $cid) {
  445.                           $cdata['pid'] = Filter::$id;
  446.                           $cdata['cid'] = intval($cid);
  447.                           self::$db->insert(self::rTable, $cdata);
  448.                       }
  449.                   }
  450.               } else {
  451.                   // Process Categories
  452.                   if (isset($_POST['cid'])) {
  453.                       foreach ($_POST['cid'] as $cid) {
  454.                           $cdata['pid'] = $lastid;
  455.                           $cdata['cid'] = intval($cid);
  456.                           self::$db->insert(self::rTable, $cdata);
  457.                       }
  458.                   }
  459.               }
  460.              
  461.               $message = (Filter::$id) ? Lang::$word->_MOD_DS_PRODUPDATED : Lang::$word->_MOD_DS_PRODADDED;
  462.    
  463.               if (self::$db->affected()) {
  464.                   Security::writeLog($message, "", "no", "module");
  465.                   $json['type'] = 'success';
  466.                   $json['message'] = Filter::msgOk($message, false);
  467.               } else {
  468.                   $json['type'] = 'success';
  469.                   $json['message'] = Filter::msgAlert(Lang::$word->_SYSTEM_PROCCESS, false);
  470.               }
  471.               print json_encode($json);
  472.    
  473.    
  474.           } else {
  475.               $json['message'] = Filter::msgStatus();
  476.               print json_encode($json);
  477.           }
  478.       }
  479.  
  480.       /**
  481.        * Digishop::renderSingleCategory()
  482.        *
  483.        * @return
  484.        */
  485.       private function renderSingleCategory()
  486.       {
  487.  
  488.           $sql = "SELECT * FROM " . self::ctTable . " WHERE slug = '" . Registry::get("Content")->_url[2] . "' AND active = 1";
  489.           $row = self::$db->first($sql);
  490.  
  491.           return ($row) ? Registry::get("Content")->moduledata->mod = $row : 0;
  492.  
  493.       }
  494.      
  495.       /**
  496.        * Digishop::renderSingleProduct()
  497.        *
  498.        * @return
  499.        */
  500.       public function renderSingleProduct()
  501.       {
  502.  
  503.           $sql = "SELECT * FROM " . self::mTable . " WHERE slug = '" . Registry::get("Content")->_url[1] . "' AND active = 1";
  504.           $row = self::$db->first($sql);
  505.  
  506.           return ($row) ? Registry::get("Content")->moduledata->mod = $row : 0;
  507.       }
  508.      
  509.  
  510.       /**
  511.        * Digishop::renderProducts()
  512.        *
  513.        * @return
  514.        */
  515.       public function renderProducts()
  516.       {
  517.    
  518.           $pager = Paginator::instance();
  519.           $pager->items_total = countEntries(self::mTable);
  520.           $pager->default_ipp = $this->fpp;
  521.           $pager->path = doUrl(false, false, "digishop", "?");
  522.           $pager->paginate();
  523.    
  524.           $sql = "SELECT p.*, c.id as cid, c.name" . Lang::$lang . " as catname, p.title" . Lang::$lang . " as ptitle"
  525.           . "\n FROM " . self::mTable . " as p"
  526.           . "\n LEFT JOIN " . self::ctTable . " as c ON c.id = p.cid"
  527.           . "\n WHERE p.active = 1"
  528.           . "\n AND c.active = 1"
  529.           . "\n ORDER BY p.created DESC" . $pager->limit;
  530.           $row = self::$db->fetch_all($sql);
  531.    
  532.           return ($row) ? $row : 0;
  533.       }
  534.  
  535.       /**
  536.        * Digishop::renderProductByCategory()
  537.        *
  538.        * @param mixed $cid
  539.        * @return
  540.        */
  541.       public function renderProductByCategory($cid, $slug)
  542.       {
  543.  
  544.           $q = "SELECT COUNT(p.id) FROM " . self::mTable . " p"
  545.           . "\n INNER JOIN " . self::rTable . " rc on p.id = rc.pid"
  546.           . "\n WHERE rc.cid = " . (int)$cid . " AND p.active = 1 LIMIT 1";
  547.           $record = self::$db->query($q);
  548.           $total = self::$db->fetchrow($record);
  549.           $counter = $total[0];
  550.    
  551.           $pager = Paginator::instance();
  552.           $pager->items_total = $counter;
  553.           $pager->default_ipp = $this->ipp;
  554.           $pager->path = doUrl(false, $slug, "digishop-cat", "?");
  555.           $pager->paginate();
  556.          
  557.           $sql = "SELECT p.*, p.title" . Lang::$lang . " as ptitle"
  558.           . "\n FROM " . self::mTable . " as p"
  559.           . "\n INNER JOIN " . self::rTable . " rc ON p.id = rc.pid"
  560.           . "\n LEFT JOIN " . self::ctTable . " as c ON c.id = rc.cid"
  561.           . "\n WHERE rc.cid = " . (int)$cid
  562.           . "\n AND p.active = 1"
  563.           . "\n AND c.active = 1"
  564.           . "\n ORDER BY p.created DESC" . $pager->limit;
  565.           $row = self::$db->fetch_all($sql);
  566.    
  567.           return ($row) ? $row : 0;
  568.       }
  569.  
  570.       /**
  571.        * Digishop::getLatestPluginDigishop()
  572.        *
  573.        * @return
  574.        */
  575.       public function getLatestPluginDigishop()
  576.       {
  577.    
  578.    
  579.           $sql = "SELECT p.*, c.id as cid, c.name" . Lang::$lang . " as catname, p.title" . Lang::$lang . " as ptitle"
  580.           . "\n FROM " . self::mTable . " as p"
  581.           . "\n LEFT JOIN " . self::ctTable . " as c ON c.id = p.cid"
  582.           . "\n WHERE p.active = 1"
  583.           . "\n AND c.active = 1"
  584.           . "\n ORDER BY p.created DESC LIMIT " . $this->fpp;
  585.           $row = self::$db->fetch_all($sql);
  586.    
  587.           return ($row) ? $row : 0;
  588.       }
  589.      
  590.       /**
  591.        * Digishop::getPriceMembershipData()
  592.        *
  593.        * @param mixed $id
  594.        * @param mixed $token
  595.        * @param mixed $price
  596.        * @param mixed $memid
  597.        * @return
  598.        */
  599.       public function getPriceMembershipData($id, $token, $price, $memid)
  600.       {
  601.  
  602.           $m_arr = explode(",", $memid);
  603.           reset($m_arr);
  604.          
  605.           if(Registry::get("Users")->logged_in and Registry::get("Users")->memvalid and in_array(Registry::get("Users")->membership_id, $m_arr)) {
  606.               print '<a href="' . SITEURL . '/modules/digishop/download.php?member=' . $token . '"
  607.               class="wojo warning labeled icon button" data-content="' . Lang::$word->_MOD_DS_MEMVALID . '"><i class="icon download disk"></i>' . Lang::$word->_MOD_DS_DOWNMEM . '</a>';
  608.                
  609.           } else
  610.               print '<a data-id="' . $id . '" class="wojo warning labeled icon button" data-content="' . Lang::$word->_MOD_DS_MEMREQ . '"><i class="icon user"></i>' . Lang::$word->_MOD_DS_MEMREQ . '</a>';
  611.       }
  612.        public function getPriceMembershipData2($id, $token2, $price, $memid)
  613.       {
  614.  
  615.           $m_arr = explode(",", $memid);
  616.           reset($m_arr);
  617.          
  618.           if(Registry::get("Users")->logged_in and Registry::get("Users")->memvalid and in_array(Registry::get("Users")->membership_id, $m_arr)) {
  619.               print '<a href="' . SITEURL . '/modules/digishop/download.php?member=' . $token2 . '"
  620.               class="wojo warning labeled icon button" data-content="' . Lang::$word->_MOD_DS_MEMVALID . '"><i class="icon download disk"></i>' . Lang::$word->_MOD_DS_DOWNMEM . '</a>';
  621.              
  622.           } else
  623.               print '';
  624.       }
  625.  
  626.  
  627.       /**
  628.        * Digishop::getPriceData()
  629.        *
  630.        * @param mixed $id
  631.        * @param mixed $token
  632.        * @param mixed $price
  633.        * @return
  634.        */
  635.       public function getPriceData($id, $token, $price)
  636.      
  637.         {
  638.           if($price == 0) {
  639.               switch ($this->allow_free) {
  640.                   case "1":
  641.                               print '<a data-id="' . $id . '" class="add wojo labeled icon button"><i class="icon cart"></i>' . Lang::$word->_MOD_DS_ADD_TO . '</a>';
  642.  
  643.                     print '<a href="' . SITEURL . '/modules/digishop/download.php?free=' . $token . '"
  644.                     class="wojo warning button"><i class="icon unlock"></i>' . Lang::$word->_MOD_DS_MSDS . '</a>';
  645.                    
  646.                   break;
  647.  
  648.                   case "0" and Registry::get("Digishop")->logged_in :
  649.                                               print '<a data-id="' . $id . '" class="add wojo labeled icon button"><i class="icon cart"></i>' . Lang::$word->_MOD_DS_ADD_TO . '</a>';
  650.  
  651.                     print '<a href="' . SITEURL . '/modules/digishop/download.php?free=' . $token . '"
  652.                     class="wojo warning button"><i class="icon unlock"></i>' . Lang::$word->_MOD_DS_TDS . '</a>';
  653.                    
  654.                   break;
  655.                  
  656.                   default:
  657.                   print Lang::$word->_MOD_DS_LOGIN_TO;
  658.                   break;
  659.               }
  660.           } else
  661.               print '';
  662.       }
  663.    
  664.     public function getPriceData2($id, $token2, $price)
  665.    
  666.       {
  667.          
  668.           if($price == 0) {
  669.               switch ($this->allow_free) {
  670.                   case "1":
  671.                               print '';
  672.  
  673.                  
  674.                     print '<a href="' . SITEURL . '/modules/digishop/download.php?free=' . $token2 . '"
  675.                     class="wojo warning button"><i class="icon unlock"></i>' . Lang::$word->_MOD_DS_MSDS . '</a>';
  676.                    
  677.                   break;
  678.  
  679.                   case "0" and Registry::get("Digishop")->logged_in :
  680.                                               print '';
  681.  
  682.            
  683.                     print '<a href="' . SITEURL . '/modules/digishop/download.php?free=' . $token2 . '"
  684.                     class="wojo warning button"><i class="icon unlock"></i>' . Lang::$word->_MOD_DS_TDS . '</a>';
  685.                   break;
  686.                  
  687.                   default:
  688.                   print Lang::$word->_MOD_DS_LOGIN_TO;
  689.                   break;
  690.               }
  691.           } else
  692.               print '';
  693.       }
  694.  
  695.       /**
  696.        * Digishop::layoutSwitchList()
  697.        *
  698.        * @return
  699.        */
  700.       public function layoutSwitchList()
  701.       {
  702.           $active = '';
  703.           if (isset($_COOKIE['DIGIVIEW_CMSPRO']) && $_COOKIE['DIGIVIEW_CMSPRO'] == 'list') {
  704.               $active = ' active';
  705.           } elseif($this->layout == 0 && !isset($_COOKIE['DIGIVIEW_CMSPRO'])) {
  706.               $active = ' active';
  707.           }
  708.          
  709.           return $active;
  710.       }
  711.  
  712.       /**
  713.        * Digishop::layoutSwitchGrid()
  714.        *
  715.        * @return
  716.        */
  717.       public function layoutSwitchGrid()
  718.       {
  719.           $active = '';
  720.           if (isset($_COOKIE['DIGIVIEW_CMSPRO']) && $_COOKIE['DIGIVIEW_CMSPRO'] == 'grid') {
  721.               $active = ' active';
  722.           } elseif($this->layout == 1 && !isset($_COOKIE['DIGIVIEW_CMSPRO'])) {
  723.               $active = ' active';
  724.           }
  725.          
  726.           return $active;
  727.       }
  728.                          
  729.       /**
  730.        * Digishop::getCategories()
  731.        *
  732.        * @return
  733.        */
  734.       public function getCategories($array, $parent_id = 0, $menuid = 'digicats', $class = 'digi-menu')
  735.       {
  736.          
  737.           if(is_array($array) && count($array) > 0) {
  738.               $submenu = false;
  739.               $attr = (!$parent_id) ? ' class="' . $class . '" id="' . $menuid . '"' : ' class="menu-submenu"';
  740.               $attr2 = (!$parent_id) ? ' class="nav-item"' : ' class="nav-submenu-item"';
  741.               $icon = (!$parent_id) ? '<i class="icon open folder"></i>' :null ;
  742.              
  743.    
  744.               foreach ($array as $key => $row) {
  745.                  
  746.                   if ($row['parent_id'] == $parent_id) {
  747.                       if ($submenu === false) {
  748.                           $submenu = true;
  749.                          
  750.                           print "<ul" . $attr . ">\n";
  751.                       }
  752.    
  753.                       $url = doUrl(false, $row['slug'], "digishop-cat");
  754.    
  755.                       $counter = ($this->show_counter) ? '<small>('.$row['totalitems'].')</small> ' : null;
  756.                       $active = (isset(Registry::get("Content")->_url[2]) and Registry::get("Content")->_url[2] == $row['slug']) ? " active" : "normal";
  757.                       $link = '<a href="' . $url . '" class="' . $active . '" title="' . $row['name'.Lang::$lang] . '">' . $icon . $row['name'.Lang::$lang] . $counter.'</a>';
  758.        
  759.                      
  760.                       print '<li>';
  761.                       print $link;
  762.                       $this->getCategories($array, $key);
  763.                       print "</li>\n";
  764.                   }
  765.               }
  766.               unset($row);
  767.              
  768.               if ($submenu === true)
  769.                   print "</ul>\n";
  770.           }
  771.       }
  772.  
  773.       /**
  774.        * Digishop::getCatDropList()
  775.        *
  776.        * @return
  777.        */
  778.       public function getCatDropList($parent_id, $level = 0, $spacer, $selected = false)
  779.       {
  780.          
  781.           foreach ($this->cattree as $key => $row) {
  782.               $sel = ($row['id'] == $selected) ? " selected=\"selected\"" : "" ;
  783.               if ($parent_id == $row['parent_id']) {
  784.                   print "<option value=\"" . $row['id'] . "\"".$sel.">";
  785.                  
  786.                   for ($i = 0; $i < $level; $i++)
  787.                       print $spacer;
  788.                  
  789.                   print $row['name'.Lang::$lang] . "</option>\n";
  790.                   $level++;
  791.                   $this->getCatDropList($key, $level, $spacer, $selected);
  792.                   $level--;
  793.               }
  794.           }
  795.           unset($row);
  796.       }
  797.      
  798.       /**
  799.        * Digishop::processCategory()
  800.        *
  801.        * @return
  802.        */
  803.       public function processCategory()
  804.       {
  805.    
  806.           Filter::checkPost('name' . Lang::$lang, Lang::$word->_MOD_DS_CATNAME);
  807.    
  808.           if (empty(Filter::$msgs)) {
  809.               $data = array(
  810.                   'name' . Lang::$lang => sanitize($_POST['name' . Lang::$lang]),
  811.                   'parent_id' => intval($_POST['parent_id']),
  812.                   'slug' => (empty($_POST['slug'])) ? doSeo($_POST['name' . Lang::$lang]) : doSeo($_POST['slug']),
  813.                   'metakey' . Lang::$lang => sanitize($_POST['metakey' . Lang::$lang]),
  814.                   'metadesc' . Lang::$lang => sanitize($_POST['metadesc' . Lang::$lang]),
  815.                   'active' => 1
  816.                   );
  817.    
  818.               (Filter::$id) ? self::$db->update(self::ctTable, $data, "id=" . Filter::$id) : self::$db->insert(self::ctTable, $data);
  819.               $message = (Filter::$id) ? Lang::$word->_MOD_DS_CATUPDATED : Lang::$word->_MOD_DS_CATADDED;
  820.    
  821.               if (self::$db->affected()) {
  822.                   Security::writeLog($message, "", "no", "module");
  823.                   $json['type'] = 'success';
  824.                   $json['message'] = Filter::msgOk($message, false);
  825.               } else {
  826.                   $json['type'] = 'success';
  827.                   $json['message'] = Filter::msgAlert(Lang::$word->_SYSTEM_PROCCESS, false);
  828.               }
  829.               print json_encode($json);
  830.    
  831.           } else {
  832.               $json['message'] = Filter::msgStatus();
  833.               print json_encode($json);
  834.           }
  835.       }
  836.      
  837.       /**
  838.        * Digishop::getCategoryList()
  839.        *
  840.        * @return
  841.        */
  842.       public function getCategoryList($active = false)
  843.       {
  844.           $where = ($active) ? "WHERE active = 1" : null;
  845.           $sql = "SELECT *, "
  846.           . "\n (SELECT COUNT(" . self::mTable . ".cid) FROM " . self::mTable . " WHERE " . self::mTable . ".cid = " . self::ctTable . ".id) as total"
  847.           . "\n FROM " . self::ctTable
  848.           . "\n $where"
  849.           . "\n ORDER BY sorting";
  850.           $row = self::$db->fetch_all($sql);
  851.    
  852.           return ($row) ? $row : 0;
  853.       }
  854.  
  855.       /**
  856.        * Digishop::getPayments()
  857.        *
  858.        * @param bool $from
  859.        * @return
  860.        */
  861.       public function getPayments($from = false)
  862.       {
  863.    
  864.           if (isset($_POST['fromdate_submit']) && $_POST['fromdate_submit'] <> "" || isset($from) && $from != '') {
  865.               $enddate = date("Y-m-d");
  866.               $fromdate = (empty($from)) ? $_POST['fromdate_submit'] : $from;
  867.               if (isset($_POST['enddate_submit']) && $_POST['enddate_submit'] <> "") {
  868.                   $enddate = $_POST['enddate_submit'];
  869.               }
  870.               $q = "SELECT COUNT(*) FROM " . self::trTable . " WHERE created BETWEEN '" . trim($fromdate) . "' AND '" . trim($enddate) . " 23:59:59'";
  871.               $where = " WHERE t.created BETWEEN '" . trim($fromdate) . "' AND '" . trim($enddate) . " 23:59:59'";
  872.           } else {
  873.               $q = "SELECT COUNT(*) FROM " . self::trTable . " LIMIT 1";
  874.               $where = null;
  875.           }
  876.    
  877.           $record = self::$db->query($q);
  878.           $total = self::$db->fetchrow($record);
  879.           $counter = $total[0];
  880.    
  881.           $pager = Paginator::instance();
  882.           $pager->items_total = $counter;
  883.           $pager->default_ipp = Registry::get("Core")->perpage;
  884.           $pager->paginate();
  885.    
  886.           $sql = "SELECT t.*, t.id as id, u.id as uid, u.username, p.id as did, p.title" . Lang::$lang
  887.           . "\n FROM " . self::trTable . " as t"
  888.           . "\n LEFT JOIN " . Users::uTable . " as u ON u.id = t.uid"
  889.           . "\n LEFT JOIN " . self::mTable . " as p ON p.id = t.pid"
  890.           . "\n " . $where
  891.           . "\n ORDER BY t.created DESC" . $pager->limit;
  892.    
  893.           $row = self::$db->fetch_all($sql);
  894.    
  895.           return ($row) ? $row : 0;
  896.       }
  897.  
  898.       /**
  899.        * Digishop::activateTransaction()
  900.        *
  901.        * @return
  902.        */
  903.       public function activateTransaction()
  904.       {
  905.    
  906.           $row = self::$db->first("SELECT t.*, t.id as id, p.title" . Lang::$lang . " as atitle, u.email, CONCAT(u.fname,' ',u.lname) as name"
  907.           . "\n FROM " . self::trTable . " as t"
  908.           . "\n LEFT JOIN " . Users::uTable . " as u ON u.id = t.uid"
  909.           . "\n LEFT JOIN " . self::mTable . " as p ON p.id = t.pid"
  910.           . "\n WHERE t.id = " . Filter::$id);
  911.    
  912.           if ($row) {
  913.               require_once (BASEPATH . "lib/class_mailer.php");
  914.               $mailer = Mailer::sendMail();
  915.    
  916.               $items = '
  917.                 <table width="100%" border="0" cellpadding="4" cellspacing="2">
  918.                   <thead>
  919.                     <tr>
  920.                       <td width="20"><strong>#</strong></td>
  921.                       <td><strong>' . Lang::$word->_MOD_DS_NAME . '</strong></td>
  922.                       <td><strong>' . Lang::$word->_MOD_DS_PRODPRICE . '</strong></td>
  923.                       <td><strong>' . Lang::$word->_MOD_DS_QTY . '</strong></td>
  924.                       <td><strong>' . Lang::$word->_MOD_DS_TOTPRICE . '</strong></td>
  925.                     </tr>
  926.                   </thead>
  927.                   <tbody>
  928.                       <tr>
  929.                         <td style="border-bottom-width:1px; border-bottom-color:#bbb; border-bottom-style:dashed">' . $row->id . '.</td>
  930.                         <td style="border-bottom-width:1px; border-bottom-color:#bbb; border-bottom-style:dashed">' . sanitize($row->atitle, 30) . '</td>
  931.                         <td style="border-bottom-width:1px; border-bottom-color:#bbb; border-bottom-style:dashed">' . Registry::get("Core")->formatMoney($row->price) . '</td>
  932.                         <td align="center" style="border-bottom-width:1px; border-bottom-color:#bbb; border-bottom-style:dashed">' . $row->item_qty . '</td>
  933.                         <td align="right" style="border-bottom-width:1px; border-bottom-color:#bbb; border-bottom-style:dashed">' . Registry::get("Core")->formatMoney($row->item_qty * $row->price) . '</td>
  934.                       </tr>
  935.                   <tr>
  936.                     <td colspan="4" align="right" valign="top"><strong style="color:#F00">' . Lang::$word->_MOD_DS_GTOTAL . ':</strong></td>
  937.                     <td align="right" valign="top"><strong style="color:#F00">' . Registry::get("Core")->formatMoney($row->item_qty * $row->price) . '</strong></td>
  938.                   </tr>
  939.                     </tbody>
  940.                 </table>';
  941.               $body = str_replace(array(
  942.                   '[NAME]',
  943.                   '[ITEMS]',
  944.                   '[DASH]',
  945.                   '[SITE_NAME]',
  946.                   '[URL]'), array(
  947.                   $row->name,
  948.                   $items,
  949.                   doUrl(false, Registry::get("Core")->account_page, "page"),
  950.                   Registry::get("Core")->site_name,
  951.                   SITEURL), $this->template);
  952.    
  953.               $message = Swift_Message::newInstance()
  954.                         ->setSubject(Lang::$word->_MOD_DS_R_SUBJECT . Registry::get("Core")->site_name)
  955.                         ->setTo(array($row->email => $row->name))
  956.                         ->setFrom(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))
  957.                         ->setBody(cleanOut($body), 'text/html');
  958.    
  959.               if ($mailer->send($message)):
  960.                   $data = array(
  961.                       'status' => 1,
  962.                       'active' => 1,
  963.                       );
  964.                   self::$db->update(self::trTable, $data, "id = " . Filter::$id);
  965.                   $json['type'] = 'success';
  966.                   $json['title'] = Lang::$word->_SUCCESS;
  967.                   $json['message'] = Lang::$word->_MOD_DS_RSENT;
  968.    
  969.               else:
  970.                   $json['type'] = 'error';
  971.                   $json['title'] = Lang::$word->_ERROR;
  972.                   $json['message'] = Lang::$word->_MOD_DS_RSENT_ERR;
  973.               endif;
  974.                   print json_encode($json);
  975.    
  976.            }
  977.       }
  978.  
  979.       /**
  980.        * Digishop::getUserTransactions()
  981.        *
  982.        * @param bool $sesid
  983.        * @return
  984.        */
  985.       public function getUserTransactions()
  986.       {
  987.    
  988.           $sql = "SELECT t.*, p.id as pid, p.title" . Lang::$lang . " as ptitle, p.price, p.thumb, p.slug"
  989.           . "\n FROM " . self::trTable . " as t"
  990.           . "\n LEFT JOIN " . self::mTable . " as p ON p.id = t.pid"
  991.           . "\n WHERE t.uid = " . Registry::get("Users")->uid
  992.           . "\n AND t.status = 1"
  993.           . "\n AND t.active = 1"
  994.           . "\n AND p.active = 1"
  995.           . "\n GROUP BY t.pid ORDER BY t.created DESC";
  996.          
  997.           $row = self::$db->fetch_all($sql);
  998.    
  999.           return ($row) ? $row : 0;
  1000.       }
  1001.      
  1002.       /**
  1003.        * Digishop::getCartContent()
  1004.        *
  1005.        * @param bool $sesid
  1006.        * @return
  1007.        */
  1008.       public function getCartContent($sesid = false)
  1009.       {
  1010.    
  1011.           $uid = ($sesid) ? $sesid : Registry::get("Users")->sesid;
  1012.    
  1013.           $sql = "SELECT c.*, p.id as pid, p.title" . Lang::$lang . " as ptitle, p.price, p.thumb, p.slug, COUNT(c.pid) as total"
  1014.           . "\n FROM " . self::xTable . " as c"
  1015.           . "\n LEFT JOIN " . self::mTable . " as p ON p.id = c.pid"
  1016.           . "\n WHERE c.user_id = '" . self::$db->escape($uid) . "'"
  1017.           . "\n GROUP BY c.pid ORDER BY c.pid DESC";
  1018.          
  1019.           $row = self::$db->fetch_all($sql);
  1020.    
  1021.           return ($row) ? $row : 0;
  1022.       }
  1023.  
  1024.       /**
  1025.        * Digishop::getCartTotal()
  1026.        *
  1027.        * @param bool $sesid
  1028.        * @return
  1029.        */
  1030.       public function getCartTotal($sesid = false)
  1031.       {
  1032.    
  1033.           $uid = ($sesid) ? $sesid : Registry::get("Users")->sesid;
  1034.    
  1035.           $sql = "SELECT SUM(c.price) as total, COUNT(c.pid) as titems"
  1036.           . "\n FROM " . self::xTable . " as c"
  1037.           . "\n WHERE c.user_id = '" . self::$db->escape($uid) . "'"
  1038.           . "\n GROUP BY c.user_id";
  1039.    
  1040.           $row = self::$db->first($sql);
  1041.    
  1042.           return ($row) ? $row : 0;
  1043.       }
  1044.  
  1045.       /**
  1046.        * Digishop::getFreeDownload()
  1047.        *
  1048.        * @param mixed $token
  1049.        * @return
  1050.        */
  1051.       public function getFreeDownload($token)
  1052.       {
  1053.          
  1054.           $id = sanitize($token);
  1055.           $id = self::$db->escape($token);
  1056.          
  1057.           $sql = "SELECT * FROM " . self::mTable
  1058.           . "\n WHERE token = '" .$id . "' AND active = 1 AND price = 0";
  1059.           $row = self::$db->first($sql);
  1060.          
  1061.           return ($row) ? $row : 0;
  1062.       }
  1063.  public function getFreeDownload2($token2)
  1064.       {
  1065.          
  1066.           $id = sanitize($token2);
  1067.           $id = self::$db->escape($token2);
  1068.          
  1069.           $sql = "SELECT * FROM " . self::mTable
  1070.           . "\n WHERE token2 = '" .$id . "' AND active = 1 AND price = 0";
  1071.           $row = self::$db->first($sql);
  1072.          
  1073.           return ($row) ? $row : 0;
  1074.       }
  1075.       /**
  1076.        * Digishop::getMembershipDownload()
  1077.        *
  1078.        * @param mixed $token
  1079.        * @return
  1080.        */
  1081.       public function getMembershipDownload($token)
  1082.       {
  1083.          
  1084.           $id = sanitize($token);
  1085.           $id = self::$db->escape($token);
  1086.          
  1087.           $sql = "SELECT * FROM " . self::mTable
  1088.           . "\n WHERE token = '" .$id . "' AND active = 1 AND membership_id <> 0";
  1089.           $row = self::$db->first($sql);
  1090.          
  1091.           return ($row) ? $row : 0;
  1092.       }
  1093.      public function getMembershipDownload2($token2)
  1094.       {
  1095.          
  1096.           $id = sanitize($token2);
  1097.           $id = self::$db->escape($token2);
  1098.          
  1099.           $sql = "SELECT * FROM " . self::mTable
  1100.           . "\n WHERE token2 = '" .$id . "' AND active = 1 AND membership_id <> 0";
  1101.           $row = self::$db->first($sql);
  1102.          
  1103.           return ($row) ? $row : 0;
  1104.       }
  1105.  
  1106.       /**
  1107.        * Digishop::getPaidDownload()
  1108.        *
  1109.        * @param mixed $token
  1110.        * @return
  1111.        */
  1112.       public function getPaidDownload($token)
  1113.       {
  1114.    
  1115.           $id = sanitize($token);
  1116.           $id = self::$db->escape($token);
  1117.    
  1118.           $row = self::$db->first("SELECT t.*, p.filename"
  1119.           . " \n FROM " . self::trTable . " as t"
  1120.           . " \n LEFT JOIN " . self::mTable . " as p ON t.pid = p.id"
  1121.           . " \n WHERE t.token = '" . self::$db->escape($id) . "'"
  1122.           . " \n AND t.uid = " . Registry::get("Users")->uid
  1123.           . " \n AND t.status = 1 AND t.active = 1"
  1124.           . " \n AND p.active = 1");
  1125.    
  1126.           return ($row) ? $row : 0;
  1127.       }
  1128.  
  1129.       public function getPaidDownload2($token2)
  1130.       {
  1131.    
  1132.           $id = sanitize($token2);
  1133.           $id = self::$db->escape($token2);
  1134.    
  1135.           $row = self::$db->first("SELECT t.*, p.filename2"
  1136.           . " \n FROM " . self::trTable . " as t"
  1137.           . " \n LEFT JOIN " . self::mTable . " as p ON t.pid = p.id"
  1138.           . " \n WHERE t.token2 = '" . self::$db->escape($id) . "'"
  1139.           . " \n AND t.uid = " . Registry::get("Users")->uid
  1140.           . " \n AND t.status = 1 AND t.active = 1"
  1141.           . " \n AND p.active = 1");
  1142.    
  1143.           return ($row) ? $row : 0;
  1144.       }
  1145.              
  1146.                                  
  1147.       /**
  1148.        * Digishop::verifyTxnId()
  1149.        *
  1150.        * @param mixed $txn_id
  1151.        * @return
  1152.        */
  1153.       public static function verifyTxnId($txn_id)
  1154.       {
  1155.          
  1156.           $sql = self::$db->query("SELECT id"
  1157.                 . "\n FROM ".self::trTable.""
  1158.                 . "\n WHERE txn_id = '" . sanitize($txn_id) . "'"
  1159.                 . "\n LIMIT 1");
  1160.                
  1161.           if (self::$db->numrows($sql) > 0)
  1162.               return false;
  1163.           else
  1164.               return true;
  1165.       }
  1166.  
  1167.       /**
  1168.        * Digishop::downloadErrors()
  1169.        *
  1170.        * @return
  1171.        */
  1172.       public static function downloadErrors()
  1173.       {
  1174.           print '<div id="showerror" style="display:none"> ';
  1175.           switch($_GET['msg']) {
  1176.               case 1 :
  1177.                 print '<p class="wojo warning message"><i class="icon attention"></i> ' . Lang::$word->_MOD_DS_MSG1 . '</p>';
  1178.               break;
  1179.              
  1180.               case 2 :
  1181.                 print '<p class="wojo warning message"><i class="icon attention"></i> ' . Lang::$word->_MOD_DS_MSG2 . '</p>';
  1182.               break;
  1183.              
  1184.               case 3 :
  1185.                 print '<p class="wojo warning message"><i class="icon attention"></i> ' . Lang::$word->_MOD_DS_MSG3 . '</p>';
  1186.               break;
  1187.              
  1188.               case 4 :
  1189.                 print '<p class="wojo warning message"><i class="icon attention"></i> ' . Lang::$word->_MOD_DS_MSG4 . '</p>';
  1190.               break;
  1191.              
  1192.               case 5 :
  1193.                 print '<p class="wojo error message"><i class="icon attention"></i>' . str_replace("[IP]", $_SERVER['REMOTE_ADDR'], Lang::$word->_MOD_DS_MSG5) . '</p>';
  1194.               break;
  1195.           }
  1196.           print '</div>';
  1197.       }
  1198.   }
  1199. ?>
Advertisement
Add Comment
Please, Sign In to add comment