Пример #1
0
 /**
  *
  */
 public function store($preventUpdate = false)
 {
     // Set date if none exist
     if ($preventUpdate != true) {
         $now = new JDate();
         $this->created = $now->toMySQL();
         $this->updated = $now->toMySQL();
     }
     return parent::store();
 }
Пример #2
0
 function savePayment()
 {
     $orderid = JRequest::getVar('orderid');
     $Itemid = JRequest::getVar('Itemid');
     $order = JTable::getInstance('OrdersTable', 'JTheFactory');
     if (!$order->load($orderid)) {
         $app = JFactory::getApplication();
         $app->redirect('index.php?option=' . APP_EXTENSION . '&Itemid=' . $Itemid, JText::_("FACTORY_ORDER_DOES_NOT_EXIST"));
         return;
     }
     $paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
     $date = new JDate();
     $paylog->date = $date->toMySQL();
     $paylog->amount = $order->order_total;
     $paylog->currency = $order->order_currency;
     $paylog->refnumber = JRequest::getVar('customer_note');
     $paylog->invoice = $orderid;
     $paylog->ipn_response = print_r($_REQUEST, true);
     $paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
     $paylog->status = 'manual_check';
     $paylog->userid = $order->userid;
     $paylog->orderid = $order->id;
     $paylog->payment_method = $this->name;
     $paylog->store();
     $order->paylogid = $paylog->id;
     $order->store();
 }
Пример #3
0
 function processIPN()
 {
     $model = JModel::getInstance('Gateways', 'JTheFactoryModel');
     $params = $model->loadGatewayParams($this->name);
     $test_mode = $params->get('test_mode', 0);
     $x_login = $params->get('x_login', '');
     $paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
     $date = new JDate();
     $paylog->date = $date->toMySQL();
     $paylog->amount = JRequest::getVar('x_amount');
     $paylog->currency = '';
     //JRequest::getVar('');
     $paylog->refnumber = JRequest::getVar('x_trans_id');
     $paylog->invoice = JRequest::getVar('x_invoice_num');
     $paylog->ipn_response = print_r($_REQUEST, true);
     $paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
     $paylog->status = 'error';
     $paylog->userid = null;
     $paylog->orderid = JRequest::getVar('x_invoice_num');
     $paylog->payment_method = $this->name;
     $receiver_email = JRequest::getVar('receiver_email');
     $payment_status = JRequest::getVar('x_2checked');
     if ($payment_status == 'Y') {
         $paylog->status = 'ok';
     } else {
         $paylog->status = 'error';
     }
     $paylog->store();
     return $paylog;
 }
Пример #4
0
 public function store()
 {
     $now = new JDate();
     // Always update the stream last updated time
     $this->updated = $now->toMySQL();
     return parent::store();
 }
Пример #5
0
 function getList(&$params)
 {
     global $mainframe;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $userId = (int) $user->get('id');
     $count = (int) $params->get('count', 5);
     $catid = trim($params->get('catid'));
     $secid = trim($params->get('secid'));
     $show_front = $params->get('show_front', 1);
     $aid = $user->get('aid', 0);
     $contentConfig =& JComponentHelper::getParams('com_content');
     $access = !$contentConfig->get('shownoauth');
     $nullDate = $db->getNullDate();
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     $where = 'a.state = 1' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
     // User Filter
     switch ($params->get('user_id')) {
         case 'by_me':
             $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
             break;
         case 'not_me':
             $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
             break;
     }
     // Ordering
     switch ($params->get('ordering')) {
         case 'm_dsc':
             $ordering = 'a.modified DESC, a.created DESC';
             break;
         case 'c_dsc':
         default:
             $ordering = 'a.created DESC';
             break;
     }
     if ($catid) {
         $ids = explode(',', $catid);
         JArrayHelper::toInteger($ids);
         $catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
     }
     if ($secid) {
         $ids = explode(',', $secid);
         JArrayHelper::toInteger($ids);
         $secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
     }
     // Content Items only
     $query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
     $db->setQuery($query, 0, $count);
     $rows = $db->loadObjectList();
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         $lists[$i]->text = htmlspecialchars($row->title);
         $i++;
     }
     return $lists;
 }
Пример #6
0
 function apply()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $applicant = JRequest::get('POST');
     jimport('joomla.utilities.date');
     $now = new JDate();
     if ($applicant['job_id'] != 0) {
         $unsol_id = $applicant['id'];
         $applicant['id'] = false;
         $applicant['request_date'] = $now->toMySQL();
         $record =& JTable::getInstance('Applicant', 'Table');
         if (!$record->save($applicant)) {
             // uh oh failed to save
             JError::raiseError('500', JTable::getError());
         }
         $unsol =& JTable::getInstance('Unsolicited', 'Table');
         if (!$unsol->delete($unsol_id)) {
             // uh oh failed to delete
             JError::raiseError('500', JTable::getError());
         }
         $this->extendApply($applicant);
     } else {
         $applicant['last_updated'] = $now->toMySQL();
         $unsol_record =& JTable::getInstance('Unsolicited', 'Table');
         if (!$unsol_record->save($applicant)) {
             // uh oh failed to save
             JError::raiseError('500', JTable::getError());
         }
         $this->extendApply($applicant);
     }
 }
Пример #7
0
 function __construct(&$_db)
 {
     parent::__construct('#__banner', 'bid', $_db);
     jimport('joomla.utilities.date');
     $now = new JDate();
     $this->set('date', $now->toMySQL());
 }
