1
0

Merge remote branch 'upstream/master'

This commit is contained in:
colings 2011-01-09 11:42:40 -06:00
commit 90ff865b86
724 changed files with 2899 additions and 568 deletions

View File

@ -0,0 +1,76 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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.
*/
class about_this_album_block_Core {
static function get_site_list() {
return array("aboutthisalbum" => t("About This Album"));
}
static function get($block_id, $theme) {
switch ($block_id) {
case "aboutthisalbum":
$item = $theme->item;
if ((!$item) or (!$theme->item->is_album())) {
return "";
}
if ($theme->item->is_album()) {
$block = new Block();
$block->css_id = "g-about-this-album";
$block->content = new View("about_this_album.html");
if ($theme->item()->id == item::root()->id) {
$block->title = t("About this Site");
$block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all();
$block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
$block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c;
} Else {
$block->title = t("About this Album");
$block->content->album_count = $item->descendants_count(array(array("type", "=", "album")));
$block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo")));
// $block->content->vcount= $theme->item()->view_count;
$descds = $item->descendants();
$descds_view = 0;
foreach ($descds as $descd) {
if ($descd->is_photo()) {
$descds_view += $descd->view_count;
}
}
$block->content->vcount = $descds_view;
if ($item->description) {
$block->content->description = html::clean($item->description);
}
}
$all_tags = ORM::factory("tag")
->join("items_tags", "items_tags.tag_id", "tags.id")
->join("items", "items.id", "items_tags.item_id", "LEFT")
->where("items.parent_id", "=", $item->id)
->order_by("tags.id", "ASC")
->find_all();
if (count($all_tags) > 0) {
$block->content->all_tags = $all_tags;
}
}
break;
}
return $block;
}
}

View File

@ -0,0 +1,3 @@
name = "About this Album"
description = "Show some simple, specific and useful info about a given album"
version = 1

View File

@ -0,0 +1,68 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? date_default_timezone_set('Australia/ACT'); ?>
<div class="g-metadata">
<span class="g-about-this">
<table cellspacing="0" cellpadding="0" border="0">
<? if ($album_count > 0): ?>
<tr>
<td><strong class="caption"><?= t("Albums:&nbsp;") ?></strong></td>
<td><?= $album_count ?></td>
</tr>
<? endif ?>
<tr>
<td><strong class="caption"><?= t("Images:&nbsp;") ?></strong></td>
<td><?= $photo_count ?></td>
</tr>
<tr>
<td><strong class="caption"><?= t("Views:&nbsp;") ?></strong></td>
<td><?= $vcount ?></td>
</tr>
</table>
<span >
<!--This Div will insert a margin either side of the desciption if there are tags to display-->
<? if (count($all_tags) > 0): ?>
<div style="margin-top: 10px; margin-bottom: 10px;">
<? endif ?>
<? if ($description <> ""): ?>
<strong class="caption"><?= t("Details:&nbsp;") ?></strong>
<?= $description ?>
</span ><br>
<? endif ?>
<? if (count($all_tags) > 0): ?>
</div>
<span >
<strong class=="caption"><?= t("Tags:&nbsp;") ?></strong>
</span >
<?
// Create an array to store the tag names and urls in.
$display_tags = array();
// Loop through all tags in the album, copying their
// names and urls into the array and skipping duplicates.
$last_tagid = "";
foreach ($all_tags as $one_tag) {
if ($last_tagid != $one_tag->id) {
$tag = ORM::factory("tag", $one_tag->id);
$display_tags[] = array(html::clean($tag->name), $tag->url());
$last_tagid = $one_tag->id;
}
}
// Sort the array.
asort($display_tags);
// Print out the list of tags as clickable links.
$not_first = 0;
foreach ($display_tags as $one_tag) {
if ($not_first++ > 0) {
print ", ";
}
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
}
?>
<? endif ?>
</span>
</div>

View File

@ -27,6 +27,10 @@ class about_this_photo_block_Core {
$block = new Block();
switch ($block_id) {
case "simple":
$item = $theme->item;
if ((!$item) or (!$item->is_photo())) {
return "";
}
$block->css_id = "g-about-this-photo";
$block->title = t("About this photo");
$block->content = new View("about_this_photo.html");
@ -37,11 +41,25 @@ class about_this_photo_block_Core {
if ($exif->loaded()) {
$exif = unserialize($exif->data);
$timestamp = strtotime($exif["DateTime"]);
$block->content->date = gallery::date($timestamp);
//$block->content->date = gallery::date($timestamp);
$block->content->date = date('D j M Y', $timestamp);
$block->content->time = gallery::time($timestamp);
}
}
$block->content->vcount = $theme->item()->view_count;
// IPTC - copied more or less from iptc.php
if (module::is_active("iptc")) {
$record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find();
if ($record->loaded()) {
$record = unserialize($record->data);
$block->content->name = $record["ObjectName"];
$block->content->caption = $record["Caption"];
}
}
if (module::is_active("tag")) {
$block->content->tags = tag::item_tags($theme->item());
}
@ -49,4 +67,5 @@ class about_this_photo_block_Core {
}
return $block;
}
}
}

