function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     $first = $page * $limit;
     $sql = "SELECT `member_id`, `name`, `server`, `region`, `guild_id`, `class`, `level`, `note`, `guild_rank`,`guild_title`, `zone`, `last_online`" . " FROM `" . $roster->db->table('members') . "`" . " WHERE (`member_id` LIKE '%{$search}%'" . " OR `name` LIKE '%" . ucfirst($search) . "%'" . " OR `name` LIKE '%" . $search . "%'" . " OR `server` LIKE '%{$search}%'" . " OR `region` LIKE '%{$search}%'" . " OR `guild_id` LIKE '%{$search}%'" . " OR `class` LIKE '%{$search}%'" . " OR `level` LIKE '%{$search}%'" . " OR `note` LIKE '%{$search}%'" . " OR `guild_rank` LIKE '%{$search}%'" . " OR `guild_title` LIKE '%{$search}%'" . " OR `zone` LIKE '%{$search}%')" . " GROUP BY `member_id`" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     // calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $crows = 0;
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0) {
         while ($x > 0) {
             list($member_id, $name, $server, $region, $guild_id, $class, $level, $note, $guild_rank, $guild_title, $zone, $last_online) = $roster->db->fetch($result);
             $item['title'] = $name;
             $item['date'] = $last_online;
             $item['html'] = '<td class="SearchRowCell">' . $level . '</td><td class="SearchRowCell">' . $class . '</td><td class="SearchRowCell"><a href="' . makelink("char-info&amp;a=c:{$member_id}") . '"><strong>' . $name . '</strong></a></td><td class="SearchRowCellRight">' . $guild_title . '</td>';
             $this->add_result($item);
             unset($item);
             $x--;
         }
     }
     $roster->db->free_result($result);
 }
 function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     $first = $page * $limit;
     $search_zone = $this->zone == '' ? '' : "`q`.`zone` = '" . $this->zone . "' AND";
     $search_level = $this->levelid == '' ? '' : "`q`.`quest_level` = '" . $this->levelid . "' AND";
     $sql = "SELECT `q`.`quest_name`, `q`.`quest_level`, `q`.`quest_tag`, `q`.`zone`, `p`.`region`, `p`.`server`" . " FROM `" . $roster->db->table('quests') . "` AS q" . " LEFT JOIN `" . $roster->db->table('players') . "` AS p USING (`member_id`)" . " WHERE {$search_zone} {$search_level} `q`.`quest_name` LIKE '%{$search}%'" . " GROUP BY `quest_name`" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     //calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0) {
         while ($x > 0) {
             list($quest_name, $quest_level, $quest_tag, $zone, $region, $server) = $roster->db->fetch($result);
             $item['title'] = $quest_name;
             $item['html'] = '<td class="SearchRowCell">' . $quest_level . '</td>' . '<td class="SearchRowCell"><a href="' . makelink('realm-questlist&amp;a=r:' . $region . '-' . urlencode($server) . '&amp;questid=' . urlencode($quest_name)) . '"><strong>' . $quest_name . '</strong></a></td>' . '<td class="SearchRowCellRight">' . $zone . '</td>';
             $this->add_result($item);
             unset($item);
             $x--;
         }
     }
     $roster->db->free_result($result);
 }
Exemple #3
0
 function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     $first = $page * $limit;
     $sql = "SELECT `players`.`name`, `players`.`member_id`, `players`.`server`, `players`.`region`, `recipes`.*" . " FROM `" . $roster->db->table('recipes') . "` AS recipes,`" . $roster->db->table('players') . "` AS players" . " WHERE `recipes`.`member_id` = `players`.`member_id`" . " AND (`recipes`.`recipe_name` LIKE '%{$search}%' OR `recipes`.`recipe_tooltip` LIKE '%{$search}%')" . ($this->minlvl != '' ? " AND `recipes`.`level` >= '{$this->minlvl}'" : '') . ($this->maxlvl != '' ? " AND `recipes`.`level` <= '{$this->maxlvl}'" : '') . $this->quality_sql . " ORDER BY `recipes`.`recipe_name` ASC, `recipes`.`recipe_type` ASC" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     //calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0 && $limit > 0) {
         while ($x > 0) {
             $row = $roster->db->fetch($result);
             $icon = new recipe($row);
             $item['html'] = '<td class="SearchRowCell">' . $icon->out(true) . '</td>' . '<td class="SearchRowCell">' . $icon->data['level'] . '</td>' . '<td class="SearchRowCell"><span style="color:#' . $icon->data['item_color'] . '">[' . $icon->data['recipe_name'] . ']</span></td>' . '<td class="SearchRowCell">' . $icon->data['skill_name'] . '<br />' . $icon->data['recipe_type'] . '</td>' . '<td class="SearchRowCell">' . str_replace('<br>', '<br />', $icon->data['reagents']) . '</td>' . '<td class="SearchRowCellRight"><a href="' . makelink('char-info-recipes&amp;a=c:' . $row['member_id'] . '#' . strtolower(str_replace(' ', '', $icon->data['skill_name']))) . '"><strong>' . $row['name'] . '</strong></a></td>';
             $this->add_result($item);
             unset($item);
             $x--;
         }
     } else {
         $this->result_count = $nrows;
     }
     $roster->db->free_result($result);
 }