Пример #8
0
 function save($data)
 {
     $row =& JTable::getInstance('Articles', 'Table');
     $id = $data['id'];
     if (!$id) {
         jimport('joomla.utilities.date');
         $dateNow = new JDate();
         $dateMySql = $dateNow->toMySQL();
         $data['createdate'] = $dateMySql;
         $data['addedby'] = 'server';
         $data['author'] = 'Administrator';
     }
     if (!$row->bind($data)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$row->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     return true;
 }
Пример #9
0
 function save($data)
 {
     $row =& JTable::getInstance('codefile', 'Table');
     $id = $data['id'];
     if (!$id) {
         jimport('joomla.utilities.date');
         $dateNow = new JDate();
         $dateMySql = $dateNow->toMySQL();
         $data['creationdate'] = $dateMySql;
         $data['addedby'] = 'server';
     }
     if (!$row->bind($data)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$row->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
         return false;
     } else {
         if (!$id) {
             $row->load($row->{$id});
         }
         if ($_FILES['cfile']['size']) {
             $this->fileupdload($row->id);
         }
     }
     return true;
 }
Пример #10
0
 function &getData()
 {
     if (empty($this->_data)) {
         $query = ' SELECT * FROM #__fst_comments ' . '  WHERE id = ' . FSTJ3Helper::getEscaped($this->_db, $this->_id);
         $this->_db->setQuery($query);
         $this->_data = $this->_db->loadObject();
     }
     if (!$this->_data) {
         $this->_data = new stdClass();
         $this->_data->id = 0;
         $this->_data->ident = 5;
         //
         $this->_data->itemid = 0;
         $this->_data->body = null;
         $this->_data->email = null;
         $this->_data->name = null;
         $this->_data->website = null;
         $this->_data->published = 1;
         $current_date = new JDate();
         if (FSTJ3Helper::IsJ3()) {
             $mySQL_conform_date = $current_date->toSql();
         } else {
             $mySQL_conform_date = $current_date->toMySQL();
         }
         $this->_data->created = $mySQL_conform_date;
     }
     return $this->_data;
 }
Пример #11
0
 public function store($updateNulls = false)
 {
     $now = new JDate();
     if ($this->created == null) {
         $this->created = $now->toMySQL();
     }
     return parent::store($updateNulls);
 }
Пример #12
0
 public function store($updateNulls = false)
 {
     $now = new JDate();
     if ($this->created == null) {
         $this->created = $now->toMySQL();
     }
     $this->_generatePreview();
     $this->params = $this->_params->toString();
     return parent::store();
 }
Пример #13
0
 private function PurgeExpiredSessions()
 {
     //$app = JFactory::getApplication();
     //global $app;
     //$lifetime = $app->getCfg("lifetime");
     $lifetime = JFactory::$config->get("lifetime");
     $date = new JDate("-" . $lifetime . " minute");
     $sql = "DELETE FROM #__" . $GLOBALS["ext_name"] . "_sessions WHERE birth < '" . $date->toMySQL() . "';";
     $this->db->setQuery($sql);
     $this->db->query();
 }
 public function getList($params)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $aid = $user->get('aid', 0);
     $items = (int) $params->get('items', 0);
     $order = $params->get('order', 'o_asc');
     $noauth = !JComponentHelper::getParams('com_content')->get('shownoauth');
     if (!($catid = $params->get('catid', 0))) {
         return array();
     }
     $nullDate = $db->getNullDate();
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     // Ordering
     $direction = null;
     switch ($params->get('order')) {
         case 'random':
             $ordering = 'RAND()';
             break;
         case 'date':
             $ordering = 'a.created';
             break;
         case 'rdate':
             $ordering = 'a.created DESC';
             break;
         case 'alpha':
             $ordering = 'a.title';
             break;
         case 'ralpha':
             $ordering = 'a.title DESC';
             break;
         case 'hits':
             $ordering = 'a.hits';
             break;
         case 'rhits':
             $ordering = 'a.hits DESC';
             break;
         case 'ordering':
         default:
             $ordering = 'a.ordering';
             break;
     }
     $parts = explode(':', $catid);
     $section = array_shift($parts);
     $category = array_shift($parts);
     // Query to determine article count
     $query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.name) THEN CONCAT_WS(":", cc.id, cc.name) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE a.state = 1 ' . ($noauth ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ' AND (a.publish_up = "' . $nullDate . '" OR a.publish_up <= "' . $now . '" ) ' . ' AND (a.publish_down = "' . $nullDate . '" OR a.publish_down >= "' . $now . '" )' . ($category ? ' AND cc.id = ' . (int) $category : '') . ' AND cc.section = ' . (int) $section . ' AND cc.published = 1' . ' AND s.published = 1' . ' ORDER BY ' . $ordering . ' LIMIT 0,' . (int) $items;
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Пример #15
0
 function getList($params)
 {
     global $mainframe;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $option = JRequest::getCmd('option');
     $view = JRequest::getCmd('view');
     $temp = JRequest::getString('id');
     $temp = explode(':', $temp);
     $id = $temp[0];
     $showDate = $params->get('showDate', 0);
     $nullDate = $db->getNullDate();
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     $related = array();
     if ($option == 'com_content' && $view == 'article' && $id) {
         // select the meta keywords from the item
         $query = 'SELECT metakey' . ' FROM #__content' . ' WHERE id = ' . (int) $id;
         $db->setQuery($query);
         if ($metakey = trim($db->loadResult())) {
             // explode the meta keys on a comma
             $keys = explode(',', $metakey);
             $likes = array();
             // assemble any non-blank word(s)
             foreach ($keys as $key) {
                 $key = trim($key);
                 if ($key) {
                     $likes[] = $db->getEscaped($key);
                 }
             }
             if (count($likes)) {
                 // select other items based on the metakey field 'like' the keys found
                 $query = 'SELECT a.id, a.title, DATE_FORMAT(a.created, "%Y-%m-%d") AS created, a.sectionid, a.catid, cc.access AS cat_access, s.access AS sec_access, cc.published AS cat_state, s.published AS sec_state,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid' . ' LEFT JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE a.id != ' . (int) $id . ' AND a.state = 1' . ' AND a.access <= ' . (int) $user->get('aid', 0) . ' AND ( a.metakey LIKE "%' . implode('%" OR a.metakey LIKE "%', $likes) . '%" )' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
                 $db->setQuery($query);
                 $temp = $db->loadObjectList();
                 if (count($temp)) {
                     foreach ($temp as $row) {
                         if (($row->cat_state == 1 || $row->cat_state == '') && ($row->sec_state == 1 || $row->sec_state == '') && ($row->cat_access <= $user->get('aid', 0) || $row->cat_access == '') && ($row->sec_access <= $user->get('aid', 0) || $row->sec_access == '')) {
                             $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
                             $related[] = $row;
                         }
                     }
                 }
                 unset($temp);
             }
         }
     }
     return $related;
 }
