public function testDataFiles() { newConf('df', "components:\n df:\n files_path: /var/www/imagineapuddle.com/www/siteplay/site/test/files/\n"); if (!file_exists(dirname(__FILE__) . '/files/')) { mkdir(dirname(__FILE__) . '/files/'); } if (!file_exists(dirname(__FILE__) . '/files/test/')) { mkdir(dirname(__FILE__) . '/files/test/'); } file_put_contents(dirname(__FILE__) . '/files/test/testfile', 'Title: A Bing-a-bong Bar Biz: Bang Content '); $site = new Site(getConf('df')); $this->assertType('SiteDataFilesController', $site->df); $this->assertType('SiteDataFiles', $site->df->test); $f = $site->df->test->get(array('title' => 'A Bing-a-bong')); $this->assertType('SiteDataFile', $f); $this->assertEquals($f->title, 'A Bing-a-bong'); $this->assertEquals($f->bar_biz, 'Bang'); $this->assertEquals($f->content, "Content\n"); $f = $site->df->test->get(array('title' => 'Not-a-Title')); $this->assertNull($f); unlink(dirname(__FILE__) . '/files/test/.index'); unlink(dirname(__FILE__) . '/files/test/testfile'); rmdir(dirname(__FILE__) . '/files/test/'); rmdir(dirname(__FILE__) . '/files/'); killConf('df'); }
public function testTemplate() { newConf('tpl', "\ncomponents:\n tpl:\n template_dir: " . dirname(__FILE__) . "/view\n compile_dir: " . dirname(__FILE__) . "/view/_compile\n config_dir: " . dirname(__FILE__) . "/view/_config\n cache_dir: " . dirname(__FILE__) . "/view/_cache\n"); $site = new Site(getConf('tpl')); $site->tpl->display('test.tpl'); killConf('tpl'); }
public function testAddons() { newConf('addons', "\naddon_path: " . dirname(__FILE__) . "/addons1/:" . dirname(__FILE__) . "/addons2/\n"); if (!file_exists(dirname(__FILE__) . '/addons1/')) { mkdir(dirname(__FILE__) . '/addons1/'); } if (!file_exists(dirname(__FILE__) . '/addons2/')) { mkdir(dirname(__FILE__) . '/addons2/'); } file_put_contents(dirname(__FILE__) . '/addons1/addon1.php', ' <?php class SiteAddon1 extends SiteComponent { } ?> '); file_put_contents(dirname(__FILE__) . '/addons2/addon2.php', ' <?php class SiteAddon2 extends SiteComponent { } ?> '); $site = new Site(getConf('addons')); $this->assertType('SiteAddon1', $site->addon1); $this->assertType('SiteAddon2', $site->addon2); unlink(dirname(__FILE__) . '/addons1/addon1.php'); unlink(dirname(__FILE__) . '/addons2/addon2.php'); rmdir(dirname(__FILE__) . '/addons1/'); rmdir(dirname(__FILE__) . '/addons2/'); killConf('addons'); }
public function testDBs() { newConf('dbs', "\ncomponents:\n dbs:\n rw:\n model: true\n pool:\n - host: localhost\n username: fake\n password: fake\n database: fake\n - host: localhost\n username: sitetest\n password: st123\n database: sitetest_rw2\n ro:\n model: true\n host: localhost\n username: sitetest\n password: st123\n database: sitetest_ro1\n\n rw1:\n model: true\n host: localhost\n username: sitetest\n password: st123\n database: sitetest_rw1\n ro1:\n model: true\n host: localhost\n username: sitetest\n password: st123\n database: sitetest_ro1\n"); $site = new Site(getConf('dbs')); $this->assertType('SiteDatabase', $site->dbs->rw); $this->assertType('SiteDatabase', $site->dbs->ro); $this->assertFalse($site->dbs->rw === $site->dbs->ro); $this->assertType('null', $site->dbs->notadb); $site->dbs->ro1->ro1->all(1); $site->dbs->rw1->rw1->all(1); killConf('dbs'); }
function changeFromFtp() { global $message; global $specialchars; $success = false; $dirgallery = getDirAsArray(GALLERIES_DIR_REL, "dir"); foreach ($dirgallery as $currentgalerien) { $change = false; if (true !== ($error = setChmod(GALLERIES_DIR_REL . $currentgalerien))) { $message .= returnMessage(false, $error); return; } $test_galerie = $specialchars->replaceSpecialChars($specialchars->rebuildSpecialChars($currentgalerien, false, false), false); if ($test_galerie != $currentgalerien) { $nr = 0; $new_name = $test_galerie; while (in_array($new_name, $dirgallery)) { $new_name = "%23_" . $nr . "_" . $test_galerie; $nr++; } if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien, GALLERIES_DIR_REL . $new_name))) { $message .= returnMessage(false, $error); return; } $change = true; $currentgalerien = $new_name; } if (!is_dir(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME)) { if (true !== ($error = mkdirMulti(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME))) { $message .= returnMessage(false, $error); return; } $change = true; } if (!file_exists(GALLERIES_DIR_REL . $currentgalerien . "/texte.conf.php")) { if (false === newConf(GALLERIES_DIR_REL . $currentgalerien . "/texte.conf.php")) { $message .= returnMessage(false, getLanguageValue("gallery_error_subtitle_conf")); return; } $change = true; } $dirimg = getDirAsArray(GALLERIES_DIR_REL . $currentgalerien, "img"); foreach ($dirimg as $currentimg) { if (true !== ($error = setChmod(GALLERIES_DIR_REL . $currentgalerien . "/" . $currentimg))) { $message .= returnMessage(false, $error); return; } $test_img = cleanUploadFile($currentimg); if ($test_img != $currentimg) { $nr = 0; $new_name = $test_img; while (in_array($new_name, $dirimg)) { $new_name = "_" . $nr . "_" . $test_img; $nr++; } if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien . "/" . $currentimg, GALLERIES_DIR_REL . $currentgalerien . "/" . $new_name))) { $message .= returnMessage(false, $error); return; } $change = true; if (is_file(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $currentimg)) { if (true !== ($error = moveFileDir(GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $currentimg, GALLERIES_DIR_REL . $currentgalerien . '/' . PREVIEW_DIR_NAME . "/" . $new_name))) { $message .= returnMessage(false, $error); return; } $change = true; } } } if ($change) { $success .= "<b>" . $specialchars->rebuildSpecialChars($currentgalerien, false, true) . "</b><br />"; } } if ($success) { $message .= returnMessage(true, getLanguageValue("gallery_messages_from_ftp") . "<br /><br />" . $success); } else { $message .= returnMessage(true, getLanguageValue("gallery_messages_from_ftp_no") . ""); } }
function plugins() { global $ADMIN_CONF; global $CatPage; global $message; global $specialchars; global $debug; $plugin_manage_open = false; # plugins löschen if (getRequestValue('plugin-all-del', 'post') and getRequestValue('plugin-del', 'post')) { plugin_del(); $plugin_manage_open = true; } # hochgeladenes plugin installieren if (isset($_FILES["plugin-install-file"]["error"]) and getRequestValue('plugin-install', 'post') and $_FILES["plugin-install-file"]["error"] == 0 and strtolower(substr($_FILES["plugin-install-file"]["name"], -4)) == ".zip") { $debug .= "install=" . $_FILES["plugin-install-file"]["name"] . "<br />\n"; plugin_install(); $plugin_manage_open = true; } elseif ($plugin_select = $specialchars->rebuildSpecialChars(getRequestValue('plugin-install-select', 'post'), false, false) and getRequestValue('plugin-install', 'post') and is_file(PLUGIN_DIR_REL . $specialchars->replaceSpecialChars($plugin_select, false)) !== false and strtolower(substr($plugin_select, -4)) == ".zip") { $debug .= "local install=" . getRequestValue('plugin-install-select', 'post') . "<br />\n"; plugin_install($plugin_select); $plugin_manage_open = true; } $showdebug = false; if ($showdebug and !empty($debug)) { $message .= returnMessage(false, $debug); } require_once BASE_DIR_CMS . "Plugin.php"; if (false !== ($plugin_name = getRequestValue('pluginadmin'))) { #,'get' if (file_exists(PLUGIN_DIR_REL . $plugin_name)) { define("PLUGINADMIN", $plugin_name); if (file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/index.php")) { require_once PLUGIN_DIR_REL . PLUGINADMIN . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists(PLUGINADMIN) and in_array(PLUGINADMIN, get_declared_classes())) { # $PLUGIN_ADMIN_ADD_HEAD gibts nur hier und ist für sachen die in den head sollen global $PLUGIN_ADMIN_ADD_HEAD; $PLUGIN_ADMIN_ADD_HEAD = array(); $multi_user = ""; if (defined('MULTI_USER') and MULTI_USER) { $multi_user = "******"; } define("PLUGINADMIN_GET_URL", URL_BASE . ADMIN_DIR_NAME . "/index.php?pluginadmin=" . PLUGINADMIN . "&nojs=true&action=" . ACTION . $multi_user); $plugin = new $plugin_name(); $info = $plugin->getInfo(); $config = $plugin->getConfig(); if (PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"] == PLUGIN_DIR_REL . PLUGINADMIN . "/index.php") { return $plugin->getContent(""); } else { return require_once PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"]; } } } else { die; } } else { die; } } if (getRequestValue('chanceplugin', 'post') == "true" and false !== ($plugin_name = getRequestValue('plugin_name', 'post'))) { if (file_exists(PLUGIN_DIR_REL . $plugin_name) and file_exists(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . $plugin_name . "/index.php")) { $conf_plugin = new Properties(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php"); } else { die("Fatal Error"); } if (false !== ($activ = getRequestValue(array($plugin_name, 'active'), 'post')) and ($activ == "true" or $activ == "false")) { $conf_plugin->set("active", $activ); ajax_return("success", true); } elseif ($conf_plugin->get("active") == "true") { require_once PLUGIN_DIR_REL . $plugin_name . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists($plugin_name) and in_array($plugin_name, get_declared_classes())) { $plugin = new $plugin_name(); # das ist nötig weil es sein kann das in getInfo() variblen initaliesiert werden $tmp = $plugin->getInfo(); $config = $plugin->getConfig(); echo save_plugin_settings($conf_plugin, $config, $plugin_name); exit; } else { die("Fatal Error"); } } die("Fatal Error"); } $pagecontent = ''; $show = $ADMIN_CONF->get("plugins"); if (!is_array($show)) { $show = array(); } if (ROOT or in_array("plugin_-_manage", $show)) { $multi_user = ""; if (defined('MULTI_USER') and MULTI_USER) { $multi_user = "******"; } $html_manage = ""; $plugin_manage = array(); $disabled = ''; if (!function_exists('gzopen')) { $disabled = ' disabled="disabled"'; } $plugin_install = array(); foreach (getDirAsArray(PLUGIN_DIR_REL, array(".zip")) as $zip_file) { $plugin_install[] = '<option value="' . mo_rawurlencode($zip_file) . '">' . $zip_file . '</option>'; } $plugin_install_html = ""; if (count($plugin_install) > 0) { $plugin_install_html .= '<br /><select class="mo-install-select mo-select-div" name="plugin-install-select" size="1"' . $disabled . '>' . '<option value="">' . getLanguageValue("plugins_select", true) . '</option>' . implode("", $plugin_install) . '</select>'; } $plugin_manage["plugins_title_manage"][] = '<form id="js-plugin-manage" action="index.php?nojs=true&action=plugins' . $multi_user . '" method="post" enctype="multipart/form-data">' . '<div class="mo-nowrap align-right ui-helper-clearfix">' . '<span class="align-left" style="float:left"><span class="mo-bold">' . getLanguageValue("plugins_text_filebutton") . '</span><br />' . getLanguageValue("plugins_text_fileinfo") . '</span>' . '<input type="file" id="js-plugin-install-file" name="plugin-install-file" class="mo-select-div"' . $disabled . ' />' . $plugin_install_html . '<input type="submit" id="js-plugin-install-submit" name="plugin-install" value="' . getLanguageValue("plugins_button_install", true) . '"' . $disabled . ' /><br />' . '<input type="submit" id="js-plugin-del-submit" value="' . getLanguageValue("plugins_button_delete", true) . '" class="mo-margin-top js-send-del-stop" />' . '</div></form>'; $plugin_manage["plugins_title_manage"]["toggle"] = true; $html_manage = contend_template($plugin_manage); $html_manage = str_replace("js-toggle", "js-toggle-manage", $html_manage); # es wurde in der template verwaltung was gemacht dann soll die aufgeklapt bleiben if ($plugin_manage_open) { $html_manage = str_replace("display:none;", "", $html_manage); } $pagecontent .= $html_manage; } $pagecontent .= '<ul class="js-plugins mo-ul">'; $dircontent = getDirAsArray(PLUGIN_DIR_REL, "dir", "natcasesort"); foreach ($dircontent as $currentelement) { $new_plugin_conf = false; if (!ROOT and !in_array($currentelement, $show)) { continue; } if (file_exists(PLUGIN_DIR_REL . $currentelement . "/index.php")) { if (!is_file(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) { if (false === newConf(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) { die; } else { $new_plugin_conf = true; } } require_once PLUGIN_DIR_REL . $currentelement . "/index.php"; # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname? if (class_exists($currentelement) and in_array($currentelement, get_declared_classes())) { $plugin = new $currentelement(); } else { # Plugin Dirname stimt nicht mit Plugin Classnamen überein continue; } # plugin.conf.php wurde neu erstelt. # Wenn es die getDefaultSettings() gibt fühle die plugin.conf.php damit if ($new_plugin_conf and method_exists($plugin, 'getDefaultSettings')) { $plugin->settings->setFromArray($plugin->getDefaultSettings()); } $plugin_css_li_error = NULL; $plugin_error = false; $plugin_info = $plugin->getInfo(); # Plugin Info Prüfen if (isset($plugin_info) and count($plugin_info) > 0) { $plugin_name = strip_tags($plugin_info[0], '<b>'); if (substr(strip_tags($plugin_name), 0, strlen($currentelement)) != $currentelement) { $plugin_name = "<b>" . $currentelement . "</b> " . strip_tags($plugin_name); } $plugin_name = htmlentities($plugin_name, ENT_COMPAT, CHARSET); $plugin_name = str_replace(array("<", ">", "\$"), array("<", ">", ""), $plugin_name); } else { $plugin_error = '<img class="mo-tool-icon mo-icons-icon mo-icons-error" src="' . ICON_URL_SLICE . '" alt="error" />' . getLanguageValue('plugins_error') . ' <b>' . $currentelement . '</b>'; $plugin_css_li_error = ' ui-state-error'; } $pagecontent .= '<li class="js-plugin mo-li ui-widget-content ui-corner-all' . $plugin_css_li_error . '">' . '<div class="js-tools-show-hide mo-li-head-tag mo-li-head-tag-no-ul ui-state-active ui-corner-all ui-helper-clearfix">'; $check_show = ' style="display:none;"'; if ($plugin_manage_open) { $check_show = ''; } if ($plugin_error === false) { $pagecontent .= '<span class="js-plugin-name mo-padding-left mo-middle">' . $plugin_name . '</span>' . '<div style="float:right;" class="mo-tag-height-from-icon mo-middle mo-nowrap">' . '<span class="js-plugin-active mo-staus">' . buildCheckBox($currentelement . '[active]', $plugin->settings->get("active") == "true", getLanguageValue("plugins_input_active")) . '</span>' . '<img class="js-tools-icon-show-hide js-toggle mo-tool-icon mo-icons-icon mo-icons-edit" src="' . ICON_URL_SLICE . '" alt="edit" />' . '<input type="checkbox" value="' . $currentelement . '" class="mo-checkbox mo-checkbox-del js-plugin-del"' . $check_show . ' />' . '</div>' . '</div>' . '<div class="js-toggle-content mo-in-ul-ul ui-helper-clearfix" style="display:none;">' . get_plugin_info($plugin_info); # geändert damit getConfig() nicht 2mal ausgeführt wird $config = $plugin->getConfig(); # Beschreibung und inputs der Konfiguration Bauen und ausgeben $pagecontent .= get_plugin_config($plugin->settings, $config, $currentelement); } else { $pagecontent .= $plugin_error; } $pagecontent .= '</div></li>'; unset($plugin); } } $pagecontent .= '</ul>'; return $pagecontent; }
function makeUpdate() { $update_page_files = array(); if (is_file(BASE_DIR . PLUGIN_DIR_NAME . '/Galerie/plugin.conf')) { updateConf(BASE_DIR . PLUGIN_DIR_NAME . '/Galerie/plugin.conf'); } if (is_file(BASE_DIR . PLUGIN_DIR_NAME . '/Galerie/plugin.conf.php')) { global $gallery_plugin; $gallery_plugin = new Properties(BASE_DIR . PLUGIN_DIR_NAME . '/Galerie/plugin.conf.php'); } if (is_dir(BASE_DIR . 'update')) { $cms_confs = array("basic", "main", "passwords", "gallery", "version", "logindata", "downloads", "catpage", "syntax", "user"); $files = getDirAsArray(BASE_DIR . 'update', array(".conf"), "none"); if (count($files) > 0) { global $GALLERY, $SYNTAX; $SYNTAX = new Properties(BASE_DIR_CMS . CONF_DIR_NAME . '/syntax.conf.php'); $GALLERY = new Properties(BASE_DIR_CMS . CONF_DIR_NAME . '/gallery.conf.php'); foreach ($files as $datei) { if (in_array(str_replace(".conf", "", $datei), $cms_confs)) { updateCMSConf($datei); mo_unlink(BASE_DIR . 'update/' . $datei); } } } } if (is_dir(BASE_DIR . 'galerien') and is_readable(BASE_DIR . 'galerien')) { foreach (getDirAsArray(BASE_DIR . GALLERIES_DIR_NAME, "dir", "none") as $datei) { $tmp_conf = false; if (is_file(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei . '/texte.conf')) { updateConf(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei . '/texte.conf'); } else { newConf(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei . "/texte.conf.php"); } if (is_file(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei . '/texte.conf.php')) { $tmp_conf = new Properties(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei . "/texte.conf.php"); } $update_text = array(); foreach (getDirAsArray(BASE_DIR . GALLERIES_DIR_NAME . '/' . $datei, "file", "none") as $img) { if ($img == 'texte.conf') { continue; } if (false !== ($newname = isUpdateFileName($img, "file", true))) { $status = updateRename($img, $newname, BASE_DIR . GALLERIES_DIR_NAME . "/" . $datei . "/"); if ($status) { $newname = $status; } if ($tmp_conf !== false and $tmp_conf->keyExists($img)) { $tmp_conf->set($newname, toUtf($tmp_conf->get($img))); $tmp_conf->delete($img); } $update_page_files[$img] = $newname; if (is_file(BASE_DIR . GALLERIES_DIR_NAME . "/" . $datei . "/" . PREVIEW_DIR_NAME . "/" . $img)) { updateRename($img, $newname, BASE_DIR . GALLERIES_DIR_NAME . "/" . $datei . "/" . PREVIEW_DIR_NAME . "/"); } } } unset($tmp_conf); if (false !== ($newname = isUpdateFileName($datei, false, true))) { updateRename($datei, $newname, BASE_DIR . GALLERIES_DIR_NAME . "/"); } } } if (is_dir(BASE_DIR . 'kategorien')) { $sort_array = array(); $cats = getDirAsArray(BASE_DIR . CONTENT_DIR_NAME, "dir", "sort"); $cats = sort_cat_page($cats, BASE_DIR . CONTENT_DIR_NAME, "dir"); foreach ($cats as $cat) { #echo $cat."<br />\n"; if (false !== ($newname = isUpdateFileName($cat, "catpage", true))) { updateRename($cat, $newname, BASE_DIR . CONTENT_DIR_NAME . "/"); $cat = $newname; } $sort_array[$cat] = "null"; if (substr($cat, -EXT_LENGTH) == EXT_LINK) { continue; } $sort_array[$cat] = array(); $pages = getDirAsArray(BASE_DIR . CONTENT_DIR_NAME . '/' . $cat, "file", "sort"); $pages = sort_cat_page($pages, BASE_DIR . CONTENT_DIR_NAME . '/' . $cat, "file"); foreach ($pages as $page) { if (false !== ($newname = isUpdateFileName($page, "catpage", true))) { updateRename($page, $newname, BASE_DIR . CONTENT_DIR_NAME . "/" . $cat . "/"); $page = $newname; } $sort_array[$cat][$page] = "null"; } if (is_dir(BASE_DIR . CONTENT_DIR_NAME . '/' . $cat . '/' . CONTENT_FILES_DIR_NAME)) { foreach (getDirAsArray(BASE_DIR . CONTENT_DIR_NAME . '/' . $cat . '/' . CONTENT_FILES_DIR_NAME, "file", "none") as $file) { if (false !== ($newname = isUpdateFileName($file, "file", true))) { $status = updateRename($file, $newname, BASE_DIR . CONTENT_DIR_NAME . "/" . $cat . "/" . CONTENT_FILES_DIR_NAME . "/"); if ($status) { $newname = $status; } $tmp_file = cleanUploadFile(changeMoziloOldSpecialChars($file, false)); $update_page_files[rawurldecode($cat)][$tmp_file] = $newname; } } } } $sort_array = var_export($sort_array, true); file_put_contents(SORT_CAT_PAGE, "<?php if(!defined('IS_CMS')) die();\n\$cat_page_sort_array = " . $sort_array . ";\n?>", LOCK_EX); if (isset($_POST['update_pages']) and $_POST['update_pages'] == "true") { updatePages($update_page_files); } } if (is_dir(BASE_DIR . 'plugins')) { foreach (getDirAsArray(BASE_DIR . PLUGIN_DIR_NAME, "dir", "none") as $datei) { if (is_file(BASE_DIR . PLUGIN_DIR_NAME . '/' . $datei . '/plugin.conf')) { updateConf(BASE_DIR . PLUGIN_DIR_NAME . '/' . $datei . '/plugin.conf'); } if ($datei == "CONTACT") { makeCONTACTSetings(BASE_DIR . PLUGIN_DIR_NAME . '/' . $datei . '/plugin.conf.php'); } } } if (is_dir(BASE_DIR . 'layouts')) { foreach (getDirAsArray(BASE_DIR . LAYOUT_DIR_NAME, "dir", "none") as $datei) { if (is_file(BASE_DIR . LAYOUT_DIR_NAME . '/' . $datei . '/layoutsettings.conf') and is_file(BASE_DIR . LAYOUT_DIR_NAME . '/' . $datei . '/template.html')) { updateTemplate(BASE_DIR . LAYOUT_DIR_NAME . '/' . $datei . '/'); } if (is_dir(BASE_DIR . LAYOUT_DIR_NAME . '/' . $datei . '/css')) { updateTemplateCSS(BASE_DIR . LAYOUT_DIR_NAME . '/' . $datei . '/'); } if (false !== ($newname = isUpdateFileName($datei, false, true))) { updateRename($datei, $newname, BASE_DIR . LAYOUT_DIR_NAME . "/"); } } } }
public function testSplitDB() { newConf('split_db', ' components: db: model: false rw: host: localhost username: sitetest password: st123 database: sitetest_rw1 ro: host: localhost username: sitetest password: st123 database: sitetest_ro1 '); $rw1 = new Site(getConf('rw1')); $rw1id = $rw1->db->insert('st', array('str' => 'rw1')); $ro1 = new Site(getConf('ro1')); $ro1id = $ro1->db->insert('st', array('str' => 'ro1')); $site = new Site(getConf('split_db')); $rores = $site->db->queryRO('select * from st'); $this->assertEquals(1, $rores->count()); $this->assertEquals('ro1', $rores[0]['str']); $rwres = $site->db->queryRW('select * from st'); $this->assertEquals(1, $rwres->count()); $this->assertEquals('rw1', $rwres[0]['str']); // NOTE: subsequent calls after a RW query always hit RW $rores = $site->db->queryRO('select * from st'); $this->assertEquals(1, $rores->count()); $this->assertEquals('rw1', $rores[0]['str']); killConf('split_db'); }