View File

@ -1,3 +1,3 @@
name = "About this Photo"
description = "Show some simple, specific and useful info about a given photo"
version = 1
version = 3

View File

@ -1,17 +1,34 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul class="g-metadata">
<li>
<strong class="caption"><?= t("Date:") ?></strong>
<?= $date ?>
</li>
<li>
<strong class="caption"><?= t("Time:") ?></strong>
<?= $time ?>
</li>
<li>
<strong class=="caption"><?= t("Tags:") ?></strong>
<? date_default_timezone_set('Australia/ACT'); ?>
<div class="g-metadata">
<span class="g-about-this">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><strong class="caption"><?= t("Date:&nbsp;") ?></strong></td>
<td><?= $date ?></td>
</tr>
<tr>
<td><strong class="caption"><?= t("Time:&nbsp;") ?></strong></td>
<td><?= $time ?></td>
</tr>
<tr>
<td><strong class="caption"><?= t("Views:&nbsp;") ?></strong></td>
<td><?= $vcount ?></td>
</tr>
<tr>
<td><strong class="caption"><?= t("Name:&nbsp;") ?></strong></td>
<td><?= $name ?></td>
</tr>
</table>
<div style="margin-top: 10px; margin-bottom: 10px;">
<strong class="caption"><?= t("Caption:&nbsp;") ?></strong>
<?= $caption ?>
</div >
<span >
<strong class=="caption"><?= t("Tags: &nbsp;&nbsp;") ?></strong>
<? foreach ($tags as $tag): ?>
<a href="<?= $tag->url() ?>"><?= html::clean($tag->name) ?></a>
<a href="<?= $tag->url() ?>"><?= html::clean($tag->name) ?></a>,
<? endforeach?>
</li>
</ul>
</span ><br>
</span>
</div>

View File

@ -34,5 +34,5 @@
<? endif ?>
<? endwhile ?>
</ul>
</div>

View File

@ -30,6 +30,18 @@ class Captionator_Controller extends Controller {
$v = new Theme_View("page.html", "collection", "captionator");
$v->content = new View("captionator_dialog.html");
$v->content->album = $album;
$v->content->enable_tags = module::is_active("tag");
if ($v->content->enable_tags) {
$v->content->tags = array();
foreach ($album->viewable()->children() as $child) {
$item = ORM::factory("item", $child->id);
$tag_names = array();
foreach (tag::item_tags($item) as $tag) {
$tag_names[] = $tag->name;
}
$v->content->tags[$child->id] = implode(", ", $tag_names);
}
}
print $v;
}
@ -42,12 +54,23 @@ class Captionator_Controller extends Controller {
if (Input::instance()->post("save")) {
$titles = Input::instance()->post("title");
$descriptions = Input::instance()->post("description");
$tags = Input::instance()->post("tags");
$enable_tags = module::is_active("tag");
foreach (array_keys($titles) as $id) {
$item = ORM::factory("item", $id);
if ($item->loaded() && access::can("edit", $item)) {
$item->title = $titles[$id];
$item->description = $descriptions[$id];
$item->save();
if ($enable_tags) {
tag::clear_all($item);
foreach (explode(",", $tags[$id]) as $tag_name) {
if ($tag_name) {
tag::add($item, trim($tag_name));
}
}
tag::compact();
}
}
}
message::success(t("Captions saved"));

View File

@ -1,5 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-captionator-dialog">
<script type="text/javascript">
$('form input[name^=tags]').ready(function() {
$('form input[name^=tags]').autocomplete(
'/tags/autocomplete', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1});
});
</script>
<form action="<?= url::site("captionator/save/{$album->id}") ?>" method="post" id="g-captionator-form">
<?= access::csrf_form_field() ?>
<fieldset>
@ -23,6 +29,12 @@
<label for="description[<?= $child->id ?>]"> <?= t("Description") ?> </label>
<textarea style="height: 5em" name="description[<?= $child->id ?>]"><?= $child->description ?></textarea>
</li>
<? if ($enable_tags): ?>
<li>
<label for="tags[<?= $child->id ?>]"> <?= t("Tags (comma separated)") ?> </label>
<input type="text" name="tags[<?= $child->id ?>]" class="ac_input" autocomplete="off" value="<?= $tags[$child->id] ?>"/>
</li>
<? endif ?>
</ul>
</td>
</tr>

View File

@ -28,7 +28,7 @@ class ecard_block_Core {
case "ecard":
if ($theme->item() && $theme->item()->is_photo() && module::get_var("ecard", "location") == "sidebar") {
$block = new Block();
$block->css_id = "g-send-ecard";
$block->css_id = "g-sendecard";
$block->title = t("eCard");
$block->content = new View("ecard_block.html");
}

View File

@ -25,6 +25,6 @@ class ecard_installer {
"Click the image to be taken to the gallery.");
module::set_var("ecard", "bcc", "");
module::set_var("ecard", "access_permissions", "everybody");
module::set_version("ecard", 4);
module::set_version("ecard", 5);
}
}

