derekivey |
08-05-2008 01:45 AM |
Hello,
To fix the security token problem, use this modified code for the tDigg - Template Edits plugin:
PHP Code:
if ($vbulletin->options['tDigg_enabled']) { $vbulletin->templatecache['SHOWTHREAD'] = preg_replace('#</head>#i', ' ".((!in_array($forum[forumid], explode(",", "' . $vbulletin->options['tDigg_forums'] . '", -1))) ? ("") : (" <script type=\"text/javascript\" language=\"javascript\"> var tdigg_request = false; var threadnum = null; function maketdiggRequest(url, parameters) { tdigg_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... tdigg_request = new XMLHttpRequest(); if (tdigg_request.overrideMimeType) { // set type accordingly to anticipated content type //tdigg_request.overrideMimeType(\'text/xml\'); tdigg_request.overrideMimeType(\'text/html\'); } } else if (window.ActiveXObject) { // IE try { tdigg_request = new ActiveXObject(\"Msxml2.XMLHTTP\"); } catch (e) { try { tdigg_request = new ActiveXObject(\"Microsoft.XMLHTTP\"); } catch (e) {} } } if (!tdigg_request) { alert(\'Cannot create XMLHTTP instance\'); return false; } tdigg_request.onreadystatechange = alerttdiggContents; tdigg_request.open(\'POST\', url, true); tdigg_request.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\"); tdigg_request.setRequestHeader(\"Content-length\", parameters.length); tdigg_request.setRequestHeader(\"Connection\", \"close\"); tdigg_request.send(parameters); }
function alerttdiggContents() { if (tdigg_request.readyState == 4) { if (tdigg_request.status == 200) { document.getElementById(\'votecount_\' + threadnum).innerHTML = tdigg_request.responseText; } else { alert(\'There was a problem with the request.\'); } } } function vote(ID,type) { var threadid = document.getElementById(\'qr_threadid\').value; threadnum = ID; if (type == \'give\'){ var poststr = \"threadid=\" + encodeURI( threadid ) + \"&action=give&securitytoken=\" + SECURITYTOKEN; document.getElementById(\'votecount_\' + ID).innerHTML = \'<img src=\"$stylevar[imgdir_misc]/13x13progress.gif\">\'; maketdiggRequest( \'ajax.php?do=tdigg\', poststr); } else if (type == \'take\') { var poststr = \"threadid=\" + encodeURI( threadid ) + \"&action=take&securitytoken=\" + SECURITYTOKEN; document.getElementById(\'votecount_\' + ID).innerHTML = \'<img src=\"$stylevar[imgdir_misc]/13x13progress.gif\">\'; maketdiggRequest( \'ajax.php?do=tdigg\', poststr); } } </script> <style type=\"text/css\"> <!-- .topicv { position:relative; height: 18px; } .countbg { position:relative; top: -5px; text-align: center; color: #000000; font-weight:bold } .news-tDigg { position: relative; top: 0.8em; text-align: center; font-size: 85%; margin: 0; padding: 0; list-style: none; background: url($stylevar[imgdir_misc]/t-shade.gif) no-repeat; } .news-tDigg li { margin: 0; padding: 0; } .tDigg-count a , .tDigg-count span, .tDigg-count-s a, .tDigg-count-s span { display: block; position: relative; padding: 6px 0 4px 0; text-decoration: none; width: 50px; min-height: 20px; color: #93883F; text-align: center; font: 13px arial, sans-serif; } .news-summary .tDigg-count strong, .news-full .tDigg-count strong, .news-summary .tDigg-count-s strong, .news-full .tDigg-count-s strong { font-size: 160%; font-weight: normal; letter-spacing: -1px; line-height: 1; display: block; position: relative; color: #736926; } .news-summary .tDigg-count-s strong, .news-full .tDigg-count-s strong { font-size: 160%; } .tDigg-count img, .tDigg-count-s img { position: relative; top: 0; left: 0; border: none; } .tDigg-count a:hover, .tDigg-count-s a:hover, .tDigg-count a:hover strong, .tDigg-count-s a:hover strong { color: #998D43; } --></style> ")) . " </head>', $vbulletin->templatecache['SHOWTHREAD']); $vbulletin->templatecache['threadbit'] = preg_replace('#\"\.\(\(\$show\[\'moderated\'\] OR #i',' ".((!in_array($thread[forumid], explode(",", "' . $vbulletin->options['tDigg_forums'] . '", -1))) ? ("") : (" <span style=\'float: right;\' ><b><span id=\'votecount_$threadnum\' style=\'position: relative; top: -5px;\'>$thread[tdiggs]</span></b> " . (($thread[\'tdiggs\'] >= 0) ? ("<img src=\"$stylevar[imgdir_misc]/t-us.png\" width=\"18px\" height=\"18px\">") : ("<img src=\"$stylevar[imgdir_misc]/t-ds.png\" width=\"18px\" height=\"18px\">")) . "</span>")) . " ".(($show[\'moderated\'] OR ', $vbulletin->templatecache['threadbit']); if ($vbulletin->options['legacypostbit']) { $vbulletin->templatecache['postbit_legacy'] = preg_replace('#<div id=\\\"post_message_\$post\[postid\]\\\" class=\\\"vb_postbit\\\">\$post\[message\]</div>#i',' ".((!in_array($forum[forumid], explode(",", "' . $vbulletin->options['tDigg_forums'] . '", -1))) ? ("") : (" ".(($post[postcount] == 1) ? (" <div style=\'position: relative; display: inline; float: right; padding: 0px 10px 0px 0px;\'> <div class=\"news-summary\"> <ul class=\"news-tDigg\"> <li class=\"tDigg-count\"> <a><strong id=\"votecount_$thread[threadid]\">$thread[tdiggs]</strong></a> </li> '.(($vbulletin->userinfo['usergroupid'] != 1) ? ('<li><img src=\"$stylevar[imgdir_misc]/t-dg.png\" onmouseover=\"this.src=\'$stylevar[imgdir_misc]/t-d.png\'\" onmouseout=\"this.src=\'$stylevar[imgdir_misc]/t-dg.png\'\" onclick=\"javascript: vote($thread[threadid],\'take\');\" width=\"25px\" height=\"18px\"><img src=\"$stylevar[imgdir_misc]/t-ug.png\" onmouseover=\"this.src=\'$stylevar[imgdir_misc]/t-u.png\'\" onmouseout=\"this.src=\'$stylevar[imgdir_misc]/t-ug.png\'\" onclick=\"javascript: vote($thread[threadid],\'give\');\" width=\"25px\" height=\"18px\"></li>') : ('')).' </ul> </div> </div>") : ("")) . "")) . " <div id=\"post_message_$post[postid]\">$post[message]</div> <div style=\"display: block; clear: both;\"> </div>', $vbulletin->templatecache['postbit_legacy']); } else { $vbulletin->templatecache['postbit'] = preg_replace('#<div id=\\\"post_message_\$post\[postid\]\\\">\$post\[message\]</div>#i',' ".((!in_array($forum[forumid], explode(",", "' . $vbulletin->options['tDigg_forums'] . '", -1))) ? ("") : (" ".(($post[postcount] == 1) ? (" <div style=\'position: relative; display: inline; float: right; padding: 0px 10px 0px 0px;\'> <div class=\"news-summary\"> <ul class=\"news-tDigg\"> <li class=\"tDigg-count\"> <a><strong id=\"votecount_$thread[threadid]\">$thread[tdiggs]</strong></a> </li> '.(($vbulletin->userinfo['usergroupid'] != 1) ? ('<li><img src=\"$stylevar[imgdir_misc]/t-dg.png\" onmouseover=\"this.src=\'$stylevar[imgdir_misc]/t-d.png\'\" onmouseout=\"this.src=\'$stylevar[imgdir_misc]/t-dg.png\'\" onclick=\"javascript: vote($thread[threadid],\'take\');\" width=\"25px\" height=\"18px\"><img src=\"$stylevar[imgdir_misc]/t-ug.png\" onmouseover=\"this.src=\'$stylevar[imgdir_misc]/t-u.png\'\" onmouseout=\"this.src=\'$stylevar[imgdir_misc]/t-ug.png\'\" onclick=\"javascript: vote($thread[threadid],\'give\');\" width=\"25px\" height=\"18px\"></li>') : ('')).' </ul> </div> </div>") : ("")) . "")) . " <div id=\"post_message_$post[postid]\">$post[message]</div> <div style=\"display: block; clear: both;\"> </div>', $vbulletin->templatecache['postbit']); } }
I had to help someone get this working, so I thought I'd share the modified code.
|