function refresh_access_token($refreshCode, $redirect = '') { $clientid = di_getparam('clientID'); $clientsecret= di_getparam('clientSecret'); $postVars = array ('client_id' => $clientid, 'client_secret' => $clientsecret, 'refresh_token' => $refreshCode, 'grant_type' => 'refresh_token', 'redirect_uri' => $redirect, 'scope' => 'uri:discussit' ); $url = $this->oauthserver . '/v2/OAuth2-13'; $cleanVars = http_build_query ( $postVars ); $ch = curl_init (); $timeout = 10; curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_POST, true ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $cleanVars ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, Array ("Content-Type: application/x-www-form-urlencoded" ) ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE ); //curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 1 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, $timeout ); $data = curl_exec ( $ch ); curl_close ( $ch ); $json = json_decode ( $data ); $_SESSION['access_token'] = $json->access_token; return $json->access_token; }
function renderBlock($name, $label, $type, $val, $desc = '') { $label = '<label for="' . $name . '">' . $label . '</label>'; switch ($type) { case '0': //text $content = '<input type="text" id="' . $name . '" name="' . $name . '" value="' . $val . '" />'; break; case '1': //bool if ($val == 0) { $sel0 = ' checked '; $sel1 = ''; } else { $sel1 = ' checked '; $sel0 = ''; } $content = '<fieldset id="' . $name . '" name="' . $name . '" class="radio">' . '<input type="radio" id="' . $name . '" name="' . $name . '" value="0" ' . $sel0 . '/><label for="' . $name . '">No</label>' . '<input type="radio" id="' . $name . '" name="' . $name . '" value="1" ' . $sel1 . ' /><label for="' . $name . '">Yes</label>' . '</fieldset>'; break; case '2': //textarea $content = '<textarea id="' . $name . '" rows="4" style="width:145px" name="' . $name . '">' . $val . '</textarea>'; break; case '3': //sections $active = NULL; $javascript = NULL; $name = 'sections[]'; $size = 10; $db =& JFactory::getDBO(); $query = 'SELECT id AS value, title AS text' . ' FROM #__categories' . ' WHERE published = 1 AND extension = \'com_content\''; $db->setQuery($query); $categories = $db->loadObjectList(); $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" multiple="multiple" style="width:145px" size="' . $size . '" ' . $javascript, 'value', 'text', explode(',', di_getparam('sections'))); $content = $category; break; case '4': //langs $url = 'http://account.discussit.com/external/ListAvailableLanguages'; $attr = ''; $ch = curl_init(); $timeout = 10; curl_setopt($ch, CURLOPT_URL, $url); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); $json = json_decode($data); $languages = (array) $json; $db = JFactory::getDBO(); $query = "SELECT * FROM #__di_langs"; $db->setQuery($query); $results = $db->loadResultArray(); if (!is_array($languages)) { $lanuages = array($languages); } foreach ($languages as $language) { $sc = substr($language->ShortCode, 0, 2); if (!in_array($sc, $results)) { $db = JFactory::getDBO(); $query = "INSERT INTO #__di_langs (tag, language) VALUES ({$sc}, '{$language->Name}')"; $db->setQuery($query); $db->query(); } } $lang = di_getparam('langs'); $content = JHTML::_('select.genericlist', $languages, 'langs', trim($attr), 'ShortCode', 'Name', $lang); break; case '5': $content = ''; break; case '6': $content = '<input type="text" id="' . $name . '" name="' . $name . '" value="' . $val . '" class="required validate numeric" />'; break; } if ($content != '') { $block = '<tr><th>' . $label . '</th><td>' . $content . '</td>' . di_helpbutton($desc) . '</tr>' . PHP_EOL; } else { $block = ''; } return $block; }
public function onContentAfterDisplay($article, &$params, $limitstart) { $db = JFactory::getDbo (); $query = 'select * from #__extensions where element = "plg_discussit"'; $db->setQuery ( $query ); if (JRequest::getCmd ( 'option' ) == 'com_content' && JRequest::getCmd ( 'view' ) == 'article') { if ($this->params->get ( 'showcomments' ) == '1') { if (di_getparam ( 'poweredBy' ) == '1') { $poweredBy = '<img border="0" src="http://account.dis.cuss.it/Content/i/cp.gif" alt="Comments powered by Dis.cuss.It" />'; } else { $poweredBy = ''; } if ((is_numeric ( di_getparam ( 'widgetWidth' ) ) == true) and (is_numeric ( di_getparam ( 'widgetMargin' ) ) == true)) { if (di_getparam ( 'widgetWidth' ) != '0') { $distyle = ' style="width: ' . di_getparam ( 'widgetWidth' ) . 'px; margin-top:' . di_getparam ( 'widgetMargin' ) . 'px"'; } else { $distyle = ' style="width: AUTO; margin-top:' . di_getparam ( 'widgetMargin' ) . 'px"'; } } else { $distyle = ' style="width: AUTO; margin-top:' . di_getparam ( 'widgetMargin' ) . 'px"'; } $db = JFactory::getDBO (); $query = "SELECT * FROM #__di_langs"; $db->setQuery ( $query ); $languages = $db->loadResultArray (); $langObj = JFactory::getLanguage (); $langTag = $langObj->getTag (); $lang = substr ( $langTag, 0, 2 ); if (! in_array ( $lang, $languages )) { $lang = di_getparam ( 'Langs' ); } $w1 = '<!--DiscussIt Comments Plugin for Joomla v2.0-->' . '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript"> jQuery.noConflict() ;</script>' . '<script type="text/javascript">var widgetID="'; $w2 = '"</script>' . '<script src="http://blob.discussit.com/javascript/j-' . $lang . '.js" type="text/javascript"></script>' . '<link href="http://account.discussit.com/content/widget/thread/' . di_getparam ( 'widgetID' ) . '.css" rel="stylesheet" type="text/css" />' . '<div id="diThr"' . $distyle . '>'; $w3 = '</div>' . '<a href="http://dis.cuss.it" title="Comments powered by DiscussIt" id="dilnkback"><div id="diPoweredBy">' . $poweredBy . '</div></a>' . '<!--DiscussIt Comments-->'; // if (di_getparam ( 'widgetID' ) != '') { $user = JFactory::getUser (); $usrinfo = JFactory::getUser (); $usrname = $usrinfo->name; $usremail = $usrinfo->email; $jsuname = '<script type="text/javascript">jQuery(window).load(function() { jQuery("#txtdiNickname").val("' . $usrname . '"); jQuery("#txtdiEmail").val("' . $usremail . '"); } );</script>'; $widgetid = di_getparam ( 'widgetID' ); $tref = '"; var threadRef="' . $params->id; $url = 'http://www.discussit.com/' . $widgetid . '/' . $params->id; if ($user->username != NULL) { //logged in logic $jsuname = '<script type="text/javascript">jQuery(window).load(function() { jQuery("#txtdiNickname").parent().parent().replaceWith("<p>Logged in as: <strong>' . $user->name . '</strong></p><input id=\"txtdiNickname\" name=\"txtdiNickname\" type=\"hidden\" value=\"' . $user->name . '\"/>"); jQuery("#txtdiEmail").parent().parent().replaceWith("<input id=\"txtdiEmail\" name=\"txtdiEmail\" type=\"hidden\" value=\"' . $user->email . '\"/>"); } ); function diReply(b) { var a = "#dim_" + jQuery("#diRT").attr("value"); jQuery(a).append(jQuery(b[0].widget)); jQuery("#direp").show("slow"); jQuery("#direp").find(".diOAuth").text( "Replying to: " + jQuery(a).find(".diAuth").text()); jQuery("#txtdiRNickname").val(jQuery("#txtdiNickname").val()); jQuery("#txtdiREmail").val(jQuery("#txtdiEmail").val()); jQuery("#txtdiRURL").val(jQuery("#txtdiURL").val()); jQuery("#txtdiReplyBody").focus(); jQuery("#di-eralert").parent().parent().hide(); jQuery("#txtdiRNickname").parent().parent().replaceWith("<p>Logged in as: <strong>' . $user->name . '</strong></p><input id=\"txtdiRNickname\" name=\"txtdiRNickname\" type=\"hidden\" value=\"' . $user->name . '\"/>"); jQuery("#txtdiREmail").parent().parent().replaceWith("<input id=\"txtdiREmail\" name=id=\"txtdiREmail\" type=\"hidden\" value=\"' . $user->email . '\"/>"); } var messageSent = 0; function diPosted(){ messageSent = 1; } function diCbEnd(){ if (messageSent == 1){ jQuery("#txtdiNickname").parent().parent().replaceWith("<p>Logged in as: <strong>' . $user->name . '</strong></p><input id=\"txtdiNickname\" type=\"hidden\" value=\"' . $user->name . '\"/>"); jQuery("#txtdiEmail").parent().parent().replaceWith("<input id=\"txtdiEmail\" type=\"hidden\" value=\"' . $user->email . '\"/>"); } } </script>'; } else { // anonymous logic if (di_getparam ( 'anonView' ) == '0') { if (di_getparam ( 'anonPost' ) == '1') { $jsuname = '<script type="text/javascript">jQuery(window).load(function() { jQuery("#txtdiBody").parent().parent().parent().parent().parent().replaceWith(\'<p id="diLITP">You must be logged in to post comments.</p>\'); jQuery(".diRep").hide(); } );</script>'; } else { // do nothing $jsuname = ''; } } else { return '<p id="diLITV">You must be logged in to view comments.</p>'; } } if (di_getparam('closeComments') == 1 && $params->created <= strtotime ( "-14 day" )) { $jsuname = '<script type="text/javascript">jQuery(window).load(function() { jQuery("#txtdiBody").parent().parent().parent().parent().parent().replaceWith(\'<p id="diTC">This thread is now closed.</p>\'); jQuery(".diRep").hide(); } );</script>'; } $user = JFactory::getUser (); $content = '<form class="comment-form" id="comment-form" name="comment-form" action="" method="post">'; $content .= $w1 . $widgetid . $tref . $w2 . getseo ( $url, $widgetid ) . $w3 . $jsuname; $content .= '<script src="plugins/content/plg_discussit/plg_discussit.js" type="text/javascript"></script>'; $content .= '<form class="comment-form" name="comment-form" action="" method="post">'; $content .= '</form>'; } else if (di_getparam ( 'Key' ) == '') { $content = 'Please enter correct API key in plugin settings!'; } else { $content = 'Error: widgetID not found. Please check that scripts can make outgoing connections from this host.'; } } else { $content = di_getparam ( 'disabledText' ); } } else if (JRequest::getCmd ( 'option' ) == 'com_content' && JRequest::getCmd ( 'view' ) == 'featured') { //front-page mode if (di_getparam ( 'ShowViewAdd' ) != '') { if ($GLOBALS ['sc'] == 'yes') { $num_com = ''; //' [' . $num_com . ']' $query = "SELECT COUNT(*) FROM #__di_comments WHERE pid = '$params->id' and status in ('a', 'h')"; $db = JFactory::getDbo (); $db->setQuery ( $query ); $count = $db->loadResult (); if (di_getparam ( 'showCount' ) == 1) $num_com = " ($count) "; $route = JRoute::_ ( JURI::base () . 'index.php?view=article&catid=' . $params->catslug . '&id=' . $params->slug ); $link = '<a href="' . $route . '">' . di_getparam ( 'ShowViewAdd' ) . '</a>' . $num_com; $content = $link; } else { $content = ''; } } else { $content = ''; } } else { $content = ''; } return $content; }