зеркало из https://github.com/mozilla/pjs.git
Added central config for caching and shadow DB.
This commit is contained in:
Родитель
b6f9b2c5a4
Коммит
5a5e2372f9
|
@ -4,9 +4,6 @@
|
|||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*
|
||||
* @todo Do something to spice up this page.
|
||||
* @todo Get main template spruced up.
|
||||
*/
|
||||
|
||||
$currentTab = 'home';
|
||||
|
@ -32,7 +29,6 @@ switch( $_GET['app'] ) {
|
|||
}
|
||||
|
||||
// $sql['app'] can equal $clean['app'] since it was assigned in a switch().
|
||||
// We have to ucfirst() it because the DB has caps.
|
||||
$sql['app'] = $clean['app'];
|
||||
|
||||
$amo = new AMO_Object();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
* @todo make this dynamic based on an SQL field (recommended)
|
||||
*/
|
||||
|
||||
startProcessing('recommended.tpl', null, $compileId, 'nonav');
|
||||
|
|
|
@ -92,6 +92,15 @@ if (empty($errors)) {
|
|||
$os_query = ($sql['os_id']) ? " OR version.OSID = '{$sql['os_id']}' " : ''; // Set up os_id.
|
||||
|
||||
// Query for possible updates.
|
||||
//
|
||||
// The query sorts by version.vid, which is an auto_increment primary key for that table.
|
||||
//
|
||||
// The reason why this was used is that the version.version column was a varchar and
|
||||
// it was failing to sort correctly in some cases.
|
||||
//
|
||||
// There is a possibility that the version.vid sort could be incorrect, but only in edge
|
||||
// cases where the version was added retroactively, and I've actually _never_ seen such
|
||||
// a case.
|
||||
$query = "
|
||||
SELECT
|
||||
main.guid AS extguid,
|
||||
|
@ -119,9 +128,7 @@ if (empty($errors)) {
|
|||
'{$sql['appVersion']}+' >= version.minappver AND
|
||||
'{$sql['version']}' <= version.version
|
||||
ORDER BY
|
||||
extversion DESC,
|
||||
version.MaxAppVer_int DESC,
|
||||
version.OSID DESC
|
||||
version.vid DESC
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
|
|
|
@ -35,10 +35,53 @@ define('COMPILE_DIR',ROOT_PATH.'/templates_c');
|
|||
define('CACHE_DIR',ROOT_PATH.'/cache');
|
||||
define('CONFIG_DIR',ROOT_PATH.'/configs');
|
||||
|
||||
// Database information.
|
||||
// DB configuration.
|
||||
// This database has read/write capabilities.
|
||||
define('DB_USER','');
|
||||
define('DB_PASS','');
|
||||
define('DB_HOST','');
|
||||
define('DB_NAME','');
|
||||
define('DB_PORT', '');
|
||||
define('DB_PORT', '3306');
|
||||
|
||||
// Shadow DB configuration.
|
||||
// This database has read-only access.
|
||||
define('SHADOW_USER','');
|
||||
define('SHADOW_PASS','');
|
||||
define('SHADOW_HOST','');
|
||||
define('SHADOW_NAME','');
|
||||
define('SHADOW_PORT', '3306');
|
||||
|
||||
/**
|
||||
* Config arrays.
|
||||
*
|
||||
* These arrays are for shadow database and cache configuration. The goal here is to
|
||||
* adjust application behavior based on membership in these arrays.
|
||||
*
|
||||
* Not only should we be able to control these behaviors, but we wanted to do so from
|
||||
* a central config file that would be external to the CVS checkout.
|
||||
*
|
||||
* This gives us flexibility in production to make on-the-fly adjustments under duress,
|
||||
* and lets sysadmins tweak things without creating CVS conflicts in production.
|
||||
*/
|
||||
|
||||
// Shadow array defines which pages are going to use the shadow database.
|
||||
// Filenames found in this array must work with read-only access to the database.
|
||||
//
|
||||
// Array contains [script name] values. For example, we could set the main page to
|
||||
// use the shadow database:
|
||||
// 'index.php'
|
||||
//
|
||||
// In the case where the PHP script is in a subdirectory, use the relative path from webroot:
|
||||
// 'somedirectory/index.php'
|
||||
$shadow_config = array(
|
||||
);
|
||||
|
||||
// Array contains [script name] => [timeout] entries. For example, we could set
|
||||
// a timeout of 1800 for index.php:
|
||||
// 'index.php' => '1800'
|
||||
//
|
||||
// In the case where the PHP script is in a subdirectory, use the relative path from webroot:
|
||||
// 'somedirectory/index.php' => '1800'
|
||||
$cache_config = array(
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -17,17 +17,39 @@ class AMO_SQL extends SQL
|
|||
{
|
||||
function AMO_SQL()
|
||||
{
|
||||
global $shadow_config;
|
||||
|
||||
require_once("DB.php");
|
||||
$dsn = array (
|
||||
'phptype' => 'mysql',
|
||||
'dbsyntax' => 'mysql',
|
||||
'username' => DB_USER,
|
||||
'password' => DB_PASS,
|
||||
'hostspec' => DB_HOST,
|
||||
'database' => DB_NAME,
|
||||
'port' => DB_PORT
|
||||
);
|
||||
$this->connect($dsn);
|
||||
|
||||
/**
|
||||
* If our current script is in the shadow array, we should
|
||||
* connect to the shadow db instead of the default.
|
||||
*/
|
||||
if (in_array(SCRIPT_NAME, $shadow_config)) {
|
||||
$shadow_dsn = array (
|
||||
'phptype' => 'mysql',
|
||||
'dbsyntax' => 'mysql',
|
||||
'username' => SHADOW_USER,
|
||||
'password' => SHADOW_PASS,
|
||||
'hostspec' => SHADOW_HOST,
|
||||
'database' => SHADOW_NAME,
|
||||
'port' => SHADOW_PORT
|
||||
);
|
||||
|
||||
$this->connect($shadow_dsn);
|
||||
} else {
|
||||
$dsn = array (
|
||||
'phptype' => 'mysql',
|
||||
'dbsyntax' => 'mysql',
|
||||
'username' => DB_USER,
|
||||
'password' => DB_PASS,
|
||||
'hostspec' => DB_HOST,
|
||||
'database' => DB_NAME,
|
||||
'port' => DB_PORT
|
||||
);
|
||||
|
||||
$this->connect($dsn);
|
||||
}
|
||||
|
||||
// Test connection; display "gone fishing" on failure.
|
||||
if (DB::isError($this->db)) {
|
||||
|
|
|
@ -17,6 +17,16 @@ require_once(SMARTY_BASEDIR.'/Smarty.class.php'); // Smarty
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Name of the current script.
|
||||
*
|
||||
* This is used in important comparisons with $shadow_config and $cache_config,
|
||||
* so it was pulled out of config.php so it's immutable.
|
||||
*/
|
||||
define('SCRIPT_NAME',substr($_SERVER['SCRIPT_NAME'], strlen(WEB_PATH.'/'), strlen($_SERVER['SCRIPT_NAME'])));
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set runtime options.
|
||||
*/
|
||||
|
@ -96,7 +106,7 @@ class AMO_Smarty extends Smarty
|
|||
function startProcessing($aTplName, $aCacheId, $aCompileId, $aPageType='default')
|
||||
{
|
||||
// Pass in our global variables.
|
||||
global $tpl, $pageType, $content, $cacheId, $compileId;
|
||||
global $tpl, $pageType, $content, $cacheId, $compileId, $cache_config;
|
||||
|
||||
$pageType = $aPageType;
|
||||
$content = $aTplName;
|
||||
|
@ -105,9 +115,17 @@ function startProcessing($aTplName, $aCacheId, $aCompileId, $aPageType='default'
|
|||
|
||||
$tpl = new AMO_Smarty();
|
||||
|
||||
// If our page is already cached, display from cache and exit.
|
||||
if ($tpl->is_cached($aTplName, $aCacheId, $aCompileId)) {
|
||||
require_once('finish.php');
|
||||
exit;
|
||||
|
||||
// Otherwise, we will check to see if this page is flagged for caching.
|
||||
// If it is, set caching to true and set the timeout to the value
|
||||
// in the config before continuing to the rest of the script.
|
||||
} elseif (!empty($cache_config[SCRIPT_NAME])) {
|
||||
$tpl->caching = true;
|
||||
$tpl->cache_timeout = $cache_config[SCRIPT_NAME];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -6,7 +6,7 @@ released on {$addon->VersionDateAdded|date_format}
|
|||
</p>
|
||||
|
||||
<h3>Be Careful With Old Versions</h3>
|
||||
<p>These versions are displayed for reference and testing purposes. You should always use the latest version on an addon. </p>
|
||||
<p>These versions are displayed for reference and testing purposes. You should always use the latest version of an addon. </p>
|
||||
|
||||
<h3>Version History with Changelogs</h3>
|
||||
<dl>
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<div id="mBody">
|
||||
|
||||
<h2>{$addon->Name} » Rate Comment</h2>
|
||||
<p class="first">
|
||||
<strong><a href="{$config.webpath}/{$app}/{$addon->ID}/">{$addon->Name} {$addon->Version}</a></strong>,
|
||||
by <a href="{$config.webpath}/{$app}/{$addon->UserID}/author/">{$addon->UserName}</a>,
|
||||
released on {$addon->VersionDateAdded|date_format}
|
||||
</p>
|
||||
|
||||
<h2>Comment Rating for {$addon->Name}</h2>
|
||||
<p><strong>Thanks for your input!</strong></p>
|
||||
<p>You have successfully rated the following comment as <strong>{$clean.helpful}</strong>:</p>
|
||||
<div id="comment-rate">
|
||||
|
@ -10,3 +17,5 @@
|
|||
</div>
|
||||
|
||||
<p>« <a href="./addon.php?id={$addon->ID}">Return to information about{$addon->Name}</a></p>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="mBody">
|
||||
<h1>Getting Started with Extensions</h1>
|
||||
|
||||
<p>With over thousands of extensions available, there's something for everyone. To get you started, here's a list of some of our recommended extensions that make use of popular online services.</p>
|
||||
<p>With over a thousand extensions available, there's something for everyone. To get you started, here's a list of some of our recommended extensions that make use of popular online services.</p>
|
||||
|
||||
{section name=re loop=$recommendedExtensions step=1 start=0}
|
||||
<div class="recommended">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div id="mBody">
|
||||
|
||||
<h1 class="first">{$title}</h1>
|
||||
<div class="front-section">
|
||||
{if $success}
|
||||
<p>An email has been sent. Please follow the instructions included within it.</p>
|
||||
{else}
|
||||
|
@ -15,5 +15,5 @@ sent an email to help you recover it.</p>
|
|||
<input id="submit" name="submit" type="submit" value="Recover Password" />
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div id="mBody">
|
||||
|
||||
<h1 class="first">{$title}</h1>
|
||||
<div class="front-section">
|
||||
{if $confirmed}
|
||||
<p>The account {$email|escape} has been activated successfully.</p>
|
||||
<ul>
|
||||
|
@ -15,5 +15,5 @@ registered yet, please register before activating.</p>
|
|||
</ul>
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,4 @@ CREATE TABLE `session_data` (
|
|||
|
||||
ALTER TABLE `feedback` ADD `UserID` INT( 11 ) AFTER `ID`;
|
||||
ALTER TABLE `feedback` ADD INDEX ( `UserID` );
|
||||
|
||||
ADD CONSTRAINT `feedback_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `userprofiles`
|
||||
(`UserID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `userprofiles` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче