diff --git a/webtools/addons/public/htdocs/index.php b/webtools/addons/public/htdocs/index.php index bdbf031d0fc6..c0cdfde23c95 100644 --- a/webtools/addons/public/htdocs/index.php +++ b/webtools/addons/public/htdocs/index.php @@ -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(); diff --git a/webtools/addons/public/htdocs/recommended.php b/webtools/addons/public/htdocs/recommended.php index cb9ef40b66f4..6de570197903 100644 --- a/webtools/addons/public/htdocs/recommended.php +++ b/webtools/addons/public/htdocs/recommended.php @@ -4,6 +4,7 @@ * * @package amo * @subpackage docs + * @todo make this dynamic based on an SQL field (recommended) */ startProcessing('recommended.tpl', null, $compileId, 'nonav'); diff --git a/webtools/addons/public/htdocs/update.php b/webtools/addons/public/htdocs/update.php index 253a0d1511ec..ef6af99e4913 100644 --- a/webtools/addons/public/htdocs/update.php +++ b/webtools/addons/public/htdocs/update.php @@ -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 "; diff --git a/webtools/addons/public/inc/config-dist.php b/webtools/addons/public/inc/config-dist.php index fc80bef65fe3..fe5e671520a4 100644 --- a/webtools/addons/public/inc/config-dist.php +++ b/webtools/addons/public/inc/config-dist.php @@ -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( +); ?> diff --git a/webtools/addons/public/inc/includes.php b/webtools/addons/public/inc/includes.php index 254f3f140156..aa3cecbe0ca9 100644 --- a/webtools/addons/public/inc/includes.php +++ b/webtools/addons/public/inc/includes.php @@ -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)) { diff --git a/webtools/addons/public/inc/init.php b/webtools/addons/public/inc/init.php index 7ff7844e9c05..31ad6261af35 100644 --- a/webtools/addons/public/inc/init.php +++ b/webtools/addons/public/inc/init.php @@ -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]; } } ?> diff --git a/webtools/addons/public/tpl/history.tpl b/webtools/addons/public/tpl/history.tpl index d1865e8d4e47..5655712e729d 100755 --- a/webtools/addons/public/tpl/history.tpl +++ b/webtools/addons/public/tpl/history.tpl @@ -6,7 +6,7 @@ released on {$addon->VersionDateAdded|date_format}

Be Careful With Old Versions

-

These versions are displayed for reference and testing purposes. You should always use the latest version on an addon.

+

These versions are displayed for reference and testing purposes. You should always use the latest version of an addon.

Version History with Changelogs

diff --git a/webtools/addons/public/tpl/ratecomment.tpl b/webtools/addons/public/tpl/ratecomment.tpl index 094de92445b5..4fd739bc90a3 100755 --- a/webtools/addons/public/tpl/ratecomment.tpl +++ b/webtools/addons/public/tpl/ratecomment.tpl @@ -1,5 +1,12 @@ +
+ +

{$addon->Name} » Rate Comment

+

+{$addon->Name} {$addon->Version}, +by {$addon->UserName}, +released on {$addon->VersionDateAdded|date_format} +

-

Comment Rating for {$addon->Name}

Thanks for your input!

You have successfully rated the following comment as {$clean.helpful}:

@@ -10,3 +17,5 @@

« Return to information about{$addon->Name}

+ +
diff --git a/webtools/addons/public/tpl/recommended.tpl b/webtools/addons/public/tpl/recommended.tpl index b09efddeba70..09a358029537 100644 --- a/webtools/addons/public/tpl/recommended.tpl +++ b/webtools/addons/public/tpl/recommended.tpl @@ -1,7 +1,7 @@

Getting Started with Extensions

-

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.

+

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.

{section name=re loop=$recommendedExtensions step=1 start=0}