function doSkinVar($skinType, $numOfPostsToShow) { global $blog; if ($numOfPostsToShow <= 0) { $numOfPostsToShow = 10; } $q = "SELECT inumber as id, ititle as title, " . "citem,COUNT(cnumber) as num_of_comments, " . "SUM(SubComment.cVal)*POW(COUNT(cnumber),2)*MAX(SubComment.iVal) as CurrentVal " . "FROM ( " . "SELECT *, " . "SQRT(1.0 / POW((DATEDIFF(c.ctime,CURDATE()) / 365),2)) as cVal," . "SQRT(1.0 / POW((DATEDIFF(i.itime,CURDATE()) / 365),2)) as iVal " . "FROM " . sql_table('comment') . " as c " . "INNER JOIN " . sql_table('item') . " as i " . "ON i.inumber=c.citem) as SubComment " . "GROUP BY inumber, ititle " . "ORDER BY `CurrentVal` DESC " . "LIMIT 0, " . intval($numOfPostsToShow); $res = mysql_query($q); echo $this->getOption('header'); $link_templ = $this->getOption('link'); while ($row = mysql_fetch_array($res)) { $out = str_replace("%l", createItemLink($row[id]), $link_templ); $out = str_replace("%p", $row['title'], $out); $out = str_replace("%c", $row['num_of_comments'], $out); $out = str_replace("%s", $row['CurrentVal'], $out); echo $out; } echo $this->getOption('footer'); }
function _createItemLink($itemid) { global $CONF, $manager, $blog; $blogid = getBlogIDFromItemID($itemid); $b =& $manager->getBlog($blogid); $blogurl = $b->getURL(); if (!$blogurl) { if ($blog) { $b_tmp =& $manager->getBlog($CONF['DefaultBlog']); $blogurl = $b_tmp->getURL(); } if (!$blogurl) { $blogurl = $CONF['IndexURL']; if ($CONF['URLMode'] != 'pathinfo') { $blogurl = $CONF['Self']; } } } if ($CONF['URLMode'] == 'pathinfo') { $blogurl = preg_replace('/\\/$/', '', $blogurl); } $CONF['ItemURL'] = $blogurl; return createItemLink($itemid); }
function sendNewItemNotification($itemid, $title, $body) { global $CONF, $member; // create text version of html post $ascii = toAscii($body); $mailto_msg = _NOTIFY_NI_MSG . " \n"; // $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n"; $temp = parse_url($CONF['Self']); if ($temp['scheme']) { $mailto_msg .= createItemLink($itemid) . "\n\n"; } else { $tempurl = $this->getURL(); if (substr($tempurl, -1) == '/' || substr($tempurl, -4) == '.php') { $mailto_msg .= $tempurl . '?itemid=' . $itemid . "\n\n"; } else { $mailto_msg .= $tempurl . '/?itemid=' . $itemid . "\n\n"; } } $mailto_msg .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n"; $mailto_msg .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n"; $mailto_msg .= getMailFooter(); $mailto_title = $this->getName() . ': ' . _NOTIFY_NI_TITLE; $frommail = $member->getNotifyFromMailAddress(); $notify =& new NOTIFICATION($this->getNotifyAddress()); $notify->notify($mailto_title, $mailto_msg, $frommail); }
function doAction($type = '') { global $CONF, $manager; if (!$type) { $type = 'google'; } if ($type !== 'google' && $type !== 'yahoo') { return; } $sitemap = array(); $blog_res = sql_query('SELECT * FROM ' . sql_table('blog')); while ($blog = sql_fetch_array($blog_res)) { if ($this->getBlogOption($blog['bnumber'], 'IncludeSitemap') == 'yes') { if ($blog['bnumber'] != $CONF['DefaultBlog']) { $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createBlogidLink($blog['bnumber'])), 'priority' => '1.0', 'changefreq' => 'daily'); } else { $sitemap[] = array('loc' => $blog['burl'], 'priority' => '1.0', 'changefreq' => 'daily'); } $params = array(sql_table('category'), $blog['bnumber']); $cat_res = sql_query(vsprintf('SELECT * FROM %s WHERE cblog=%s ORDER BY catid', $params)); while ($cat = sql_fetch_array($cat_res)) { $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createCategoryLink($cat['catid'])), 'priority' => '1.0', 'changefreq' => 'daily'); } $b =& $manager->getBlog($blog['bnumber']); $item_res = sql_query(' SELECT *, UNIX_TIMESTAMP(itime) AS timestamp FROM ' . sql_table('item') . ' WHERE iblog = ' . $blog['bnumber'] . ' AND idraft = 0 AND itime <= ' . mysqldate($b->getCorrectTime()) . ' ORDER BY inumber DESC '); $now = $_SERVER['HTTP_REQUEST_TIME']; while ($item = sql_fetch_array($item_res)) { $tz = date('O', $item['timestamp']); $tz = substr($tz, 0, 3) . ':' . substr($tz, 3, 2); $pasttime = $now - $item['timestamp']; if ($pasttime < 86400 * 2) { $fq = 'hourly'; } elseif ($pasttime < 86400 * 14) { $fq = 'daily'; } elseif ($pasttime < 86400 * 62) { $fq = 'weekly'; } else { $fq = 'monthly'; } $sitemap[] = array('loc' => $this->_prepareLink($blog['bnumber'], createItemLink($item['inumber'])), 'lastmod' => gmdate('Y-m-d\\TH:i:s', $item['timestamp']) . $tz, 'priority' => '1.0', 'changefreq' => $fq); } } } $eventdata = array('sitemap' => &$sitemap); $manager->notify('SiteMap', $eventdata); if ($type == 'google') { header("Content-type: application/xml"); echo "<?xml version='1.0' encoding='UTF-8'?>\n\n"; echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' "; echo "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "; echo "xsi:schemaLocation='http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'>\n"; $tpl = "\t\t<%s>%s</%s>\n"; foreach ($sitemap as $url) { echo "\t<url>\n"; foreach ($url as $key => $value) { echo sprintf($tpl, $key, htmlspecialchars($value, ENT_QUOTES, _CHARSET), $key); } echo "\t</url>\n"; } echo "</urlset>\n"; } else { header("Content-type: text/plain"); foreach ($sitemap as $url) { echo $url['loc'] . "\n"; } } exit; }
function _genarateObjectLink($data, $scatFlag = '') { global $CONF, $manager, $blog; $ext = substr(serverVar('REQUEST_URI'), -4); if ($ext == '.rdf' || $ext == '.xml') { $CONF['URLMode'] = 'pathinfo'; } if ($CONF['URLMode'] != 'pathinfo') { return; } $query = 'SELECT %s as result FROM %s WHERE %s = "%s"'; switch ($data[0]) { case 'b': if ($data[2] == 'n') { $bid = getBlogIDFromName($data[1]); } else { $bid = $data[1]; } $blog_id = intval($bid); $param = array('blog', 'bnumber', $blog_id); if (!$this->_isValid($param)) { $url = _NOT_VALID_BLOG; } else { $url = $this->_generateBlogLink($blog_id) . '/'; } break; case 'c': if ($data[2] == 'n') { $cid = getCatIDFromName($data[1]); } else { $cid = $data[1]; } $cat_id = intval($cid); $param = array('category', 'catid', $cat_id); if (!$this->_isValid($param)) { $url = _NOT_VALID_CAT; } else { $url = createCategoryLink($cat_id); } break; case 's': $mcategories = $this->pluginCheck('MultipleCategories'); if ($mcategories) { if ($data[2] == 'n') { $temp = $this->quote_smart($data[1]); $sque = sprintf($query, 'scatid', _C_SUBCAT_TABLE, 'sname', $temp); $scid = quickQuery($sque); } else { $scid = $data[1]; } $sub_id = intval($scid); $param = array('plug_multiple_categories_sub', 'scatid', $sub_id); if (!$this->_isValid($param)) { $url = _NOT_VALID_SUBCAT; } else { $cqe = sprintf($query, 'catid', _C_SUBCAT_TABLE, 'scatid', $sub_id); $cid = quickQuery($cqe); $cid = intval($cid); if (method_exists($mcategories, "getRequestName")) { $subrequest = $mcategories->getRequestName(); } if (!$subrequest) { $subrequest = 'subcatid'; } $linkParam = array($subrequest => $sub_id); $url = createCategoryLink($cid, $linkParam); } } break; case 'i': $param = array('item', 'inumber', intval($data[1])); if (!$this->_isValid($param)) { $url = _NOT_VALID_ITEM; } else { if ($scatFlag) { global $catid, $subcatid; if (!empty($catid)) { $linkparams['catid'] = intval($catid); } if (!empty($subcatid)) { $mcategories = $this->pluginCheck('MultipleCategories'); if ($mcategories) { if (method_exists($mcategories, 'getRequestName')) { $subrequest = $mcategories->getRequestName(); } else { $subrequest = 'subcatid'; } } $linkparams[$subrequest] = intval($subcatid); } $url = createItemLink(intval($data[1]), $linkparams); } else { $blink = $this->_generateBlogLink(getBlogIDFromItemID(intval($data[1]))); $i_query = 'SELECT obj_name as result ' . 'FROM %s ' . 'WHERE obj_param = "item" ' . 'AND obj_id = %d'; $i_query = sprintf($i_query, _CUSTOMURL_TABLE, intval($data[1])); $path = quickQuery($i_query); if ($path) { if ($data[2] == 'path') { $url = $path; } else { $url = $blink . '/' . $path; } } else { if ($data[2] == 'path') { $url = $CONF['ItemKey'] . '/' . intval($data[1]); } else { $url = $blink . '/' . $CONF['ItemKey'] . '/' . intval($data[1]); } } } } break; case 'm': if ($data[2] == 'n') { $data[1] = $this->quote_smart($data[1]); $mque = sprintf($query, 'mnumber', sql_table('member'), 'mname', $data[1]); $mid = quickQuery($mque); } else { $mid = $data[1]; } $member_id = intval($mid); $param = array('member', 'mnumber', $member_id); if (!$this->_isValid($param)) { $url = _NOT_VALID_MEMBER; } else { $url = createMemberLink($member_id); } break; } return $url; }
/** For keywords list user Skinvar. This TemplVar function make "see also" links to articles with same keywords @param int $limit number of links for each article's keywords @param string $anyblog If set to "anyblog", will produce see-also links not only to current blog's entries, but all blogs */ function doTemplateVar(&$item, $limit = 5, $anyblog = "") { $keys = array(0 => $item->itemid); $sql = sprintf('SELECT keyword_id FROM %s WHERE key_id=%d', sql_table('plug_keywords_relationship'), intval($item->itemid)); $res = sql_query($sql); if ($anyblog == "anyblog") { $onlyblog = ""; } else { $onlyblog = "AND i.iblog = " . $this->_getBlogid(); } echo '<ul>'; // get keyword IDs for this article, now need to get list of articles that have same keyword while ($o = sql_fetch_array($res)) { $sql2 = sprintf('SELECT i.inumber, i.ititle, k.keyword FROM %s as kr, %s as i, %s as k WHERE kr.keyword_id = %d AND kr.key_id = i.inumber AND i.idraft = 0 AND i.itime<=%s AND k.keyword_id = kr.keyword_id %s ORDER BY i.itime DESC LIMIT %d', sql_table('plug_keywords_relationship'), sql_table('item'), sql_table('plug_keywords_keyword'), intval($o[0]), mysqldate(time() + 3600 * $manager->settings['btimeoffset']), $onlyblog, intval($limit)); $res2 = sql_query($sql2); while ($o2 = sql_fetch_array($res2)) { // uniques only if (!in_array($o2[0], $keys)) { //echo '<font color=gray>' . $o2[2] . ':</font> <a href="' . createItemLink($o2[0]) . '">' . $o2[1] .'</a><br/>'; echo '<li><a href="' . createItemLink($o2[0]) . '">' . $o2[1] . '</a> <span>(' . $o2[2] . ')</span></li>'; $keys[] = $o2[0]; } } sql_free_result($res2); } sql_free_result($res); echo '</ul>'; }
/** * Adds a new comment to the database * @param string $timestamp * @param array $comment * @return mixed */ function addComment($timestamp, $comment) { global $CONF, $member, $manager; $blogid = getBlogIDFromItemID($this->itemid); $settings =& $manager->getBlog($blogid); $settings->readSettings(); // begin if: comments disabled if (!$settings->commentsEnabled()) { return _ERROR_COMMENTS_DISABLED; } // end if // begin if: public cannot comment if (!$settings->isPublic() && !$member->isLoggedIn()) { return _ERROR_COMMENTS_NONPUBLIC; } // end if // begin if: comment uses a protected member name if ($CONF['ProtectMemNames'] && !$member->isLoggedIn() && MEMBER::isNameProtected($comment['user'])) { return _ERROR_COMMENTS_MEMBERNICK; } // end if // begin if: email required, but missing (doesn't apply to members) if ($settings->emailRequired() && strlen($comment['email']) == 0 && !$member->isLoggedIn()) { return _ERROR_EMAIL_REQUIRED; } // end if ## Note usage of mb_strlen() vs strlen() below ## // begin if: commenter's name is too long if (mb_strlen($comment['user']) > 40) { return _ERROR_USER_TOO_LONG; } // end if // begin if: commenter's email is too long if (mb_strlen($comment['email']) > 100) { return _ERROR_EMAIL_TOO_LONG; } // end if // begin if: commenter's url is too long if (mb_strlen($comment['userid']) > 100) { return _ERROR_URL_TOO_LONG; } // end if $comment['timestamp'] = $timestamp; $comment['host'] = gethostbyaddr(serverVar('REMOTE_ADDR')); $comment['ip'] = serverVar('REMOTE_ADDR'); // begin if: member is logged in, use that data if ($member->isLoggedIn()) { $comment['memberid'] = $member->getID(); $comment['user'] = ''; $comment['userid'] = ''; $comment['email'] = ''; } else { $comment['memberid'] = 0; } // spam check $continue = FALSE; $plugins = array(); if (isset($manager->subscriptions['ValidateForm'])) { $plugins = array_merge($plugins, $manager->subscriptions['ValidateForm']); } if (isset($manager->subscriptions['PreAddComment'])) { $plugins = array_merge($plugins, $manager->subscriptions['PreAddComment']); } if (isset($manager->subscriptions['PostAddComment'])) { $plugins = array_merge($plugins, $manager->subscriptions['PostAddComment']); } $plugins = array_unique($plugins); while (list(, $plugin) = each($plugins)) { $p = $manager->getPlugin($plugin); $continue = $continue || $p->supportsFeature('handleSpam'); } $spamcheck = array('type' => 'comment', 'body' => $comment['body'], 'id' => $comment['itemid'], 'live' => TRUE, 'return' => $continue); // begin if: member logged in if ($member->isLoggedIn()) { $spamcheck['author'] = $member->displayname; $spamcheck['email'] = $member->email; } else { $spamcheck['author'] = $comment['user']; $spamcheck['email'] = $comment['email']; $spamcheck['url'] = $comment['userid']; } // end if $manager->notify('SpamCheck', array('spamcheck' => &$spamcheck)); if (!$continue && isset($spamcheck['result']) && $spamcheck['result'] == TRUE) { return _ERROR_COMMENTS_SPAM; } // isValidComment returns either "1" or an error message $isvalid = $this->isValidComment($comment, $spamcheck); if ($isvalid != 1) { return $isvalid; } // begin if: send email to notification address if ($settings->getNotifyAddress() && $settings->notifyOnComment()) { $mailto_msg = _NOTIFY_NC_MSG . ' ' . $this->itemid . "\n"; // $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $this->itemid . "\n\n"; $temp = parse_url($CONF['Self']); if ($temp['scheme']) { $mailto_msg .= createItemLink($this->itemid) . "\n\n"; } else { $tempurl = $settings->getURL(); if (substr($tempurl, -1) == '/' || substr($tempurl, -4) == '.php') { $mailto_msg .= $tempurl . '?itemid=' . $this->itemid . "\n\n"; } else { $mailto_msg .= $tempurl . '/?itemid=' . $this->itemid . "\n\n"; } } if ($comment['memberid'] == 0) { $mailto_msg .= _NOTIFY_USER . ' ' . $comment['user'] . "\n"; $mailto_msg .= _NOTIFY_USERID . ' ' . $comment['userid'] . "\n"; } else { $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n"; } $mailto_msg .= _NOTIFY_HOST . ' ' . $comment['host'] . "\n"; $mailto_msg .= _NOTIFY_COMMENT . "\n " . $comment['body'] . "\n"; $mailto_msg .= getMailFooter(); $item =& $manager->getItem($this->itemid, 0, 0); $mailto_title = _NOTIFY_NC_TITLE . ' ' . strip_tags($item['title']) . ' (' . $this->itemid . ')'; $frommail = $member->getNotifyFromMailAddress($comment['email']); $notify =& new NOTIFICATION($settings->getNotifyAddress()); $notify->notify($mailto_title, $mailto_msg, $frommail); } $comment = COMMENT::prepare($comment); $manager->notify('PreAddComment', array('comment' => &$comment, 'spamcheck' => &$spamcheck)); $name = sql_real_escape_string($comment['user']); $url = sql_real_escape_string($comment['userid']); $email = sql_real_escape_string($comment['email']); $body = sql_real_escape_string($comment['body']); $host = sql_real_escape_string($comment['host']); $ip = sql_real_escape_string($comment['ip']); $memberid = intval($comment['memberid']); $timestamp = date('Y-m-d H:i:s', $comment['timestamp']); $itemid = $this->itemid; $qSql = 'SELECT COUNT(*) AS result ' . 'FROM ' . sql_table('comment') . ' WHERE ' . 'cmail = "' . $url . '"' . ' AND cmember = "' . $memberid . '"' . ' AND cbody = "' . $body . '"' . ' AND citem = "' . $itemid . '"' . ' AND cblog = "' . $blogid . '"'; $result = (int) quickQuery($qSql); if ($result > 0) { return _ERROR_BADACTION; } $query = 'INSERT INTO ' . sql_table('comment') . ' (CUSER, CMAIL, CEMAIL, CMEMBER, CBODY, CITEM, CTIME, CHOST, CIP, CBLOG) ' . "VALUES ('{$name}', '{$url}', '{$email}', {$memberid}, '{$body}', {$itemid}, '{$timestamp}', '{$host}', '{$ip}', '{$blogid}')"; sql_query($query); // post add comment $commentid = sql_insert_id(); $manager->notify('PostAddComment', array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck)); // succeeded ! return TRUE; }
function getWikidataItems($PROP, $ID) { global $PROP_CODES, $API_QUERY; $propCode = $PROP_CODES->{$PROP}->{"wikidataProp"}; $apiQuery = http_build_query(array('q' => "string[{$propCode}:\"{$ID}\"]")); $apiResponse = json_decode(file_get_contents($API_QUERY . '?' . $apiQuery)); $items = $apiResponse->items; if (isset($_GET['debug'])) { header('Content-Type: text/plain'); echo "Query: {$apiQuery}\n\n"; echo "Query API Response:\n"; echo json_encode($apiResponse, JSON_PRETTY_PRINT); foreach ($items as $item) { echo "\n"; echo "WP API response:\n"; echo json_encode(getMetadataFor($item), JSON_PRETTY_PRINT); echo "\n"; echo $item; echo ": "; echo createItemLink($item); } exit; } return $items; }
function doSkinVar($skinType, $type = 'cloud', $sort = 'alp', $maxtags = -1, $blogid = "current") { global $blog, $manager, $CONF; if (!$blog) { echo "<!-- TechnoratiTags fatal error: no blog object?? -->"; //ACTIONLOG::add(WARNING, 'TechnoratiTags Error:' . serverVar("REQUEST_URI")); } if ($type == 'tagsearch') { if ($CONF['URLMode'] == 'pathinfo') { $uri = serverVar('REQUEST_URI'); $temp = explode('/', $uri); $i = array_search('tags', $temp); $i++; if (function_exists('mb_convert_encoding')) { $tag = mb_convert_encoding($temp[$i], _CHARSET, _CHARSET); $tag = rawurldecode($tag); } else { // This will not work for UTF-8 tag..... not something // we can fix unless we bundle mb_convert_encoding() $tag = urlencode($temp[$i]); } if ($blog->getId() != 1) { $i = array_search('blogid', $temp); $i++; $blogid = $temp[$i]; } } else { $tag = str_replace(' ', '+', RequestVar('tag')); if (function_exists('mb_convert_encoding')) { $tag = mb_convert_encoding($tag, _CHARSET, _CHARSET); $tag = rawurldecode($tag); } else { // This will not work for UTF-8 tag..... not something // we can fix unless we bundle mb_convert_encoding() $tag = urlencode($tag); } } if ($tag == '') { return; } if ($this->getOption('PlusSwitch') == 'yes') { $displayed_tag = str_replace('+', ' ', $tag); } else { $displayed_tag = $tag; } echo "<div class=\"contenttitle\"><h2>" . $this->getOption('SearchTitleText') . " " . $displayed_tag . "</h2></div>"; // **** need better than tags like %% ??? ***** $query = "select t.itemid, i.ititle from " . $this->tablename . " as t, " . sql_table('item') . " as i where tags like \"%" . $tag . "%\" and t.itemid = i.inumber and i.idraft != 1 "; if (is_numeric($blogid)) { $query .= " and i.iblog = " . $blogid; } else { $query .= " and i.iblog = " . $blog->getID(); } // else for "all", which has not i.iblog=xyz $query .= " order by i.itime desc"; // else for "all" or anything we will show tagged posts from all blogs.... // it's a feature, not a bug..... I could have choke it here... $res = sql_query($query); echo "<br /><br /><ul>"; while ($row = sql_fetch_object($res)) { $link = createItemLink($row->itemid); echo "<li><a href=\"" . $link . "\">" . $row->ititle . "</a></li>"; } echo "</ul>"; } else { if ($type == 'cloud' || $type == 'dcloud' || $type == 'localcloud') { if ($blogid == "current") { $blogid = $blog->getID(); } else { if (is_numeric($blogid)) { // $blogid provided by user } else { $blogid = 0; } } // get all tags and counts $tags = $this->getAllTags($blogid); // Show only top x tags override from skinvar arsort($tags); if ($maxtags > 0) { $tags = array_slice($tags, 0, $maxtags, true); } // spread tags amount 4 levels of formating in the tag cloud $newtags = $tags; $total = sizeof($newtags); $pcnt = 0; $diff = $total / 4; $l = $diff; $m = 2 * $diff; $s = 3 * $diff; foreach ($newtags as $curtag => $curtagcount) { if ($pcnt < $l) { $newtags[$curtag] = 3; } else { if ($pcnt < $m) { $newtags[$curtag] = 2; } else { if ($pcnt < $s) { $newtags[$curtag] = 1; } else { $newtags[$curtag] = 0; } } } $pcnt++; } if ($sort == 'alp') { ksort($newtags); } // for debug count $tc = 0; $sc = 0; $mc = 0; $lc = 0; // cant figure out a good way to fit this in, or even if we want to. $separator = $this->getOption('TagSeparator'); foreach ($newtags as $curtag => $level) { $count = ""; if ($level == 3) { echo "<span class=\"largeT\">"; $lc++; } else { if ($level == 2) { echo "<span class=\"mediumT\">"; $mc++; } else { if ($level == 1) { echo "<span class=\"smallT\">"; $sc++; } else { echo "<span class=\"tinyT\">"; $tc++; } } } if ($this->getOption('ShowCount') == "yes") { $count = " [" . $tags[$curtag] . "]"; } if ($this->getOption('PlusSwitch') == 'yes') { $displayed_tag = str_replace('+', ' ', $curtag); } else { $displayed_tag = $curtag; } $style = 'background: none;padding: 0px; margin: 0px; text-decoration: none;'; if ($type == 'cloud') { echo sprintf('<a href="%s/%s" title="Find tag %s on Technorati" style="%s">%s</a>', $this->technoratiurl, $curtag, $curtag, $style, $displayed_tag, $count); } elseif ($type == 'dcloud') { echo sprintf('<a href="%s/%s" title="Find tag %s on del.icio.us" style="%s">%s</a>', $this->deliciousurl, $curtag, $curtag, $style, $displayed_tag, $count); } else { if ($CONF['URLMode'] == 'pathinfo') { $link = $blog->getURL(); $link .= '/tags/' . $curtag; } else { $self = rtrim(str_replace('index.php', '', $CONF['Self']), '/') . '/'; if ($self === '/') { $self = './'; } $link = "{$self}tags.php?tag={$curtag}"; if ($blog->getId() != 1) { $link .= "&blogid=" . $blog->getId(); } } echo "<a href=\"" . $link . "\" style=\"{$style}\">" . $displayed_tag . $count . "</a>"; } echo "</span>\n"; // finish it off } echo '<!-- ' . $tc . '-' . $sc . '-' . $mc . '-' . $lc . ' -->'; } } }
function selector() { global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults; global $archive, $skinid, $blog, $memberinfo, $CONF, $member; global $imagepopup, $catid, $special; global $manager; $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin'); $action = requestVar('action'); if (in_array($action, $actionNames)) { global $DIR_LIBS, $errormessage; include_once $DIR_LIBS . 'ACTION.php'; $a = new ACTION(); $errorInfo = $a->doAction($action); if ($errorInfo) { $errormessage = $errorInfo['message']; } } // show error when headers already sent out if (headers_sent() && $CONF['alertOnHeadersSent']) { // try to get line number/filename (extra headers_sent params only exists in PHP 4.3+) if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=')) { headers_sent($hsFile, $hsLine); $extraInfo = sprintf(_GFUNCTIONS_HEADERSALREADYSENT_FILE, $hsFile, $hsLine); } else { $extraInfo = ''; } startUpError(sprintf(_GFUNCTIONS_HEADERSALREADYSENT_TXT, $extraInfo), _GFUNCTIONS_HEADERSALREADYSENT_TITLE); exit; } // make is so ?archivelist without blogname or blogid shows the archivelist // for the default weblog if (serverVar('QUERY_STRING') == 'archivelist') { $archivelist = $CONF['DefaultBlog']; } // now decide which type of skin we need if ($itemid) { // itemid given -> only show that item $type = 'item'; if (!$manager->existsItem($itemid, intval($CONF['allowFuture']), intval($CONF['allowDrafts']))) { doError(_ERROR_NOSUCHITEM); } global $itemidprev, $itemidnext, $catid, $itemtitlenext, $itemtitleprev; // 1. get timestamp, blogid and catid for item $query = 'SELECT itime, iblog, icat FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid); $res = sql_query($query); $obj = sql_fetch_object($res); // if a different blog id has been set through the request or selectBlog(), // deny access if ($blogid && intval($blogid) != $obj->iblog) { if (!headers_sent()) { $b =& $manager->getBlog($obj->iblog); $CONF['ItemURL'] = $b->getURL(); if ($CONF['URLMode'] == 'pathinfo' and substr($CONF['ItemURL'], -1) == '/') { $CONF['ItemURL'] = substr($CONF['ItemURL'], 0, -1); } $correctURL = createItemLink($itemid, ''); redirect($correctURL); exit; } else { doError(_ERROR_NOSUCHITEM); } } // if a category has been selected which doesn't match the item, ignore the // category. #85 if ($catid != 0 && $catid != $obj->icat) { $catid = 0; } $blogid = $obj->iblog; $timestamp = strtotime($obj->itime); $b =& $manager->getBlog($blogid); if ($b->isValidCategory($catid)) { $catextra = ' and icat=' . $catid; } else { $catextra = ''; } // get previous itemid and title $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime<' . mysqldate($timestamp) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime DESC LIMIT 1'; $res = sql_query($query); $obj = sql_fetch_object($res); if ($obj) { $itemidprev = $obj->inumber; $itemtitleprev = $obj->ititle; } // get next itemid and title $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime>' . mysqldate($timestamp) . ' and itime <= ' . mysqldate($b->getCorrectTime()) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime ASC LIMIT 1'; $res = sql_query($query); $obj = sql_fetch_object($res); if ($obj) { $itemidnext = $obj->inumber; $itemtitlenext = $obj->ititle; } } elseif ($archive) { // show archive $type = 'archive'; // get next and prev month links ... global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists; // sql queries for the timestamp of the first and the last published item $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM " . sql_table('item') . " WHERE idraft=0 AND iblog=" . (int) ($blogid ? $blogid : $CONF['DefaultBlog']) . " ORDER BY itime ASC"; $first_timestamp = quickQuery($query); $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM " . sql_table('item') . " WHERE idraft=0 AND iblog=" . (int) ($blogid ? $blogid : $CONF['DefaultBlog']) . " ORDER BY itime DESC"; $last_timestamp = quickQuery($query); sscanf($archive, '%d-%d-%d', $y, $m, $d); if ($d != 0) { $archivetype = _ARCHIVETYPE_DAY; $t = mktime(0, 0, 0, $m, $d, $y); // one day has 24 * 60 * 60 = 86400 seconds $archiveprev = strftime('%Y-%m-%d', $t - 86400); // check for published items if ($t > $first_timestamp) { $archiveprevexists = true; } else { $archiveprevexists = false; } // one day later $t += 86400; $archivenext = strftime('%Y-%m-%d', $t); if ($t < $last_timestamp) { $archivenextexists = true; } else { $archivenextexists = false; } } elseif ($m == 0) { $archivetype = _ARCHIVETYPE_YEAR; $t = mktime(0, 0, 0, 12, 31, $y - 1); // one day before is in the previous year $archiveprev = strftime('%Y', $t); if ($t > $first_timestamp) { $archiveprevexists = true; } else { $archiveprevexists = false; } // timestamp for the next year $t = mktime(0, 0, 0, 1, 1, $y + 1); $archivenext = strftime('%Y', $t); if ($t < $last_timestamp) { $archivenextexists = true; } else { $archivenextexists = false; } } else { $archivetype = _ARCHIVETYPE_MONTH; $t = mktime(0, 0, 0, $m, 1, $y); // one day before is in the previous month $archiveprev = strftime('%Y-%m', $t - 86400); if ($t > $first_timestamp) { $archiveprevexists = true; } else { $archiveprevexists = false; } // timestamp for the next month $t = mktime(0, 0, 0, $m + 1, 1, $y); $archivenext = strftime('%Y-%m', $t); if ($t < $last_timestamp) { $archivenextexists = true; } else { $archivenextexists = false; } } } elseif ($archivelist) { $type = 'archivelist'; if (is_numeric($archivelist)) { $blogid = intVal($archivelist); } else { $blogid = getBlogIDFromName($archivelist); } if (!$blogid) { doError(_ERROR_NOSUCHBLOG); } } elseif ($query) { global $startpos; $type = 'search'; $query = stripslashes($query); if (preg_match("/^(¡{2}|ã€{2}| )+\$/", $query)) { $type = 'index'; } // $order = (_CHARSET == 'EUC-JP') ? 'EUC-JP, UTF-8,' : 'UTF-8, EUC-JP,'; // $query = mb_convert_encoding($query, _CHARSET, $order . ' JIS, SJIS, ASCII'); switch (strtolower(_CHARSET)) { case 'utf-8': $order = 'ASCII, UTF-8, EUC-JP, JIS, SJIS, EUC-CN, ISO-8859-1'; break; case 'gb2312': $order = 'ASCII, EUC-CN, EUC-JP, UTF-8, JIS, SJIS, ISO-8859-1'; break; case 'shift_jis': // Note that shift_jis is only supported for output. // Using shift_jis in DB is prohibited. $order = 'ASCII, SJIS, EUC-JP, UTF-8, JIS, EUC-CN, ISO-8859-1'; break; default: // euc-jp,iso-8859-x,windows-125x $order = 'ASCII, EUC-JP, UTF-8, JIS, SJIS, EUC-CN, ISO-8859-1'; break; } $query = mb_convert_encoding($query, _CHARSET, $order); if (is_numeric($blogid)) { $blogid = intVal($blogid); } else { $blogid = getBlogIDFromName($blogid); } if (!$blogid) { doError(_ERROR_NOSUCHBLOG); } } elseif ($memberid) { $type = 'member'; if (!MEMBER::existsID($memberid)) { doError(_ERROR_NOSUCHMEMBER); } $memberinfo = $manager->getMember($memberid); } elseif ($imagepopup) { // media object (images etc.) $type = 'imagepopup'; // TODO: check if media-object exists // TODO: set some vars? } else { // show regular index page global $startpos; $type = 'index'; } // any type of skin with catid if ($catid && !$blogid) { $blogid = getBlogIDFromCatID($catid); } // decide which blog should be displayed if (!$blogid) { $blogid = $CONF['DefaultBlog']; } $b =& $manager->getBlog($blogid); $blog = $b; // references can't be placed in global variables? if (!$blog->isValid) { doError(_ERROR_NOSUCHBLOG); } // set catid if necessary if ($catid) { // check if the category is valid if (!$blog->isValidCategory($catid)) { doError(_ERROR_NOSUCHCATEGORY); } else { $blog->setSelectedCategory($catid); } } // decide which skin should be used if ($skinid != '' && $skinid == 0) { selectSkin($skinid); } if (!$skinid) { $skinid = $blog->getDefaultSkin(); } //$special = requestVar('special'); //get at top of file as global if (!empty($special) && isValidShortName($special)) { $type = strtolower($special); } $skin = new SKIN($skinid); if (!$skin->isValid) { doError(_ERROR_NOSUCHSKIN); } // set global skinpart variable so can determine quickly what is being parsed from any plugin or phpinclude global $skinpart; $skinpart = $type; // parse the skin $skin->parse($type); // check to see we should throw JustPosted event $blog->checkJustPosted(); }
$max_item = $row->total; //echo "total count " . $max_item . "<br/>"; $query = "SELECT id,views FROM " . sql_table('plugin_views') . " ORDER BY " . $sorting . $desc . " LIMIT " . $offset . ",40"; $rows = sql_query($query); if ($sorting == 'id') { $idir = "(" . $order . ")"; } else { $vdir = "(" . $order . ")"; } echo "<table>\n"; echo "<tr><th><a href=\"" . $viewsURL . "?sort=id" . $param . "\">ItemID " . $idir . "</a></th><th><a href =\"" . $viewsURL . "?sort=views" . $param . "\">View Count " . $vdir . "</a></th><th>Action</th></tr>"; while ($row = sql_fetch_object($rows)) { $item = $manager->getItem($row->id, 0, 0); $delurl = $CONF['ActionURL'] . '?action=plugin&name=Views&type=resetview&id=' . $row->id . "&order=" . $orderby . "&sort=" . $sortby; echo "<tr>"; echo "<td><a href=\"" . createItemLink($row->id) . "\">" . $item['title'] . "</a></td>"; echo "<td>" . $row->views . "</td>"; echo "<td>" . "<a href=\"" . $delurl . "\">Reset count</a>" . "</td>"; echo "</tr>"; } echo "</table>\n"; if ($max_item == 0) { echo "No item found<br/>"; } $noffset = -1; if ($offset - 40 >= 0) { $noffset = $offset - 40; $nparam = ''; if ($sorting != '') { $nparam = $nparam . "sort=" . $sorting . "&order=" . $order . "&"; }
/** * Creates an item link and if no id is given a todaylink */ function _itemlink($id, $linktext = '') { global $CONF; if ($id) { echo $this->_link(createItemLink($id, $this->linkparams), $linktext); } else { $this->parse_todaylink($linktext); } }
/** * Handle karma votes */ function doKarma($type) { global $itemid, $member, $CONF, $manager; // check if itemid exists if (!$manager->existsItem($itemid, 0, 0)) { doError(_ERROR_NOSUCHITEM); } $blogid = getBlogIDFromItemID($itemid); $this->checkban($blogid); $karma =& $manager->getKarma($itemid); // check if not already voted if (!$karma->isVoteAllowed(serverVar('REMOTE_ADDR'))) { doError(_ERROR_VOTEDBEFORE); } // check if item does allow voting $item =& $manager->getItem($itemid, 0, 0); if ($item['closed']) { doError(_ERROR_ITEMCLOSED); } switch ($type) { case 'pos': $karma->votePositive(); break; case 'neg': $karma->voteNegative(); break; } // $blogid = getBlogIDFromItemID($itemid); $blog =& $manager->getBlog($blogid); // send email to notification address, if any if ($blog->getNotifyAddress() && $blog->notifyOnVote()) { $mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n"; $itemLink = createItemLink(intval($itemid)); $temp = parse_url($itemLink); if (!$temp['scheme']) { $itemLink = $CONF['IndexURL'] . $itemLink; } $mailto_msg .= $itemLink . "\n\n"; if ($member->isLoggedIn()) { $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n"; } $mailto_msg .= _NOTIFY_IP . ' ' . serverVar('REMOTE_ADDR') . "\n"; $mailto_msg .= _NOTIFY_HOST . ' ' . gethostbyaddr(serverVar('REMOTE_ADDR')) . "\n"; $mailto_msg .= _NOTIFY_VOTE . "\n " . $type . "\n"; $mailto_msg .= getMailFooter(); $mailto_title = _NOTIFY_KV_TITLE . ' ' . strip_tags($item['title']) . ' (' . $itemid . ')'; $frommail = $member->getNotifyFromMailAddress(); $notify = new NOTIFICATION($blog->getNotifyAddress()); $notify->notify($mailto_title, $mailto_msg, $frommail); } $refererUrl = serverVar('HTTP_REFERER'); if ($refererUrl) { $url = $refererUrl; } else { // $url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid; $url = $itemLink; } redirect($url); exit; }