Exemple #4
0
 /**
  * Consumes the resource by method and returns the results of the request.
  *
  * @param string $method Request method
  * @param array $params Parameters
  * @throws ResourceException If request method is not allowed
  * @return array Request data
  */
 public function consume($method, $params = array())
 {
     global $roster;
     $makecache = false;
     $msg = '';
     if (!in_array($method, $this->methods_allowed)) {
         $roster->set_message('The selected api action is not allowed', 'Method not allowed.', 'error');
         //throw new ResourceException('Method not allowed.', 405);
     }
     // new prity url builder ... much better then befor...
     $ui = API_URI;
     //sprintf(self::API_URI, $this->region);
     // new cache system see hwo old teh file is only live update files more then X days/hours old
     $this->querytime = format_microtime();
     $roster->db->query_count++;
     $url = $this->url->BuildUrl($ui, $method, $params['server'], $params['name'], $params);
     if ($method == 'auction') {
         $data = $this->Curl->makeRequest($url, $params['type'], $params, $url, $method);
         if ($this->Curl->errno !== CURLE_OK) {
             throw new ResourceException($this->Curl->error, $this->Curl->errno);
         }
         $auction = json_decode($data['response'], true);
         $url = $auction['files'][0]['url'];
     }
     $data = $this->Curl->makeRequest($url, null, $params, $url, $method);
     if ($this->Curl->errno !== CURLE_OK) {
         //throw new ResourceException($this->Curl->error, $this->Curl->errno);
         $roster->set_message("The selected api action is not allowed <br/>\n\r [" . $this->Curl->errno . '] : ' . $this->Curl->error . '', 'Curl has Failed!', 'error');
     }
     $errornum = empty($data['response_headers']['http_code']) ? $data['response_headers']['http_code'] : '_911_';
     //Battle.net returned a HTTP error code
     $x = json_decode($data['response'], true);
     //$makecache
     if (isset($x['reason'])) {
         $this->seterrors(array('type' => $method, 'msg' => $x['reason']));
         $msg = $this->transhttpciode($data['response_headers']['http_code']);
         $roster->set_message(' ' . $method . ': ' . $msg . ' : ' . $x['reason'] . '<br>' . $url . ' ', 'Api call fail!', 'error');
         //$roster->set_message( ' '.$method.': '.$x['reason'].' ', 'Api call fail!', 'error' );
         $this->query['result'] = false;
         // over ride cache and set to false no data or no url no file lol
     }
     $roster->api2->cache->api_track($method, $url, $this->Curl->http_code, $this->Curl->content_type);
     $this->usage = array('type' => $method, 'url' => $url, 'responce_code' => $this->Curl->http_code, 'content_type' => $this->Curl->content_type, 'locale' => $this->region);
     if (method_exists($roster->api2->cache, 'insert' . $method) && is_callable(array($roster->api2->cache, 'insert' . $method))) {
         call_user_func(array($roster->api2->cache, 'insert' . $method), $result, $this->usage, $params);
     }
     //print_r($data['response_headers']);
     $data = json_decode($data['response'], true);
     $info = $data;
     //$this->utf8_array_decode($data);
     return $info;
 }