Пример #16
0
 function loadChartData()
 {
     $db = $this->getDBO();
     $type = JRequest::getCmd('type');
     switch ($type) {
         case 'sales':
             jimport('joomla.utilities.date');
             $date = JFactory::getDate();
             $interval = JRequest::getInt('interval', '14');
             $today = $date->toFormat('%Y-%m-%d');
             $startDate = strtotime('-' . $interval . ' day', strtotime($today));
             $startDate = new JDate($startDate);
             $query = "SELECT COUNT(virtuemart_order_id) AS sales, DATE(created_on) as `date` FROM #__virtuemart_orders WHERE created_on > " . $db->Quote($startDate->toMySQL()) . " GROUP BY `date` ORDER BY `date`";
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             $data = array();
             foreach ($rows as $row) {
                 $data[$row->date] = (int) $row->sales;
             }
             $today = $date->toUnix();
             for ($time = $startDate->toUnix(); $time <= $today; $time += 86400) {
                 $date = date('Y', $time) . '-' . date('m', $time) . '-' . date('d', $time);
                 if (!array_key_exists($date, $data)) {
                     $data[$date] = 0;
                 }
             }
             ksort($data);
             $startYear = $startDate->toFormat('%Y');
             $startMonth = $startDate->toFormat('%m') - 1;
             $startDay = $startDate->toFormat('%d');
             $script = "\r\n                k2martSalesChartOptions.title.text = '" . JText::_('K2MART_TOTAL_SALES', true) . "';\r\n                k2martSalesChartOptions.subtitle.text = '* " . JText::_('K2MART_CLICK_AND_DRAG_IN_THE_PLOT_AREA_TO_ZOOM_IN', true) . "';\r\n                k2martSalesChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n                k2martSalesChartOptions.series[0].pointStart=Date.UTC(" . $startYear . ", " . $startMonth . ", " . $startDay . "); \r\n                k2martSalesChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n                ";
             break;
         case 'products':
             $limit = JRequest::getInt('limit', '20');
             $query = "SELECT product.product_sales, productData.product_name FROM #__virtuemart_products AS product \r\n                LEFT JOIN #__virtuemart_products_" . VMLANG . " AS productData ON product.virtuemart_product_id = productData.virtuemart_product_id\r\n                WHERE  product.product_sales > 0 ORDER BY product.product_sales DESC LIMIT 0, {$limit}";
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             $data = array();
             $categories = array();
             foreach ($rows as $row) {
                 $data[] = (int) $row->product_sales;
                 $categories[] = "'" . $row->product_name . "'";
             }
             $script = "\r\n                k2martProductsChartOptions.title.text = '" . JText::_('K2MART_TOP_SELLING_PRODUCTS', true) . "';\r\n                k2martProductsChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n                k2martProductsChartOptions.xAxis.categories =[" . implode(',', $categories) . "]; \r\n                k2martProductsChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n                ";
             break;
     }
     $script .= "k2martChartType = '{$type}';";
     echo $script;
 }
