/** * Generates a html-view of either the first or the specified svn-commit message. * Uses the template to render the * @param string $objLogRootNode * @return SimpleXMLElement */ public function generateHtmlFromLogContent($strLogRootNode, $strRevisionNumber = "") { $objOneLogEntry = $this->getLogNodeToProcess($strLogRootNode, $strRevisionNumber); $arrObjAttributes = $objOneLogEntry->attributes(); //prepare log-message $strChangedFiles = ""; foreach ($objOneLogEntry->paths->path as $objOnePath) { $objPathAttributes = $objOnePath->attributes(); $strChangedFiles .= "<li>" . $objPathAttributes->action . " " . $objOnePath . "</li>"; } $arrTemplate = array(); $arrTemplate["revision"] = $arrObjAttributes->revision . ""; $arrTemplate["author"] = $objOneLogEntry->author . ""; $arrTemplate["date"] = date("r", strtotime($objOneLogEntry->date)); $arrTemplate["description"] = nl2br(htmlentities($objOneLogEntry->msg . "")); $arrTemplate["changedfiles"] = nl2br($strChangedFiles); //read the template if (!file_exists(SVN2RSS_PROJECT_ROOT . "/" . SVN2RSS_SYSTEM_FOLDER . "/" . $this->objConfig->getStrHtmlViewTemplate())) { throw new Svn2RssException("Template could not be loaded: " . SVN2RSS_PROJECT_ROOT . "/" . SVN2RSS_SYSTEM_FOLDER . "/" . $this->objConfig->getStrHtmlViewTemplate()); } $strTemplateContent = file_get_contents(SVN2RSS_PROJECT_ROOT . "/" . SVN2RSS_SYSTEM_FOLDER . "/" . $this->objConfig->getStrHtmlViewTemplate()); foreach ($arrTemplate as $strKey => $strValue) { $strTemplateContent = str_replace("%%" . $strKey . "%%", $strValue, $strTemplateContent); } return $strTemplateContent; }
/** * @covers Main\Config\ConfigReader::readConfig * @todo Implement testReadConfig(). */ public function testReadConfig() { $configLocal = $this->object->readConfig(); $this->assertInternalType('array', $configLocal); $configProd = (require BASE_DIR . '/config/appConfig.php'); $this->assertArrayHasKey('app', $configProd); }
public function getConfig() { $configAddress = dirname(__FILE__) . "/config/ConfigReader.php"; require $configAddress; $configReader = new ConfigReader(); $db = $configReader->getDatabaseConfig(); return $db; }
public static function getExecute($sIniFile) { $config = new ConfigReader($sIniFile); $config_data = $config->getConfig(); $database_class = key($config_data) . '_spdo'; include_once $database_class . '.php'; $exec = BaseDatosFactory::getExecute($database_class); return $exec; }
/** * Gets the current theme for the album */ function getCurrentTheme($albumName) { $cp = new ConfigReader(PF_CONFIG_FILE); $albums = $cp->getChildren("settings/albums"); foreach($albums as $album) { if($album['attributes']['name'] == $albumName) { return $album['attributes']['theme']; } } }
function init($args) { $name = $args['name']; $location = $args['location']; //check if album already exists $cp = new ConfigReader(PF_CONFIG_FILE); $albums = $cp->getChildren("settings/albums"); if ($albums) { foreach ($albums as $album) { if ($album['attributes']['name'] == $name) { error("Album {$name} already exists!"); return; } } } define("ALBUM_DIR", realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $location)); //check if it exists if (!is_dir(ALBUM_DIR)) { error("It seems like the directory {$location} does not exist."); return; } //check if directory writeable if (!is_writeable(ALBUM_DIR)) { error("Could not create album. Could not write to {$location}." . ALBUM_DIR); return; } //get a list of photos (jpg/png) //generate thumbnails chdir(ALBUM_DIR); //try to make thumbnail directory if (!is_dir(PF_THUMBNAIL_DIR)) { if (!mkdir(PF_THUMBNAIL_DIR)) { error("Could not create thumbnails directory in {$location}"); return; } } //generate thumbnails //it seems glob cannot take multiple patterns $pattern = array("*.jpg", "*.jpeg", "*.png"); foreach ($pattern as $pat) { foreach (glob($pat) as $file) { if (!makeThumbnail($file, PF_THUMBNAIL_DIR . $file)) { error("Could not create thumbnail for image {$file}"); return; } } } //add album to config file $cp = new ConfigWriter(PF_CONFIG_FILE); $attributes = array("name" => $name, "location" => str_replace($_SERVER['DOCUMENT_ROOT'], "", ALBUM_DIR), "theme" => PF_DEFAULT_THEME); $cp->addWithAttributes('settings/albums/album', $attributes, ""); if (!$cp->close()) { error("Could not write to configuration file"); } success("Successfully created album {$name} in {$location}."); }
public function set(ConfigReader $config) { $config_data = $config->getConfig(); $keybd = key($config_data); $this->host = $config_data[$keybd]['host']; $this->port = $config_data[$keybd]['port']; $this->dbname = $config_data[$keybd]['dbname']; $this->user = $config_data[$keybd]['username']; $this->password = trim($config_data[$keybd]['password']); }
function init($args) { $name = $args['name']; $cp = new ConfigReader(PF_CONFIG_FILE); $albums = $cp->getChildren("settings/albums"); if (!$albums) { error("It seems you don't have any albums. Why don't you create one."); return; } $location = ""; //find our album location foreach ($albums as $album) { if ($album['attributes']['name'] == $name) { $location = $album['attributes']['location']; } } if ($location == "") { error("Could not find album {$name}"); return; } //see if it exists if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/' . $location)) { error("Album directory does not exist"); return; } $thumbnailDir = $_SERVER['DOCUMENT_ROOT'] . '/' . $location . '/' . PF_THUMBNAIL_DIR; //try removing the thumbnails if (@chdir($thumbnailDir)) { $pattern = array("*.jpg", "*.jpeg", "*.png"); foreach ($pattern as $pat) { foreach (glob($pat) as $file) { if (!unlink($file)) { error("Could not remove thumbnail for image {$file}"); return; } } } } //try removing thumbnails directory @rmdir($thumbnailDir); //remove from config $cp = new ConfigWriter(PF_CONFIG_FILE); if (!($cp->removeWithAttributes("settings/albums/album", "name", $name) && $cp->close())) { error("Could not remove album {$name}"); return; } success("Successfully removed album {$name}"); }
public function __construct($templateName = null) { $this->templateName = $templateName; $this->keyVal = array(); /** @var ConfigReader $conf */ $conf = ConfigReader::getInstance(); $this->templatePath = $conf->getTemplatePath(); $this->templateExtension = $conf->getTemplateExtension(); }
function init($args) { $albumName = $args['albumName']; $theme = $args['theme']; $location = ""; //read, delete, write $cpr = new ConfigReader(PF_CONFIG_FILE); $albums = $cpr->getChildren('settings/albums'); if (!$albums) { error("It seems you don't have any albums"); return; } $found = FALSE; foreach ($albums as $album) { if ($album['attributes']['name'] == $albumName) { $found = TRUE; $location = $album['attributes']['location']; break; } } if (!$found) { error("The album {$albumName} was not found"); return; } $cpr = new ConfigWriter(PF_CONFIG_FILE); if (!$cpr->removeWithAttributes('settings/albums/album', 'name', $albumName)) { error("Could not change theme for {$albumName}"); return; } $attrs = array("name" => $albumName, "location" => $location, "theme" => $theme); $cpr->addWithAttributes('settings/albums/album', $attrs, ""); if (!$cpr->close()) { error("Could not write to configuration file"); return; } success("Successfully changed theme for {$albumName} to {$theme}"); }
/** * Generates a rss-node-structure from the passed log-node-structure * @param string $objLogRootNode * @return SimpleXMLElement */ public function generateRssNodesFromLogContent($strLogRootNode) { $objFeedRootNode = new SimpleXMLElement("<rss version=\"2.0\"></rss>"); $objChannel = $objFeedRootNode->addChild("channel"); $objChannel->addChild("title", $this->objConfig->getStrFeedTitle()); $objChannel->addChild("description", $this->objConfig->getStrFeedDescription()); $objChannel->addChild("link", $this->objConfig->getStrSvnUrl()); $objChannel->addChild("pubDate", date("r", time())); //build a xml-tree out of the passed svn-log-content libxml_use_internal_errors(); $objSimpleXmlElement = simplexml_load_string($strLogRootNode); $arrParseErrors = libxml_get_errors(); libxml_clear_errors(); if (count($arrParseErrors) > 0) { throw new Svn2RssException("Error parsing xml-based svn log content.\nErrors:\n" . implode("\n", $arrParseErrors)); } foreach ($objSimpleXmlElement->logentry as $objOneLogEntry) { $arrObjAttributes = $objOneLogEntry->attributes(); $objRssItemNode = $objChannel->addChild("item"); //prepare log-message $strDescription = $objOneLogEntry->msg . ""; //include changed files? if ($this->objConfig->getBitFeedWithChangedFiles()) { $strDescription .= "\n\n"; foreach ($objOneLogEntry->paths->path as $objOnePath) { $objPathAttributes = $objOnePath->attributes(); $strDescription .= $objPathAttributes->action . " " . $objOnePath . "\n"; } } $strDescription = html_entity_decode($strDescription, ENT_COMPAT, "UTF-8"); $strDetailsLink = SVN2RSS_WEB_ROOT . "?feed=" . $this->objConfig->getStrConfigSetName() . "&revision=" . $arrObjAttributes->revision; //but: encode &, <, > $strDescription = nl2br($this->xmlSafeString($strDescription)); $strDetailsLink = $this->xmlSafeString($strDetailsLink); //title, description, logdate $objRssItemNode->addChild("title", $arrObjAttributes->revision . " by " . $objOneLogEntry->author); $objDescNode = $objRssItemNode->addChild("description", $strDescription); //$objRssItemNode->addChild("pubDate", $objOneLogEntry->date.""); $objRssItemNode->addChild("pubDate", date("r", strtotime($objOneLogEntry->date)) . ""); $objGuidNode = $objRssItemNode->addChild("guid", $arrObjAttributes->revision . ""); $objGuidNode->addAttribute("isPermaLink", "false"); $objRssItemNode->addChild("link", $strDetailsLink); } return $objFeedRootNode; }
private function generateCachename() { return md5($this->objConfig->getStrSvnUrl() . $this->objConfig->getStrConfigSetName()) . ".log"; }
function update_and_supress_output($data) { $cr = new ConfigReader(); $cr->udate_pending_items_count(-count($data)); return true; }
public function queueDataImport() { $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig'); $immediateImportRecordLimit = $configReader->getConfig('immediateImportLimit'); $numberOfRecordsToImport = $this->numberOfRecords; if ($numberOfRecordsToImport > $immediateImportRecordLimit) { $this->userInputObject->set('is_scheduled', true); } Import_Queue_Controller::add($this->userInputObject, $this->user); }
function __construct() { self::$default_conf_file = Utils::get_parent_dir() . '/config/config.json'; $this->config = array(); $this->read_config(); }
public static function getDbTableName($user) { $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig'); $userImportTablePrefix = $configReader->getConfig('userImportTablePrefix'); return $userImportTablePrefix . $user->id; }
<!---Albums--> <h3 id="album-header">Albums</h3> <div id="add-album-div"> <a href="" id="add-album-link">Add an Album</a> </div> <h4>Select an Album below to change its settings:</h4> <p id="no-albums-message">It seems you don't have any albums yet. Click on "Add an Album" above to add one.</p> <?php include_once "../scripts/pf_constants.php"; include_once PF_SCRIPTS_DIR . "pf_configparser.php"; $cp = new ConfigReader(PF_CONFIG_FILE); $albums = $cp->getChildren("settings/albums"); print '<ul id="album-list">'; if ($albums) { foreach ($albums as $album) { print '<li>' . $album['attributes']['name'] . '</li>'; } } print '</ul>'; ?> <h3 id="password-header">Change password</h3> <div id="password-div"> <form action="" id="password-change-form">
<?php require_once "defines.php"; if ($devMod) { error_reporting(E_ALL); ini_set('display_errors', true); } require_once 'ConfigReader.php'; //init config reader $configReader = new ConfigReader($mainFolderName, $templateName); $userConfigs = $configReader->getConfig(); //so beautifull code <3 if ($userConfigs) { foreach ($userConfigs as $configName => $userConfig) { if (!empty(${$configName})) { ${$configName} = $configReader->getConfig($configName); } } } require_once "config_smarty.php"; require_once CLASS_DIR . "/Controller.php"; require_once CLASS_DIR . "/FrontController.php"; if (file_exists(CLASS_DIR . "/" . $configReader->getControllerName() . ".php")) { require_once CLASS_DIR . "/" . $configReader->getControllerName() . ".php"; }
<?php //ini_set('display_errors', 1); //ini_set('display_startup_errors', 1); //error_reporting(E_ALL ); include_once "classes/API/RutrackerAPI.php"; include "ConfigReader.php"; include_once "classes/Utils.php"; $c = new ConfigReader(); $config = $c->getConfig(); $rt = new RutrackerAPI(); $rt->parse_user_params(); // Items from tracker $flist = $rt->getFutureList(); // Items from saved file //$file = $rt->read_from_file(); $file = Utils::read_from_file(); $items_from_file = array(); $new_items_counter = 0; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Rtracker lists</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">
public function createRecords() { $adb = PearDatabase::getInstance(); $moduleName = $this->module; $focus = CRMEntity::getInstance($moduleName); $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user); $moduleMeta = $moduleHandler->getMeta(); $moduleObjectId = $moduleMeta->getEntityId(); $moduleFields = $moduleMeta->getModuleFields(); $tableName = Import_Utils::getDbTableName($this->user); $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Controller::$IMPORT_RECORD_NONE; if ($this->batchImport) { $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig'); $importBatchLimit = $configReader->getConfig('importBatchLimit'); $sql .= ' LIMIT ' . $importBatchLimit; } $result = $adb->query($sql); $numberOfRecords = $adb->num_rows($result); if ($numberOfRecords <= 0) { return; } $fieldMapping = $this->fieldMapping; $fieldColumnMapping = $moduleMeta->getFieldColumnMapping(); for ($i = 0; $i < $numberOfRecords; ++$i) { $row = $adb->raw_query_result_rowdata($result, $i); $rowId = $row['id']; $entityInfo = null; $fieldData = array(); foreach ($fieldMapping as $fieldName => $index) { $fieldData[$fieldName] = $row[$fieldName]; } $mergeType = $this->mergeType; $createRecord = false; if (method_exists($focus, 'importRecord')) { $entityInfo = $focus->importRecord($this, $fieldData); } else { if (!empty($mergeType) && $mergeType != Import_Utils::$AUTO_MERGE_NONE) { $queryGenerator = new QueryGenerator($moduleName, $this->user); $queryGenerator->initForDefaultCustomView(); $fieldsList = array('id'); $queryGenerator->setFields($fieldsList); $mergeFields = $this->mergeFields; foreach ($mergeFields as $index => $mergeField) { if ($index != 0) { $queryGenerator->addConditionGlue(QueryGenerator::$AND); } $comparisonValue = $fieldData[$mergeField]; $fieldInstance = $moduleFields[$mergeField]; if ($fieldInstance->getFieldDataType() == 'owner') { $userId = getUserId_Ol($comparisonValue); $comparisonValue = getUserFullName($userId); } if ($fieldInstance->getFieldDataType() == 'reference') { if (strpos($comparisonValue, '::::') > 0) { $referenceFileValueComponents = explode('::::', $comparisonValue); } else { $referenceFileValueComponents = explode(':::', $comparisonValue); } if (count($referenceFileValueComponents) > 1) { $comparisonValue = trim($referenceFileValueComponents[1]); } } $queryGenerator->addCondition($mergeField, $comparisonValue, 'e'); } $query = $queryGenerator->getQuery(); $duplicatesResult = $adb->query($query); $noOfDuplicates = $adb->num_rows($duplicatesResult); if ($noOfDuplicates > 0) { if ($mergeType == Import_Utils::$AUTO_MERGE_IGNORE) { $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED; } elseif ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) { for ($index = 0; $index < $noOfDuplicates - 1; ++$index) { $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']); $entityId = vtws_getId($moduleObjectId, $duplicateRecordId); vtws_delete($entityId, $this->user); } $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']); $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId); if ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); $fieldData['id'] = $baseEntityId; $entityInfo = vtws_update($fieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.overwrite', $entityData); } if ($mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) { $filteredFieldData = array(); $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta); foreach ($fieldData as $fieldName => $fieldValue) { if (!empty($fieldValue)) { $filteredFieldData[$fieldName] = $fieldValue; } } $existingFieldValues = vtws_retrieve($baseEntityId, $this->user); foreach ($existingFieldValues as $fieldName => $fieldValue) { if (empty($fieldValue) && empty($filteredFieldData[$fieldName]) && !empty($defaultFieldValues[$fieldName])) { $filteredFieldData[$fieldName] = $fieldValue; } } $filteredFieldData = $this->transformForImport($filteredFieldData, $moduleMeta, false, true); $filteredFieldData['id'] = $baseEntityId; $entityInfo = vtws_revise($filteredFieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_MERGED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.merge', $entityData); } } else { $createRecord = true; } } else { $createRecord = true; } } else { $createRecord = true; } if ($createRecord) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); if ($fieldData == null) { $entityInfo = null; } else { $entityInfo = vtws_create($moduleName, $fieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_CREATED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.create', $entityData); } } } if ($entityInfo == null) { $entityInfo = array('id' => null, 'status' => self::$IMPORT_RECORD_FAILED); } $this->importedRecordInfo[$rowId] = $entityInfo; $this->updateImportStatus($rowId, $entityInfo); } unset($result); return true; }
<?php include_once "classes/API/RutrackerAPI.php"; include_once "classes/API/RutorAPI.php"; include "ConfigReader.php"; include_once "classes/Utils.php"; $c = new ConfigReader(); $config = $c->getConfig(); $rt = new RutrackerAPI(); $rt->init_action($config['rutracker']['username'], $config['rutracker']['password']); $rt->parse_user_params(); $flist = $rt->getFutureList(); $rutor = new RutorAPI(); $rt_result = $rutor_search = []; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Rtracker search <?php if (isset($_GET['search'])) { echo " - " . trim($_GET['search']); } ?> </title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<?php include_once "classes/API/RutrackerAPI.php"; include_once "classes/API/RutorAPI.php"; include "ConfigReader.php"; include_once "classes/Utils.php"; $c = new ConfigReader(); $config = $c->getConfig(); $rt = new RutrackerAPI(); $rt->parse_user_params(); $flist = $rt->getFutureList(); $response = false; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $c->save_param('rutracker', 'username', $_POST['rutracker-username'], false); $c->save_param('rutracker', 'password', $_POST['rutracker-password'], false); $c->save_param('search-in', 'rutracker', isset($_POST['search-in-rutracker']), false); $c->save_param('search-in', 'rutor', isset($_POST['search-in-rutor']), false); $response = $c->save_config_to_file(); $config = $c->getConfig(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Rtracker - Config page</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">