$value) { if ($ret != '') { $ret .= $config_content['menu_separator']; } if ($key == $_GET['page']) { $value = "$value"; } $ret .= "$value"; } return $ret; } function template_load($template_name, $replacements = '') { if (file_exists('templates/'.$template_name.'.tpl')) { $content = file_get_contents('templates/'.$template_name.'.tpl'); if (is_array($replacements)) { foreach ($replacements as $key => $value) { $content = str_replace('{%'.strtoupper($key).'%}',$value,$content); } } } return $content; } function template_msg($template_name, $replacements = '') { global $template_msgs; $content = $template_msgs[$template_name]; if (is_array($replacements)) { foreach ($replacements as $key => $value) { $content = str_replace('{%'.strtoupper($key).'%}',$value,$content); } } return $content; } function tpl_genoptions($array, $default = '') { if (is_array($array) ) { foreach ($array as $key => $value) { $ret .= ""; } } return $ret; } function template_genoptions($array, $default = '') { if (is_array($array) ) { foreach ($array as $key => $value) { $ret .= ""; } } return $ret; } function options_from_sql($query) { $res = sql_query($query); if (sql_notzero($res)) { while ($temp = sql_fetch($res)) { $array[$temp['op_key']] = $temp['op_value']; } } return $array; } function humane_datetime($uts) { if ($uts != 0) { return date('Y.m.d., G:i', $uts); } else { return "-"; } } class TemplateEngine { protected $_templates = ''; protected $_template_name = ''; public function __toString() { # Make sure, if the instance is called as a string (e.g. print $instance; ), it will execute this procedure. return $this->process(); } public function load_template($template_name) { # this will be used to identify the specific class' name, that inherited from this class (e.g. Lister will extend this class). $keyword = strtolower(get_called_class()); $this->_template_name = $template_name; $temp = file_get_contents("templates/{$keyword}_{$template_name}.tpl"); $subject = ''; $container = ''; # print $temp; foreach ( explode(PHP_EOL, $temp) as $line ) { if ( preg_match('/^::#.*::$/', $line, $matches) ) { # this was just a comment } elseif ( preg_match('/^::([a-z0-9_]*)::$/', $line, $matches) ) { if ( $subject != '' ) { send_debug(get_called_class().' -> '.__FUNCTION__, "Ending previous subject: $subject"); $this->_templates[$subject] = $container; } $subject = $matches[1]; send_debug(get_called_class().' -> '.__FUNCTION__, "Subject found: $subject"); $container = ''; } else { $container .= $line."\n"; } # print "$subject :: $line\n"; } if ( ($container != '') && ($subject != 'end') ) { send_debug(get_called_class().' -> '.__FUNCTION__, "Ending last subject: $subject"); $this->_templates[$subject] = $container; } } } class Lister extends TemplateEngine { protected $_items; protected $_item_count; protected $_session_tag = ''; protected $_template_group = ''; protected $_new_item_action = ''; protected $_empty_result_text = "Currently there are no items. Add new one?"; protected $_is_custom = 'no'; # how should we process(); protected $_custom_config; # generic config, like styles protected $_custom_def; # column definitions protected $_custom_column_nr = '0'; # well, obv. protected $_custom_two_pass_replace = 'no'; protected $_custom_sort; protected $_sorts; protected $_sort_default; protected $_sort_current; protected $_images; public function __construct( $session_tag = '', $template_name = '', $template_group = '') { if ( $session_tag != '') { $this->_session_tag = $session_tag; } # we can initialize with a template filename, to load it directly. if ( $template_name != '' ) { $this->load_template( $template_name ); } if ( $template_group != '') { $this->_template_group = $template_group . '_'; } } public function new_item_action( $link ) { $this->_new_item_action = $link; } public function define_column( $label, $name, $options = '') { # this function sets the definition of a custom column. Columns are defined by sequentially calling the function multiple times. # $options take 'key'=>'value' pairs, as well as keys only, which will be converted to 'key'=>'yes'. $this->_is_custom = 'yes'; $column_def['label'] = $label; $column_def['name'] = $name; if ( is_array( $options ) ) { foreach ($options as $key => $value) { if ( is_int($key) ) { $column_def[$value] = 'yes'; } else { $column_def[$key] = $value; } } } if ( $column_def['sortable'] == 'yes' ) { $this->_sorts[ $column_def['sort_key'] ]['asc'] = $column_def['sort_asc']; $this->_sorts[ $column_def['sort_key'] ]['desc'] = $column_def['sort_desc']; } if ($this->_custom_column_nr == '0') { $this->_custom_sort[] = "$name ASC"; } $this->_custom_def[] = $column_def; $this->_custom_column_nr++; } public function set_default_sort( $sort_key, $sort_dir ) { # if the table is initialized with this, it will use this if no other sorts are given $this->_sort_default['key'] = $sort_key; $this->_sort_default['dir'] = $sort_dir; } public function set_current_sort( $sort_key, $sort_dir ) { if ( $sort_key != '' && $sort_dir != '' ) { $this->_sort_current['key'] = $sort_key; $this->_sort_current['dir'] = $sort_dir; } } public function get_sort() { # get an SQL sort part based on what we have. if ( $this->_sort_current['key'] != '') { $sort = " ORDER BY " . $this->_sorts[ $this->_sort_current['key'] ][ $this->_sort_current['dir'] ]; } else { $sort = " ORDER BY " . $this->_sorts[ $this->_sort_default['key'] ][ $this->_sort_default['dir'] ]; } return $sort; } public function define_class( $target, $class1, $class2 = '') { if ( $target == 'header') { $this->_custom_config['class_header'] = $class1; } elseif ( $target == 'frame' ) { $this->_custom_config['class_frame'] = $class1; } elseif ( $target == 'item' ) { $this->_custom_config['class_item']['0'] = $class1; if ( $class2 != '') { $this->_custom_config['class_item']['1'] = $class2; } else { $this->_custom_config['class_item']['1'] = $class1; } } } public function define_image( $type, $location ) { if ( $type == 'sort_asc' ) { $this->_images['sort_asc'] = $location; } elseif ( $type == 'sort_desc' ) { $this->_images['sort_desc'] = $location; } elseif ( $type == 'sort_na' ) { $this->_images['sort_na'] = $location; } } public function additem( $data ) { $this->_items[] = $data; } public function process() { if ( $this->_is_custom == 'yes') { # print_r($this->_custom_def); if ( is_array($this->_items) ) { list($header_template, $item_template) = $this->generate_templates(); $content .= $header_template; $item_count = 0; foreach ( $this->_items as $one_item ) { # one line of data $current_item = $item_template; # print_r($one_item); # process the key->value pair for the actual item foreach ( $one_item as $key => $value ) { $current_item = str_replace('{%'.strtoupper($key).'_CONTENT%}', $value, $current_item); } if ( $this->_custom_two_pass_replace == 'yes' ) { foreach ( $one_item as $key => $value ) { $current_item = str_replace('{%'.strtoupper($key).'%}', $value, $current_item); } } $mod2 = ($item_count % 2); $item_class = $this->_custom_config['class_item'][$mod2]; $current_item = str_replace('{%CLASS_ITEM_MOD2%}', $item_class, $current_item); $content .= $current_item; $item_count++; } $content = "\n\n\n$content
\n"; } else { $content = $this->_empty_result_text; $content = str_replace('{%LINK%}', $this->_new_item_action, $content); } return $content; } else { if ($this->_items != '') { $content = $this->_templates[$this->_template_group . 'frame']; $content = str_replace('{%ITEMS%}', $this->_items, $content ); return $content; } else { return $this->_templates[$this->_template_group . 'empty']; } } } private function generate_templates() { $header_template = ""; $item_template = ""; # print_r($this->_custom_def); if ( $this->_sort_current['key'] != '') { $local_sort_key = $this->_sort_current['key']; $local_sort_dir = $this->_sort_current['dir']; } else { $local_sort_key = $this->_sort_default['key']; $local_sort_dir = $this->_sort_default['dir']; } foreach ( $this->_custom_def as $col ) { unset($additional_style); # set the header. if ( $col['width'] != '') { $additional_header_style = 'width: ' . $col['width'] . '; '; } if ( $additional_header_style != '') { $additional_header_style = "style='$additional_header_style' "; } if ( $col[hidden_header] != 'yes' ) { if ( $col['sortable'] == 'yes' ) { if ( $col['sort_key'] == $local_sort_key ) { if ( $local_sort_dir == 'asc' ) { $sort_icon = $this->_images['sort_asc']; $sort_link = "{%PHP_SELF%}?page={%PAGE%}&sort_by=" . $col['sort_key'] . "&sort_dir=desc"; } else { $sort_icon = $this->_images['sort_desc']; $sort_link = "{%PHP_SELF%}?page={%PAGE%}&sort_by=" . $col['sort_key'] . "&sort_dir=asc"; } } else { $sort_icon = $this->_images['sort_na']; $sort_link = "{%PHP_SELF%}?page={%PAGE%}&sort_by=" . $col['sort_key'] . "&sort_dir=asc"; } $header_template .= " " . $col['label'] . " \n"; } else { $header_template .= " " . $col['label'] . "\n"; } } else { $header_template .= "  \n"; } # handle additional styles. may be better to do this in a separate funcion in the future. if ( $col['align'] == 'right') { $additional_style .= "text-align: right; "; } elseif ( $col['align'] == 'left' ) { $additional_style .= "text-align: left; "; } elseif ( $col['align'] == 'center' ) { $additional_style .= "text-align: center; "; } if ( $additional_style != '') { $additional_style = "style='$additional_style' "; } $item_content = "{%". strtoupper($col['name']) . "_CONTENT%}"; $item_link = "{%" . strtoupper($col['name']) . "_LINK%}"; if ( $col['content'] != '') { $item_content = $col['content']; $this->_custom_two_pass_replace = 'yes'; } if ( $col['link'] != '') { $item_link = $col['link']; $this->_custom_two_pass_replace = 'yes'; } if ( $col['link_target'] != '' ) { $item_link_target = $col['link_target']; } if ( $col['type'] == '' ) { $item_template .= " $item_content\n"; } elseif ( $col['type'] == 'link' ) { if ( $item_link_target == '' ) { $item_template .= " $item_content\n"; } else { $item_template .= " $item_content\n"; } } } $header_template .= "\n"; $item_template .= "\n"; return array( $header_template, $item_template ); } public function add_item($replacements = '') { # Kind of decrepated. if ($this->_templates[$this->_template_group . 'item'] != '') { $content = $this->_templates[$this->_template_group . 'item']; if (is_array($replacements)) { foreach ($replacements as $key => $value) { $content = str_replace('{%'.strtoupper($key).'%}', $value, $content); } } $content = str_replace('{%MOD2%}', ($this->_item_count % 2), $content ); $this->_items .= $content; $this->_item_count++; } else { send_debug(get_called_class().' -> '.__FUNCTION__, "ERROR: Lister: No 'item' segment is defined in template: " . $this->_template_name); } } } class Former extends TemplateEngine { protected $_frame = 'frame'; protected $_items = ''; protected $_datahash = ''; protected $_defaults = ''; protected $_error_messages = ''; protected $_form_title = ''; protected $_form_action = ''; protected $_form_replacements; protected $_id = ''; protected $_skip_replacement_clear = array('{%PHP_SELF%}', '{%PAGE%}'); public function __construct( $template_name = '', $frame_template_name = '' ) { $this->_defaults['input']['size'] = '64'; # we can initialize with a template filename, to load it directly. if ( $template_name != '' ) { $this->load_template( $template_name ); } # we allow to override the default 'frame' template, but will still default to 'frame' if ( $frame_template_name != '') { $this->_frame = $frame_template_name; } } public function set_title( $title ) { $this->_form_title = $title; } public function set_frame( $frame_template_name ) { $this->_frame = $frame_template_name; } public function set_form_action( $action ) { $this->_form_action = $action; } public function set_id( $id ) { $this->_id = $id; } public function add_error_message( $message ) { $this->_error_messages[] = $message; } public function add_replacement( $pattern, $value ) { $this->_form_replacements[$pattern] = $value; } public function additem( $type, $label, $name, $value = '', $extra = '' ) { if ( $this->_templates[$type] != '' ) { # look for properties in the $extra if ( is_array($extra) ) { foreach ( $extra as $t_key => $t_value ) { if ( preg_match('/^(prop|property):(.*)$/', $t_key, $matches) ) { $property_values[$matches[2]] = $t_value; $properties .= " ${matches[2]}=\"$t_value\""; } } } if ( ($type == 'input') && ($property_values['size'] == '') ) { $property_values['size'] = $this->_defaults['input']['size']; $properties .= ' size="'.$property_values['size'].'"'; } $content = $this->_templates[$type]; # we process this, so e.g. {%POSTFIX%} can contain references to {%NAME%}, etc. # also, we need to do it twice, so back references will be translated properly. nesting suxx if ( is_array($extra) ) { for ($i = 0; $i < 2; $i++) { foreach ($extra as $t_key => $t_value) { $content = str_replace('{%'.strtoupper($t_key).'%}', $t_value, $content); } } } $content = str_replace('{%LABEL%}', $label, $content ); $content = str_replace('{%NAME%}', $name, $content ); $content = str_replace('{%VALUE%}', $value, $content ); if ( $type == 'checkbox' ) { if (($value != '') && ($value == $extra['checked_value'])) { $content = str_replace('{%CHECKED%}', 'checked', $content ); } } $content = str_replace('{%PROPERTIES%}', $properties, $content ); # purge unset macros # $content = preg_replace('/{%[a-zA-Z0-9_]*%}/', '', $content); preg_match_all('/({%[a-zA-Z0-9_]*%})/', $content, $matches, PREG_SET_ORDER); foreach ( $matches as $one_match ) { if ( in_array($one_match[0], $this->_skip_replacement_clear) ) { continue; } # print $one_match[0]."
"; $content = str_replace($one_match[0], '', $content); } $this->_items .= $content; } else { send_debug(get_called_class().' -> '.__FUNCTION__, "ERROR: Former: No '{$type}' type is defined in template: " . $this->_template_name); } } public function fill_data( $data ) { if ( is_array($data) ) { foreach ($data as $key => $value) { $this->_datahash[$key] = $value; } } # print_r($this->_datahash); } public function additems_from_sheet( $form_sheet ) { $temp = file_get_contents("templates/former_{$form_sheet}.form"); foreach ( explode(PHP_EOL, $temp) as $line ) { if ( $line != '' ) { $el = explode(':', $line); if ($el[3] != '') { foreach (explode(',', $el[3]) as $t_extra) { $t_vals = explode('=', $t_extra); $extra[$t_vals[0]] = $t_vals[1]; } } switch( $el[0] ) { case 'title': $this->set_title($el[1]); break; case 'form_action': $this->set_form_action($el[1]); break; default: $this->additem($el[0], $el[1], $el[2], $this->_datahash[$el[2]], $extra); } } } } public function process() { # $content = $this->_templates['frame']; $content = $this->_templates[ $this->_frame ]; $content = str_replace('{%FORM_TITLE%}', $this->_form_title, $content ); $content = str_replace('{%FORM_ACTION%}', $this->_form_action, $content ); if ( is_array($this->_error_messages) ) { foreach ($this->_error_messages as $t_error) { $temp = $this->_templates['error_message_item']; $temp = str_replace('{%MSG%}', $t_error, $temp); $temp_error .= $temp; } $content = str_replace('{%ERROR_MESSAGES%}', $temp_error, $content ); } else { $content = str_replace('{%ERROR_MESSAGES%}', '', $content ); } $content = str_replace('{%ITEMS%}', $this->_items, $content ); $content = str_replace('{%ID%}', $this->_id, $content ); if (is_array($this->_form_replacements)) { foreach ($this->_form_replacements as $pattern => $value) { $content = str_replace('{%'.strtoupper($pattern).'%}', $value, $content ); } } # purge unset macros # $content = preg_replace('/{%[a-zA-Z0-9_]*%}/', '', $content); return $content; } public function flush_items() { $this->_items = ''; } } ?> prepare($query); # stmt = statement if($stmt === false) { print 'Wrong SQL: ' . $sql . ' Error: ' . $conn->errno . ' ' . $conn->error; } # bind is a pain in the arse. hack from http://www.pontikis.net/blog/dynamically-bind_param-array-mysqli $aref[] = & $query_bind; foreach ($data as $key => $value) { $aref[] = & $data[$key]; } call_user_func_array(array($stmt, 'bind_param'), $aref); $res = $stmt->execute(); $last_id = $stmt->insert_id; $conn->close(); return $last_id; } } function sql_safe_update($table, $data, $where) { global $db; if (($table != '') && (is_array($data)) && ($where != '')) { $query_fields = '`' . implode('` = ?, `', array_keys($data)) . '` = ?'; $query_bind = str_repeat('s', count(array_keys($data))); $query = "UPDATE $table SET $query_fields WHERE $where"; $conn = new mysqli($db[host], $db[username], $db[password], $db[dbname]); $stmt = $conn->prepare($query); # bind is a pain in the arse. hack from http://www.pontikis.net/blog/dynamically-bind_param-array-mysqli $aref[] = & $query_bind; foreach ($data as $key => $value) { $aref[] = & $data[$key]; } call_user_func_array(array($stmt, 'bind_param'), $aref); $res = $stmt->execute(); $conn->close(); } } function sql_fetch($res) { $hash = mysql_fetch_assoc($res); return $hash; } function sql_numrows($res) { return mysql_numrows($res); } function sql_notzero($res) { if (mysql_numrows($res) != 0) { return true; } else { return false; } } function sql_lastid() { return mysql_insert_id(); } ?> ", ">", $text); $text = str_replace("\"", """, $text); $text = str_replace("'", "'", $text); $text = str_replace("_", "", $text); $text = str_replace("%", "", $text); $text = str_replace("*", "", $text);*/ return $text; } ### inter-module messaging function imm_send($subject, $message) { global $intermodule_messages; $intermodule_messages[$subject] = $message; } function imm_get($subject) { global $intermodule_messages; if ($intermodule_messages[$subject] != '') { return $intermodule_messages[$subject]; } } ### debug function send_debug($module, $msg) { global $debug; $debug[$module][] = $msg; } function print_debug($module = '') { global $debug; print "
";
	print_r($debug);
	print "
"; } ### curl function http_fetch_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if ( preg_match('/^https:/', $url) ) { ### fixme: this is a hazard, will need fix curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } $content = curl_exec($ch); curl_close($ch); return $content; } function module_debug() { if ( $_GET['action'] == 'clear') { $_SESSION['tumblr_pending'] = array(); $_SESSION['tumblr'] = array(); } $ret .= "

_SESSION

"; $ret .= "
";
	$ret .= print_r($_SESSION, true);
	$ret .= "
"; $ret .= "

_SERVER

"; $ret .= "
";
	$ret .= print_r($_SERVER, true);
	$ret .= "
"; return $ret; } ?>Core ERROR: Module not found: {%MODULENAME%}

"; $template_msgs['core_redirect'] = ""; ?>members) > 0 ) { foreach( $jres->members as $char ) { $data['region'] = $config['mini_wow_armory']['region']; $data['realm'] = $char->character->realm; $data['guild_name'] = $char->character->guild; $data['name'] = $char->character->name; $data['class'] = $config['mini_wow_armory']['classes'][ $char->character->class ]; $data['level'] = $char->character->level; $data['guild_rank'] = $char->rank; $data['guild_rank_name'] = $config['mini_wow_armory']['guild_rank'][ $char->rank ]; $data['race'] = $config['mini_wow_armory']['races'][ $char->character->race ]; $data['gender'] = $config['mini_wow_armory']['genders'][ $char->character->gender ]; $data['achievement_points'] = $char->character->achievementPoints; $data['armory_thumbnail'] = $char->character->thumbnail; # It's possible, that the new guild is not updated for the new joiners. But if they are returned by the guild member query, then they are member of the guild, rite'? if ( $data['guild_name'] == '' ) { $data['guild_name'] = $guild_name; } $members[] = $data; unset($data); # flush collected info. } } return $members; } function mini_wow_armory_get_character_info( $region, $realm, $name, $query = 'items,audit' ) { global $config; $url = "https://" . $region . ".api.battle.net/wow/character/" . $realm . "/" . $name . "?fields=" . $query . "&locale=" . $config['mini_wow_armory']['locale'] . "&apikey=" . $config['mini_wow_armory']['apikey']; $jres = json_decode( http_fetch_content( $url ) ); # get itemlevel $data['item_level'] = $jres->items->averageItemLevelEquipped; if ( $data['item_level'] == '' ) { $data['item_level'] = '0'; } # long time not logged in. FIXME # audit items $data['empty_sockets'] = $jres->audit->emptySockets; $enchant_audit = array('neck', 'back', 'finger1', 'finger2'); foreach ( $enchant_audit as $slot ) { if ( $jres->items->$slot->tooltipParams->enchant == '' ) { $data['missing_enchants'][] = $slot; $data['missing_enchants_text'] .= '  ' . ucfirst( $slot ) . '
'; } } if ( $jres->level >= $config['mini_wow_armory']['require_audit_at_level'] ) { if ( $data['missing_enchants_text'] != '' ) { $data['audit'] = 'Missing enchants:
' . $data['missing_enchants_text']; } if ( $data['empty_sockets'] > 0 ) { $data['audit'] .= 'Empty sockets:
  ' . $data['empty_sockets']; } if ( $data['audit'] == '' ) { $data['audit'] = 'ok'; } } else { $data['audit'] = 'n/a'; } # fingerprints to detect characters on the same accounts # all pets if ( is_array( $jres->pets->collected ) ) { foreach ( $jres->pets->collected as $p_item ) { $coll_p .= $p_item->battlePetGuid . ','; } $data['fingerprint_pets'] = hash( 'md5', $coll_p ); } else { $data['fingerprint_pets'] = 'n/a'; } # pet slots if ( is_array( $jres->petSlots ) ) { foreach ( $jres->petSlots as $ps_item ) { $coll_ps .= $ps_item->battlePetGuid . ','; foreach ( $ps_item->abilities as $psa_item ) { $coll_ps .= $psa_item . ','; } } $data['fingerprint_petslots'] = hash( 'md5', $coll_ps ); } else { $data['fingerprint_petslots'] = 'n/a'; } ### # print 'pets: ' . $data['fingerprint_pets'] . '
'; # print 'petslots: ' . $data['fingerprint_petslots'] . '
'; # print 'ps:' . $coll_ps . '
'; # print "
".print_r($jres, 1)."
"; return $data; } function module_mini_wow_armory_guild_list () { global $config; if ( $_GET['sort_by'] != '' ) { $sort_by = $_GET['sort_by']; } if ( $_POST['sort_by'] != '' ) { $sort_by = $_POST['sort_by']; } if ( $_GET['sort_dir'] != '' ) { $sort_dir = $_GET['sort_dir']; } if ( $_POST['sort_dir'] != '' ) { $sort_dir = $_POST['sort_dir']; } $list = new Lister('mini_wow_armory_guild_list'); $list->define_class( 'frame', 'armory_list_table' ); $list->define_class( 'header', 'armory_list_table_header' ); $list->define_class( 'item', 'armory_list_table_row0', 'armory_list_table_row1' ); $list->define_image( 'sort_asc', 'images/armory/icon_sort_asc.png'); $list->define_image( 'sort_desc', 'images/armory/icon_sort_desc.png'); $list->define_image( 'sort_na', 'images/armory/icon_sort_none.png'); $list->set_default_sort('guild_rank', 'asc'); $list->set_current_sort($sort_by, $sort_dir); $list->define_column( 'Name', 'name_colored', array('align' => 'left', 'sortable', 'sort_key' => 'name', 'sort_asc' => 'name ASC', 'sort_desc' => 'name DESC') ); $list->define_column( 'Level', 'level', array('align' => 'right', 'sortable', 'sort_key' => 'level', 'sort_asc' => 'level DESC, name ASC', 'sort_desc' => 'level ASC, name ASC') ); $list->define_column( ' ', 'race_gender_icon', array('') ); $list->define_column( 'Class', 'class_icon', array('align' => 'center', 'sortable', 'sort_key' => 'class', 'sort_asc' => 'class ASC, name ASC', 'sort_desc' => 'class DESC, name ASC') ); $list->define_column( 'Rank', 'guild_rank', array( 'sortable', 'sort_key' => 'guild_rank', 'sort_asc' => 'guild_rank ASC, level DESC, name ASC', 'sort_desc' => 'guild_rank DESC, level DESC, name ASC') ); $list->define_column( 'Audit', 'audit_details', array('align' => 'center') ); $list->define_column( 'Item level', 'item_level', array('align' => 'right', 'sortable', 'sort_key' => 'item_level', 'sort_asc' => 'item_level DESC, name ASC', 'sort_desc' => 'item_level ASC, name ASC') ); $list->define_column( 'Ach. Points', 'achievement_points', array('align' => 'right', 'sortable', 'sort_key' => 'achievement_points', 'sort_asc' => 'achievement_points DESC, name ASC', 'sort_desc' => 'achievement_points ASC, name ASC') ); $list->define_column( 'Last update', 'datetime_last_update_date', array( 'sortable', 'sort_key' => 'last_update', 'sort_asc' => 'uts_last_update DESC, name ASC', 'sort_desc' => 'uts_last_update ASC, name ASC') ); $list->define_column( ' ', 'datetime_last_update_time', array('') ); $list->define_column( 'Update', 'manual_update', array( 'hidden_header', 'type'=>'link', 'link_target' => '_blank', 'content' => "", 'link' => "{%PHP_SELF%}?page=guild_list_refresh&action=guild_member_refresh&id={%ID%}") ); $list->define_column( 'Update', 'manual_update', array( 'hidden_header', 'type'=>'link', 'link_target' => '_blank', 'content' => "", 'link' => "http://".$config['mini_wow_armory']['region'].".battle.net/wow/en/character/".$config['mini_wow_armory']['realm']."/{%NAME%}/advanced") ); $list->define_column( 'Main', 'char_join_name', array( 'sortable', 'sort_key' => 'char_join_name', 'sort_asc' => 'char_join_name ASC, guild_rank ASC, name ASC', 'sort_desc' => 'char_join_name DESC, guild_rank ASC, name ASC') ); $res = sql_query("SELECT * FROM mini_wow_armory_guild_members WHERE status='active' OR status='pending_audit' " . $list->get_sort() ); if ( sql_notzero($res) ) { while ( $data = sql_fetch($res) ) { if ( $sort_by == 'char_join_name' ) { if ( $data['name'] != $data['char_join_name'] ) { $data['name_colored'] = "
   " . $data['name'] . "
"; } else { $data['name_colored'] = "
" . $data['name'] . "
"; } } else { $data['name_colored'] = "
" . $data['name'] . "
"; } $data['guild_rank'] = $config['mini_wow_armory']['guild_rank'][ $data['guild_rank'] ]; $data['class_icon'] = "" . ucfirst( $data["; $data['race_gender_icon'] = "" . ucfirst( $data["; $data['achievement_points'] .= " "; $data['datetime_last_update_date'] = date( 'Y.M.j', $data['uts_last_update'] ); $data['datetime_last_update_time'] = date( 'H:i:s', $data['uts_last_update'] ); if ( $data['audit'] == '' ) { $data['audit_details'] = '?'; } elseif ( $data['audit'] == 'n/a' ) { $data['audit_details'] = '-'; } elseif ( $data['audit'] == 'ok' ) { $data['audit_details'] = ""; } else { $data['audit_details'] = "
" . $data['audit'] . "
"; } $list->additem( $data ); } } $ret .= $list->process(); return $ret; } function module_mini_wow_armory_guild_list_refresh () { global $config; if ( $_GET['action'] != '' ) { $action = $_GET['action']; } if ( $_POST['action'] != '' ) { $action = $_POST['action']; } if ( $action == '' ) { print "moo"; } elseif ( $action == 'guild_list_refresh') { $members = mini_wow_armory_get_guild_member_list( $config['mini_wow_armory']['region'], $config['mini_wow_armory']['realm'], $config['mini_wow_armory']['guild'] ); $res = sql_query( "UPDATE mini_wow_armory_guild_members SET status='pending_guildlist_update', guild_name='' "); if ( count( $members) > 0 ) { foreach( $members as $char ) { # print_r($char); $res = sql_query("SELECT id FROM mini_wow_armory_guild_members WHERE name='" . $char['name'] . "'"); if ( sql_notzero($res) ) { $data = sql_fetch($res); mini_wow_armory_guild_member_update( $data['id'], $char ); $ret .= "Updating: " . $char['name'] . "
"; } else { mini_wow_armory_guild_member_add( $char ); $ret .= "Inserting: " . $char['name'] . "
"; } } $ret .= "Done
\n"; $upd = sql_query("UPDATE mini_wow_armory_guild_members SET is_outside_guild='no' WHERE guild_name='" . $config['mini_wow_armory']['guild'] . "'"); $upd = sql_query("UPDATE mini_wow_armory_guild_members SET is_outside_guild='yes' WHERE guild_name=''"); $upd = sql_query("UPDATE mini_wow_armory_guild_members SET status='active' WHERE level < " . $config['mini_wow_armory']['require_audit_at_level'] ); $upd = sql_query("UPDATE mini_wow_armory_guild_members SET status='pending_audit' WHERE level >= " . $config['mini_wow_armory']['require_audit_at_level'] ); } } elseif ( $action == 'guild_member_refresh' ) { if ( $_GET['id'] != '' ) { $id = $_GET['id']; } if ( $_POST['id'] != '' ) { $id = $_POST['id']; } $res = sql_query("select name from mini_wow_armory_guild_members WHERE id='$id'"); if ( sql_notzero($res) ) { $data = sql_fetch($res); $results = mini_wow_armory_get_character_info( $config['mini_wow_armory']['region'], $config['mini_wow_armory']['realm'], $data['name'], 'items,audit,pets,petSlots' ); $upd = sql_query("UPDATE mini_wow_armory_guild_members SET item_level='" . $results['item_level'] . "', audit='" . $results['audit'] . "', fingerprint_pets='" . $results['fingerprint_pets'] . "', fingerprint_petslots='" . $results['fingerprint_petslots'] . "', status='active', uts_last_update='".time()."' WHERE id='$id'"); $ret .= "Auditing: " . $data['name'] . "
"; } else { $ret .= "Character with id '$id' not found!"; } } elseif ( $action == 'mass_refresh' ) { set_time_limit(300); $batch_size = $config['mini_wow_armory']['mass_refresh_batch_size']; if ( $batch_size == '' || $batch_size > 90 ) { $batch_size = 50; } $res = sql_query("select id, name from mini_wow_armory_guild_members WHERE status='pending_audit' ORDER BY guild_rank ASC LIMIT $batch_size"); if ( sql_notzero( $res ) ) { while ( $data = sql_fetch( $res ) ) { $results = mini_wow_armory_get_character_info( $config['mini_wow_armory']['region'], $config['mini_wow_armory']['realm'], $data['name'], 'items,audit,pets,petSlots' ); $upd = sql_query("UPDATE mini_wow_armory_guild_members SET item_level='" . $results['item_level'] . "', audit='" . $results['audit'] . "', fingerprint_pets='" . $results['fingerprint_pets'] . "', fingerprint_petslots='" . $results['fingerprint_petslots'] . "', status='active', uts_last_update='".time()."' WHERE id='" . $data['id'] . "'"); $ret .= "Auditing: " . $data['name'] . "
"; } } } elseif ( $action == 'align_by_account' ) { $res = sql_query("SELECT distinct(fingerprint_pets) as fingerprint FROM mini_wow_armory_guild_members WHERE fingerprint_pets != 'n/a'"); if ( sql_notzero( $res ) ) { while ( $data = sql_fetch( $res ) ) { $main = ''; $sub_res = sql_query("SELECT name FROM mini_wow_armory_guild_members WHERE fingerprint_pets='".$data['fingerprint']."' ORDER BY guild_rank ASC LIMIT 1"); $fingerprint_data = sql_fetch( $sub_res ); sql_query("UPDATE mini_wow_armory_guild_members SET char_join_name='" . $fingerprint_data['name'] . "' WHERE fingerprint_pets='".$data['fingerprint']."'"); } } $res = sql_query("SELECT id, name FROM mini_wow_armory_guild_members WHERE fingerprint_pets='n/a'"); if ( sql_notzero($res) ) { while ( $data = sql_fetch( $res ) ) { sql_query("UPDATE mini_wow_armory_guild_members SET char_join_name='" . $data['name'] . "' WHERE id='" . $data['id'] . "'"); } } } return $ret; } function mini_wow_armory_guild_member_add ( $data ) { global $config; $data['uts_last_update'] = time(); $res_id = sql_safe_insert('mini_wow_armory_guild_members', $data ); } function mini_wow_armory_guild_member_update ( $id, $data ) { global $config; unset($data['region']); unset($data['name']); unset($data['class']); $data['uts_last_update'] = time(); $res_id = sql_safe_update('mini_wow_armory_guild_members', $data, "id='$id'"); } ?> $key ) { if ( $page == $item ) { $image = $config['guild_page']['menu'][$item]['active']; $link = "{%PHP_SELF%}?page=$item"; } else { $image = $config['guild_page']['menu'][$item]['inactive']; $link = "{%PHP_SELF%}?page=$item"; } $ret .= "\n"; } return $ret; } ?> data[0] // $user_search->data[0]->id - User ID // $user_search->data[0]->first_name - User First name // $user_search->data[0]->last_name - User Last name // $user_search->data[0]->profile_picture - User Profile Picture URL // $user_search->data[0]->username - Username ##print_r($user_search); ## $user_id = $user_search->data[0]->id; // or use string 'self' to get your own media # $user_id = '224950587'; function module_instagram_gallery () { $access_token = '224950587.1f8f643.6a4a74e5e2bd40299c927e474a40bfd3'; #$user_id = '1108104717'; $user_id = 'self'; $return = rudr_instagram_api_curl_connect("https://api.instagram.com/v1/users/" . $user_id . "/media/recent?access_token=" . $access_token); // var_dump( $return ); // if you want to display everything the function returns #$ret .= print_r($return, 1); # if ( defined( $return->data ) ) { foreach ($return->data as $post) { # $ret .= ''; $ret .= '
'; $ret .= date('Y.m.d', $post->created_time) . "
"; } # } $ret .= "

"; return $ret; } ?>