Exemple #5
0
 /**
  * helper function for debugging
  *
  * @param string $string
  * @return string date
  */
 function _debug($level = 0, $ret = false, $info = false, $status = false)
 {
     global $roster, $addon;
     if ($level > $addon['config']['ApiSync_debuglevel']) {
         return;
     }
     $timestamp = round(format_microtime() - APISYNC_STARTTIME, 4);
     if (version_compare(phpversion(), '4.3.0', '>=')) {
         $tmp = debug_backtrace();
         $trace = $tmp[1];
     }
     $array = array('time' => $timestamp, 'file' => isset($trace['file']) ? str_replace($addon['dir'], '', $trace['file']) : 'ApiSync.class.php', 'line' => isset($trace['line']) ? $trace['line'] : '', 'function' => isset($trace['function']) ? $trace['function'] : '', 'class' => isset($trace['class']) ? $trace['class'] : '', 'args' => $addon['config']['ApiSync_debugdata'] != 0 && isset($trace['args']) && !is_object($trace['args']) ? $trace['args'] : '', 'ret' => $addon['config']['ApiSync_debugdata'] != 0 && isset($ret) && !is_object($ret) ? $ret : '', 'info' => isset($info) ? $info : '', 'status' => isset($status) ? $status : '');
     if (!($level > $addon['config']['ApiSync_debuglevel'])) {
         $this->debugmessages[] = $array;
     }
     if ($level == 0) {
         $this->errormessages[] = $array;
     }
 }
 function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     $first = $page * $limit;
     $sql = "SELECT `news`.`news_id`, `news`.`author`, `news`.`title`, `news`.`content`, `news`.`html`, " . "DATE_FORMAT(  DATE_ADD(`news`.`date`, INTERVAL " . $roster->config['localtimeoffset'] . " HOUR ), '" . $roster->locale->act['timeformat'] . "' ) AS 'date_format', " . "COUNT(`comments`.`comment_id`) comm_count " . "FROM `" . $roster->db->table('news', 'news') . "` news " . "LEFT JOIN `" . $roster->db->table('comments', 'news') . "` comments USING (`news_id`) " . "WHERE `news`.`news_id` LIKE '%{$search}%' " . "OR `news`.`author` LIKE '%{$search}%' " . "OR `news`.`date` LIKE '%{$search}%' " . "OR `news`.`title` LIKE '%{$search}%' " . "OR `news`.`content` LIKE '%{$search}%' " . "GROUP BY `news`.`news_id` " . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     //calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0) {
         while ($x > 0) {
             list($news_id, $author, $title, $content, $html, $date, $comments) = $roster->db->fetch($result);
             $item['author'] = $author;
             $item['date'] = $date;
             $item['title'] = $title;
             $item['url'] = makelink('util-news-comment&amp;id=' . $news_id);
             if ($html == '1' && $this->data['config']['news_html'] >= 0) {
                 $content = $content;
             } else {
                 $content = htmlentities($content);
             }
             $content = nl2br($content);
             $array = explode(' ', $content, 101);
             if (isset($array[100])) {
                 unset($array[100]);
                 $item['more_text'] = true;
             } else {
                 $item['more_text'] = false;
             }
             $item['short_text'] = implode(' ', $array);
             $item['footer'] = ($comments == 0 ? 'No' : $comments) . ' comment' . ($comments == 1 ? '' : 's');
             $this->add_result($item);
             unset($item);
             $x--;
         }
     }
     $roster->db->free_result($result);
 }
Exemple #7
0
 /**
  * Parses the files and put it in $uploadData
  *
  * @return string $output | Output messages
  */
 function parseFiles()
 {
     global $roster;
     if (!is_array($_FILES)) {
         return '<span class="red">Upload failed: No files present</span>' . "<br />\n";
     }
     require_once ROSTER_LIB . 'luaparser.php';
     $output = $roster->locale->act['parsing_files'] . "<br />\n<ul>";
     foreach ($_FILES as $file) {
         if (!empty($file['name']) && $this->upload_error_check($file)) {
             $filename = explode('.', $file['name']);
             $filebase = strtolower($filename[0]);
             if (in_array($filebase, $this->files)) {
                 // Get start of parse time
                 $parse_starttime = format_microtime();
                 $luahandler = new lua();
                 $data = $luahandler->luatophp($file['tmp_name'], isset($this->blinds[$filebase]) ? $this->blinds[$filebase] : array());
                 // Calculate parse time
                 $parse_totaltime = round(format_microtime() - $parse_starttime, 2);
                 if ($data) {
                     $output .= '<li>' . sprintf($roster->locale->act['parsed_time'], $filename[0], $parse_totaltime) . "</li>\n";
                     $this->uploadData[$filebase] = $data;
                 } else {
                     $output .= '<li>' . sprintf($roster->locale->act['error_parsed_time'], $filebase, $parse_totaltime) . "</li>\n";
                     $output .= $luahandler->error() != '' ? '<li>' . $luahandler->error() . "</li>\n" : '';
                 }
                 unset($luahandler);
             } else {
                 $output .= '<li>' . sprintf($roster->locale->act['upload_not_accept'], $file['name']) . "</li>\n";
             }
         } else {
             $output .= '<li>' . sprintf($roster->locale->act['error_parsed_time'], $file['name'], '0') . "</li>\n";
         }
     }
     $output .= "</ul><br />\n";
     return $output;
 }
Exemple #8
0
 function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     include_once $this->data['inc_dir'] . 'vault_item.php';
     // Get all the vault page names first
     $sql = "SELECT `guild_id`, `item_slot`, `item_name`, `item_texture` FROM `" . $roster->db->table('addons_vault_items') . "` WHERE `item_parent` = 'vault';";
     $result = $roster->db->query($sql);
     $x = $roster->db->num_rows($result);
     $tab_name = array();
     while ($x > 0) {
         $row = $roster->db->fetch($result);
         $tab_name[$row['guild_id']][$row['item_slot']] = array('name' => $row['item_name'], 'icon' => $row['item_texture']);
         $x--;
     }
     $roster->db->free_result($result);
     // Search the items
     $first = $page * $limit;
     $sql = "SELECT *, SUM(item_quantity) AS total_quantity" . " FROM `" . $roster->db->table('addons_vault_items') . "`" . " WHERE (`item_parent` LIKE 'Tab%') AND (`item_name` LIKE '%{$search}%' OR `item_tooltip` LIKE '%{$search}%')" . ($this->minlvl != '' ? " AND `level` >= '{$this->minlvl}'" : '') . ($this->maxlvl != '' ? " AND `level` <= '{$this->maxlvl}'" : '') . $this->quality_sql . " GROUP BY `item_name`" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     // calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0 && $limit > 0) {
         while ($x > 0) {
             $row = $roster->db->fetch($result);
             $row['item_quantity'] = $row['total_quantity'];
             // Totals quantity, found on all pages
             $icon = new VaultItem($row, false);
             $item['html'] = '<td class="SearchRowCell">' . $icon->out(true) . '</td>' . '<td class="SearchRowCell">' . $icon->requires_level . '</td>' . '<td class="SearchRowCell"><span style="color:#' . $icon->color . '">[' . $icon->name . ']</span></td>' . '<td class="SearchRowCellRight"><a href="' . makelink('guild-vault&amp;a=g:' . $row['guild_id']) . '">' . '<span class="item-sm">' . '<img src="' . $roster->config['interface_url'] . 'Interface/Icons/' . $tab_name[$row['guild_id']][$row['item_parent']]['icon'] . '.' . $roster->config['img_suffix'] . '" alt="" />' . '<span class="mask none"></span></span>&nbsp;' . $tab_name[$row['guild_id']][$row['item_parent']]['name'] . '</a></td>';
             $this->add_result($item);
             unset($item);
             $x--;
         }
     } else {
         $this->result_count = $nrows;
     }
     $roster->db->free_result($result);
 }
Exemple #9
0
 /**
  * Consumes the resource by method and returns the results of the request.
  *
  * @param string $method Request method
  * @param array $params Parameters
  * @throws ResourceException If request method is not allowed
  * @return array Request data
  */
 public function consume($method, $params = array())
 {
     global $roster;
     $makecache = false;
     $msg = '';
     if (!in_array($method, $this->methods_allowed)) {
         $roster->set_message('The selected api action is not allowed', 'Method not allowed.', 'error');
         //throw new ResourceException('Method not allowed.', 405);
     }
     // new prity url builder ... much better then befor...
     $ui = API_URI;
     //sprintf(self::API_URI, $this->region);
     // new cache system see hwo old teh file is only live update files more then X days/hours old
     $this->querytime = format_microtime();
     $this->query_count++;
     $url = $this->url->BuildUrl($ui, $method, $params['server'], $params['name'], $params);
     if (isset($_GET['debug'])) {
         echo '--[ ' . $url . ' ]--<br>';
     }
     $data = $this->Curl->makeRequest($url, null, $params, $url, $method);
     if ($this->Curl->errno !== CURLE_OK) {
         //throw new ResourceException($this->Curl->error, $this->Curl->errno);
         $roster->set_message("The selected api action is not allowed <br/>\n\r [" . $this->Curl->errno . '] : ' . $this->Curl->error . '', 'Curl has Failed!', 'error');
     }
     $roster->db->queries['api/' . $method][$this->query_count]['query'] = $url;
     $roster->db->queries['api/' . $method][$this->query_count]['time'] = round(format_microtime() - $this->querytime, 4);
     $roster->db->queries['api/' . $method][$this->query_count]['line'] = '94';
     $roster->db->queries['api/' . $method][$this->query_count]['error'] = empty($data['response_headers']['http_code']) ? $data['response_headers']['http_code'] : '';
     // update the tracker...
     $q = "SELECT * FROM `" . $roster->db->table('api_usage') . "` WHERE `date`='" . date("Y-m-d") . "' AND `type` = '" . $method . "'";
     $y = $roster->db->query($q);
     $row = $roster->db->fetch($y);
     if (!isset($row['total'])) {
         $query = 'INSERT INTO `' . $roster->db->table('api_usage') . '` VALUES ';
         $query .= "('','" . $method . "','" . date("Y-m-d") . "','+1'); ";
     } else {
         $query = "Update `" . $roster->db->table('api_usage') . "` SET `total`='" . ($row['total'] + 1) . "' WHERE `type` = '" . $method . "' AND `date` = '" . date("Y-m-d") . "'";
     }
     $ret = $roster->db->query($query);
     //Battle.net returned a HTTP error code
     $x = json_decode($data['response'], true);
     if (isset($data['response_headers']) && $data['response_headers']['http_code'] != '200') {
         $msg = $this->transhttpciode($data['response_headers']['http_code']);
         $roster->set_message(' ' . $method . ': ' . $msg . ' : ' . $x['reason'] . '<br>' . $url . ' ', 'Api call fail!', 'error');
         // update the tracker...
         /* this is not in the main roster install as of yet
         			$errornum = empty($data['response_headers']['http_code']) ? $data['response_headers']['http_code'] : '';
         			$q = "SELECT * FROM `" . $roster->db->table('api_error') . "` WHERE `error_info` = '".$params['name']."' AND `type` = '".$method."'";
         			$y = $roster->db->query($q);
         			$row = $roster->db->fetch($y);
         			if (!isset($row['total']))
         			{
         				$query = 'INSERT INTO `' . $roster->db->table('api_error') . '` VALUES ';
         				$query .= "('','".$method."','".$msg."','".$params['name']."','+1'); ";
         			}
         			else
         			{
         				$query = "Update `" . $roster->db->table('api_error') . "` SET `total`='".($row['total']+1)."' WHERE `type` = '".$method."' AND `error_info` = '".$params['name']."'";
         			}
         			$ret = $roster->db->query($query);
         			*/
         //throw new HttpException(json_decode($data['response'], true), $data['response_headers']['http_code']);
         //$this->seterrors(array('type'=>$method,'msg'=>''.$msg.'<br>'.$url.''));
         //$this->query['result'] = false; // over ride cache and set to false no data or no url no file lol
     }
     //$makecache
     if (isset($x['reason'])) {
         $this->seterrors(array('type' => $method, 'msg' => $x['reason']));
         $msg = $this->transhttpciode($data['response_headers']['http_code']);
         $roster->set_message(' ' . $method . ': ' . $msg . ' : ' . $x['reason'] . '<br>' . $url . ' ', 'Api call fail!', 'error');
         //$roster->set_message( ' '.$method.': '.$x['reason'].' ', 'Api call fail!', 'error' );
         $this->query['result'] = false;
         // over ride cache and set to false no data or no url no file lol
     }
     //print_r($data['response_headers']);
     $data = json_decode($data['response'], true);
     $info = $data;
     //$this->utf8_array_decode($data);
     return $info;
 }
Exemple #10
0
 /**
  * Basic query function
  *
  * @param $query Query string
  * @return mixed Query ID / Error string / Bool
  */
 function query($query)
 {
     // Remove pre-existing query resources
     unset($this->query_id);
     //$query = preg_replace('/;.*$/', '', $query);
     $this->querytime = format_microtime();
     if ($query != '') {
         $this->query_count++;
         $this->query_id = @mysql_query($query, $this->link_id);
     }
     if (!empty($this->query_id)) {
         if ($this->log_level > 0) {
             $this->_log($query);
         }
         unset($this->record[$this->query_id]);
         unset($this->record_set[$this->query_id]);
         return $this->query_id;
     } elseif ($this->error_die) {
         // I think we should use this method for dying
         die(__FILE__ . ': line[' . __LINE__ . ']<br />Database Error "' . $query . '"<br />MySQL said:<br />' . $this->error());
         //die_quietly($this->error(), 'Database Error',__FILE__,__LINE__,$query);
     } else {
         $this->_log($query);
         trigger_error('Database error. See query log for details', E_USER_NOTICE);
         return false;
     }
 }
Exemple #11
0
 /**
  * Basic query function
  *
  * @param $query Query string
  * @return mixed Query ID / Error string / Bool
  */
 function query($query)
 {
     global $roster;
     // Remove pre-existing query resources
     unset($this->query_id);
     //$query = preg_replace('/;.*$/', '', $query);
     $this->querytime = format_microtime();
     if ($query != '') {
         $this->query_count++;
         $this->query_id = @mysql_query($query, $this->link_id);
     }
     if (!empty($this->query_id)) {
         if ($this->log_level > 0) {
             $this->_log($query);
         }
         unset($this->record[$this->query_id]);
         unset($this->record_set[$this->query_id]);
         return $this->query_id;
     } elseif ($this->error_die) {
         die_quietly($this->error(), 'Database Error', __FILE__, __LINE__, $query);
     } else {
         $this->_log($query);
         trigger_error('Database error. See query log for details', E_USER_NOTICE);
         return false;
     }
 }
 /**
  * Информация о ресурсах потребляемых на каком-то участке кода
  * @param string $key Имя метки
  * @param bool $store Необходимо ли сохранить информацию о метке в памяти
  * @param bool $clear Нужно ли выполнить сброс меток
  */
 function point_info($key, $store = false, $clear = false)
 {
     static $marks = array();
     $out = array();
     if (is_scalar($key) && !empty($key)) {
         if ($store) {
             $marks[$key] = array('time' => microtime(true), 'memory' => memory_get_usage());
             $out = array('memory' => format_bytes($marks[$key]['memory']), 'time' => format_microtime($marks[$key]['time']));
         } else {
             $out = get_key($marks, $key, array('time' => get_key($_SERVER, 'REQUEST_TIME_FLOAT', 0), 'memory' => 0), 'is_array');
             $out['time'] = format_microtime(microtime(true) - $out['time']);
             $out['memory'] = format_bytes(memory_get_usage() - $out['memory']);
         }
     }
     if ($clear) {
         $marks = array();
     }
     return $out;
 }
Exemple #13
0
 /**
  * Basic query function
  *
  * @param $query Query string
  * @return mixed Query ID / Error string / Bool
  */
 function query($query)
 {
     // Remove pre-existing query resources
     unset($this->query_id);
     //$query = preg_replace('/;.*$/', '', $query);
     $this->querytime = format_microtime();
     try {
         if ($query != '') {
             $this->query_count++;
             //$this->query_id = $this->link_id->query($query);//, $this->link_id);
             //print_r($this->query_id);echo ' ~<br>';
             $this->query_id = $this->link_id->prepare($query);
             //print_r($res);echo ' ~~<br>';
             $this->query_id->execute();
             //print_r($this->query_id);echo ' ~~~<br>';
         }
         if (!empty($this->query_id)) {
             if ($this->log_level > 0) {
                 $this->_log($query);
             }
             unset($this->record[spl_object_hash($this->query_id)]);
             unset($this->record_set[spl_object_hash($this->query_id)]);
             return $this->query_id;
         }
     } catch (PDOException $e) {
         $err = "The statement failed.<br />";
         $err .= "getCode: " . $e->getCode() . "<br />";
         $err .= "getMessage: " . $e->getMessage() . "<br />";
         $this->queries[$this->file][$this->query_count]['error'] = $e->getMessage();
         //die(__FILE__ . ': line[' . __LINE__ . ']<br />Database Error "' . $query . '"<br />PDO said:<br />' .  $err . ' <br />' . $this->_backtrace());
     }
     /*
     if( $query != '' )
     {
     	$this->query_count++;
     	$this->query_id = $this->link_id->query($query);//, $this->link_id);
     	//print_r($this->query_id);
     }
     
     if( !empty($this->query_id) )
     {
     	if( $this->log_level > 0 )
     	{
     		$this->_log($query);
     	}
     	unset($this->record[spl_object_hash($this->query_id)]);
     	unset($this->record_set[spl_object_hash($this->query_id)]);
     	return $this->query_id;
     }
     else
     */
     if ($this->error_die) {
         // I think we should use this method for dying
         die(__FILE__ . ': line[' . __LINE__ . ']<br />Database Error "' . $query . '"<br />PDO said:<br />' . $this->errno());
         //die_quietly($this->error(), 'Database Error',__FILE__,__LINE__,$query);
     } else {
         $this->_log($query);
         trigger_error('Database error. See query log for details', E_USER_NOTICE);
         return false;
     }
 }
Exemple #14
0
<?php

/**
 * WoWRoster.net WoWRoster
 *
 * Contants and defines file for ArmorySync
 *
 * LICENSE: Licensed under the Creative Commons
 *          "Attribution-NonCommercial-ShareAlike 2.5" license
 *
 * @copyright  2002-2007 WoWRoster.net
 * @license    http://creativecommons.org/licenses/by-nc-sa/2.5   Creative Commons "Attribution-NonCommercial-ShareAlike 2.5"
 * @version    SVN: $Id$
 * @link       http://www.wowroster.net
 * @since      File available since Release 2.6.0
 * @package    ArmorySync
*/
if (!defined('IN_ROSTER')) {
    exit('Detected invalid access to this file!');
}
define('ARMORYSYNC_STARTTIME', isset($_POST['ARMORYSYNC_STARTTIME']) ? $_POST['ARMORYSYNC_STARTTIME'] : format_microtime());
define('ARMORYSYNC_CACHE', ROSTER_CACHEDIR);
define('ARMORYSYNC_VERSION', '1.0');
define('ARMORYSYNC_REQUIRED_ROSTER_VERSION', '2.1.9.2400');
Exemple #15
0
 *
 * LICENSE: Licensed under the Creative Commons
 *          "Attribution-NonCommercial-ShareAlike 2.5" license
 *
 * @copyright  2002-2008 WoWRoster.net
 * @license    http://creativecommons.org/licenses/by-nc-sa/2.5   Creative Commons "Attribution-NonCommercial-ShareAlike 2.5"
 * @version    SVN: $Id: footer.php 1791 2008-06-15 16:59:24Z Zanix $
 * @link       http://www.wowroster.net
 * @since      File available since Release 1.6.0
 * @package    WoWRoster
 */