Пример #17
0
 function processIPN()
 {
     $model = JModel::getInstance('Gateways', 'JTheFactoryModel');
     $params = $model->loadGatewayParams($this->name);
     $paypal_address = $params->get('paypalemail', '');
     $paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
     $date = new JDate();
     $paylog->date = $date->toMySQL();
     $paylog->amount = JRequest::getVar('mc_gross');
     $paylog->currency = JRequest::getVar('mc_currency');
     $paylog->refnumber = JRequest::getVar('txn_id');
     $paylog->invoice = JRequest::getVar('invoice');
     $paylog->ipn_response = print_r($_REQUEST, true);
     $paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
     $paylog->status = 'error';
     $paylog->userid = null;
     $paylog->orderid = JRequest::getVar('invoice');
     $paylog->payment_method = $this->name;
     $receiver_email = JRequest::getVar('receiver_email');
     $payment_status = JRequest::getVar('payment_status');
     switch ($payment_status) {
         case "Completed":
         case "Processed":
             $paylog->status = 'ok';
             break;
         case "Failed":
         case "Denied":
         case "Canceled-Reversal":
         case "Canceled_Reversal":
         case "Expired":
         case "Voided":
         case "Reversed":
         case "Refunded":
             $paylog->status = 'error';
             break;
         default:
         case "In-Progress":
         case "Pending":
             $paylog->status = 'manual_check';
             break;
     }
     if (!$this->validate_ipn() || $receiver_email != $paypal_address) {
         $paylog->status = 'error';
     } elseif (!$params->get('auto_accept', 1)) {
         $paylog->status = 'manual_check';
     }
     $paylog->store();
     return $paylog;
 }
Пример #18
0
 function check()
 {
     // make published by default and get a new order no
     if (!$this->id) {
         if ($this->created == "") {
             $current_date = new JDate();
             if (FSSJ3Helper::IsJ3()) {
                 $mySQL_conform_date = $current_date->toSql();
             } else {
                 $mySQL_conform_date = $current_date->toMySQL();
             }
             $this->set('created', $mySQL_conform_date);
         }
     }
     return true;
 }
Пример #19
0
 function markAsSent($blogId)
 {
     $posts = EB::table('TwitterPosts');
     $posts->load($blogId);
     $date = new JDate();
     $now = $date->toMySQL();
     if (empty($posts->id)) {
         $posts->created = $now;
     }
     $posts->modified = $now;
     if ($posts->store()) {
         return true;
     } else {
         return false;
     }
 }
