<img src="components/com_discussit/media/images/DiscussitLogo_square.png" /> <br /> <br /> <table width="560px"> <tr><td><label for="comment">Enter API Key Here:</label></td><td><input type = "text" id="key" name="key" size="54"></td><td colspan=""><input type="submit" name="submit" onclick="window.parent.document.getElementById( \'sbox-window\' ).close;"/></td></tr> </table></form> <div id="console"> '; break; case 'submitapi': echo '<style type="text/css">html{overflow:auto !important}</style>'; $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $apikey = trim(JRequest::getVar('key')); $di = new discussit(); $details = $di->get_details_from_api_key($apikey); if (!in_array('curl', get_loaded_extensions())) { die('Error - cURL not forund. <hr /> cURL must be installed, enabled and not blocked for DiscussIt to function properly. '); } echo '<br />Retrieved: ' . date('Y-m-d D H:i:s') . '<hr />'; $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = $endtime - $starttime; echo "Request completed in {$totaltime} seconds <hr />"; if ($details->siteID == '' || $details->widgetID == '' || $details->clientID == '' || $details->clientSecret == '' || $details->refreshToken == '') { echo 'Error - Incorrect API key click <a href="?option=com_discussit&action=enterapiform&tmpl=component">here</ a> to try again.'; } else { foreach ($details as $key => $detail) {
function onContentBeforeDisplay($article, &$params, $limitstart) { global $sc; /** * * comment controller * */ if ((isset ( $_POST ['txtdiBody'] ) && isset ( $_POST ['txtdiNickname'] ) && isset ( $_POST ['txtdiEmail'] )) || (isset ( $_POST ['txtdiReplyBody'] ) && isset ( $_POST ['txtdiRNickname'] ) && isset ( $_POST ['txtdiREmail'] ))) { if (isset ( $_POST ['diRT'] )) { $diRT = $_POST ['diRT']; $db = JFactory::getDBO (); $query = "SELECT cid FROM `#__di_comments` WHERE did = '$diRT'"; $db->setQuery ( $query ); $com_rt = $db->loadResult (); } else $com_rt = 0; try { if (isset ( $_POST ['txtdiReplyBody'] ) && isset ( $_POST ['txtdiRNickname'] ) && isset ( $_POST ['txtdiREmail'] )) { $com_body = $_POST ['txtdiReplyBody']; $com_name = $_POST ['txtdiRNickname']; $com_mail = $_POST ['txtdiREmail']; $com_replyto = $_POST ['diRT']; } else { $com_body = $_POST ['txtdiBody']; $com_name = $_POST ['txtdiNickname']; $com_mail = $_POST ['txtdiEmail']; $com_replyto = ''; } //TODO: get comments from prev 24 hrs compare to $com_body; $query = "SELECT comment FROM #__di_comments WHERE comment = " . $db->quote ( $com_body ); //TODO: add escape string!!! $db = JFactory::getDBO (); $db->setQuery ( $query ); $resp = $db->loadResult (); if ($resp != '') return "<script>alert('Duplicate comment detected!')</script>"; $query = "INSERT INTO #__di_comments (comment, name, email, pid, date, parent" . ") VALUES (" . "'$com_body', '$com_name', '$com_mail', '$params->id', NOW(), '$com_rt')"; $db = JFactory::getDBO (); $db->setQuery ( $query ); $db->query (); $cid = $db->insertid (); $di = new discussit (); $wid = di_getparam ( 'widgetID' ); $realurl = JURI::current(); $pageurl = 'http://www.discussit.com/' . $wid . '/' . $params->id; $cip = '127.0.0.1'; if (isset ( $_POST ['txtdiRNickname'] )) { $cuser = $_POST ['txtdiRNickname']; } else { $cuser = $_POST ['txtdiNickname']; } if (isset ( $_POST ['txtdiREmail'] )) { $cemail = $_POST ['txtdiREmail']; } else { $cemail = $_POST ['txtdiEmail']; } $curl = 'test'; //$replyto = 0; if (isset ( $_POST ['txtdiReplyBody'] )) { $comment_body = $_POST ['txtdiReplyBody']; } else { $comment_body = $_POST ['txtdiBody']; } $rm = $di->message_post ( $cid, $wid, $pageurl, $realurl, $_POST ['diIdent'], $cuser, $cip, $cemail, $curl, $comment_body, $com_replyto ); $carray = explode ( ',', $rm ); $did = $carray [1]; echo "<script>alert('Message posted');</script>"; $query = "UPDATE #__di_comments SET did = '$did' WHERE cid='$cid'"; $db = JFactory::getDBO (); $db->setQuery ( $query ); $db->query (); } catch ( Exception $e ) { } } $sections = di_getparam ( 'sections' ); $sect = explode ( ',', $sections ); if (JRequest::getCmd ( 'option' ) == 'com_content' && JRequest::getCmd ( 'view' ) == 'article') { //article mode if (! empty ( $sect )) { $catId = $params->catid; if (in_array ( $catId, $sect )) { $this->params->set ( 'showcomments', '1' ); } else { $this->params->set ( 'showcomments', '0' ); } } else { $this->params->set ( 'showcomments', '0' ); } if (strpos ( $params->text, '{nocomments}' ) != false) { $outText = str_replace ( "{nocomments}", '', $params->text ); $params->text = $outText; $this->params->set ( 'showcomments', '0' ); } if (strpos ( $params->text, '{showcomments}' ) != false) { $outText = str_replace ( "{showcomments}", '', $params->text ); $params->text = $outText; $this->params->set ( 'showcomments', '1' ); } } else { //frontpage mode if (! empty ( $sect )) { $catId = $params->catid; if (in_array ( $catId, $sect )) { $sc = 'yes'; } else { $sc = 'no'; } } else { $sc = 'no'; } if (strpos ( $params->introtext, '{nocomments}' ) != false) { $outText = str_replace ( "{nocomments}", '', $params->introtext ); $params->introtext = $outText; $sc = 'no'; } if (strpos ( $params->introtext, '{showcomments}' ) != false) { $outText = str_replace ( "{showcomments}", '', $params->introtext ); $params->introtext = $outText; $sc = 'yes'; } } return ''; }