/**
  * Inserts tag links into an HTML-formatted text.
  *
  * @param string $html
  * @param array $tags
  * @param array $options
  * @return string
  */
 public static function autoTag($html, array $tags, array &$options = array())
 {
     if (empty($tags)) {
         return $html;
     }
     $html = strval($html);
     $htmlNullified = utf8_strtolower($html);
     $htmlNullified = preg_replace_callback('#<a[^>]+>.+?</a>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     $htmlNullified = preg_replace_callback('#<[^>]+>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     // prepare the options
     $onceOnly = empty($options['onceOnly']) ? false : true;
     $options['autoTagged'] = array();
     // reset this
     // sort tags with the longest one first
     // since 1.0.3
     usort($tags, array(__CLASS__, '_autoTag_sortTagsByLength'));
     foreach ($tags as $tag) {
         $offset = 0;
         $tagText = utf8_strtolower($tag['tag']);
         $tagLength = utf8_strlen($tagText);
         while (true) {
             $pos = utf8_strpos($htmlNullified, $tagText, $offset);
             if ($pos !== false) {
                 // the tag has been found
                 if (self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) {
                     // and it has good surrounding characters
                     // start replacing
                     $displayText = utf8_substr($html, $pos, $tagLength);
                     $template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag');
                     $template->setParam('tag', $tag);
                     $template->setParam('displayText', $displayText);
                     $replacement = $template->render();
                     if (strlen($replacement) === 0) {
                         // in case template system hasn't been initialized
                         $replacement = sprintf('<a href="%s">%s</a>', XenForo_Link::buildPublicLink('tags', $tag), $displayText);
                     }
                     $html = utf8_substr_replace($html, $replacement, $pos, $tagLength);
                     $htmlNullified = utf8_substr_replace($htmlNullified, str_repeat('_', utf8_strlen($replacement)), $pos, $tagLength);
                     // sondh@2012-09-20
                     // keep track of the auto tagged tags
                     $options['autoTagged'][$tagText][$pos] = $replacement;
                     $offset = $pos + utf8_strlen($replacement);
                     if ($onceOnly) {
                         // auto link only once per tag
                         // break the loop now
                         break;
                         // while (true)
                     }
                 } else {
                     $offset = $pos + $tagLength;
                 }
             } else {
                 // no match has been found, stop working with this tag
                 break;
                 // while (true)
             }
         }
     }
     return $html;
 }
Example #2
0
 private static function standardise($langtag)
 {
     $glue = ',';
     $result = is_array($langtag) ? implode($glue, $langtag) : $langtag;
     $result = utf8_strtolower(str_replace('_', '-', $result));
     return is_array($langtag) ? explode($glue, $result) : $result;
 }
Example #3
0
 private function buildFilterString($data = array())
 {
     $filter = "o.customer_id = " . $this->customer->getId();
     if (isset($data['selected_items']) && count($data['selected_items'])) {
         $filter = "op.order_product_id in (" . implode($data['selected_items'], ',') . ")";
     } else {
         if (!empty($data['filter_supplier'])) {
             $filter .= ($filter ? " AND" : "") . " LCASE(s.name) LIKE '" . $this->getDb()->escape(utf8_strtolower($data['filter_supplier'])) . "%'";
         }
         if (!empty($data['filter_supplier_group'])) {
             $filter .= ($filter ? " AND" : "") . " s.supplier_group_id = " . (int) $data['filter_supplier_group'];
         }
         if (!empty($data['filterItem'])) {
             $filter .= " AND (\r\n                    op.model LIKE '%" . $this->getDb()->escape($data['filterItem']) . "%'\r\n                    OR op.name LIKE '%" . $this->getDb()->escape($data['filterItem']) . "%')";
         }
         if (!empty($data['filterOrderId'])) {
             $filter .= " AND op.order_id = " . (int) $data['filterOrderId'];
         }
         if (!empty($data['filterOrderItemId'])) {
             $filter .= ($filter ? " AND" : "") . " op.order_product_id = " . (int) $data['filterOrderItemId'];
         }
         if (!empty($data['filterProductId'])) {
             $filter .= ($filter ? " AND" : "") . " op.product_id = " . (int) $data['filterProductId'];
         }
         if (!empty($data['filterStatusId'])) {
             $filter .= ($filter ? " AND" : "") . " op.status_id IN (" . implode(', ', $data['filterStatusId']) . ")";
         }
     }
     return $filter;
 }
Example #4
0
 public function generateHtmlRecurrence($days, $amount, $currency, $comment, array $data, XenForo_View $view)
 {
     $data[] = utf8_strtolower($currency);
     $data[] = $amount;
     $processorModel = $this->_getProcessorModel();
     $itemId = $processorModel->generateItemId('bdshop', XenForo_Visitor::getInstance(), $data);
     $processorNames = $processorModel->getProcessorNames();
     $processors = array();
     foreach ($processorNames as $processorId => $processorClass) {
         $processors[$processorId] = bdPaygate_Processor_Abstract::create($processorClass);
     }
     $recurringInterval = false;
     $recurringUnit = false;
     if ($days > 0) {
         if ($days % 360 == 0) {
             $recurringInterval = $days / 365;
             $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_YEAR;
         } elseif ($days % 30 == 0) {
             $recurringInterval = $days / 30;
             $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_MONTH;
         } else {
             $recurringInterval = $days;
             $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_DAY;
         }
     }
     return implode('', bdPaygate_Processor_Abstract::prepareForms($processors, $amount, $currency, $comment, $itemId, $recurringInterval, $recurringUnit, array(bdPaygate_Processor_Abstract::EXTRA_RETURN_URL => XenForo_Link::buildPublicLink('full:shop/thanks'))));
 }
 public function insert_field($data = array())
 {
     $name = preg_replace("/[^a-zA-Z0-9_]/", "", utf8_strtolower(isset($data['lang']) ? $data['lang'] : $this->in->get('language')));
     if (!$name || !strlen($name)) {
         $data['name'] = (isset($data['fieldtype']) ? $data['fieldtype'] : $this->in->get('type')) . '_' . rand();
     }
     //End if a field with this name exists
     $fields = $this->pdh->get('profile_fields', 'fields');
     if ($fields[$name]) {
         return false;
     }
     $options = array();
     if ($this->in->get('type') == 'dropdown') {
         $in_options_id = $this->in->getArray('option_id', 'string');
         $in_options_lang = $this->in->getArray('option_lang', 'string');
         foreach ($in_options_id as $key => $value) {
             if ($value != "" && $in_options_lang[$key] != "") {
                 $options[$value] = $in_options_lang[$key];
             }
         }
     }
     $data = array('name' => isset($data['name']) ? $data['name'] : $name, 'fieldtype' => isset($data['fieldtype']) ? $data['fieldtype'] : $this->in->get('type'), 'category' => isset($data['category']) ? $data['category'] : $this->in->get('category'), 'language' => isset($data['lang']) ? $data['lang'] : $this->in->get('language'), 'size' => isset($data['size']) ? intval($data['size']) : $this->in->get('size', 3), 'options' => isset($data['option']) ? serialize($data['option']) : serialize($options), 'visible' => '1', 'image' => isset($data['image']) ? $data['image'] : $this->in->get('image'), 'undeletable' => $data['undeletable'] ? '1' : '0', 'enabled' => 1, 'custom' => $data['no_custom'] ? '0' : '1');
     $sql = $this->db->query("INSERT INTO __member_profilefields :params", $data);
     if (!$sql) {
         return false;
     }
     $this->pdh->enqueue_hook('game_update');
     return true;
 }
 public function check_password($password, $hash, $strSalt = '', $boolUseHash = false, $strUsername = '')
 {
     if (sha1(utf8_strtolower($strUsername) . $password) == $hash) {
         return true;
     }
     return false;
 }
Example #7
0
 public function getAttributesByAttributeGroupId($data = array())
 {
     $sql = "SELECT *, (SELECT agd.name FROM " . DB_PREFIX . "attribute_group_description agd WHERE agd.attribute_group_id = a.attribute_group_id AND agd.language_id = '" . (int) $this->config->get('config_language_id') . "') AS attribute_group FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE ad.language_id = '" . (int) $this->config->get('config_language_id') . "'";
     if (!empty($data['filter_name'])) {
         $sql .= " AND LCASE(ad.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     if (!empty($data['filter_attribute_group_id'])) {
         $sql .= " AND a.attribute_group_id = '" . $this->db->escape($data['filter_attribute_group_id']) . "'";
     }
     $sort_data = array('ad.name', 'attribute_group', 'a.sort_order');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY ad.name";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #8
0
 public function getDownloads($data = array())
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE dd.language_id = '" . (int) $this->config->get('config_language_id') . "'";
     if (!empty($data['filter_name'])) {
         $sql .= " AND LCASE(dd.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     $sort_data = array('dd.name', 'd.remaining');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY dd.name";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #9
0
 public function login($email, $password, $customer_id = false)
 {
     //+mod by yp
     //+mod by yp start
     if (!$email && !$password && !$customer_id) {
         return false;
     }
     if ($customer_id !== false && preg_match("/^\\d+\$/", $customer_id)) {
         $affiliate_query = $this->db->query("SELECT " . DB_PREFIX . "affiliate.* FROM " . DB_PREFIX . "affiliate, " . DB_PREFIX . "accc_customer_affiliate WHERE " . DB_PREFIX . "accc_customer_affiliate.affiliate_id=" . DB_PREFIX . "affiliate.affiliate_id AND " . DB_PREFIX . "accc_customer_affiliate.customer_id = '" . (int) $customer_id . "' AND " . DB_PREFIX . "affiliate.status = '1' AND " . DB_PREFIX . "affiliate.approved = '1' LIMIT 1");
     } else {
         //+mod by yp end
         $affiliate_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "affiliate WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '******') AND status = '1' AND approved = '1'");
     }
     //+mod by yp
     if ($affiliate_query->num_rows) {
         $this->_set_own_tracking();
     }
     //+mod by yp
     if ($affiliate_query->num_rows) {
         $this->session->data['affiliate_id'] = $affiliate_query->row['affiliate_id'];
         $this->affiliate_id = $affiliate_query->row['affiliate_id'];
         $this->firstname = $affiliate_query->row['firstname'];
         $this->lastname = $affiliate_query->row['lastname'];
         $this->email = $affiliate_query->row['email'];
         $this->telephone = $affiliate_query->row['telephone'];
         $this->fax = $affiliate_query->row['fax'];
         $this->code = $affiliate_query->row['code'];
         return true;
     } else {
         return false;
     }
 }
Example #10
0
 public function login($email, $password, $override = false)
 {
     if ($override) {
         $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND status = '1'");
     } else {
         $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '******') AND status = '1' AND approved = '1'");
     }
     if ($customer_query->num_rows) {
         $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         $this->customer_id = $customer_query->row['customer_id'];
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->email = $customer_query->row['email'];
         $this->telephone = $customer_query->row['telephone'];
         $this->fax = $customer_query->row['fax'];
         $this->newsletter = $customer_query->row['newsletter'];
         $this->address_id = $customer_query->row['address_id'];
         $this->folder_name = $customer_query->row['folder_name'];
         $this->custom_field = $customer_query->row['custom_field'];
         $this->db->query("UPDATE " . DB_PREFIX . "customer SET ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->customer_id . "'");
         return true;
     } else {
         return false;
     }
 }
Example #11
0
File: do.php Project: rauschen/do
 function handle($match, $state, $pos, &$handler)
 {
     $data = array('task' => array(), 'state' => $state);
     switch ($state) {
         case DOKU_LEXER_ENTER:
             $match = trim(substr($match, 3, -1));
             if (preg_match('/\\b(\\d\\d\\d\\d-\\d\\d-\\d\\d)\\b/', $match, $grep)) {
                 $data['task']['date'] = $grep[1];
                 $match = trim(str_replace($data['task']['date'], '', $match));
             }
             if ($match !== '') {
                 //FIXME call $auth->cleanUser()
                 $data['task']['user'] = $match;
             }
             $ReWriter = new Doku_Handler_Nest($handler->CallWriter, 'plugin_do_do');
             $handler->CallWriter =& $ReWriter;
             $handler->addPluginCall('do_do', $data, $state, $pos, $match);
             break;
         case DOKU_LEXER_UNMATCHED:
             $handler->_addCall('cdata', array($match), $pos);
             break;
         case DOKU_LEXER_EXIT:
             global $ID;
             $data['task']['text'] = trim(strip_tags(p_render('xhtml', array_slice($handler->CallWriter->calls, 1), $ignoreme)));
             $data['task']['md5'] = md5(utf8_strtolower(preg_replace('/\\s/', '', $data['task']['text'])) . $ID);
             // Add missing data from ENTER and EXIT to the other
             $handler->CallWriter->calls[0][1][1]['task'] += $data['task'];
             $data['task'] += $handler->CallWriter->calls[0][1][1]['task'];
             $handler->addPluginCall('do_do', $data, $state, $pos, $match);
             $handler->CallWriter->process();
             $ReWriter =& $handler->CallWriter;
             $handler->CallWriter =& $ReWriter->CallWriter;
     }
     return false;
 }
Example #12
0
 public function getImage()
 {
     //filemanger library for file type error
     include 'include/mime_type_lib.php';
     $this->data = $this->load->language('filemanager/filemanager');
     $this->load->model('tool/image');
     $json = array();
     if ($this->request->server['HTTPS']) {
         $server = HTTPS_CATALOG;
     } else {
         $server = HTTP_CATALOG;
     }
     $filename = basename(html_entity_decode($this->request->get['image_url'], ENT_QUOTES, 'UTF-8'));
     // Validate the filename length
     if (utf8_strlen($filename) < 3 || utf8_strlen($filename) > 255) {
         $json['error'] = $this->data['error_filename'];
     }
     // Allowed file extension types
     $allowed = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'svg');
     if (!in_array(utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)), $allowed)) {
         $json['error'] = $this->data['error_file_type'];
     }
     $filetype = get_file_mime_type($filename);
     // Allowed file mime types
     $allowed = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif');
     if (!in_array($filetype, $allowed)) {
         $json['error'] = $this->data['error_file_type'];
     }
     if (!$json && $this->request->get['image_url']) {
         $json = array('thumb' => $this->model_tool_image->resize(utf8_substr($this->request->get['image_url'], utf8_strlen($server . 'image/')), 100, 100), 'path' => utf8_substr($this->request->get['image_url'], utf8_strlen($server . 'image/')), 'href' => $this->request->get['image_url']);
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
 function handle()
 {
     if (!is_array($_REQUEST['d']) || !checkSecurityToken()) {
         return;
     }
     $sqlite = $this->dthlp->_getDB();
     if (!$sqlite) {
         return false;
     }
     $sqlite->query("BEGIN TRANSACTION");
     if (!$sqlite->query("DELETE FROM aliases")) {
         $sqlite->query('ROLLBACK TRANSACTION');
         return;
     }
     foreach ($_REQUEST['d'] as $row) {
         $row = array_map('trim', $row);
         $row['name'] = utf8_strtolower($row['name']);
         $row['name'] = rtrim($row['name'], 's');
         if (!$row['name']) {
             continue;
         }
         // Clean enum
         $arr = preg_split('/\\s*,\\s*/', $row['enum']);
         $arr = array_unique($arr);
         asort($arr);
         $row['enum'] = implode(', ', $arr);
         if (!$sqlite->query("INSERT INTO aliases (name, type, prefix, postfix, enum)\n                                 VALUES (?,?,?,?,?)", $row)) {
             $sqlite->query('ROLLBACK TRANSACTION');
             return;
         }
     }
     $sqlite->query("COMMIT TRANSACTION");
 }
Example #14
0
 public function getTabs($data = array())
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "tab t LEFT JOIN " . DB_PREFIX . "tab_description td ON (t.tab_id = td.tab_id) WHERE td.language_id = '" . (int) $this->config->get('config_language_id') . "'";
     if (!empty($data['filter_name']) and trim($data['filter_name'], ' ') != '') {
         $sql .= " AND LCASE(td.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     $sort_data = array('td.name', 't.sort_order');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY td.name";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #15
0
 public function getOptions($data = array())
 {
     $sql = "SELECT * FROM `" . DB_PREFIX . "option` o LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE od.language_id = '" . (int) $this->config->get('config_language_id') . "'";
     if (isset($data['filter_name']) && !is_null($data['filter_name'])) {
         $sql .= " AND LCASE(od.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     $sort_data = array('od.name', 'o.type', 'o.sort_order');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY od.name";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #16
0
 public function getManufacturers($data = array())
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "manufacturer";
     if (!empty($data['filter_name'])) {
         $sql .= " WHERE LCASE(name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     $sort_data = array('name', 'sort_order');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY name";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #17
0
 protected function _getTagMatchUsers(array $matches)
 {
     $usersByMatch = parent::_getTagMatchUsers($matches);
     if (bdTagMe_Option::get('groupTag')) {
         $engine = bdTagMe_Engine::getInstance();
         $taggableUserGroups = $engine->getTaggableUserGroups();
         $matchesToLower = array();
         foreach ($matches as $key => $match) {
             $matchesToLower[$key] = utf8_strtolower($match[1][0]);
         }
         $userGroupTitlesToLower = array();
         foreach ($taggableUserGroups as $taggableUserGroup) {
             $userGroupTitlesToLower[$taggableUserGroup['user_group_id']] = utf8_strtolower($taggableUserGroup['title']);
         }
         $changedMatchKeys = array();
         foreach ($userGroupTitlesToLower as $userGroupId => $userGroupTitleToLower) {
             foreach ($matchesToLower as $matchKey => $matchToLower) {
                 if (strpos($userGroupTitleToLower, $matchToLower) === 0) {
                     $userGroupInfo = array('user_id' => 'ug_' . $userGroupId, 'username' => $taggableUserGroups[$userGroupId]['title'], 'lower' => $userGroupTitleToLower, 'user_group_id' => $userGroupId);
                     $usersByMatch[$matchKey][$userGroupInfo['user_id']] = $userGroupInfo;
                     $changedMatchKeys[$matchKey] = true;
                 }
             }
         }
         foreach (array_keys($changedMatchKeys) as $matchKey) {
             uasort($usersByMatch[$matchKey], array(__CLASS__, 'sortByLowerLength'));
         }
     }
     return $usersByMatch;
 }
Example #18
0
 public function getNews($data = array())
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "news n LEFT JOIN " . DB_PREFIX . "news_description nd ON (n.news_id = nd.news_id) LEFT JOIN " . DB_PREFIX . "news_to_store n2s ON (n.news_id = n2s.news_id) WHERE nd.language_id = '" . (int) $this->config->get('config_language_id') . "' AND n2s.store_id = '" . (int) $this->config->get('config_store_id') . "' AND n.status = '1'";
     if (!empty($data['filter_name'])) {
         $sql .= " AND LCASE(nd.title) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
     }
     $sort_data = array('nd.title', 'nd.description', 'n.date_added', 'n.viewed', 'n.status');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY n.date_added";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
Example #19
0
 public function actionBdtagmeFind()
 {
     if (bdTagMe_Option::get('reorder')) {
         /** @var bdTagMe_XenForo_Model_User $userModel */
         $userModel = $this->_getUserModel();
         $userModel->bdTagMe_setOrderByMemberActivity(true);
     }
     $response = parent::actionFind();
     if ($response instanceof XenForo_ControllerResponse_View) {
         $users =& $response->params['users'];
         $q = utf8_strtolower($this->_input->filterSingle('q', XenForo_Input::STRING));
         if (!empty($q) and bdTagMe_Option::get('groupTag')) {
             $userGroups = bdTagMe_Engine::getInstance()->getTaggableUserGroups();
             $userGroupTitlesToLower = array();
             foreach ($userGroups as $userGroup) {
                 $userGroupTitlesToLower[$userGroup['user_group_id']] = utf8_strtolower($userGroup['title']);
             }
             foreach ($userGroupTitlesToLower as $userGroupId => $userGroupTitleToLower) {
                 if (strpos($userGroupTitleToLower, $q) === 0) {
                     // run extra check to eliminate users with matching username with this user group
                     foreach (array_keys($users) as $userId) {
                         if (utf8_strtolower($users[$userId]['username']) == $userGroupTitleToLower) {
                             unset($users[$userId]);
                         }
                     }
                     array_unshift($users, array('user_id' => -1, 'username' => $userGroups[$userGroupId]['title'], 'gravatar' => bdTagMe_Option::get('userGroupGravatar')));
                 }
             }
         }
     }
     return $response;
 }
Example #20
0
 public function login($email, $password, $override = false)
 {
     if ($override) {
         $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND status = '1'");
     } else {
         $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '******') AND status = '1' AND approved = '1'");
     }
     if ($customer_query->num_rows) {
         // Create customer login cookie if HTTPS
         if ($this->config->get('config_secure')) {
             if ($this->request->isSecure()) {
                 // Create a cookie and restrict it to HTTPS pages
                 $this->session->data['customer_cookie'] = hash_rand('md5');
                 setcookie('customer', $this->session->data['customer_cookie'], 0, '/', '', true, true);
             } else {
                 return false;
             }
         }
         // Regenerate session id
         $this->session->regenerateId();
         // Token used to protect account functions against CSRF
         $this->setToken();
         $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         $this->session->data['customer_login_time'] = time();
         if ($customer_query->row['cart'] && is_string($customer_query->row['cart'])) {
             $cart = unserialize($customer_query->row['cart']);
             foreach ($cart as $key => $value) {
                 if (!array_key_exists($key, $this->session->data['cart'])) {
                     $this->session->data['cart'][$key] = $value;
                 } else {
                     $this->session->data['cart'][$key] += $value;
                 }
             }
         }
         if ($customer_query->row['wishlist'] && is_string($customer_query->row['wishlist'])) {
             if (!isset($this->session->data['wishlist'])) {
                 $this->session->data['wishlist'] = array();
             }
             $wishlist = unserialize($customer_query->row['wishlist']);
             foreach ($wishlist as $product_id) {
                 if (!in_array($product_id, $this->session->data['wishlist'])) {
                     $this->session->data['wishlist'][] = $product_id;
                 }
             }
         }
         $this->customer_id = $customer_query->row['customer_id'];
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         $this->email = $customer_query->row['email'];
         $this->telephone = $customer_query->row['telephone'];
         $this->fax = $customer_query->row['fax'];
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->db->query("UPDATE " . DB_PREFIX . "customer SET ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->customer_id . "'");
         return true;
     } else {
         return false;
     }
 }
Example #21
0
 public function login($email, $password)
 {
     $affiliate_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "affiliate WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '******') AND status = '1' AND approved = '1'");
     if ($affiliate_query->num_rows) {
         // Create affiliate login cookie if HTTPS
         if ($this->config->get('config_secure')) {
             if ($this->request->isSecure()) {
                 // Create a cookie and restrict it to HTTPS pages
                 $this->session->data['affiliate_cookie'] = hash_rand('md5');
                 setcookie('affiliate', $this->session->data['affiliate_cookie'], 0, '/', '', true, true);
             } else {
                 return false;
             }
         }
         // Regenerate session id
         $this->session->regenerateId();
         // Token used to protect affiliate functions against CSRF
         $this->setToken();
         $this->session->data['affiliate_id'] = $affiliate_query->row['affiliate_id'];
         $this->session->data['affiliate_login_time'] = time();
         $this->affiliate_id = $affiliate_query->row['affiliate_id'];
         $this->firstname = $affiliate_query->row['firstname'];
         $this->lastname = $affiliate_query->row['lastname'];
         $this->email = $affiliate_query->row['email'];
         $this->telephone = $affiliate_query->row['telephone'];
         $this->fax = $affiliate_query->row['fax'];
         $this->code = $affiliate_query->row['code'];
         return true;
     } else {
         return false;
     }
 }
Example #22
0
 public function display()
 {
     $strTag = utf8_strtolower($this->patharray[0]);
     if (!strlen($strTag)) {
         redirect($this->controller_path_plain . $this->SID);
     }
     $arrArticleIDs = $this->pdh->get('articles', 'articles_for_tag', array($strTag));
     $arrArticleIDs = $this->pdh->sort($arrArticleIDs, 'articles', 'date', 'desc');
     $intStart = $this->in->get('start', 0);
     $arrLimitedIDs = $this->pdh->limit($arrArticleIDs, $intStart, $this->user->data['user_nlimit']);
     //Articles to template
     foreach ($arrLimitedIDs as $intArticleID) {
         $userlink = '<a href="' . $this->routing->build('user', $this->pdh->geth('articles', 'user_id', array($intArticleID)), 'u' . $this->pdh->get('articles', 'user_id', array($intArticleID))) . '">' . $this->pdh->geth('articles', 'user_id', array($intArticleID)) . '</a>';
         //Content dependet from list_type
         //1 = until readmore
         //2 = Headlines only
         //3 = only first 600 characters
         $strText = $this->pdh->get('articles', 'text', array($intArticleID));
         $arrContent = preg_split('#<hr(.*)id="system-readmore"(.*)\\/>#iU', xhtml_entity_decode($strText));
         $strText = $this->bbcode->parse_shorttags($arrContent[0]);
         $strPath = $this->pdh->get('articles', 'path', array($intArticleID));
         $intCategoryID = $this->pdh->get('articles', 'category', array($intArticleID));
         //Replace Image Gallery
         $arrGalleryObjects = array();
         preg_match_all('#<p(.*)class="system-gallery"(.*) data-sort="(.*)" data-folder="(.*)">(.*)</p>#iU', $strText, $arrGalleryObjects, PREG_PATTERN_ORDER);
         if (count($arrGalleryObjects[0])) {
             include_once $this->root_path . 'core/gallery.class.php';
             foreach ($arrGalleryObjects[4] as $key => $val) {
                 $objGallery = registry::register('gallery');
                 $strGalleryContent = $objGallery->create($val, (int) $arrGalleryObjects[3][$key], $this->server_path . $strPath, 1);
                 $strText = str_replace($arrGalleryObjects[0][$key], $strGalleryContent, $strText);
             }
         }
         //Replace Raidloot
         $arrRaidlootObjects = array();
         preg_match_all('#<p(.*)class="system-raidloot"(.*) data-id="(.*)"(.*) data-chars="(.*)">(.*)</p>#iU', $strText, $arrRaidlootObjects, PREG_PATTERN_ORDER);
         if (count($arrRaidlootObjects[0])) {
             include_once $this->root_path . 'core/gallery.class.php';
             foreach ($arrRaidlootObjects[3] as $key => $val) {
                 $objGallery = registry::register('gallery');
                 $withChars = $arrRaidlootObjects[5][$key] == "true" ? true : false;
                 $strRaidlootContent = $objGallery->raidloot((int) $val, $withChars);
                 $strText = str_replace($arrRaidlootObjects[0][$key], $strRaidlootContent, $strText);
             }
         }
         $this->comments->SetVars(array('attach_id' => $intArticleID, 'page' => 'articles'));
         $intCommentsCount = $this->comments->Count();
         //Tags
         $arrTags = $this->pdh->get('articles', 'tags', array($intArticleID));
         $this->tpl->assign_block_vars('article_row', array('ARTICLE_CONTENT' => $strText, 'ARTICLE_TITLE' => $this->pdh->get('articles', 'title', array($intArticleID)), 'ARTICLE_SUBMITTED' => sprintf($this->user->lang('news_submitter'), $userlink, $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, true)), 'ARTICLE_DATE' => $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, false, true), 'ARTICLE_PATH' => $this->controller_path . $this->pdh->get('articles', 'path', array($intArticleID)), 'ARTICLE_SOCIAL_BUTTONS' => $arrCategory['social_share_buttons'] ? $this->social->createSocialButtons($this->env->link . $this->pdh->get('articles', 'path', array($intArticleID)), strip_tags($this->pdh->get('articles', 'title', array($intArticleID)))) : '', 'PERMALINK' => $this->pdh->get('articles', 'permalink', array($intArticleID)), 'S_TAGS' => count($arrTags) && $arrTags[0] != "" ? true : false, 'ARTICLE_CUTTED_CONTENT' => truncate($strText, 600, '...', false, true), 'S_READMORE' => isset($arrContent[1]) ? true : false, 'COMMENTS_COUNTER' => $intCommentsCount == 1 ? $intCommentsCount . ' ' . $this->user->lang('comment') : $intCommentsCount . ' ' . $this->user->lang('comments'), 'S_COMMENTS' => $this->pdh->get('articles', 'comments', array($intArticleID)) ? true : false, 'S_FEATURED' => $this->pdh->get('articles', 'featured', array($intArticleID))));
         if (count($arrTags) && $arrTags[0] != "") {
             foreach ($arrTags as $tag) {
                 $this->tpl->assign_block_vars('article_row.tag_row', array('TAG' => $tag, 'U_TAG' => $this->routing->build('tag', $tag)));
             }
         }
     }
     $this->tpl->assign_vars(array('TAG' => sanitize($strTag), 'PAGINATION' => generate_pagination($this->strPath . $this->SID, count($arrArticleIDs), $this->user->data['user_nlimit'], $intStart, 'start')));
     $this->tpl->add_meta('<link rel="canonical" href="' . $this->env->link . $this->routing->build('tag', $tag, false, false, true) . '" />');
     $this->core->set_vars(array('page_title' => $this->user->lang("tag") . ': ' . sanitize($strTag), 'template_file' => 'tag.html', 'display' => true));
 }
 function prepareInputForAdd($input)
 {
     //LDAP parameters MUST be in lower case
     //because the are retieved in lower case  from the directory
     $input["value"] = utf8_strtolower($input["value"]);
     return $input;
 }
Example #24
0
 public function index()
 {
     // Add rewrite to url class
     if ($this->config->get('config_seo_url')) {
         $this->url->addRewrite($this);
     }
     // Decode URL
     if (isset($this->request->get['_route_'])) {
         $route = $this->request->get['_route_'];
         unset($this->request->get['_route_']);
         $parts = explode('/', trim(utf8_strtolower($route), '/'));
         list($last_part) = explode('.', array_pop($parts));
         array_push($parts, $last_part);
         $keyword_in = array_map(array($this->db, 'escape'), $parts);
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword IN ('" . implode("', '", $keyword_in) . "')");
         if ($query->num_rows == sizeof($parts)) {
             $queries = array();
             foreach ($query->rows as $row) {
                 $queries[utf8_strtolower($row['keyword'])] = $row['query'];
             }
             reset($parts);
             foreach ($parts as $part) {
                 $url = explode('=', $queries[$part], 2);
                 if ($url[0] == 'category_id') {
                     if (!isset($this->request->get['path'])) {
                         $this->request->get['path'] = $url[1];
                     } else {
                         $this->request->get['path'] .= '_' . $url[1];
                     }
                 } else {
                     $this->request->get[$url[0]] = $url[1];
                 }
             }
         } else {
             $this->request->get['route'] = 'error/not_found';
         }
         if (isset($this->request->get['product_id'])) {
             $this->request->get['route'] = 'product/product';
             if (!isset($this->request->get['path'])) {
                 $path = $this->getPathByProduct($this->request->get['product_id']);
                 if ($path) {
                     $this->request->get['path'] = $path;
                 }
             }
         } elseif (isset($this->request->get['path'])) {
             $this->request->get['route'] = 'product/category';
         } elseif (isset($this->request->get['manufacturer_id'])) {
             $this->request->get['route'] = 'product/manufacturer/product';
         } elseif (isset($this->request->get['information_id'])) {
             $this->request->get['route'] = 'information/information';
         }
         if (isset($this->request->get['route']) && $this->request->get['route'] != 'error/not_found') {
             $this->validate($route);
         }
         if (isset($this->request->get['route'])) {
             return $this->forward($this->request->get['route']);
         }
     }
 }
Example #25
0
 public function getOrders($data = array())
 {
     $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int) $this->config->get('config_language_id') . "') AS status, o.currency_code, o.currency_value, o.date_added, IF(ao.order_id IS NULL, IF(auso.order_id IS NULL, IF(eo.order_id IS NULL, 'web', 'ebay'), 'amazonus'), 'amazon') AS channel FROM `" . DB_PREFIX . "order` o";
     if ($this->config->get('openbay_status')) {
         $sql .= " LEFT JOIN " . DB_PREFIX . "ebay_order eo ON o.order_id = eo.order_id ";
     } else {
         $sql .= " JOIN (SELECT NULL AS order_id) eo ";
     }
     if ($this->config->get('amazon_status')) {
         $sql .= " LEFT JOIN " . DB_PREFIX . "amazon_order ao ON o.order_id = ao.order_id ";
     } else {
         $sql .= " JOIN (SELECT NULL AS order_id) ao ";
     }
     if ($this->config->get('amazonus_status')) {
         $sql .= " LEFT JOIN " . DB_PREFIX . "amazonus_order auso ON o.order_id = auso.order_id ";
     } else {
         $sql .= " JOIN (SELECT NULL AS order_id) auso ";
     }
     if (isset($data['filter_order_status_id']) && !is_null($data['filter_order_status_id'])) {
         $sql .= " WHERE o.order_status_id = '" . (int) $data['filter_order_status_id'] . "'";
     } else {
         $sql .= " WHERE o.order_status_id > '0'";
     }
     if (!empty($data['filter_order_id'])) {
         $sql .= " AND o.order_id = '" . (int) $data['filter_order_id'] . "'";
     }
     if (!empty($data['filter_customer'])) {
         $sql .= " AND LCASE(CONCAT(o.firstname, ' ', o.lastname)) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_customer'])) . "%'";
     }
     if (!empty($data['filter_date_added'])) {
         $sql .= " AND DATE(o.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
     }
     if (!empty($data['filter_channel'])) {
         $sql .= " HAVING channel = '" . $this->db->escape($data['filter_channel']) . "'";
     }
     $sort_data = array('o.order_id', 'customer', 'status', 'o.date_added', 'channel');
     if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
         $sql .= " ORDER BY " . $data['sort'];
     } else {
         $sql .= " ORDER BY o.order_id";
     }
     if (isset($data['order']) && $data['order'] == 'DESC') {
         $sql .= " DESC";
     } else {
         $sql .= " ASC";
     }
     if (isset($data['start']) || isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         if ($data['limit'] < 1) {
             $data['limit'] = 20;
         }
         $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
     }
     $query = $this->db->query($sql);
     return $query->rows;
 }
 /**
  * constuctor
  */
 function phpbb_seo()
 {
     global $config, $phpEx;
     // fix for an interesting bug with parse_str http://bugs.php.net/bug.php?id=48697
     // and apparently, the bug is still here in php5.3
     @ini_set("mbstring.internal_encoding", 'UTF-8');
     // URL Settings
     $this->seo_opt = array('profile_inj' => false, 'rem_small_words' => false, 'virtual_folder' => false, 'virtual_root' => false);
     // --> DOMAIN SETTING <-- //
     // SSL, beware with cookie secure, it won't force ssl here,
     // so you will need to switch to ssl for your user to use cookie based session (no sid)
     // could be done by using an https link to login form (or within the redirect after login)
     $this->ssl['requested'] = (bool) (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === true) || isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
     $this->ssl['forced'] = (bool) ($config['server_protocol'] === 'https://');
     $this->ssl['use'] = (bool) ($this->ssl['requested'] || $this->ssl['forced']);
     // Server Settings, rely on DB
     $server_protocol = $this->ssl['use'] ? 'https://' : 'http://';
     $server_name = trim($config['server_name'], '/ ');
     $server_port = max(0, (int) $config['server_port']);
     $server_port = $server_port && $server_port != 80 ? ':' . $server_port : '';
     $script_path = trim($config['script_path'], '/ ');
     $script_path = empty($script_path) ? '' : $script_path . '/';
     $this->seo_path['root_url'] = utf8_strtolower($server_protocol . $server_name . $server_port . '/');
     $this->seo_path['phpbb_urlR'] = $this->seo_path['phpbb_url'] = $this->seo_path['root_url'] . $script_path;
     $this->seo_path['phpbb_script'] = $script_path;
     $this->seo_path['canonical'] = '';
     // File setting
     $this->seo_req_uri();
     $this->seo_opt['seo_base_href'] = $this->seo_opt['req_file'] = $this->seo_opt['req_self'] = '';
     if ($script_name = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF')) {
         // From session.php
         // Replace backslashes and doubled slashes (could happen on some proxy setups)
         $this->seo_opt['req_self'] = str_replace(array('\\', '//'), '/', $script_name);
         // basenamed page name (for example: index)
         $this->seo_opt['req_file'] = urlencode(htmlspecialchars(str_replace(".{$phpEx}", '', basename($this->seo_opt['req_self']))));
     }
     // see if we have some custom replacement
     if (!empty($this->url_replace)) {
         $this->url_replace = array('find' => array_keys($this->url_replace), 'replace' => array_values($this->url_replace));
     }
     // preg_replace() patterns for format_url()
     // One could want to add |th|horn after |slash, but I'm not sure that Þ should be replaced with t and Ð with e
     $this->RegEx['url_find'] = array('`&([a-z]+)(acute|grave|circ|cedil|tilde|uml|lig|ring|caron|slash);`i', '`&(amp;)?[^;]+;`i', '`[^a-z0-9]`i');
     // Do not remove : deaccentuation, html/xml entities & non a-z chars
     $this->RegEx['url_replace'] = array('\\1', '-', '-');
     if ($this->seo_opt['rem_small_words']) {
         $this->RegEx['url_find'][] = '`(^|-)[a-z0-9]{1,2}(?=-|$)`i';
         $this->RegEx['url_replace'][] = '-';
     }
     $this->RegEx['url_find'][] = '`[-]+`';
     // Do not remove : multi hyphen reduction
     $this->RegEx['url_replace'][] = '-';
     // $1 parent : string/
     // $2 title / url : topic-title / forum-url-fxx
     // $3 id
     $this->sftpl = array('topic' => ($this->seo_opt['virtual_folder'] ? '%1$s/' : '') . '%2$s' . $this->seo_delim['topic'] . '%3$s', 'topic_smpl' => ($this->seo_opt['virtual_folder'] ? '%1$s/' : '') . $this->seo_static['topic'] . '%3$s', 'forum' => $this->modrtype >= 2 ? '%2$s' : $this->seo_static['forum'] . '%3$s', 'group' => $this->seo_opt['profile_inj'] ? '%2$s' . $this->seo_delim['group'] . '%3$s' : $this->seo_static['group'] . '%3$s');
     return;
 }