Пример #20
0
 function addVisitor($ip)
 {
     $data = array();
     $dateNow = new JDate();
     $data['ipaddress'] = $ip;
     $data['accesstime'] = $dateNow->toMySQL();
     $row =& JTable::getInstance('visitor', 'Table');
     if (!$row->bind($data)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     return true;
 }
Пример #21
0
 function saveuser($data)
 {
     $dateNow = new JDate();
     $data['registrationdate'] = $dateNow->toMySQL();
     $data['password'] = sha1($data['password']);
     $data['addedbyip'] = $_SERVER['REMOTE_ADDR'];
     $data['published'] = 0;
     $row =& JTable::getInstance('user', 'Table');
     if (!$row->bind($data)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     return true;
 }
Пример #22
0
 function update_null_dates($redirect = true)
 {
     global $mainframe;
     // Get all the attachment IDs
     $db =& JFactory::getDBO();
     $query = "SELECT * FROM #__attachments";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (count($rows) == 0) {
         return 0;
     }
     // Update the dates for all the attachments
     $numUpdated = 0;
     foreach ($rows as $row) {
         // Update the new create and update dates if they are null
         $updated = false;
         $create_date = $row->create_date;
         if (is_null($create_date) || $create_date == '') {
             jimport('joomla.utilities.date');
             $cdate = new JDate(filemtime($row->filename_sys), $mainframe->getCfg('offset'));
             $create_date = $cdate->toMySQL();
             $updated = true;
         }
         $mod_date = $row->modification_date;
         if (is_null($mod_date) || $mod_date == '') {
             jimport('joomla.utilities.date');
             $mdate = new JDate(filemtime($row->filename_sys), $mainframe->getCfg('offset'));
             $mod_date = $mdate->toMySQL();
             $updated = true;
         }
         // Update the record
         if ($updated) {
             $query = "UPDATE #__attachments set modification_date='{$mod_date}', create_date='{$create_date}' WHERE id='{$row->id}'";
             $db->setQuery($query);
             if (!$db->query()) {
                 echo "Error updating {$row->filename}: " . $db->stderr();
             }
             $numUpdated++;
         }
     }
     return $numUpdated;
 }
Пример #23
0
 function getList(&$params, &$access)
 {
     global $mainframe;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $aid = $user->get('aid', 0);
     $catid = (int) $params->get('catid', 0);
     $items = (int) $params->get('items', 0);
     $contentConfig =& JComponentHelper::getParams('com_content');
     $noauth = !$contentConfig->get('shownoauth');
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     $nullDate = $db->getNullDate();
     // query to determine article count
     $query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.name) THEN CONCAT_WS(":", cc.id, cc.name) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE a.state = 1 ' . ($noauth ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ' AND (a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' ) ' . ' AND (a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' AND cc.id = ' . (int) $catid . ' AND cc.section = s.id' . ' AND cc.published = 1' . ' AND s.published = 1' . ' ORDER BY a.ordering';
     $db->setQuery($query, 0, $items);
     $rows = $db->loadObjectList();
     return $rows;
 }
Пример #24
0
function saveCatg()
{
    require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php';
    $is_admin = array(7, 8);
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $userGroups = JAccess::getGroupsByUser($user->id, true);
    $post = JRequest::get('post');
    //$post['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
    $row = new DatsoCategories($db);
    if (!array_intersect($is_admin, $userGroups)) {
        $category = explode(',', $ad_category);
        $getfirst = array_shift($category);
        $db->setQuery('SELECT cid' . ' FROM #__datsogallery_catg' . ' WHERE user_id = ' . (int) $user->id . ' AND parent = ' . $ad_category);
        $result = $db->loadResult();
        $row->parent = $result ? $result : $ad_category;
        $row->ordering = $row->getNextOrder('parent = ' . $row->parent);
    } else {
        $row->ordering = $row->getNextOrder('parent = 0');
    }
    $row->user_id = $user->id;
    $row->approved = !$user_categories_approval || array_intersect($is_admin, $userGroups) ? 1 : 0;
    $row->published = 1;
    jimport('joomla.utilities.date');
    $dtz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
    $date = new JDate($row->date);
    $date->setTimezone($dtz);
    $row->date = $date->toMySQL(true);
    if (!$row->bind($post)) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->check()) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->store()) {
        JError::raiseError(500, $row->getError());
    }
    if ($ad_category_notify && !array_intersect($is_admin, $userGroups)) {
        categoryNotify($user->username, $post['name']);
    }
}
Пример #25
0
 function getList(&$params, &$access)
 {
     global $mainframe;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $aid = $user->get('aid', 0);
     $catid = (int) $params->get('catid', 0);
     $items = (int) $params->get('items', 0);
     $order = $params->get('order', 'o_asc');
     $contentConfig =& JComponentHelper::getParams('com_content');
     $noauth = !$contentConfig->get('shownoauth');
     $nullDate = $db->getNullDate();
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     // Ordering
     switch ($order) {
         case 'm_dsc':
             $ordering = 'a.modified DESC, a.created DESC';
             break;
         case 'h_dsc':
             $ordering = 'a.hits DESC, a.created DESC';
             break;
         case 'c_dsc':
             $ordering = 'a.created DESC';
             break;
         case 'o_asc':
         default:
             $ordering = 'a.ordering';
             break;
     }
     // Query to determine article count
     $query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.name) THEN CONCAT_WS(":", cc.id, cc.name) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE a.state = 1 ' . ($noauth ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ' AND (a.publish_up = "' . $nullDate . '" OR a.publish_up <= "' . $now . '" ) ' . ' AND (a.publish_down = "' . $nullDate . '" OR a.publish_down >= "' . $now . '" )' . ' AND cc.id = ' . $catid . ' AND cc.section = s.id' . ' AND cc.published = 1' . ' AND s.published = 1' . ' ORDER BY ' . $ordering;
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($order == 'rnd') {
         shuffle($rows);
     }
     return array_slice($rows, 0, $items);
 }