View File

@ -1,4 +1,4 @@
name = "E-Card"
description = "Send a photo as a postcard"
version = 4
version = 5

View File

@ -1,6 +1,6 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<a href="<?= url::site("ecard/form_send/{$item->id}") ?>" id="g-send-ecard"
<a href="<?= url::site("ecard/form_send/{$item->id}") ?>"
class="g-dialog-link g-button ui-state-default ui-corner-all">
<span class="ui-icon-ecard"></span>
<span class="ui-icon-ecard" id="g-send-ecard"></span>
<?= t("Send as eCard") ?>
</a>

View File

@ -232,7 +232,10 @@ class Ldap_User implements User_Definition {
}
public function display_name() {
return $this->ldap_entry["displayname"][0];
if (!empty($this->ldap_entry["displayname"][0])) {
return $this->ldap_entry["displayname"][0];
}
return $this->ldap_entry["cn"][0];
}
public function __get($key) {

View File

@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Moduleupdates_Controller extends Admin_Controller {
/**
@ -44,15 +43,10 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
$view->page_title = t("Gallery 3 :: Manage Module Updates");
$view->content = new View("admin_moduleupdates.html");
$devDebug = false;
$refreshCache = false;
$cache = unserialize(Cache::instance()->get("moduleupdates_cache"));
$cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates"));
//---------------------------------------------------------------------------------------------
//echo 'Message 01: ' .$cache_updates . '<br>';
//---------------------------------------------------------------------------------------------
//if someone pressed the button to refresh now
if (request::method() == "post") {
@ -78,7 +72,6 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
//Check the ability to access the Google
$Google = null;
@ -91,71 +84,82 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
$update_count = 0;
if($refreshCache == true){
foreach (module::available() as $this_module_name => $module_info) {
$font_color_local = "black";
$core_version = '';
$core_server = '';
$core_dlink = '';
$font_color_core = "black";
$contrib_version = '';
$contrib_server = '';
$contrib_dlink = '';
$font_color_contrib = "black";
$gh_version = '';
$gh_server = '';
$gh_dlink = '';
$font_color_gh = "black";
//example code for setting cache values
//Cache::instance()->set($key, "$log{$msg}", array("task", "log", "import"), 2592000);
//example delete cache
//Cache::instance()->delete("update_l10n_cache:{$task->id}");
//example for reading cache
//$log = Cache::instance()->get($key);
$remote_version = '';
$remote_server = '';
$update_count = 0;
list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name, $devDebug);
$font_color_local = $this->get_local_module_version_color ($module_info->version, $module_info->code_version);
list ($core_version, $core_server) = $this->get_remote_module_version($this_module_name, "CORE");
$font_color_core = $this->get_module_version_color ($module_info->version, $module_info->code_version, $core_version);
list ($contrib_version, $contrib_server) = $this->get_remote_module_version($this_module_name, "CONTRIB");
$font_color_contrib = $this->get_module_version_color ($module_info->version, $module_info->code_version, $contrib_version);
list ($gh_version, $gh_server) = $this->get_remote_module_version($this_module_name, "GH");
$font_color_gh = $this->get_module_version_color ($module_info->version, $module_info->code_version, $gh_version);
$font_color = "black";
//BLUE - DNE: Does Not Exist, this module was not found
if ($remote_version == "DNE") {
$font_color = "blue";
//PINK - Your installed version is newer than file version
} else if ($module_info->version != '' and $module_info->code_version < $module_info->version) {
$font_color = "pink";
//ORANGE - Your file version is newer than the installed version
} else if ($module_info->version != '' and $module_info->code_version > $module_info->version) {
$font_color = "orange";
//GREEN - Your version is newer than the GitHub
} else if ($remote_version < $module_info->code_version or ($module_info->version != ''
and $remote_version < $module_info->version)) {
$font_color = "green";
//RED - Your version is older than the GitHub
} else if ($remote_version > $module_info->code_version or ($module_info->version != ''
and $remote_version > $module_info->version)) {
$font_color = "red";
if($font_color_core == "red" or $font_color_contrib == "red" or $font_color_gh == "red"){
$update_count++;
/*
if($remote_server == "(G3)"){
$module_info->name = "<a href=\"http://github.com/gallery/gallery3/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}else if($remote_server == "(G3CC)"){
$module_info->name = "<a href=\"http://github.com/gallery/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}else if($remote_server == "(brentil)"){
$module_info->name = "<a href=\"http://github.com/brentil/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}
*/
}
$module_info->name = "<a href=\"http://codex.gallery2.org/Gallery3:Modules:".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
if (is_numeric($core_version)) {
if($core_version > $module_info->version) {
$core_dlink = "http://github.com/gallery/gallery3/tree/master/modules/".$this_module_name;
}
}
if (is_numeric($contrib_version)) {
if($contrib_version > $module_info->version) {
$contrib_dlink = "http://github.com/gallery/gallery3-contrib/tree/master/".
substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")) ."/modules/".$this_module_name;
}
}
if (is_numeric($gh_version)) {
if($gh_version > $module_info->version) {
$this_gm_repo = str_replace(".","",substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")));
if($this_gm_repo == "30"){
$gh_dlink = "http://www.gallerymodules.com/update/".$this_module_name;
} else {
$gh_dlink = "http://www.gallerymodules.com/update".this_gm_repo."/".$this_module_name;
}
}
}
//populate the list fo modules and their data
$cache->$this_module_name = array ("name" => $module_info->name, "locked" => $module_info->locked,
"code_version" => $module_info->code_version, "active" => $module_info->active,
"version" => $module_info->version,"description" => $module_info->description,
"remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color);
"core_version" => $core_version, "core_server" => $core_server, "font_color_core" => $font_color_core,
"contrib_version" => $contrib_version, "contrib_server" => $contrib_server, "font_color_contrib" => $font_color_contrib,
"gh_version" => $gh_version, "gh_server" => $gh_server, "font_color_gh" => $font_color_gh,
"font_color_local" => $font_color_local, "core_dlink" => $core_dlink, "contrib_dlink" => $contrib_dlink,
"gh_dlink" => $gh_dlink);
}
//Define right now as YYYY.MM.DD HH:MM with the # of updates that are out of date
$cache_updates = array("date" => date("Y.m.d - H:i"), "updates" => $update_count);
//---------------------------------------------------------------------------------------------
//echo 'Message 02: ' .$cache_updates . '<br>';
//---------------------------------------------------------------------------------------------
//Write out the new data to cache with a 30 day expiration & 0 for update data so it's always present
Cache::instance()->set("moduleupdates_cache", serialize($cache), array("ModuleUpdates"), 30*86400);
Cache::instance()->set("moduleupdates_cache_updates", serialize($cache_updates), array("ModuleUpdates"), null);
@ -174,6 +178,52 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
}
/**
*
**/
private function get_module_version_color ($version, $code_version, $remote_version) {
$font_color = "black";
//BLACK - no module version detected
if ($remote_version == "") {
$font_color = "black";
//BLUE - DNE: Does Not Exist, this module was not found
} else if ($remote_version == "DNE") {
$font_color = "blue";
//GREEN - Your version is newer than the GitHub
} else if ($remote_version < $code_version or ($version != ''
and $remote_version < $version)) {
$font_color = "green";
//RED - Your version is older than the GitHub
} else if ($remote_version > $code_version or ($version != ''
and $remote_version > $version)) {
$font_color = "red";
}
return $font_color;
}
/**
*
**/
private function get_local_module_version_color ($version, $code_version) {
$font_color = "black";
//PINK - Your installed version is newer than file version
if ($version != '' and $code_version < $version) {
$font_color = "pink";
//ORANGE - Your file version is newer than the installed version
} else if ($version != '' and $code_version > $version) {
$font_color = "orange";
}
return $font_color;
}
/**
* Parses the known GitHub repositories for new versions of modules.
*
@ -183,71 +233,88 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
*
* http://github.com/gallery/gallery3
* http://github.com/gallery/gallery3-contrib
* http://www.gallerymodules.com
*
* @author brentil <forums@inner-ninja.com>
* @param String The folder name of the module to search for on the remote GitHub server
* @return Array An array with the remote module version and the server it was found on.
* @param String - The folder name of the module to search for on the remote GitHub server
* @param String - The remote server to check against
* @return Array - An array with the remote module version and the server it was found on.
*/
private function get_remote_module_version ($module_name, $devDebug) {
private function get_remote_module_version ($module_name, $server_location) {
$version = 'DNE';
$version = '';
$server = '';
$file = null;
//For development debug only
if ($devDebug == true){
if ($file == null) {
try {
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/". substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")) ."/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(brentil)';
switch ($server_location) {
case "CONTRIB":
//Check the Gallery3 Community Contributions GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/".
substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," "))."/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(GCC)';
}
}
catch (Exception $e) {
}
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
}
//Check the main Gallery3 GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(G)';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
break;
case "CORE":
//Check the main Gallery3 GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(G)';
}
}
catch (Exception $e) {
}
}
break;
case "GH":
//Check GalleryModules.com
if ($file == null) {
try {
$this_gm_repo = str_replace(".","",substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")));
if($this_gm_repo == "30"){
$file = fopen ("http://www.gallerymodules.com/m/".$module_name, "r");
} else {
$file = fopen ("http://www.gallerymodules.com/".this_gm_repo."m/".$module_name, "r");
}
if ($file != null) {
$server = '(GH)';
}
}
catch (Exception $e) {
}
}
break;
}
//Check the Gallery3 Community Contributions GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/". substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")) ."/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(GCC)';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
if ($file != null) {
if ($file != null) {
while (!feof ($file)) {
$line = fgets ($file, 1024);
//Regular expression to find & gather the version number in the remote module.info file
if (preg_match ("@version = (.*)@i", $line, $out)) {
$version = $out[1];
break;
}
if ($server_location == "GH"){
//GH stores only the version info
if($line == "Not entered" or $line == "See git") {
$line = "";
}
$version = $line;
break;
} else {
//Regular expression to find & gather the version number in the remote module.info file
if (preg_match ("@version = (.*)@i", $line, $out)) {
$version = $out[1];
break;
}
}
}
fclose ($file);
}
return array ($version, $server);
}
}
return array ($version, $server);
}
}

