base_prefix . 'tokenmanager'; $TAB_TMV = $wpdb->base_prefix . 'tokenmanagerversions'; $TAB_TMT = $wpdb->base_prefix . 'tokenmanagertypes'; $TAB_TMTV = $wpdb->base_prefix . 'tokenmanagertypesversions'; $TAB_TMP = $wpdb->base_prefix . 'tokenmanagerpages'; $PLUGIN_ICON1 = plugin_dir_url( __FILE__ ) . 'icons/icon1_32.png'; $PLUGIN_ICON2 = plugin_dir_url( __FILE__ ) . 'icons/icon1_16.png'; $PLUGIN_TM_JSON_CALL = false; // Class for creating tokens class tokenmanager { // Variables private $buffer; private $tokens; // Properties public function set_buffer($_value) { $this->buffer = $_value; } public function get_buffer() { return $this->buffer; } // Construct the tokens class public function __construct() { ob_start(array($this, "obcallback")); } // Gets all the tokens into results. private function get_tokens() { global $post, $blog_id, $current_site, $OPTION_TM_INJECTURL, $TAB_TM, $TAB_TMP, $PLUGIN_TM_SITEID, $PLUGIN_TM_BLOGID, $PLUGIN_TM_PAGEID, $wpdb, $_SERVER; $PLUGIN_TM_SITEID = (isset($current_site) && isset($current_site->id)) ? $current_site->id : '0'; $PLUGIN_TM_BLOGID = (isset($blog_id) && isset($blog_id)) ? $blog_id : '0'; $PLUGIN_TM_PAGEID = (isset($post) && isset($post->ID)) ? $post->ID : '0'; // Check site id and blog main token $where = " a.siteid='$PLUGIN_TM_SITEID' AND a.blogid='$PLUGIN_TM_BLOGID' AND"; // Check site id and blog id $where .= " b.siteid='$PLUGIN_TM_SITEID' AND b.blogid='$PLUGIN_TM_BLOGID' AND"; // Check if file is frontpage if(is_front_page()) { $where = "$where b.pageid='0' OR $where b.pageid='-1'"; } else { $where = "$where b.pageid='-1' OR $where b.pageid='$PLUGIN_TM_PAGEID'"; } $this->tokens = $wpdb->get_results("SELECT DISTINCT a.tokenname as tokenname, a.id as id, a.htmlvalue as htmlvalue, a.phpvalue as phpvalue, a.cssvalue as cssvalue, a.jsvalue as jsvalue FROM $TAB_TM a LEFT JOIN $TAB_TMP b ON a.id = b.tokenid WHERE $where ORDER BY processorder DESC;", OBJECT_K); if($OPTION_TM_INJECTURL) { $host = (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST']))? $_SERVER['HTTP_HOST']: ''; $scheme = (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')?'https':'http'; $url = (isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI']))? $_SERVER['REQUEST_URI'] : ''; $uri = explode('?', $url); $uricount = count($uri); $query = ($uricount == 2 && isset($uri[1]) && !empty($uri[1])) ? $uri[1] : ''; $siteurl = "$scheme://$host"; $fullurl = $siteurl . $url; $urlpath = ($uricount > 0 && isset($uri[0]) && !empty($uri[0]))? $uri[0] : ''; $items = explode('/', $urlpath); $itemscount = count($items); $filecheck = array_pop($items); $filenameparts = explode('.', $filecheck); $filenamepartscount = count($filenameparts); $filename = ($filenamepartscount == 2 && isset($filenameparts[0]) && !empty($filenameparts[0])) ? $filenameparts[0] : ''; $fileext = ($filenamepartscount == 2 && isset($filenameparts[1]) && !empty($filenameparts[1])) ? $filenameparts[1] : ''; $fullfilename = (isset($filename) && !empty($filename) && isset($fileext) && !empty($fileext))? "$filename.$fileext" : ''; $req = new stdClass; $req->htmlvalue = false; $this->tokens['REQUEST_HASERRORS'] = $req; $req = new stdClass; $req->htmlvalue = $host; $this->tokens['REQUEST_HOST'] = $req; $req = new stdClass; $req->htmlvalue = $scheme; $this->tokens['REQUEST_SCHEME'] = $req; $req = new stdClass; $req->htmlvalue = $siteurl; $this->tokens['REQUEST_SITEURL'] = $req; $req = new stdClass; $req->htmlvalue = $fullurl; $this->tokens['REQUEST_FULLURL'] = $req; $req = new stdClass; $req->htmlvalue = $query; $this->tokens['REQUEST_QUERY'] = $req; $req = new stdClass; $req->htmlvalue = $urlpath; $this->tokens['REQUEST_URLPATH'] = $req; $req = new stdClass; $req->htmlvalue = $fullfilename; $this->tokens['REQUEST_FULLFILENAME'] = $req; $req = new stdClass; $req->htmlvalue = $filename; $this->tokens['REQUEST_FILENAME'] = $req; $req = new stdClass; $req->htmlvalue = $fileext; $this->tokens['REQUEST_FILEXT'] = $req; $req = new stdClass; $req->htmlvalue = get_template_directory(); $this->tokens['REQUEST_TEMPLATESPATH'] = $req; $req = new stdClass; $req->htmlvalue = get_bloginfo('template_url'); $this->tokens['REQUEST_TEMPLATESURL'] = $req; $req = new stdClass; $req->htmlvalue = $PLUGIN_TM_SITEID; $this->tokens['REQUEST_SITEID'] = $req; $req = new stdClass; $req->htmlvalue = $PLUGIN_TM_BLOGID; $this->tokens['REQUEST_BLOGID'] = $req; $req = new stdClass; $req->htmlvalue = $PLUGIN_TM_PAGEID; $this->tokens['REQUEST_PAGEID'] = $req; $req = new stdClass; $req->htmlvalue = is_front_page(); $this->tokens['REQUEST_ISFRONTPAGE'] = $req; } } // Parses the arguments of a query. private function parse_args($args) { $arg = array(); if(strstr($args, ',')) { $arglist = explode(',', $args); $tot = count($arglist); for($i = 0; $i<$tot; $i++) { $arg[] = urldecode(stripslashes(trim($arglist[$i], '\'" '))); } } else { $arg[] = trim($args, '\'" '); } return $arg; } // Handles php processing errors. private function php_error_handler($errormessage, $tokenname, $tokentype) { // Variables global $PLUGIN_ICON1; $html = ''; // Set haserror token $this->tokens['REQUEST_HASERRORS']->htmlvalue = true; return '
' . $code . ''; $html .= "" . htmlentities($key) . "$code"; } $html .= '