function updateDb() { $params = array(); $toReturn = array(); $toReturn['updated'] = true; $toReturn['message'] = ""; $db = new RecordSet($this->dbConnectionInfo, false, true); $rows = $db->Open("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . $this->dbConnectionInfo['dbName'] . "' AND TABLE_NAME = 'webhelp'"); if ($rows > 0) { $db->Open("SELECT * FROM webhelp;"); while ($db->MoveNext()) { $assoc = $db->getAssoc(); $params[$db->Field("parameter")] = $db->Field("value"); } $db->Close(); if ($params['databaseVersion'] != '1') { $toReturn['updated'] = false; $toReturn['message'] = "Incompatible database version found!"; } } else { $toReturn['updated'] = false; $toReturn['message'] = "Database structure does not exist! In order to create a compatible database structure you must check option <strong>\"Create new database structure\"</strong> from previous instalation page."; } return $toReturn; }
/** * @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; }
/** * @return array all products that share comments with this one */ function getSharedWith() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $this->version . "' " . (defined('__SHARE_WITH__') ? "AND product in (" . __SHARE_WITH__ . ")" : '') . ";"); 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='" . $product . "' AND version='" . $version . "';"); if ($rows == 1) { $db->MoveNext(); $toReturn = $db->Field('value'); } $db->Close(); return $toReturn; }
private function getEmails() { global $dbConnectionInfo; $this->to = array(); if (defined('__ADMIN_EMAIL__') && strlen(trim(__ADMIN_EMAIL__)) > 0) { $this->to[] = __ADMIN_EMAIL__; } if (defined("__SEND_ERRORS__") && __SEND_ERRORS__) { try { $ds = new RecordSet($dbConnectionInfo, false, true); $ds->open("SELECT email FROM users WHERE level='admin';"); while ($ds->MoveNext()) { $this->to[] = $ds->Field('email'); } $ds->close(); } catch (Exception $e) { // ignore $msg = date("Y-m-d H:i:s") . ": Error:[" . $e->getCode() . "] message:[" . $e->getMessage() . "]\tfile:[" . $e->getFile() . "] line:[" . $e->getLine() . "]"; $this->bag .= "[" . $this->getRealIpAddr() . "] - " . $msg . "<br/>"; $this->count++; $this->sendInternal(false); } } }
/** * Gather user information * * @param string $username Find information for 'username' * @param string $info Required attribute of the user account object * @return null|string User information * @throws Exception */ public function getUserInformation($username, $info) { $toReturn = null; $db = new RecordSet($this->dbConnectionInfo, false, true); $information = $db->Open("SELECT email FROM users WHERE userName = '******' AND password != '';"); switch ($information) { case 1: // User found in local database $toReturn = $db->Field('email'); break; case 0: // User not found in local database // Try to find it in LDAP if ($this->ldap instanceof Ldap) { try { $information = $this->ldap->getUserInfo($username, array($info)); $toReturn = @$information[0][$info][0]; } catch (Exception $e) { throw new Exception($e->getMessage()); } } break; default: throw new Exception('No or more than one email address found for ' . $username); } return $toReturn; }
function deleteRecursive($ids) { if (count($ids) > 0) { $db = new RecordSet($this->dbConnectionInfo, false, true); $toDelete = array(); $idsS = implode(", ", $ids); $db->open("SELECT commentId FROM comments WHERE referedComment in (" . $idsS . ");"); while ($db->MoveNext()) { $toDelete[] = $db->Field("commentId"); } $query = "DELETE FROM comments WHERE commentId in (" . $idsS . ");"; $toReturn = $db->Run($query); $db->close(); if (count($toDelete) > 0) { $this->deleteRecursive($toDelete); } } }
/** * Get allproduct for witch this user is valid * * @return multitype:Strign productId=>Name */ function getSharedProducts() { $toReturn = array(); $db = new RecordSet($this->dbConnectionInfo, false, true); $prds = $db->Open("Select product,value from webhelp where parameter='name' ;"); if ($prds > 0) { while ($db->MoveNext()) { $product = $db->Field('product'); $value = $db->Field('value'); $toReturn[$product] = $value; } } $db->close(); return $toReturn; }
Licensed under the terms stated in the license file EULA_Webhelp.txt available in the base directory of this Oxygen Webhelp plugin. */ $baseDir0 = dirname(dirname(__FILE__)); include $baseDir0 . '/oxygen-webhelp/resources/php/init.php'; $version = "@PRODUCT_VERSION@"; 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='" . $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 informations:"; echo "<table class=\"info\">"; echo "<tr><td>Host </td><td>" . $dbConnectionInfo['dbHost'] . "</td></tr>"; echo "<tr><td>Database </td><td>" . $dbConnectionInfo['dbName'] . "</td></tr>"; echo "<tr><td>User </td><td>" . $dbConnectionInfo['dbUser'] . "</td></tr>"; echo "</table>"; echo "<br/>The error was:<br/>", $ex->getMessage(), "<br/>", $ex->getTraceAsString(); $continue = false;