public static function getInstance() { if (empty(self::$instance)) { self::$instance = new Database_Config_General(); } return self::$instance; }
public function __construct($bible) { $this->bible = $bible; $this->currentParagraphStyle = ""; $this->currentParagraphContent = ""; $this->currentTextStyle = array(); $this->frameCount = 0; $this->noteCount = 0; $this->currentNoteTextStyle = array(); $database_config_general = Database_Config_General::getInstance(); $database_config_bible = Database_Config_Bible::getInstance(); $template = dirname(__FILE__) . "/template.odt"; $this->unpackedOdtFolder = Filter_Archive::unzip($template, false); Filter_Rmdir::rmdir($this->unpackedOdtFolder . "/Configurations2"); $this->contentDom = new DOMDocument(); $this->contentDom->load($this->unpackedOdtFolder . "/content.xml"); $contentXpath = new DOMXpath($this->contentDom); $this->officeTextDomNode = $contentXpath->query("office:body/office:text")->item(0); // Remove the default content from the template. This is a text:p element. $node = $contentXpath->query("text:p", $this->officeTextDomNode)->item(0); $this->officeTextDomNode->removeChild($node); $this->createdStyles = array(); $this->stylesDom = new DOMDocument(); $this->stylesDom->load($this->unpackedOdtFolder . "/styles.xml"); $stylesXpath = new DOMXpath($this->stylesDom); $this->officeStylesDomNode = $stylesXpath->query("office:styles")->item(0); // Set the page size and margins. $pageLayoutProperties = $stylesXpath->query("descendant::style:page-layout-properties")->item(0); $pageLayoutProperties->setAttribute("fo:page-width", $database_config_bible->getPageWidth($this->bible) . "mm"); $pageLayoutProperties->setAttribute("fo:page-height", $database_config_bible->getPageHeight($this->bible) . "mm"); $pageLayoutProperties->setAttribute("fo:margin-left", $database_config_bible->getInnerMargin($this->bible) . "mm"); $pageLayoutProperties->setAttribute("fo:margin-right", $database_config_bible->getOuterMargin($this->bible) . "mm"); $pageLayoutProperties->setAttribute("fo:margin-top", $database_config_bible->getTopMargin($this->bible) . "mm"); $pageLayoutProperties->setAttribute("fo:margin-bottom", $database_config_bible->getBottomMargin($this->bible) . "mm"); // Update the tab-stops in the relevant header styles. The tab stops depend on page and margin dimensions. $nodeList = $stylesXpath->query("descendant::style:style[contains(attribute::style:parent-style-name,'Header')]//descendant::style:tab-stop"); $centerPosition = $database_config_bible->getPageWidth($this->bible) - $database_config_bible->getInnerMargin($this->bible) - $database_config_bible->getOuterMargin($this->bible); $centerPosition /= 2; $counter = 0; foreach ($nodeList as $node) { $modulus = $counter % 2; $node->setAttribute("style:position", $centerPosition * ($modulus + 1) . "mm"); $counter++; } // Remove the date style for the running headers, so that it takes the default style. $numberDateStyleNode = $stylesXpath->query("descendant::number:date-style")->item(0); $numberDateStyleNode->parentNode->removeChild($numberDateStyleNode); // Whether and how to put the date in the running headers. $nodeList = $stylesXpath->query("descendant::text:date"); foreach ($nodeList as $node) { if ($database_config_bible->getDateInHeader($this->bible)) { $node->removeAttribute("text:date-value"); $node->nodeValue = ""; } else { $node->parentNode->removeChild($node); } } }
public static function user_zone(&$datetime) { $database_config_general = Database_Config_General::getInstance(); $timezone = $database_config_general->getTimezone(); if ($timezone != "") { $datetimezone = new DateTimeZone($timezone); $datetime->setTimezone($datetimezone); } }
public function testList() { $database_config_general = Database_Config_General::getInstance(); $values = $database_config_general->getList("test2"); $this->assertEquals(array(), $values); $database_config_general->setList("test", array(1, 2, 3)); $values = $database_config_general->getList("test"); $this->assertEquals(array(1, 2, 3), $values); }
private function __construct() { $database_config_general = Database_Config_General::getInstance(); $locale = $database_config_general->getSiteLanguage(); if ($locale != "") { $textdomain = dirname(__FILE__); $content = "{$textdomain}/{$locale}.mo"; $this->translate = new Zend_Translate(array('adapter' => 'gettext', 'content' => $content, 'locale' => $locale)); } }
public static function client_demo_warning() { $warning = ""; if (Filter_Client::enabled()) { $database_config_general = Database_Config_General::getInstance(); $address = $database_config_general->getServerAddress(); if ($address == self::demo_address()) { $warning = Locale_Translate::_("Warning:") . " " . Locale_Translate::_("The client is connected to a public demo server.") . " " . Locale_Translate::_("Everybody can modify the data on that server.") . " " . Locale_Translate::_("After send and receive your data will reflect the data on the server."); } } return $warning; }
public function __construct() { $config_general = Database_Config_General::getInstance(); $storagehost = $config_general->getMailStorageHost(); $storageusername = $config_general->getMailStorageUsername(); $storagepassword = $config_general->getMailStoragePassword(); $storagesecurity = $config_general->getMailStorageSecurity(); $storageport = $config_general->getMailStoragePort(); $config = array('host' => $storagehost, 'user' => $storageusername, 'password' => $storagepassword); if ($storagesecurity != "NONE") { $config = array_merge($config, array('ssl' => $storagesecurity)); } if ($storageport != "") { $config = array_merge($config, array('port' => $storageport)); } $this->storage = new Zend_Mail_Storage_Pop3($config); $this->count = $this->storage->countMessages(); }
public function __construct($title) { $this->currentParagraphStyle = ""; $this->currentParagraphContent = ""; $this->currentTextStyle = array(); $this->frameCount = 0; $this->noteCount = 0; $this->currentNoteTextStyle = array(); $database_config_general = Database_Config_General::getInstance(); $this->htmlDom = new DOMDocument(); $this->htmlDom->load(dirname(__FILE__) . "/template.html"); $htmlXpath = new DOMXpath($this->htmlDom); $nodeList = $htmlXpath->query("*"); $this->headDomNode = $nodeList->item(0); $element = $this->newElement("title"); $this->headDomNode->appendChild($element); $element->nodeValue = htmlspecialchars($title, ENT_QUOTES, "UTF-8"); $this->bodyDomNode = $nodeList->item(1); $this->notesDivDomNode = $this->newElement("div"); }
public static function setup($user = "", $hash = "") { $database_config_general = Database_Config_General::getInstance(); $database_users = Database_Users::getInstance(); if ($user == "") { $users = $database_users->getUsers(); if (empty($users)) { return false; } $user = $users[0]; $hash = $database_users->getmd5($user); } $encoded_user = bin2hex($user); $address = $database_config_general->getServerAddress(); $url = "{$address}/sync/setup.php?user={$encoded_user}&pass={$hash}"; @($response = file_get_contents($url)); if ($response >= Filter_Roles::GUEST_LEVEL && $response <= Filter_Roles::ADMIN_LEVEL) { // Set user's role on the client to be the same as on the server. $database_users->updateUserLevel($user, $response); } return $response; }
public function __construct($to_mail, $to_name, $subject, $body) { $config_general = Database_Config_General::getInstance(); $mail = new Zend_Mail(); $mail->setFrom($config_general->getSiteMailAddress(), $config_general->getSiteMailName()); $mail->addTo($to_mail, $to_name); $mail->setSubject($subject); $mail->setBodyHtml($body, "UTF-8", Zend_Mime::ENCODING_8BIT); $smtp_host = $config_general->getMailSendHost(); $smtp_authentication = $config_general->getMailSendAuthentication(); $smtp_user = $config_general->getMailSendUsername(); $smtp_password = $config_general->getMailSendPassword(); $smtp_security = $config_general->getMailSendSecurity(); $smtp_port = $config_general->getMailSendPort(); if ($smtp_host != "") { if ($smtp_authentication != "None") { $config = array('auth' => $smtp_authentication, 'username' => $smtp_user, 'password' => $smtp_password); $mta = new Zend_Mail_Transport_Smtp($smtp_host); } if ($smtp_security != "NONE") { $config = array_merge($config, array('ssl' => $smtp_security)); } if ($smtp_port != "") { $config = array_merge($config, array('port' => $smtp_port)); } if (isset($config)) { $mta = new Zend_Mail_Transport_Smtp($smtp_host, $config); } else { $mta = new Zend_Mail_Transport_Smtp($smtp_host); } $mail->send($mta); } else { // If no smtp host is given, it uses the default sendmail mail transport agent. $mail->send(); } }
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; page_access_level(Filter_Roles::MANAGER_LEVEL); Assets_Page::header(Locale_Translate::_("Changes")); $view = new Assets_View(__FILE__); $database_modifications = Database_Modifications::getInstance(); $config_general = Database_Config_General::getInstance(); $database_logs = Database_Logs::getInstance(); @($clear = $_GET['clear']); if (isset($clear)) { // Just in case there are many change notifications to clear, be sure the script does not time out or abort. ignore_user_abort(true); set_time_limit(0); $database_modifications->clearNotificationsUser($clear); } $users = Access_User::assignees(); $pendingUsers = array(); $pendingCount = array(); foreach ($users as $user) { $ids = $database_modifications->getNotificationIdentifiers($user); $count = count($ids); if ($count > 0) {
/** * handleEmailComment - handles an email received from $from with subject $subject and body $body. * Returns true if the mail was processed, else false. * The email is considered to have been processed if it comments on an existing Consultation Note. */ public function handleEmailComment($from, $subject, $body) { // Check whether the Consultation Notes Identifier in the $subject exists in the notes database. // The CNID looks like: (CNID123456789) $pos = strpos($subject, "(CNID"); if ($pos === false) { return false; } $subject = substr($subject, $pos + 5); $pos = strpos($subject, ")"); if ($pos === false) { return false; } $subject = substr($subject, 0, $pos); // At this stage, the $subject contains an identifier. // Check that the $identifier is an existing Consultation Note. $identifier = $subject; unset($subject); $database_notes = Database_Notes::getInstance(); if (!$database_notes->identifierExists($identifier)) { return false; } // Check that the $from address of the email belongs to an existing user. // Or else use the obfuscated email address as the user name. $from = Filter_Email::extractEmail($from); $database_users = Database_Users::getInstance(); if ($database_users->emailExists($from)) { $username = $database_users->getEmailToUser($from); } else { $username = $from; $username = str_replace("@", " ", $username); $username = str_replace(".", " ", $username); } // Clean the email's body. $config_general = Database_Config_General::getInstance(); $year = strftime("%Y"); $sender = $config_general->getSiteMailName(); $body = Filter_Email::extractBody($body, $year, $sender); // Remove any new lines from the body. This cleans up the email considerably, // because some emails that get posted would otherwise look untidy, // when the many new lines take up a lot of space. $body = str_replace("\n", " ", $body); // Make comment on the consultation note. $session_logic = Session_Logic::getInstance(); $sessionuser = $session_logic->currentUser(); $session_logic->setUsername($username); $this->addComment($identifier, $body); $session_logic->setUsername($sessionuser); // Mail confirmation to the $username. $database_config_user = Database_Config_User::getInstance(); if ($database_config_user->getUserNotifyMeOfMyPosts($username)) { $database_mail = Database_Mail::getInstance(); $subject = Locale_Translate::_("Your comment was posted"); $database_mail->send($username, "{$subject} [CNID{$identifier}]", $body); } // Log operation. $database_logs = Database_Logs::getInstance(); $database_logs->log("Comment posted" . ":" . " " . $body); // Job done. return true; }
public static function queueAll($now) { $database_config_bible = Database_Config_Bible::getInstance(); $database_bibles = Database_Bibles::getInstance(); $database_config_general = Database_Config_General::getInstance(); $bibles = $database_bibles->getBibles(); foreach ($bibles as $bible) { if ($database_config_bible->getRemoteRepositoryUrl($bible) != "") { if ($database_config_bible->getRepeatSendReceive($bible) || $now) { self::queuebible($bible); } } } }
function enable_client($username, $password, $level) { // Enable client mode upon a successful connection. Filter_Client::set(true); // Remove all users from the database, and add the current one. remove_all_users(); $database_users = Database_Users::getInstance(); $database_users->addNewUser($username, $password, $level, ""); // Clear all pending note actions and Bible actions and settings updates. $database_noteactions = Database_NoteActions::getInstance(); $database_bibleactions = Database_BibleActions::getInstance(); $database_config_user = Database_Config_User::getInstance(); $session_logic = Session_Logic::getInstance(); $database_noteactions->clear(); $database_noteactions->create(); $database_bibleactions->clear(); $database_bibleactions->create(); $session_logic->setUsername($username); $database_config_user->setUpdatedSettings(array()); // Set it repeats sync every so often. $database_config_general = Database_Config_General::getInstance(); $database_config_general->setRepeatSendReceive(2); // Schedule a sync operation straight-away. SendReceive_Logic::queuesync(true); }
private function __construct() { // Default encoding. mb_internal_encoding("UTF-8"); // On shared hosting the temporal location may give read or write failures. // Set private temporal location for PHP. // Set private temporal location for SQLite. // http://stackoverflow.com/questions/10394517/setting-sqlite-temp-store-directory $tmpdir = realpath(__DIR__ . "/../tmp"); putenv("TMPDIR={$tmpdir}"); // Check whether to run the website setup script. // On Linux it is sufficient to check whether the "setup" folder exists. // But on Windows, this setup folder cannot be deleted, so it would exist always. // Therefore, to support Windows, it checks whether the index file in in the setup folder. if (file_exists("../setup/index.php")) { $setupfolder = realpath("../setup"); $myfolder = realpath("."); if ($setupfolder != $myfolder) { include "../filter/url.php"; Filter_Url::redirect("../setup/index.php"); die; } } // Set the include path: Where to look for included files. $this->bibledit_root_folder = dirname(dirname(__FILE__)); $include_path = get_include_path() . PATH_SEPARATOR . $this->bibledit_root_folder; set_include_path($include_path); ini_set('include_path', $include_path); // Autoloader. // Automatically include the file that contains the $class_name. // E.g. class Database_Bibles would require file database/bibles.php. // Thus the name of the class determines which file gets required. // The above implies that all classes translate to files and folders in lower case. // An exception is made for the Zend_* classes. function __autoload($class_name) { if (substr($class_name, 0, 4) != "Zend") { $class_name = strtolower($class_name); } $path = str_replace("_", "/", $class_name); require_once $path . ".php"; } // Register the function. spl_autoload_register('__autoload'); // Disable magic quotes. if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) { foreach ($_GET as $k => $v) { $_GET[$k] = stripslashes($v); } foreach ($_POST as $k => $v) { $_POST[$k] = stripslashes($v); } foreach ($_COOKIE as $k => $v) { $_COOKIE[$k] = stripslashes($v); } } // General configuration database. $database_config_general = Database_Config_General::getInstance(); // The site's timezone. $timezone = $database_config_general->getTimezone(); if ($timezone) { date_default_timezone_set($timezone); } // Client mode setup. // In case the client mode is prepared, but not enabled, // the bootstrap script forwards to the client mode setup page, // unless it is already going to that page. if (Filter_Client::prepared()) { if (!Filter_Client::enabled()) { @($uri = $_SERVER["REQUEST_URI"]); $path = parse_url($uri, PHP_URL_PATH); $folder = pathinfo($path, PATHINFO_DIRNAME); $folder = basename($folder); $page = pathinfo($path, PATHINFO_BASENAME); if ($folder != "setup") { if ($page != "topbar.php") { if ($page != "client.php") { Filter_Url::redirect("../administration/client.php"); die; } } } } } }