Пример #26
0
 function processIPN()
 {
     $model = JModel::getInstance('Gateways', 'JTheFactoryModel');
     $params = $model->loadGatewayParams($this->name);
     $paypal_address = $params->get('paypalemail', '');
     $paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
     $date = new JDate();
     $paylog->date = $date->toMySQL();
     $paylog->amount = JRequest::getVar('mb_amount');
     $paylog->currency = JRequest::getVar('mb_currency');
     $paylog->refnumber = JRequest::getVar('mb_transaction_id');
     $paylog->invoice = JRequest::getVar('transaction_id');
     $paylog->ipn_response = print_r($_REQUEST, true);
     $paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
     $paylog->status = 'error';
     $paylog->userid = null;
     $paylog->orderid = JRequest::getVar('mb_transaction_id');
     $paylog->payment_method = $this->name;
     $receiver_email = JRequest::getVar('pay_to_email');
     $payment_status = JRequest::getVar('status');
     switch ($payment_status) {
         case "2":
             $paylog->status = 'ok';
             break;
         case "-1":
         case "-2":
         case "-3":
             $paylog->status = 'error';
             break;
         default:
         case "0":
             $paylog->status = 'manual_check';
             break;
     }
     if ($receiver_email != $paypal_address) {
         $paylog->status = 'error';
     }
     $paylog->store();
     return $paylog;
 }
Пример #27
0
 /**
  * Retturn list of all event that start with the given month/year
  */
 public function getMonthEvent($month, $year)
 {
     $db = JFactory::getDbo();
     // Filter event up to 24 hours earlier
     $date = new JDate();
     $date->setOffset(-24);
     // Select pending event and uncompleted milestone
     $where = '(	(' . $db->nameQuote('type') . '=' . $db->Quote('event') . ' AND ' . $db->nameQuote('start_date') . '>' . $db->Quote($date->toMySQL()) . ')' . ' OR ' . '(' . $db->nameQuote('type') . '=' . $db->Quote('milestone') . ' AND ' . $db->nameQuote('status') . '=' . $db->Quote('0') . ')' . ')';
     $where = $db->nameQuote('start_date') . '>= DATE(' . $db->Quote($year . '-' . $month . '-1') . ') ';
     $where .= ' AND ' . $db->nameQuote('start_date') . '<= DATE_ADD( DATE(' . $db->Quote($year . '-' . $month . '-1') . ') , INTERVAL 1 MONTH ) ';
     $where2 = $db->nameQuote('end_date') . '>= DATE(' . $db->Quote($year . '-' . $month . '-1') . ') ';
     $where2 .= ' AND ' . $db->nameQuote('end_date') . '<= DATE_ADD( DATE(' . $db->Quote($year . '-' . $month . '-1') . ') , INTERVAL 1 MONTH ) ';
     $where2 .= ' AND ' . $db->nameQuote('type') . '=' . $db->Quote('todo');
     $my = JXFactory::getUser();
     $userGroups = $my->getParam('groups_member');
     $where = '( ' . $where . ') AND (' . $db->nameQuote('access') . "=" . $db->Quote(0);
     if (!empty($userGroups)) {
         $where .= ' OR ' . $db->nameQuote('group_id') . 'IN (' . $userGroups . ') )';
     } else {
         $where .= ')';
     }
     $where2 = '( ' . $where2 . ') AND (' . $db->nameQuote('access') . "=" . $db->Quote(0);
     if (!empty($userGroups)) {
         $where2 .= ' OR ' . $db->nameQuote('group_id') . 'IN (' . $userGroups . ') )';
     } else {
         $where2 .= ')';
     }
     $query = 'SELECT * FROM #__stream WHERE ' . $where . ' UNION SELECT * FROM #__stream WHERE ' . $where2 . ' ORDER BY ' . $db->nameQuote('start_date') . ' ASC';
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $rows = array();
     if (!empty($result)) {
         foreach ($result as $row) {
             $obj = JTable::getInstance('Stream', 'StreamTable');
             $obj->bind($row);
             $rows[] = $obj;
         }
     }
     return $rows;
 }