View File

@ -27,4 +27,4 @@ class moduleupdates_event_Core {
->label(t("Module Updates"))
->url(url::site("admin/moduleupdates")));
}
}
}

View File

@ -23,8 +23,8 @@ class moduleupdates_installer {
static function install() {
$version = module::get_version("moduleupdates");
if ($version == 0) {
module::set_version("moduleupdates", 4);
if ($version < 1) {
module::set_version("moduleupdates", 5);
//Remove the ModuleUpdates cache entry 'JIC'
Cache::instance()->delete("ModuleUpdates");
//create the blank ModuleUpdates cache entry with an expiration of 0 days
@ -34,7 +34,7 @@ class moduleupdates_installer {
}
static function upgrade($version) {
module::set_version("moduleupdates", 4);
module::set_version("moduleupdates", 5);
//Remove the ModuleUpdates cache entry 'JIC'
Cache::instance()->delete("ModuleUpdates");
//Empty the ModuleUpdates cache entry so our new version starts from scratch

View File

@ -1,3 +1,3 @@
name = "Module Updates"
description = "Compares your installed module version against the ones stored in the GitHub."
version = 4
version = 5

View File

@ -2,8 +2,8 @@
<div id="g-admin-moduleupdates" class="g-block">
<h1> <?= t("Module Updates v4.0") ?> </h1>
<?= t("Compares your installed module version against the ones stored in the GitHub.") ?>
<h1> <?= t("Module Updates v5.0") ?> </h1>
<?= t("Compares your installed module version against the ones stored in the GitHub and GalleryModules.") ?>
<div class="g-block-content">
@ -16,7 +16,6 @@
<li><?= t("<font color=green>Green = Your version is newer than the GitHub</font><br>") ?></li>
<li><?= t("<font color=orange>Orange = Your file version is newer than the installed version</font><br>") ?></li>
<li><?= t("<font color=pink>Pink = Your installed version is newer than file version</font><br>") ?></li>
<li><?= t("<font color=blue>Blue = Does Not Exist/No information available</font><br>") ?></li>
<li><?= t("Outbound Status: " . $Google . " - GitHub Status: " . $GitHub . "<br>") ?></li>
<li><input type="submit" value="<?= t("Check Modules for Updates")?>" class="submit" /> <? if($update_time == ""){ echo "&nbsp;- Last Scan: Unknown";}else{ echo "&nbsp;- Last Scan: ".$update_time;} ?></li>
</ul>
@ -25,24 +24,36 @@
<br>
<ul id="g-action-status" class="g-message-block">
<li class="g-warning"><?= t("Versions are compared from the official Gallery " . $Gallery_Version . " (G) and official Gallery " . $Gallery_Version . " Community Contributions (GCC). Versions downloaded from the forums will not be shown.") ?></li>
<li class="g-warning"><?= t("Versions are compared from GitHub for Gallery Core (GC), Gallery Community Contributions (GCC), and GalleryModules.com (GM). Versions downloaded from the forums will not be shown.") ?></li>
</ul>
<table>
<tr>
<th> <?= t("Module") ?> </th>
<th> <?= t("Your Version<br>[File/Installed]") ?> </th>
<th> <?= t("Remote Version") ?> </th>
<th> <?= t("Description") ?> </th>
<th> <?= t("Module") ?> </th>
<th><center> <?= t("Local /<br>Installed") ?> </center></th>
<th width=50><center> <?= t("GC") ?> </center></th>
<th width=50><center> <?= t("GCC") ?> </center></th>
<th width=85><center> <?= t("GM") ?> </center></th>
<th> <?= t("Description") ?> </th>
</tr>
<? foreach ($vars as $module_name): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= t($module_name['name']) ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?><? if ($module_name['version'] != '') echo "/".$module_name['version']; ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['remote_version'] ?> <?= $module_name['remote_server'] ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= t($module_name['description']) ?> </font> </td>
<td> <?= t($module_name['name']) ?> </td>
<td align=center> <? echo "<font color=".$module_name['font_color_local'].">"; ?> <? if($module_name['font_color_local'] != "black"){ echo "<b><u>*"; } ?> <? if (is_numeric($module_name['code_version'])) echo $module_name['code_version']; ?><? if (is_numeric($module_name['version'])) echo " / ".$module_name['version']; ?> <? if($module_name['font_color_local'] != "black"){ echo "*</b></u>"; } ?> </td>
<td align=center> <? echo "<font color=".$module_name['font_color_core'].">"; ?> <? if($module_name['font_color_core'] != "black" and $module_name['font_color_core'] != "" ){ echo "<b><u>*"; } ?> <? if(is_numeric($module_name['core_version'])) if($module_name['core_version'] > $module_name['code_version']) { echo "<a href=\"".$module_name['core_dlink']."\" target=\"_blank\">".$module_name['core_version']."</a>";} else { echo $module_name['core_version']; } ?> <? if($module_name['font_color_core'] != "black"){ echo "*</b></u>"; } ?> </font> </td>
<td align=center> <? echo "<font color=".$module_name['font_color_contrib'].">"; ?> <? if($module_name['font_color_contrib'] != "black" and $module_name['font_color_contrib'] != "" ){ echo "<b><u>*"; } ?> <? if(is_numeric($module_name['contrib_version'])) if($module_name['contrib_version'] > $module_name['version'] or $module_name['core_version'] > $module_name['code_version']) { echo "<a href=\"".$module_name['contrib_dlink']."\" target=\"_blank\">".$module_name['contrib_version']."</a>";} else { echo $module_name['contrib_version']; } ?> <? if($module_name['font_color_contrib'] != "black"){ echo "*</b></u>"; } ?> </font> </td>
<td align=center> <? echo "<font color=".$module_name['font_color_gh'].">"; ?> <? if($module_name['font_color_gh'] != "black" and $module_name['font_color_gh'] != "" ){ echo "<b><u>*"; } ?> <? if(is_numeric($module_name['gh_version'])) if($module_name['gh_version'] > $module_name['version'] or $module_name['core_version'] > $module_name['code_version']) { echo "<a href=\"".$module_name['gh_dlink']."\" target=\"_blank\">".$module_name['gh_version']."</a>";} else { echo $module_name['gh_version']; } ?> <? if($module_name['font_color_gh'] != "black"){ echo "*</b></u>"; } ?> </font> </td>
<td> <?= t($module_name['description']) ?> </td>
</tr>
<? endforeach ?>
<tr>
<th> <?= t("Module") ?> </th>
<th><center> <?= t("Local /<br>Installed") ?> </center></th>
<th width=50><center> <?= t("GC") ?> </center></th>
<th width=50><center> <?= t("GCC") ?> </center></th>
<th width=85><center> <?= t("GM") ?> </center></th>
<th> <?= t("Description") ?> </th>
</tr>
</table>
</div>
</div>
</div>

View File

@ -21,7 +21,7 @@ class purifier {
static function purify($dirty_html) {
if (!isset(self::$_purifier)) {
require_once(MODPATH . "purifier/lib/HTMLPurifier/HTMLPurifier.auto.php");
require_once(MODPATH . "purifier/vendor/HTMLPurifier/HTMLPurifier.auto.php");
$config = HTMLPurifier_Config::createDefault();
foreach (Kohana::config("purifier") as $category => $key_value) {
foreach ($key_value as $key => $value) {

View File

@ -1,18 +0,0 @@
HTML.AllowedElements
TYPE: lookup/null
VERSION: 1.3.0
DEFAULT: NULL
--DESCRIPTION--
<p>
If HTML Purifier's tag set is unsatisfactory for your needs, you
can overload it with your own list of tags to allow. Note that this
method is subtractive: it does its job by taking away from HTML Purifier
usual feature set, so you cannot add a tag that HTML Purifier never
supported in the first place (like embed, form or head). If you
change this, you probably also want to change %HTML.AllowedAttributes.
</p>
<p>
<strong>Warning:</strong> If another directive conflicts with the
elements here, <em>that</em> directive will win and override.
</p>
--# vim: et sw=4 sts=4

View File

@ -1,14 +0,0 @@
HTML.SafeObject
TYPE: bool
VERSION: 3.1.1
DEFAULT: false
--DESCRIPTION--
<p>
Whether or not to permit object tags in documents, with a number of extra
security features added to prevent script execution. This is similar to
what websites like MySpace do to object tags. You may also want to
enable %HTML.SafeEmbed for maximum interoperability with Internet Explorer,
although embed tags will cause your website to stop validating.
<strong>Highly experimental.</strong>
</p>
--# vim: et sw=4 sts=4

View File

@ -1,3 +1,3 @@
name = "HTML Purifier"
description = "Enable XSS protection using HTMLPurifier"
version = 1
version = 2

View File

@ -7,7 +7,7 @@
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
* FILE, changes will be overwritten the next time the script is run.
*
* @version 4.0.0
* @version 4.2.0
*
* @warning
* You must *not* include any other HTML Purifier files before this file,
@ -176,6 +176,7 @@ require 'HTMLPurifier/Injector/DisplayLinkURI.php';
require 'HTMLPurifier/Injector/Linkify.php';
require 'HTMLPurifier/Injector/PurifierLinkify.php';
require 'HTMLPurifier/Injector/RemoveEmpty.php';
require 'HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php';
require 'HTMLPurifier/Injector/SafeObject.php';
require 'HTMLPurifier/Lexer/DOMLex.php';
require 'HTMLPurifier/Lexer/DirectLex.php';
@ -195,9 +196,12 @@ require 'HTMLPurifier/Token/Start.php';
require 'HTMLPurifier/Token/Text.php';
require 'HTMLPurifier/URIFilter/DisableExternal.php';
require 'HTMLPurifier/URIFilter/DisableExternalResources.php';
require 'HTMLPurifier/URIFilter/DisableResources.php';
require 'HTMLPurifier/URIFilter/HostBlacklist.php';
require 'HTMLPurifier/URIFilter/MakeAbsolute.php';
require 'HTMLPurifier/URIFilter/Munge.php';
require 'HTMLPurifier/URIScheme/data.php';
require 'HTMLPurifier/URIScheme/file.php';
require 'HTMLPurifier/URIScheme/ftp.php';
require 'HTMLPurifier/URIScheme/http.php';
require 'HTMLPurifier/URIScheme/https.php';

View File

@ -19,7 +19,7 @@
*/
/*
HTML Purifier 4.0.0 - Standards Compliant HTML Filtering
HTML Purifier 4.2.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or
@ -55,10 +55,10 @@ class HTMLPurifier
{
/** Version of HTML Purifier */
public $version = '4.0.0';
public $version = '4.2.0';
/** Constant with version of HTML Purifier */
const VERSION = '4.0.0';
const VERSION = '4.2.0';
/** Global configuration object */
public $config;

View File

@ -170,6 +170,7 @@ require_once $__dir . '/HTMLPurifier/Injector/DisplayLinkURI.php';
require_once $__dir . '/HTMLPurifier/Injector/Linkify.php';
require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php';
require_once $__dir . '/HTMLPurifier/Injector/RemoveEmpty.php';
require_once $__dir . '/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php';
require_once $__dir . '/HTMLPurifier/Injector/SafeObject.php';
require_once $__dir . '/HTMLPurifier/Lexer/DOMLex.php';
require_once $__dir . '/HTMLPurifier/Lexer/DirectLex.php';
@ -189,9 +190,12 @@ require_once $__dir . '/HTMLPurifier/Token/Start.php';
require_once $__dir . '/HTMLPurifier/Token/Text.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternal.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternalResources.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableResources.php';
require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php';
require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php';
require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php';
require_once $__dir . '/HTMLPurifier/URIScheme/data.php';
require_once $__dir . '/HTMLPurifier/URIScheme/file.php';
require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php';
require_once $__dir . '/HTMLPurifier/URIScheme/http.php';
require_once $__dir . '/HTMLPurifier/URIScheme/https.php';

View File

@ -82,6 +82,42 @@ abstract class HTMLPurifier_AttrDef
return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string);
}
/**
* Parses a possibly escaped CSS string and returns the "pure"
* version of it.
*/
protected function expandCSSEscape($string) {
// flexibly parse it
$ret = '';
for ($i = 0, $c = strlen($string); $i < $c; $i++) {
if ($string[$i] === '\\') {
$i++;
if ($i >= $c) {
$ret .= '\\';
break;
}
if (ctype_xdigit($string[$i])) {
$code = $string[$i];
for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
if (!ctype_xdigit($string[$i])) break;
$code .= $string[$i];
}
// We have to be extremely careful when adding
// new characters, to make sure we're not breaking
// the encoding.
$char = HTMLPurifier_Encoder::unichr(hexdec($code));
if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
$ret .= $char;
if ($i < $c && trim($string[$i]) !== '') $i--;
continue;
}
if ($string[$i] === "\n") continue;
}
$ret .= $string[$i];
}
return $ret;
}
}
// vim: et sw=4 sts=4

View File

@ -59,7 +59,8 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
$keywords = array();
$keywords['h'] = false; // left, right
$keywords['v'] = false; // top, bottom
$keywords['c'] = false; // center
$keywords['ch'] = false; // center (first word)
$keywords['cv'] = false; // center (second word)
$measures = array();
$i = 0;
@ -79,6 +80,13 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
$lbit = ctype_lower($bit) ? $bit : strtolower($bit);
if (isset($lookup[$lbit])) {
$status = $lookup[$lbit];
if ($status == 'c') {
if ($i == 0) {
$status = 'ch';
} else {
$status = 'cv';
}
}
$keywords[$status] = $lbit;
$i++;
}
@ -101,20 +109,19 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
if (!$i) return false; // no valid values were caught
$ret = array();
// first keyword
if ($keywords['h']) $ret[] = $keywords['h'];
elseif (count($measures)) $ret[] = array_shift($measures);
elseif ($keywords['c']) {
$ret[] = $keywords['c'];
$keywords['c'] = false; // prevent re-use: center = center center
elseif ($keywords['ch']) {
$ret[] = $keywords['ch'];
$keywords['cv'] = false; // prevent re-use: center = center center
}
elseif (count($measures)) $ret[] = array_shift($measures);
if ($keywords['v']) $ret[] = $keywords['v'];
elseif ($keywords['cv']) $ret[] = $keywords['cv'];
elseif (count($measures)) $ret[] = array_shift($measures);
elseif ($keywords['c']) $ret[] = $keywords['c'];
if (empty($ret)) return false;
return implode(' ', $ret);

View File

@ -34,37 +34,10 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
$quote = $font[0];
if ($font[$length - 1] !== $quote) continue;
$font = substr($font, 1, $length - 2);
$new_font = '';
for ($i = 0, $c = strlen($font); $i < $c; $i++) {
if ($font[$i] === '\\') {
$i++;
if ($i >= $c) {
$new_font .= '\\';
break;
}
if (ctype_xdigit($font[$i])) {
$code = $font[$i];
for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
if (!ctype_xdigit($font[$i])) break;
$code .= $font[$i];
}
// We have to be extremely careful when adding
// new characters, to make sure we're not breaking
// the encoding.
$char = HTMLPurifier_Encoder::unichr(hexdec($code));
if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue;
$new_font .= $char;
if ($i < $c && trim($font[$i]) !== '') $i--;
continue;
}
if ($font[$i] === "\n") continue;
}
$new_font .= $font[$i];
}
$font = $new_font;
}
$font = $this->expandCSSEscape($font);
// $font is a pure representation of the font name
if (ctype_alnum($font) && $font !== '') {
@ -73,12 +46,21 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
continue;
}
// complicated font, requires quoting
// bugger out on whitespace. form feed (0C) really
// shouldn't show up regardless
$font = str_replace(array("\n", "\t", "\r", "\x0C"), ' ', $font);
// armor single quotes and new lines
$font = str_replace("\\", "\\\\", $font);
$font = str_replace("'", "\\'", $font);
$final .= "'$font', ";
// These ugly transforms don't pose a security
// risk (as \\ and \" might). We could try to be clever and
// use single-quote wrapping when there is a double quote
// present, but I have choosen not to implement that.
// (warning: this code relies on the selection of quotation
// mark below)
$font = str_replace('\\', '\\5C ', $font);
$font = str_replace('"', '\\22 ', $font);
// complicated font, requires quoting
$final .= "\"$font\", "; // note that this will later get turned into &quot;
}
$final = rtrim($final, ', ');
if ($final === '') return false;

View File

@ -34,20 +34,16 @@ class HTMLPurifier_AttrDef_CSS_URI extends HTMLPurifier_AttrDef_URI
$uri = substr($uri, 1, $new_length - 1);
}
$keys = array( '(', ')', ',', ' ', '"', "'");
$values = array('\\(', '\\)', '\\,', '\\ ', '\\"', "\\'");
$uri = str_replace($values, $keys, $uri);
$uri = $this->expandCSSEscape($uri);
$result = parent::validate($uri, $config, $context);
if ($result === false) return false;
// escape necessary characters according to CSS spec
// except for the comma, none of these should appear in the
// URI at all
$result = str_replace($keys, $values, $result);
// extra sanity check; should have been done by URI
$result = str_replace(array('"', "\\", "\n", "\x0c", "\r"), "", $result);
return "url($result)";
return "url(\"$result\")";
}

View File

@ -24,7 +24,8 @@ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
if ($src) {
$alt = $config->get('Attr.DefaultImageAlt');
if ($alt === null) {
$attr['alt'] = basename($attr['src']);
// truncate if the alt is too long
$attr['alt'] = substr(basename($attr['src']),0,40);
} else {
$attr['alt'] = $alt;
}

View File

@ -33,12 +33,25 @@ class HTMLPurifier_AttrTransform_SafeParam extends HTMLPurifier_AttrTransform
case 'allowNetworking':
$attr['value'] = 'internal';
break;
case 'allowFullScreen':
if ($config->get('HTML.FlashAllowFullScreen')) {
$attr['value'] = ($attr['value'] == 'true') ? 'true' : 'false';
} else {
$attr['value'] = 'false';
}
break;
case 'wmode':
$attr['value'] = 'window';
break;
case 'movie':
case 'src':
$attr['name'] = "movie";
$attr['value'] = $this->uri->validate($attr['value'], $config, $context);
break;
case 'flashvars':
// we're going to allow arbitrary inputs to the SWF, on
// the reasoning that it could only hack the SWF, not us.
break;
// add other cases to support other param name/value pairs
default:
$attr['name'] = $attr['value'] = null;

View File

@ -272,20 +272,29 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
// setup allowed elements
$support = "(for information on implementing this, see the ".
"support forums) ";
$allowed_attributes = $config->get('CSS.AllowedProperties');
if ($allowed_attributes !== null) {
$allowed_properties = $config->get('CSS.AllowedProperties');
if ($allowed_properties !== null) {
foreach ($this->info as $name => $d) {
if(!isset($allowed_attributes[$name])) unset($this->info[$name]);
unset($allowed_attributes[$name]);
if(!isset($allowed_properties[$name])) unset($this->info[$name]);
unset($allowed_properties[$name]);
}
// emit errors
foreach ($allowed_attributes as $name => $d) {
foreach ($allowed_properties as $name => $d) {
// :TODO: Is this htmlspecialchars() call really necessary?
$name = htmlspecialchars($name);
trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING);
}
}
$forbidden_properties = $config->get('CSS.ForbiddenProperties');
if ($forbidden_properties !== null) {
foreach ($this->info as $name => $d) {
if (isset($forbidden_properties[$name])) {
unset($this->info[$name]);
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More