/** * @return array all products that share comments with this one */ function getSharedWith() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $query = "Select product,value from webhelp where parameter='name' and version='" . $db->sanitize($this->version) . "' "; if (defined('__SHARE_WITH__')) { $query .= "AND product in ("; $shareArray = explode(",", __SHARE_WITH__); foreach ($shareArray as $key => $value) { $query .= "'" . $db->sanitize($value) . "', "; } $query = substr($query, 0, -2) . ");"; } error_log($query); $prds = $db->Open($query); if ($prds > 0) { while ($db->MoveNext()) { $product = $db->Field('product'); $value = $db->Field('value'); $toReturn[$product] = $value; } } $db->close(); return $toReturn; }
function getBaseUrl($product, $version) { global $dbConnectionInfo; $toReturn = __BASE_URL__; $db = new RecordSet($dbConnectionInfo, false, true); $rows = $db->Open("SELECT value FROM webhelp WHERE parameter='path' AND product='" . $db->sanitize($product) . "' AND version='" . $db->sanitize($version) . "';"); if ($rows == 1) { $db->MoveNext(); $toReturn = $db->Field('value'); } $db->Close(); return $toReturn; }
/** * Change password for an specified email with the specified one * * @param String $email user emai * @param String $password unencripted password * @return String user name */ function changePassword($email, $password) { $toReturn = ""; $db = new RecordSet($this->dbConnectionInfo); if ($password == $db->sanitize($password)) { $query = "UPDATE users SET password = '******' WHERE email='" . $email . "'"; $rows = $db->Run($query); if ($rows > 0) { $query = "SELECT userName FROM users WHERE email='" . $email . "'"; $db->Open($query); $db->MoveNext(); $toReturn = $db->Field("userName"); } } $db->Close(); return $toReturn; }
/** * Update comment into database * * @param array $info containing 'page','text','referedComment','sessionUser','editedId' * @return array containing int no of rows affected, and commnetId of the new inserted comment */ function update($info) { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo); $commentId = isset($info['editedId']) && strlen(trim($info['editedId'])) > 0 ? trim($info['editedId']) : -1; $query = "SELECT * FROM comments WHERE commentId={$commentId};"; $toReturn['rows'] = -1; if ($db->Open($query) > 0) { $db->MoveNext(); $product = $db->Field("product"); $version = $db->Field("version"); $cmtUser = $db->Field("userId"); if ($this->isLoggedModerator($cmtUser)) { $text = $db->sanitize(Utils::strip_html_tags($info['text'])); $sql = "UPDATE comments SET date=date, text = '" . $text . "' WHERE commentId = " . $commentId . ";"; $toReturn['rows'] = $db->Run($sql); $toReturn['id'] = $commentId; } } $db->Close(); return $toReturn; }
function installProduct($dbConnectionInfo) { global $productId, $productVersion; try { $db = new RecordSet($dbConnectionInfo, false, true); $productId = $db->sanitize($productId); $productVersion = $db->sanitize($productVersion); $db->Run("DELETE FROM webhelp WHERE parameter='path' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='installDate' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='dir' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->Run("DELETE FROM webhelp WHERE parameter='name' AND product='" . $productId . "' AND version='" . $productVersion . "';"); $db->run("INSERT INTO `webhelp` (`parameter`, `value`, `product`, `version`) VALUES\r\n\t\t\t\t\t\t('installDate','" . date('YmdHis') . "','" . $productId . "','" . $productVersion . "'),\r\n\t\t\t\t\t\t\t('path','" . addslashes(Utils::getParam($_POST, 'baseUrl')) . "','" . $productId . "','" . $productVersion . "'),\r\n\t\t\t\t\t\t\t('dir','" . addslashes(dirname(dirname(__FILE__))) . "','" . $productId . "','" . $productVersion . "'),\r\n\t\t\t\t\t\t\t('name','" . addslashes(Utils::getParam($_POST, 'productName')) . "','" . $productId . "','" . $productVersion . "')\r\n\t\t\t\t\t\t\t;"); $db->Close(); } catch (Exception $e) { error_log("Exception installing product " . $productId . " version " . $productVersion . " details: " . $e->getMessage()); echo "Exception installing product " . $productId . " version " . $productVersion . " details: " . $e->getMessage(); throw $e; } }
Oxygen Webhelp plugin Copyright (c) 1998-2015 Syncro Soft SRL, Romania. All rights reserved. Licensed under the terms stated in the license file EULA_Webhelp.txt available in the base directory of this Oxygen Webhelp plugin. */ if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); } $baseDir0 = dirname(dirname(__FILE__)); include $baseDir0 . '/resources/php/init.php'; $version = "1.0"; if (isset($_POST['host']) && isset($_POST['user']) && isset($_POST['passwd']) && isset($_POST['db'])) { $dbConnectionInfo = array('dbHost' => $_POST['host'], 'dbName' => $_POST['db'], 'dbPassword' => $_POST['passwd'], 'dbUser' => $_POST['user']); try { $db = new RecordSet($dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $db->sanitize($version) . "'; "); if ($prds > 0) { echo "<div class=\"title\">Display comments from</div>\n\t\t\t<div class=\"desc\">Share other products comments (having the same version) with this one. You must select one or more products from the list. Hold down the Ctrl (windows) / Command (Mac) button to select multiple options. </div>\n\t\t\t<table>\n\t\t\t<tr>\n\t\t\t<td>Existing products sharing the same database\n\t\t\t</td>\n\t\t\t<td>"; echo "<select multiple=\"multiple\" name=\"shareWith[]\" size=\"5\">"; while ($db->MoveNext()) { $product = $db->Field('product'); $name = $db->Field('value'); echo "<option value=\"" . $product . "\">" . $name . "</option>"; } echo "</select>"; echo "</td>\n\t\t\t</tr></table></div>"; } } catch (Exception $ex) { echo "<br/>Could not connect to database using specified information:"; echo "<table class=\"info\">"; echo "<tr><td>Host </td><td>" . $dbConnectionInfo['dbHost'] . "</td></tr>";
/** * Query all versions for a specified product * * @param $product product to query versions for * @return array String:Strign */ function queryVersions($product) { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo); $query = "SELECT version,visible FROM comments WHERE product='" . $db->sanitize($product) . "' ORDER by version;"; if ($db->Open($query) > 0) { while ($db->MoveNext()) { $toReturn[$db->Field('version')] = $db->Field('visible'); } } $db->Close(); return $toReturn; }