Пример #28
0
 /**
  * Method to get a hello
  * @return object with data
  */
 function &getData()
 {
     // Load the data
     if (empty($this->_data)) {
         $query = ' SELECT * FROM #__fussball_spiel ' . '  WHERE id = ' . $this->_id;
         $this->_db->setQuery($query);
         $this->_data = $this->_db->loadObject();
     }
     if (!$this->_data) {
         $now = new JDate();
         $this->_data = new stdClass();
         $this->_data->id = 0;
         $this->_data->idMannschaft1 = 0;
         $this->_data->idMannschaft2 = 0;
         $this->_data->tore1 = 0;
         $this->_data->tore2 = 0;
         $this->_data->datum = $now->toMySQL();
         $this->_data->spielbeschreibung = '';
         $this->_data->idSpiel_typ = 0;
     }
     return $this->_data;
 }
Пример #29
0
 /**
  * Onload, we try to load existing data, if any. If not, query from Google
  */
 public function load($address)
 {
     // lowercase the incoming address
     $address = JString::strtolower($address);
     $db =& JFactory::getDBO();
     $query = 'SELECT * FROM ' . $db->nameQuote('#__community_location_cache');
     $query .= ' WHERE ';
     $query .= $db->nameQuote('address') . '= ' . $db->quote($address);
     $query .= ' LIMIT 1';
     $db->setQuery($query);
     $obj = $db->loadObject();
     if ($obj) {
         $this->bind($obj);
     } else {
         CFactory::load('libraries', 'mapping');
         $data = CMapping::getAddressData($address);
         $this->address = $address;
         $this->latitude = COMMUNITY_LOCATION_NULL;
         $this->longitude = COMMUNITY_LOCATION_NULL;
         $this->data = '';
         $this->status = 'ZERO_RESULTS';
         if ($data != null) {
             require_once AZRUL_SYSTEM_PATH . DS . 'pc_includes' . DS . 'JSON.php';
             $json = new Services_JSON();
             $content = $json->encode($data);
             if ($data->status == 'OK') {
                 $this->latitude = $data->results[0]->geometry->location->lat;
                 $this->longitude = $data->results[0]->geometry->location->lng;
                 $this->data = $content;
                 $this->status = $data->status;
             }
         }
         $date = new JDate();
         $this->created = $date->toMySQL(true);
         $this->store();
     }
     return true;
 }
Пример #30
0
 public function addReply()
 {
     $msgId = JRequest::getVar('msgid', '', 'POST');
     $reply = JRequest::getVar('reply', '', 'POST');
     $attachment = JRequest::getVar('attachment', array(), 'POST', 'array');
     $my = JXFactory::getUser();
     $messagingModel = MessagingFactory::getModel('inbox');
     $message = $messagingModel->getMessage($msgId);
     if ($my->id == 0) {
         return;
     }
     $now = new JDate();
     $obj = new stdClass();
     $obj->id = null;
     $obj->from = $my->id;
     $obj->posted_on = $now->toMySQL();
     $obj->from_name = $my->name;
     $obj->subject = 'RE:' . $message->subject;
     $obj->body = $reply;
     $obj->attachment = implode(', ', $attachment);
     $messagingModel->sendReply($obj, $msgId);
     $deleteLink = JRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $obj->id);
     $authorLink = JRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id);
     $this->_addAttachments($obj->id);
     $attachments = $messagingModel->getAttachments($obj);
     $tmpl = new MessagingTemplate();
     $tmpl->set('user', JXFactory::getUser($obj->from));
     $tmpl->set('msg', $obj);
     $tmpl->set('removeLink', $deleteLink);
     $tmpl->set('authorLink', $authorLink);
     $tmpl->set('attachments', $attachments);
     $html = $tmpl->fetch('inbox.message');
     $data = array();
     $data['html'] = $html;
     header('Content-Type: text/json');
     echo json_encode($data);
     exit;
 }