if (!defined('IN_ROSTER')) {
    exit('Detected invalid access to this file!');
}
define('ROSTER_FOOTER_INC', true);
$totaltime = round(format_microtime() - ROSTER_STARTTIME, 2);
$error_report = $roster->error->stop();
// Assign template vars
$roster->tpl->assign_vars(array('S_PROCESSTIME' => $roster->config['processtime'], 'S_DEBUG_MODE' => $roster->config['debug_mode'] && is_array($error_report), 'S_SQL_WIN' => $roster->config['sql_window'], 'S_DESCRIBE' => $roster->config['sql_window'] == 2, 'PROCESSTIME' => $totaltime, 'QUERYCOUNT' => $roster->db->query_count, 'ROSTER_PATH' => ROSTER_PATH, 'ROSTER_BODY' => (!empty($roster->config['roster_bg']) ? ' style="background-image:url(' . $roster->config['roster_bg'] . ');"' : '') . (!empty($roster->output['body_attr']) ? ' ' . $roster->output['body_attr'] : ''), 'ROSTER_ONLOAD' => !empty($roster->output['body_onload']) ? $roster->output['body_onload'] : '', 'WEBSITE_ADDRESS' => $roster->config['website_address'], 'HEADER_LOGO' => $roster->config['logo'], 'IMG_URL' => $roster->config['img_url'], 'INTERFACE_URL' => $roster->config['interface_url'], 'ROSTER_VERSION' => $roster->config['version'], 'ROSTER_CREDITS' => sprintf($roster->locale->act['roster_credits'], makelink('credits'))));
if ($roster->config['debug_mode']) {
    if (is_array($error_report)) {
        foreach ($error_report as $file => $errors) {
            $roster->tpl->assign_block_vars('php_debug', array('FILE' => substr($file, strlen(ROSTER_BASE))));
            foreach ($errors as $error) {
                $roster->tpl->assign_block_vars('php_debug.row', array('ROW_CLASS' => $roster->switch_row_class(), 'ERROR' => $error));
            }
        }
    }
}
if ($roster->config['sql_window']) {
    if (count($roster->db->queries) > 0) {
Exemple #16
0
 function _showFooter()
 {
     global $roster, $addon;
     ////aprint($this->debugmessages[0]['ret']);
     $roster->tpl->assign_vars(array('IMAGE_PATH' => $addon['image_path'], 'ARMORYSYNC_VERSION' => $addon['version'] . ' by Ulminia', 'ARMORYSYNC_CREDITS' => $roster->locale->act['armorysync_credits'], 'ERROR' => count($this->errormessages) > 0, 'DEBUG' => $addon['config']['armorysync_debuglevel'], 'DEBUG_DATA' => $addon['config']['armorysync_debugdata'], 'D_START_BORDER' => border('sblue', 'start', 'ArmorySync Debugging ' . ($addon['config']['armorysync_debugdata'] ? 'Infos & Data' : 'Infos'), '100%'), 'E_START_BORDER' => border('sred', 'start', 'ArmorySync Error ' . ($addon['config']['armorysync_debugdata'] ? 'Infos & Data' : 'Infos'), '100%'), 'RUNTIME' => round(format_microtime() - ARMORYSYNC_STARTTIME, 4), 'S_SQL_WIN' => $addon['config']['armorysync_sqldebug']));
     $this->_debug(3, null, 'Printed footer', 'OK');
     if ($roster->switch_row_class(false) != 1) {
         $roster->switch_row_class();
     }
     foreach ($this->errormessages as $message) {
         $roster->tpl->assign_block_vars('e_row', array('FILE' => $message['file'], 'LINE' => $message['line'], 'TIME' => $message['time'], 'CLASS' => $message['class'], 'FUNC' => $message['function'], 'INFO' => $message['info'], 'STATUS' => $message['status'], 'ARGS' => aprint($message['args'], '', 1), 'RET' => aprint($message['ret'], '', 1), 'ROW_CLASS1' => $addon['config']['armorysync_debugdata'] ? 1 : $roster->switch_row_class(), 'ROW_CLASS2' => 1, 'ROW_CLASS3' => 1));
     }
     $roster->tpl->assign_var('E_STOP_BORDER', border('sred', 'end', '', ''));
     if ($roster->switch_row_class(false) != 1) {
         $roster->switch_row_class();
     }
     foreach ($this->debugmessages as $message) {
         $roster->tpl->assign_block_vars('d_row', array('FILE' => $message['file'], 'LINE' => $message['line'], 'TIME' => $message['time'], 'CLASS' => $message['class'], 'FUNC' => $message['function'], 'INFO' => $message['info'], 'STATUS' => $message['status'], 'ARGS' => aprint($message['args'], '', 1), 'RET' => aprint($message['ret'], '', 1), 'ROW_CLASS1' => $addon['config']['armorysync_debugdata'] ? 1 : $roster->switch_row_class(), 'ROW_CLASS2' => 1, 'ROW_CLASS3' => 1));
     }
     $roster->tpl->assign_var('D_STOP_BORDER', border('sblue', 'end', '', ''));
     if ($addon['config']['armorysync_sqldebug']) {
         if (count($roster->db->queries) > 0) {
             foreach ($roster->db->queries as $file => $queries) {
                 if (!preg_match('#[\\\\/]{1}addons[\\\\/]{1}armorysync[\\\\/]{1}inc[\\\\/]{1}[a-z_.]+.php$#', $file)) {
                     continue;
                 }
                 $roster->tpl->assign_block_vars('sql_debug', array('FILE' => substr($file, strlen(ROSTER_BASE))));
                 foreach ($queries as $query) {
                     $roster->tpl->assign_block_vars('sql_debug.row', array('ROW_CLASS' => $roster->switch_row_class(), 'LINE' => $query['line'], 'TIME' => $query['time'], 'QUERY' => nl2br(htmlentities($query['query']))));
                 }
             }
             $roster->tpl->assign_vars(array('SQL_DEBUG_B_S' => border('sgreen', 'start', $roster->locale->act['sql_queries']), 'SQL_DEBUG_B_E' => border('sgreen', 'end')));
         }
     }
     $roster->tpl->set_filenames(array('footer' => $addon['basename'] . '/footer.html'));
     $roster->tpl->display('footer');
 }
Exemple #17
0
 function page_tail()
 {
     global $DEFAULTS, $db;
     $this->assign_var('S_SHOW_BUTTON', true);
     if (sizeof($this->install_message) > 0) {
         $this->message_out(false);
     }
     if (sizeof($this->error_message) > 0) {
         $this->assign_var('S_SHOW_BUTTON', false);
         $this->error_message[0] = '<span style="font-weight:bold;font-size:14px;" class="negative">NOTICE</span>';
         $this->error_out(false);
     }
     $this->assign_vars(array('S_SHOW_DEBUG' => true, 'U_RENDERTIME' => substr(format_microtime() - ROSTER_STARTTIME, 0, 5), 'ROSTER_VERSION' => $DEFAULTS['version']));
     $this->assign_var('NOTICE', '');
     /*/ BETA ONLY, COMMENT THIS IN RC OR LATER!
     		if( file_exists(ROSTER_BASE . 'valid.inc') )
     		{
     			$v_content = '';
     			ob_start();
     				require (ROSTER_BASE . 'valid.inc');
     			$v_content = ob_get_clean();
     
     			$this->assign_var('NOTICE', $v_content);
     		}
     // END BETA ONLY */
     if (is_object($db)) {
         $db->close_db();
     }
     $this->set_handle('footer', 'install_tail.html');
     $this->display('header');
     $this->display('body');
     $this->display('footer');
     exit;
 }
<tr class="">
	<td><?php 
echo $stat->action;
?>
</td>
	<td><?php 
echo $stat->count;
?>
</td>
	<td><?php 
echo format_microtime($stat->time_min);
?>
</td>
	<td><?php 
echo format_microtime($stat->time_max);
?>
</td>
	<!--<td><?php 
echo format_microtime($stat->time_last);
?>
</td>-->
	<td><?php 
echo format_microtime($stat->count ? (int) ($stat->time_total / $stat->count) : 0);
?>
</td>
</tr>
Exemple #19
0
        $where = '`guild_id` = "' . $_GET['guild'] . '"';
    } elseif (strpos($_GET['guild'], '@') !== FALSE) {
        list($name, $realm) = explode('@', $_GET['guild']);
        if (strpos($realm, '-') !== FALSE) {
            list($region, $realm) = explode('-', $realm, 2);
            $where = '`guild_name` = "' . $name . '" ' . 'AND `server` = "' . $realm . '" ' . 'AND `region` = "' . strtoupper($region) . '" ';
        } else {
            $where = '`guild_name` = "' . $name . '" ' . 'AND `server` = "' . $realm . '" ';
        }
    } else {
        $name = $_GET['guild'];
        $where = '`guild_name` = "' . $name . '"';
    }
    $sql = "SELECT * FROM `roster_guild` WHERE " . $where . ";";
    $siggen = new SigGen($addon, 'bnr');
}
$result = $roster->db->query($sql);
$array = $roster->db->fetch($result, SQL_ASSOC);
foreach ($array as $index => $item) {
    $siggen->tag->add_tag(array('tag' => $index, 'data' => $item));
}
//$siggen->make_image();
if (isset($_GET['test'])) {
    $siggen->get_image();
    $siggen->finish();
} else {
    print $test_string . '<br/><br/>' . $siggen->tag->parse($test_string);
    $totaltime = round(format_microtime() - $starttime, 4);
    echo "<br /><br />{$totaltime}";
    aprint($array);
}