Example #27
0
/**
 * Filter a set of strings by finding strings that start with a case-insensitive prefix.
 * @param array $p_set An array of strings to search through.
 * @param string $p_prefix The prefix to filter by.
 * @return array An array of strings which match the supplied prefix.
 */
function xmlhttprequest_filter_by_prefix( $p_set, $p_prefix ) {
	$t_matches = array();
	foreach ( $p_set as $p_item ) {
		if ( utf8_strtolower( utf8_substr( $p_item, 0, utf8_strlen( $p_prefix ) ) ) === utf8_strtolower( $p_prefix ) ) {
			$t_matches[] = $p_item;
		}
	}
	return $t_matches;
}
/**
 * Migrate the legacy category data to the new category_id-based schema.
 */
function install_category_migrate()
{
    global $g_db_log_queries;
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_category_table = db_get_table('mantis_category_table');
    $t_project_category_table = db_get_table('mantis_project_category_table');
    // disable query logging (even if it's enabled in config for this)
    if ($g_db_log_queries !== 0) {
        $t_log_queries = $g_db_log_queries;
        $g_db_log_queries = 0;
    } else {
        $t_log_queries = null;
    }
    $query = "SELECT project_id, category, user_id FROM {$t_project_category_table} ORDER BY project_id, category";
    $t_category_result = db_query_bound($query);
    $query = "SELECT project_id, category FROM {$t_bug_table} ORDER BY project_id, category";
    $t_bug_result = db_query_bound($query);
    $t_data = array();
    # Find categories specified by project
    while ($row = db_fetch_array($t_category_result)) {
        $t_project_id = $row['project_id'];
        $t_name = $row['category'];
        $t_data[$t_project_id][$t_name] = $row['user_id'];
    }
    # Find orphaned categories from bugs
    while ($row = db_fetch_array($t_bug_result)) {
        $t_project_id = $row['project_id'];
        $t_name = $row['category'];
        if (!isset($t_data[$t_project_id][$t_name])) {
            $t_data[$t_project_id][$t_name] = 0;
        }
    }
    # In every project, go through all the categories found, and create them and update the bug
    foreach ($t_data as $t_project_id => $t_categories) {
        $t_inserted = array();
        foreach ($t_categories as $t_name => $t_user_id) {
            $t_lower_name = utf8_strtolower(trim($t_name));
            if (!isset($t_inserted[$t_lower_name])) {
                $query = "INSERT INTO {$t_category_table} ( name, project_id, user_id ) VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
                db_query_bound($query, array($t_name, $t_project_id, $t_user_id));
                $t_category_id = db_insert_id($t_category_table);
                $t_inserted[$t_lower_name] = $t_category_id;
            } else {
                $t_category_id = $t_inserted[$t_lower_name];
            }
            $query = "UPDATE {$t_bug_table} SET category_id=" . db_param() . '
						WHERE project_id=' . db_param() . ' AND category=' . db_param();
            db_query_bound($query, array($t_category_id, $t_project_id, $t_name));
        }
    }
    // re-enabled query logging if we disabled it
    if ($t_log_queries !== null) {
        $g_db_log_queries = $t_log_queries;
    }
    # return 2 because that's what ADOdb/DataDict does when things happen properly
    return 2;
}
 private function buildURL()
 {
     $url = "http://www.wowprogress.com/";
     $search = array('+', "'", " ");
     $server = urlencode(strtolower(str_replace($search, '-', unsanitize($this->config->get('servername')))));
     $guild = str_replace($search, '+', urlencode(utf8_strtolower(unsanitize($this->config->get('guildtag')))));
     $url .= "guild/" . $this->config->get('uc_server_loc') . "/" . $server . "/" . $guild . "/";
     return $url;
 }
Example #30
0
 public static function strtolower($string)
 {
     global $sourcedir;
     if (function_exists('mb_strtolower')) {
         return mb_strtolower($string, 'UTF-8');
     }
     require_once $sourcedir . '/lib/Subs-Charset.php';
     return utf8_strtolower($string);
 }