broken
This commit is contained in:
parent
524ff6e14e
commit
638344c04c
4 changed files with 53 additions and 5 deletions
|
@ -288,6 +288,34 @@ class Main {
|
|||
|
||||
}
|
||||
|
||||
// Generate disqus hmac (https://github.com/disqus/DISQUS-API-Recipes/blob/master/sso/php/sso.php)
|
||||
public static function dsqHmacSha1($data, $key) {
|
||||
|
||||
$blocksize = 64;
|
||||
|
||||
if(strlen($key) > $blocksize) {
|
||||
|
||||
$key = pack('H*', sha1($key));
|
||||
|
||||
}
|
||||
|
||||
$key = str_pad($key, $blocksize, chr(0x00));
|
||||
$ipad = str_repeat(chr(0x36), $blocksize);
|
||||
$opad = str_repeat(chr(0x5c), $blocksize);
|
||||
$hmac = pack(
|
||||
'H*', sha1(
|
||||
($key ^ $opad) . pack(
|
||||
'H*', sha1(
|
||||
($key ^ $ipad) . $data
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return bin2hex($hmac);
|
||||
|
||||
}
|
||||
|
||||
// Loading info pages
|
||||
public static function loadInfoPage($id) {
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ $renderData = [
|
|||
'cookiepath' => Configuration::getConfig('cookie_path'),
|
||||
'minpwdentropy' => Configuration::getConfig('min_entropy'),
|
||||
'minusernamelength' => Configuration::getConfig('username_min_length'),
|
||||
'maxusernamelength' => Configuration::getConfig('username_max_length')
|
||||
'maxusernamelength' => Configuration::getConfig('username_max_length'),
|
||||
'disqus_shortname' => Configuration::getConfig('disqus_shortname'),
|
||||
'disqus_api_key' => Configuration::getConfig('disqus_api_key')
|
||||
|
||||
],
|
||||
|
||||
|
|
|
@ -34,18 +34,23 @@
|
|||
<div id="disqus_thread">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
||||
var disqus_shortname = 'flashii';
|
||||
|
||||
var disqus_shortname = '{{ sakura.disqus_shortname }}';
|
||||
var disqus_identifier = 'news_{{ newsPosts[0].id }}';
|
||||
var disqus_title = '{{ newsPosts[0].title }}';
|
||||
var disqus_url = 'http://{{ sakura.urls.main }}/news/{{ newsPosts[0].id }}';
|
||||
|
||||
/* * * DO NOT EDIT BELOW THIS LINE * * */
|
||||
|
||||
(function() {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
|
||||
var disqus_config = function() {
|
||||
this.page.remote_auth_s3 = '{{ page.disqus_sso }}';
|
||||
this.page.api_key = '{{ sakura.disqus_api_key }}';
|
||||
}
|
||||
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
||||
|
|
|
@ -12,10 +12,23 @@ use DOMDocument;
|
|||
// Include components
|
||||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
|
||||
|
||||
// Get user data
|
||||
$disqus_user = Users::getUser(Session::$userId);
|
||||
|
||||
// Set disqus data
|
||||
$disqus_data = [
|
||||
$disqus_user['id'],
|
||||
$disqus_user['username'],
|
||||
$disqus_user['email'],
|
||||
'http://'. Configuration::getLocalConfig('urls', 'main') .'/a/'. $disqus_user['id'],
|
||||
'http://'. Configuration::getLocalConfig('urls', 'main') .'/u/'. $disqus_user['id']
|
||||
];
|
||||
|
||||
// Add page specific things
|
||||
$renderData['newsPosts'] = Main::getNewsPosts((isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])) ? $_GET['id'] : null, (isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])));
|
||||
$renderData['page'] = [
|
||||
'title' => (isset($_GET['id']) ? (count($renderData['newsPosts']) ? $renderData['newsPosts'][0]['title'] : 'Post does not exist!') : 'Flashii News'),
|
||||
'disqus_sso' => ($disqus_user['password_algo'] == 'nologin' ? '{}' : (($disqus_message = base64_encode(json_encode($disqus_data))) .' '. Main::dsqHmacSha1($disqus_message .' '. time(), Configuration::getConfig('disqus_api_secret')) .' '. time()))
|
||||
];
|
||||
|
||||
// News XML feed
|
||||
|
|
Reference in a new issue