From: <wis...@us...> - 2017-08-30 22:08:53
|
Revision: 13289 http://sourceforge.net/p/xoops/svn/13289 Author: wishcraft Date: 2017-08-30 22:08:50 +0000 (Wed, 30 Aug 2017) Log Message: ----------- Images module for releases.xoops.org -- still alpha1! Modified Paths: -------------- XoopsModules/images/trunk/modules/images/class/ascii/engine.php XoopsModules/images/trunk/modules/images/class/ascii/php7.0/ascii_engine.php XoopsModules/images/trunk/modules/images/class/ascii/php7.0/php7.0.php XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/ascii_engine.php XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/text-image.com.php XoopsModules/images/trunk/modules/images/class/images.php XoopsModules/images/trunk/modules/images/class/objects.php XoopsModules/images/trunk/modules/images/footer.php XoopsModules/images/trunk/modules/images/header.php XoopsModules/images/trunk/modules/images/include/functions.php XoopsModules/images/trunk/modules/images/language/english/admin.php XoopsModules/images/trunk/modules/images/language/english/forms.php XoopsModules/images/trunk/modules/images/language/english/main.php XoopsModules/images/trunk/modules/images/language/english/modinfo.php XoopsModules/images/trunk/modules/images/sql/mysql.sql XoopsModules/images/trunk/modules/images/xoops_version.php Added Paths: ----------- XoopsModules/images/trunk/modules/images/.htaccess XoopsModules/images/trunk/modules/images/class/errors.php XoopsModules/images/trunk/modules/images/class/fields.php XoopsModules/images/trunk/modules/images/image.php XoopsModules/images/trunk/modules/images/include/enumerators/typal__fields.diz XoopsModules/images/trunk/modules/images/include/enumerators/type__errors.diz XoopsModules/images/trunk/modules/images/include/htaccess.txt XoopsModules/images/trunk/modules/images/language/english/errors.php Added: XoopsModules/images/trunk/modules/images/.htaccess =================================================================== --- XoopsModules/images/trunk/modules/images/.htaccess (rev 0) +++ XoopsModules/images/trunk/modules/images/.htaccess 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,6 @@ +RewriteEngine On +RewriteRule ^([0-9a-zA-Z\-]{4-18})/(icons|logo|photo|avatar)/([0-9a-zA-Z\-]{4-18})(.png|.jpg|.gif|.txt)$ ./image.php?field=$1&type=$2&hash=$3&format=$4 [L,NC,QSA] +RewriteRule ^([0-9a-zA-Z\-]{4-18})/(icons|logo|photo|avatar)/([0-9]+)/([0-9a-zA-Z\-]{4-18})(.png|.jpg|.gif|.txt)$ ./image.php?field=$1&type=$2&width=$3&hash=$4&format=$5 [L,NC,QSA] +RewriteRule ^([0-9a-zA-Z\-]{4-18})/(icons|logo|photo|avatar)/([0-9]+)x([0-9]+)/([0-9a-zA-Z\-]{4-18})(.png|.jpg|.gif)$ ./image.php?field=$1&type=$2&width=$3&height=$4&hash=$5&format=$6 [L,NC,QSA] +RewriteRule ^([0-9a-zA-Z\-]{4-18})/(icons|logo|photo|avatar)/(small|medium|large)/([0-9a-zA-Z\-]{4-18})(.txt)$ ./image.php?field=$1&type=$2&scale=$3&hash=$4&format=$5 [L,NC,QSA] +RewriteRule ^(index|icons|logo|photo|avatar)(.html)$ ./index.php?typal=$1 [L,NC,QSA] \ No newline at end of file Modified: XoopsModules/images/trunk/modules/images/class/ascii/engine.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/engine.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/ascii/engine.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,5 +1,27 @@ <?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + class AsciiEngine { Modified: XoopsModules/images/trunk/modules/images/class/ascii/php7.0/ascii_engine.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/php7.0/ascii_engine.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/ascii/php7.0/ascii_engine.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,26 @@ <?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ - $ascengine = array(); $ascengine['class']['file'] = basename(__DIR__).'.php'; $ascengine['class']['name'] = str_replace(" ", "", ucwords(str_replace(array('-','_','.', ' ', basename(__DIR__))))) . 'AsciiArtEngine'; Modified: XoopsModules/images/trunk/modules/images/class/ascii/php7.0/php7.0.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/php7.0/php7.0.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/ascii/php7.0/php7.0.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,4 +1,25 @@ -<?php +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'engine.php'; require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'WideImage' . DIRECTORY_SEPARATOR . 'WideImage.php'; Modified: XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/ascii_engine.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/ascii_engine.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/ascii_engine.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,28 @@ <?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + $ascengine = array(); $ascengine['class']['file'] = basename(__DIR__).'.php'; $ascengine['class']['name'] = str_replace(" ", "", ucwords(str_replace(array('-','_','.', ' ', basename(__DIR__))))) . 'AsciiArtEngine'; Modified: XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/text-image.com.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/text-image.com.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/text-image.com.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,5 +1,27 @@ -<?php +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'engine.php'; class TextImageComAsciiArtEngine extends AsciiEngine Added: XoopsModules/images/trunk/modules/images/class/errors.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/errors.php (rev 0) +++ XoopsModules/images/trunk/modules/images/class/errors.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,87 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + + +if (!defined("XOOPS_ROOT_PATH")) { + exit(); +} + +require_once __DIR__ . DIRECTORY_SEPARATOR . 'objects.php'; + +class ImagesErrors extends ImagesXoopsObject +{ + /** + * Constructor + * + * @param int $id ID of the tag, deprecated + */ + function __construct($id = null) + { + $this->initVar("id", XOBJ_DTYPE_INT, null, false); + $this->initVar("type", XOBJ_DTYPE_ENUM, 'unknown', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'type')); + $this->initVar("uid", XOBJ_DTYPE_INT, null, false); + $this->initVar("imageid", XOBJ_DTYPE_INT, null, false); + $this->initVar("fieldid", XOBJ_DTYPE_INT, null, false); + $this->initVar("code", XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar("when", XOBJ_DTYPE_INT, null, false); + $this->initVar("message", XOBJ_DTYPE_TXTBOX, null, false, 255); + $this->initVar("emailed", XOBJ_DTYPE_INT, null, false); + $this->initVar("created", XOBJ_DTYPE_INT, null, false); + $this->initVar("deleted", XOBJ_DTYPE_INT, null, false); + } + +} + + +class ImagesErrorsHandler extends ImagesXoopsPersistableObjectHandler +{ + + + /** + * Constructor + * + * @param object $db reference to the {@link XoopsDatabase} object + **/ + function __construct(&$db) + { + parent::__construct($db, "images_errors", "ImagesErrors", "id", "hash"); + } + + /** + * Inserts a ImagesErrors Object into the database + * + * {@inheritDoc} + * @see XoopsPersistableObjectHandler::insert() + */ + function insert(ImagesErrors $object, $force = true) + { + global $imagesConfigList; + if ($object->isNew()) + { + $object->getVar('created', time()); + } + return parent::insert($object, true); + } + +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/errors.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/class/fields.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/fields.php (rev 0) +++ XoopsModules/images/trunk/modules/images/class/fields.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,139 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + + +if (!defined("XOOPS_ROOT_PATH")) { + exit(); +} + +require_once __DIR__ . DIRECTORY_SEPARATOR . 'objects.php'; + +class ImagesFields extends ImagesXoopsObject +{ + /** + * Constructor + * + * @param int $id ID of the tag, deprecated + */ + function __construct($id = null) + { + $this->initVar("id", XOBJ_DTYPE_INT, null, false); + $this->initVar("hash", XOBJ_DTYPE_TXTBOX, null, false, 16); + $this->initVar("field", XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar("typal", XOBJ_DTYPE_ENUM, 'unknown', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'typal')); + $this->initVar("views", XOBJ_DTYPE_INT, null, false); + $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); + $this->initVar("images", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("created", XOBJ_DTYPE_INT, null, false); + $this->initVar("errored", XOBJ_DTYPE_INT, null, false); + } + + + /** + * gets Field Typal + * @return string|boolean + */ + public function getFieldTypal($options = NULL) + { + global $imagesConfigList; + if (is_null($options) || empty($options)) + { + $options = array('icons', 'logo', 'photo', 'avatar'); + shuffle($options); + shuffle($options); + shuffle($options); + shuffle($options); + } + foreach($options as $option) + if (in_array(self::getVar('field'), $imagesConfigList["$option_fields"])) + return $option; + return 'unknown'; + } +} + + +class ImagesFieldsHandler extends ImagesXoopsPersistableObjectHandler +{ + + + /** + * Constructor + * + * @param object $db reference to the {@link XoopsDatabase} object + **/ + function __construct(&$db) + { + parent::__construct($db, "images_fields", "ImagesFields", "id", "hash"); + } + + /** + * Inserts a ImagesFields Object into the database + * + * {@inheritDoc} + * @see XoopsPersistableObjectHandler::insert() + */ + function insert(ImagesFields $object, $force = true) + { + global $imagesConfigList; + if ($object->isNew()) + { + $object->getVar('created', time()); + $object->getVar('typal', $object->getFieldTypal()); + $criteria = new CriteriaCompo(new Criteria('field', $object->getVar('field'))); + $criteria->add(new Criteria('typal', $object->getVar('typal'))); + if (self::getCount($criteria) > 0) + { + $objs = self::getObjects($criteria); + if (isset($objs[0]) && !empty($objs[0])) + return $objs[0]->getVar('id'); + } + $crc = new xcp($data = $object->getVar('field').$object->getVar('created').microtime().$object->getVar('typal'), mt_rand(0,255), mt_rand(5,14)); + $object->setVar('hash', $crc->crc); + } + return parent::insert($object, true); + } + + /** + * gets ImagesFields object from hash info + * + * @param string $hash + * @param string $typal + * @return mixed|boolean + */ + function getByHash($hash = '', $typal = '') + { + $criteria = new CriteriaCompo(new Criteria('hash', $hash)); + $criteria->add(new Criteria('typal', $typal)); + if (self::getCount($criteria) > 0) + { + $objs = self::getObjects($criteria); + if (isset($objs[0]) && !empty($objs[0])) + return $objs[0]; + } + return false; + } + +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/fields.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/images/trunk/modules/images/class/images.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/images.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/images.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Webdav Propogating + Management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,15 +12,16 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage webdav - * @description Module for controlling and propogating webdav resources for XOOPS Users + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/webdav - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/webdav - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/webdav + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ + if (!defined("XOOPS_ROOT_PATH")) { exit(); @@ -53,6 +54,9 @@ $this->initVar("bytes", XOBJ_DTYPE_INT, null, false); $this->initVar("views", XOBJ_DTYPE_INT, null, false); $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes", XOBJ_DTYPE_FLOAT, null, false); $this->initVar("updated", XOBJ_DTYPE_INT, null, false); $this->initVar("created", XOBJ_DTYPE_INT, null, false); $this->initVar("checked", XOBJ_DTYPE_INT, null, false); @@ -92,6 +96,10 @@ */ public function getTmpFileSource() { + static $tmp = ''; + if (!empty($tmp) && file_exists($tmp) && filesize($tmp) > 0) + return $tmp; + global $imagesConfigList; if (self::getVar('storage') == 'database') { @@ -123,14 +131,33 @@ public function addViews($number = 1) { $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `views` = `views` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); - return $GLOBALS['xoopsDB']->queryF($sql); + @$GLOBALS['xoopsDB']->queryF($sql); + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `views` = `views` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `field` = '" . self::getVar('field') . "'"; + @$GLOBALS['xoopsDB']->queryF($sql); } + /** + * Adds megabyte count to object + * + * @param number $bytes + * @return unknown + */ + public function addMegabytes($bytes = 0) + { + $megabytes = $bytes / 1024 / 1024; + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `megabytes` = `megabytes` + '$megabytes', `updated` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); + @$GLOBALS['xoopsDB']->queryF($sql); + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `megabytes` = `megabytes` + '$megabytes' WHERE `field` = '" . self::getVar('field') . "'"; + @$GLOBALS['xoopsDB']->queryF($sql); + } + + /** * checks the URL for a new MD5 and updates it if it exists */ public function check() { + global $imagesConfigList; if (self::getVar('checked') > time()) return false; $data = self::getURLData(self::getVar('url')); @@ -370,9 +397,7 @@ $data = file($source); self::setVar('width', strlen($data[0]) - 1); self::setVar('height', count($data)); - } - break; case "database": @@ -382,7 +407,6 @@ $data = file($source); self::setVar('width', strlen($data[0]) - 1); self::setVar('height', count($data)); - break; } @@ -398,6 +422,222 @@ self::setVar('checked', time() + $imagesConfigsList['checking']); } + /** + * gets Field Typal + * @return string|boolean + */ + public function getFieldTypal($options = NULL) + { + global $imagesConfigList; + if (is_null($options) || empty($options)) + { + $options = array('icons', 'logo', 'photo', 'avatar'); + shuffle($options); + shuffle($options); + shuffle($options); + shuffle($options); + } + foreach($options as $option) + if (in_array(self::getVar('field'), $imagesConfigList["$option_fields"])) + return $option; + return false; + } + + /** + * get Default Width + * + * @return unknown|boolean + */ + function getWidth() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["$typal_width"]; + return false; + } + + /** + * gets maximum width + * + * @return unknown|boolean + */ + function getMaximumWidth() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["maximum_$typal_width"]; + return false; + } + + /* + * gets minimal width + */ + function getMinumumWidth() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["minimum_$typal_width"]; + return false; + } + + + /* + * gets original master minimal width + */ + function getOriginalWidth() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["original_$typal_width"]; + return false; + } + /** + * gets default height + * + * @return unknown|boolean + */ + function getHeight() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["$typal_height"]; + return false; + } + + /** + * gets maximum height + * + * @return unknown|boolean + */ + function getMaximumHeight() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["maximum_$typal_height"]; + return false; + } + + /** + * gets minimal height + * + * @return unknown|boolean + */ + function getMinumumHeight() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["minimum_$typal_height"]; + return false; + } + + + /** + * gets original master minimal height + * + * @return unknown|boolean + */ + function getOriginalHeight() + { + global $imagesConfigList; + if ($typal = self::getFieldTypal()) + return $imagesConfigList["original_$typal_height"]; + return false; + } + + /** + * gets the image data and mime type + * + * @param string $type + * @param number $width + */ + function getImageData($type = 'png', $width = 0, $height = 0) + { + global $imagesConfigList; + xoops_load("XoopsCache"); + if (!$result = XoopsCache::read($cachekey = basename(dirname(__DIR__)) . '-' . $type . '--' . $width . 'x' . $height . '--' . self::getVar('hash'))) + { + $result = array('mimetype' => "text/plane", 'data' => ''); + switch ($type) + { + case 'png': + if ($width <= 0 && $height <= 0) + { + $width = self::getWidth(); + $height = self::getHeight(); + } + if ($width > 0 && $height <= 0) + $height = self::getHeight(); + if ($width < self::getMinumumWidth()) + $width = self::getMinumumWidth(); + if ($width > self::getMaximumWidth()) + $width = self::getMaximumWidth(); + if ($height < self::getMinumumHeight()) + $height = self::getMinumumHeight(); + if ($height > self::getMaximumHeight()) + $height = self::getMaximumHeight(); + $img = WideImage::loadFromFile(self::getTmpFileSource()); + $result = array('mimetype' => 'image/png', 'data' => $img->resize($width, $height)->asString($type)); + break; + case 'jpg': + if ($width <= 0 && $height <= 0) + { + $width = self::getWidth(); + $height = self::getHeight(); + } + if ($width > 0 && $height <= 0) + $height = self::getHeight(); + if ($width < self::getMinumumWidth()) + $width = self::getMinumumWidth(); + if ($width > self::getMaximumWidth()) + $width = self::getMaximumWidth(); + if ($height < self::getMinumumHeight()) + $height = self::getMinumumHeight(); + if ($height > self::getMaximumHeight()) + $height = self::getMaximumHeight(); + $img = WideImage::loadFromFile(self::getTmpFileSource()); + $result = array('mimetype' => 'image/jpeg', 'data' => $img->resize($width, $height)->asString($type)); + break; + case 'gif': + if ($width <= 0 && $height <= 0) + { + $width = self::getWidth(); + $height = self::getHeight(); + } + if ($width > 0 && $height <= 0) + $height = self::getHeight(); + if ($width < self::getMinumumWidth()) + $width = self::getMinumumWidth(); + if ($width > self::getMaximumWidth()) + $width = self::getMaximumWidth(); + if ($height < self::getMinumumHeight()) + $height = self::getMinumumHeight(); + if ($height > self::getMaximumHeight()) + $height = self::getMaximumHeight(); + $img = WideImage::loadFromFile(self::getTmpFileSource()); + $result = array('mimetype' => 'image/gif', 'data' => $img->resize($width, $height)->asString($type)); + break; + case 'ascii': + $asciiHandler = new AsciiEngineHandler(); + if ($data = $asciiHandler->getAsciiArt(self::getTmpFileSource(), $width, $imagesConfigList['ascii_mode'], $imagesConfigList['ascii_engine'])) + { + $result = array('mimetype' => 'text/plane', 'data' => $data); + } + break; + } + } + XoopsCache::write($cachekey, $result, $wait = mt_rand($imagesConfigList['minimum_cache_wait'], $imagesConfigList['maximum_cache_wait'])); + if (!$caches = XoopsCache::read($sesskey = basename(dirname(__DIR__)) . '-sessions')) + { + $caches = array(); + $caches[$cachekey] = time() + $wait; + } else + $caches[$cachekey] = time() + $wait; + XoopsCache::write($sesskey, $caches, $imagesConfigList['maximum_cache_wait']); + self::addMegabytes(strlen($result['data'])); + return $result; + + } + /* function getURIData() * cURL Routine for passing $_POST Variable and retreiving URL * @@ -410,7 +650,7 @@ * * @return string */ - private function getURLData($uri = '', $timeout = 65, $connectout = 65, $posts = array()) + private function getURLData($uri = '', $timeout = 0, $connectout = 0, $posts = array()) { global $imagesModule, $imagesConfigsList, $imagesConfigs, $imagesConfigsOptions; @@ -426,8 +666,8 @@ curl_setopt($art, CURLOPT_POST, (count($posts)==0?false:true)); if (count($posts)!=0) curl_setopt($art, CURLOPT_POSTFIELDS, http_build_query($posts)); - curl_setopt($art, CURLOPT_CONNECTTIMEOUT, $connectout); - curl_setopt($art, CURLOPT_TIMEOUT, $timeout); + curl_setopt($art, CURLOPT_CONNECTTIMEOUT, ($connectout!=0?$connectout:$imagesConfigsList['curl_connections'])); + curl_setopt($art, CURLOPT_TIMEOUT, ($timeout!=0?$timeout:$imagesConfigsList['curl_timeout'])); curl_setopt($art, CURLOPT_RETURNTRANSFER, true); curl_setopt($art, CURLOPT_VERBOSE, false); curl_setopt($art, CURLOPT_SSL_VERIFYHOST, false); @@ -468,30 +708,82 @@ global $imagesConfigList; if ($object->isNew()) { - global $imagesConfigList; + if (strlen($object->getVar('field'))==0 || strlen($object->getVar('url'))== 0) + return false; if ($object->getVar('uid')==0 && is_object($GLOBALS['xoopsUser'])) $object->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); $object->setVar('created', time()); $object->setVar('type', $imagesConfigList['format']); $object->setVar('storage', $imagesConfigList['storage']); - $crc = new xcp($data = $object->getVar('uid').$object->getVar('created').microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); + $crc = new xcp($data = $object->getVar('uid').$imagesConfigList['format'].microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); $object->setVar('hash', $crc->crc); - if (in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) + $criteria = new CriteriaCompo(new Criteria('uid', $object->getVar('uid'))); + $criteria->add(new Criteria('field', $object->getVar('field'))); + if (!in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) + $criteria->add(new Criteria('type', $object->getVar('type'))); + else + $criteria->add(new Criteria('type', "('" . $object->getVar('type') . "','ascii-small','ascii-medium','ascii-large')", "IN")); + if (self::getCount($criteria) > 0) { - $asciiobjs = array(); - $asciiobjs['small'] = $object; - $asciiobjs['small']->setVar('type', 'ascii-small'); - $asciiobjs['medium'] = $object; - $asciiobjs['medium']->setVar('type', 'ascii-medium'); - $asciiobjs['large'] = $object; - $asciiobjs['large']->setVar('type', 'ascii-large'); - @parent::insert($asciiobjs['small'], true); - @parent::insert($asciiobjs['medium'], true); - @parent::insert($asciiobjs['large'], true); - unset($asciiobjs); + foreach(self::getObjects($criteria) as $obj) + { + $obj->setVar('url', $object->getVar('url')); + $obj->setVar('checked', time() + mt_rand(320, 4800)); + if ($obj->getVar('type') == $object->getVar('type')) + $id = parent::insert($obj, true); + else + @parent::insert($obj, true); + } + return $id; + } else { + + if (in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) + { + $crc = new xcp($data = $object->getVar('uid').'ascii'.microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); + $asciiobjs = array(); + $asciiobjs['small'] = $object; + $asciiobjs['small']->setVar('type', 'ascii-small'); + $asciiobjs['small']->setVar('hash', $crc->crc); + $asciiobjs['medium'] = $object; + $asciiobjs['medium']->setVar('type', 'ascii-medium'); + $asciiobjs['medium']->setVar('hash', $crc->crc); + $asciiobjs['large'] = $object; + $asciiobjs['large']->setVar('type', 'ascii-large'); + $asciiobjs['large']->setVar('hash', $crc->crc); + @parent::insert($asciiobjs['small'], true); + @parent::insert($asciiobjs['medium'], true); + @parent::insert($asciiobjs['large'], true); + unset($asciiobjs); + } } } + $object->setVar('updated', time()); return parent::insert($object, true); } + + /** + * gets ImagesFields object from hash info + * + * @param string $hash + * @param string $field + * @param string $type + * @return mixed|boolean + */ + function getByHash($hash = '', $field = '', $type = '') + { + $criteria = new CriteriaCompo(new Criteria('hash', $hash)); + if (!empty($field)) + $criteria->add(new Criteria('field', $field)); + if (!empty($type)) + $criteria->add(new Criteria('type', $type)); + if (self::getCount($criteria) > 0) + { + $objs = self::getObjects($criteria); + if (isset($objs[0]) && !empty($objs[0])) + return $objs[0]; + } + return false; + } + } ?> \ No newline at end of file Modified: XoopsModules/images/trunk/modules/images/class/objects.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/objects.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/class/objects.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * Legal Images is a module for obtain legal guardianship Images + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -9,15 +9,19 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * @copyright The XOOPS Project http://fonts2web.org.uk - * @license General Public License version 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) - * @author Simon Roberts (wishcraft) <wis...@us...> - * @subpackage Images - * @description Legal Images is a module for obtain legal guardianship Images - * @version 1.0.1 + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ + if (!defined('_MI_Images_MODULE_DIRNAME')) { return false; } Modified: XoopsModules/images/trunk/modules/images/footer.php =================================================================== --- XoopsModules/images/trunk/modules/images/footer.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/footer.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Languages management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,16 +12,15 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage languages - * @description Module for fitting languages on xoops + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/languages - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/languages - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/languages + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ - include_once XOOPS_ROOT_PATH . "/footer.php"; ?> \ No newline at end of file Modified: XoopsModules/images/trunk/modules/images/header.php =================================================================== --- XoopsModules/images/trunk/modules/images/header.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/header.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Languages management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,12 +12,12 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage languages - * @description Module for fitting languages on xoops + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/languages - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/languages - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/languages + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ Added: XoopsModules/images/trunk/modules/images/image.php =================================================================== --- XoopsModules/images/trunk/modules/images/image.php (rev 0) +++ XoopsModules/images/trunk/modules/images/image.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,91 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + + +include_once __DIR__ . "/header.php"; + +$GLOBALS['xoopsLogger']->activated = false; +if (function_exists('mb_http_output')) { + mb_http_output('pass'); +} + +$fieldsHandler = xoops_getModuleHandler('fields', basename(__DIR__)); +$imagesHandler = xoops_getModuleHandler('images', basename(__DIR__)); + +if ($field = $fieldsHandler->getByHash($_REQUEST['field'], $_REQUEST['typal'])) +{ + if ($image = $imagesHandler->getByHash($_REQUEST['hash'], $field->getVar('field'))) + { + if (isset($_REQUEST['width']) && !empty($_REQUEST['width'])) + $width = $_REQUEST['width']; + if (isset($_REQUEST['height']) && !empty($_REQUEST['height'])) + $height = $_REQUEST['height']; + else + $height = $width; + + switch((isset($_REQUEST['format']) && !empty($_REQUEST['format'])?$_REQUEST['format']:'default')) + { + default: + case $imagesConfigList['png']: + $result = $image->getImageData('png', $width, $height); + break; + case $imagesConfigList['jpg']: + $result = $image->getImageData('jpg', $width, $height); + break; + case $imagesConfigList['gif']: + $result = $image->getImageData('gif', $width, $height); + break; + case $imagesConfigList['txt']: + switch((isset($_REQUEST['scale']) && !empty($_REQUEST['scale'])?$_REQUEST['scale']:'default')) + { + default: + $result = $image->getImageData('ascii', ($width<=0?$imagesConfigList['ascii_medium_width']:$width)); + break; + case 'small': + $result = $image->getImageData('ascii', $imagesConfigList['ascii_small_width']); + break; + case 'medium': + $result = $image->getImageData('ascii', $imagesConfigList['ascii_medium_width']); + break; + case 'large': + $result = $image->getImageData('ascii', $imagesConfigList['ascii_large_width']); + break; + break; + } + } + if (!empty($result['data'])) + { + if(ini_get('zlib.output_compression')) { + ini_set('zlib.output_compression', 'Off'); + } + if (function_exists('http_response_code')) + http_response_code(201); + header('Content-Type: ' . $result['mimetype']); + die($result['data']); + } + } +} +if (function_exists('http_response_code')) + http_response_code(501); +die("No Resulting Images Found for Hash Keys!"); +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/image.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/include/enumerators/typal__fields.diz =================================================================== --- XoopsModules/images/trunk/modules/images/include/enumerators/typal__fields.diz (rev 0) +++ XoopsModules/images/trunk/modules/images/include/enumerators/typal__fields.diz 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,5 @@ +icons +logo +photo +avatar +unknown \ No newline at end of file Added: XoopsModules/images/trunk/modules/images/include/enumerators/type__errors.diz =================================================================== --- XoopsModules/images/trunk/modules/images/include/enumerators/type__errors.diz (rev 0) +++ XoopsModules/images/trunk/modules/images/include/enumerators/type__errors.diz 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,4 @@ +system +module +user +unknown \ No newline at end of file Modified: XoopsModules/images/trunk/modules/images/include/functions.php =================================================================== --- XoopsModules/images/trunk/modules/images/include/functions.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/include/functions.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Languages management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -13,15 +13,16 @@ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> * @subpackage images - * @description Module for cache url for images in profile and turning also into ASCII Art + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/languages - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/languages - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/languages + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ + function images_load_config() { global $xoopsModuleConfig; Added: XoopsModules/images/trunk/modules/images/include/htaccess.txt =================================================================== --- XoopsModules/images/trunk/modules/images/include/htaccess.txt (rev 0) +++ XoopsModules/images/trunk/modules/images/include/htaccess.txt 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,3 @@ +RewriteEngine On +RewriteRule ^%base%/([0-9]+)/([0-9]+)/index%html% ./modules/languages/index.php?start=$1&limit=$2 +RewriteRule ^%base%/requests%html% ./modules/languages/requests.php [L,NC,QSA] Modified: XoopsModules/images/trunk/modules/images/language/english/admin.php =================================================================== --- XoopsModules/images/trunk/modules/images/language/english/admin.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/language/english/admin.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Webdav Propogating + Management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,12 +12,12 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage webdav - * @description Module for controlling and propogating webdav resources for XOOPS Users + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/webdav - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/webdav - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/webdav + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ Added: XoopsModules/images/trunk/modules/images/language/english/errors.php =================================================================== --- XoopsModules/images/trunk/modules/images/language/english/errors.php (rev 0) +++ XoopsModules/images/trunk/modules/images/language/english/errors.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -0,0 +1,32 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + + +if (!defined('XOOPS_ROOT_PATH')) { exit(); } + +define("IMAGES_ERRORS_ORIGINAL_WIDTH_CODE","100"); +define("IMAGES_ERRORS_ORIGINAL_WIDTH_MESSAGE","The original source URL minimal width has not been met it is %spx and a width of %spx is required!"); +define("IMAGES_ERRORS_ORIGINAL_HEIGHT_CODE","101"); +define("IMAGES_ERRORS_ORIGINAL_HEIGHT_MESSAGE","The original source URL minimal height has not been met it is %spx and a height of %spx is required!"); +define("IMAGES_ERRORS_EMAIL_NOT_SENDING_CODE","200"); +define("IMAGES_ERRORS_EMAIL_NOT_SENDING_MESSAGE","You need to check the setting for postfix and mailman, for some reason the mail isn't transmitting!"); \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/language/english/errors.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/images/trunk/modules/images/language/english/forms.php =================================================================== --- XoopsModules/images/trunk/modules/images/language/english/forms.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/language/english/forms.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Webdav Propogating + Management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,16 +12,17 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage webdav - * @description Module for controlling and propogating webdav resources for XOOPS Users + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/webdav - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/webdav - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/webdav + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ + if (!defined('XOOPS_ROOT_PATH')) { exit(); } define("LANGS_FORMS_REQUESTS_TITLE", "Request new language to be added to supported types!"); Modified: XoopsModules/images/trunk/modules/images/language/english/main.php =================================================================== --- XoopsModules/images/trunk/modules/images/language/english/main.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/language/english/main.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Webdav Propogating + Management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,17 +12,18 @@ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license General Public License version 3 * @author Simon Roberts <wis...@us...> - * @subpackage webdav - * @description Module for controlling and propogating webdav resources for XOOPS Users + * @subpackage images + * @description Module for importing image URL listed in profile module * @version 1.0.1 - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/webdav - * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/webdav - * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/webdav + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images * @link http://internetfounder.wordpress.com */ + if (!defined('XOOPS_ROOT_PATH')) { exit(); } define("LANGS_MN_INDEX_TITLE", "Supported Languages: %s of %s"); Modified: XoopsModules/images/trunk/modules/images/language/english/modinfo.php =================================================================== --- XoopsModules/images/trunk/modules/images/language/english/modinfo.php 2017-08-30 18:15:02 UTC (rev 13288) +++ XoopsModules/images/trunk/modules/images/language/english/modinfo.php 2017-08-30 22:08:50 UTC (rev 13289) @@ -1,6 +1,6 @@ <?php /** - * XOOPS Webdav Propogating + Management module + * XOOPS Remote Images URL Cache and Management in Profile Module * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -12,17 +12,18 @@ * @copyright The XOOPS Proje... [truncated message content] |
From: <wis...@us...> - 2017-08-30 23:20:56
|
Revision: 13290 http://sourceforge.net/p/xoops/svn/13290 Author: wishcraft Date: 2017-08-30 23:20:53 +0000 (Wed, 30 Aug 2017) Log Message: ----------- Images module for releases.xoops.org -- still alpha1! Modified Paths: -------------- XoopsModules/images/trunk/modules/images/class/fields.php XoopsModules/images/trunk/modules/images/class/images.php XoopsModules/images/trunk/modules/images/image.php Added Paths: ----------- XoopsModules/images/trunk/modules/images/crons/refresh-images.php XoopsModules/images/trunk/modules/images/crons/refresh-users-avatar.php XoopsModules/images/trunk/modules/images/crons/refresh-users-icons.php XoopsModules/images/trunk/modules/images/crons/refresh-users-logo.php XoopsModules/images/trunk/modules/images/crons/refresh-users-photo.php Modified: XoopsModules/images/trunk/modules/images/class/fields.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/fields.php 2017-08-30 22:08:50 UTC (rev 13289) +++ XoopsModules/images/trunk/modules/images/class/fields.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -135,5 +135,62 @@ return false; } + /** + * get an Array of a field + * + * @param string $field + * @param string $return + * @return string[] + */ + function getFieldArray($field = '', $return = 'url') + { + $result = array(''); + $sql = "SELECT DISTINCT `$return` FROM `" . $GLOBALS['xoopsDB']->prefix('images_images') . "` WHERE `field` = '$field'"; + if ($query = $GLOBALS['xoopsDB']->queryF($sql)) + { + $value = 'https://'; + while(count($result)<$GLOBALS['xoopsDB']->getRowsNum($query)) + { + list($value) = $GLOBALS['xoopsDB']->fetchRow($query); + $result[] = $value; + } + if ($return == 'url') + { + $result[] = 'http://'; + $result[] = 'https://'; + $result[] = ''; + } + array_unique($result); + sort($result, SORT_ASC); + } + return $result; + } + + /** + * adds to the images count + * + * @param string $field + * @param string $typal + * @param number $number + */ + function addImages($field = '', $typal = '', $number = 1) + { + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `images` = `images` + '$number' WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; + @$GLOBALS['xoopsDB']->queryF($sql); + } + + + /** + * adds to the error count + * + * @param string $field + * @param string $typal + * @param number $number + */ + function addErrors($field = '', $typal = '', $number = 1) + { + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `errors` = `errors` + '$number', `errored` = UNIX_TIMESTAMP() WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; + @$GLOBALS['xoopsDB']->queryF($sql); + } } ?> \ No newline at end of file Modified: XoopsModules/images/trunk/modules/images/class/images.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/images.php 2017-08-30 22:08:50 UTC (rev 13289) +++ XoopsModules/images/trunk/modules/images/class/images.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -710,13 +710,25 @@ { if (strlen($object->getVar('field'))==0 || strlen($object->getVar('url'))== 0) return false; + + $fieldsHandler = xoops_getModuleHandler('fields', basename(__DIR__)); + $field = $fieldsHandler->create(); + $field->setVar('field', $object->getVar('field')); + $field->setVar('typal', $object->getFieldTypal()); + if (!$field = $fieldsHandler->get($fieldsHandler->insert($field, true))) + return false; + if ($object->getVar('uid')==0 && is_object($GLOBALS['xoopsUser'])) $object->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); $object->setVar('created', time()); - $object->setVar('type', $imagesConfigList['format']); + if (strlen($object->getVar('type')) == 0 || $object->getVar('type') == 'unknown') + $object->setVar('type', $imagesConfigList['format']); $object->setVar('storage', $imagesConfigList['storage']); - $crc = new xcp($data = $object->getVar('uid').$imagesConfigList['format'].microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); - $object->setVar('hash', $crc->crc); + if (strlen($object->getVar('hash')) == 0) + { + $crc = new xcp($data = $field->getVar('hash').$object->getVar('uid').$imagesConfigList['format'].microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); + $object->setVar('hash', $crc->crc); + } $criteria = new CriteriaCompo(new Criteria('uid', $object->getVar('uid'))); $criteria->add(new Criteria('field', $object->getVar('field'))); if (!in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) @@ -756,6 +768,7 @@ unset($asciiobjs); } } + $fieldsHandler->addImages($object->getVar('field'), $object->getFieldTypal()); } $object->setVar('updated', time()); return parent::insert($object, true); Added: XoopsModules/images/trunk/modules/images/crons/refresh-images.php =================================================================== --- XoopsModules/images/trunk/modules/images/crons/refresh-images.php (rev 0) +++ XoopsModules/images/trunk/modules/images/crons/refresh-images.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -0,0 +1,33 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + +global $imagesConfigList; + +include_once dirname(__DIR__) . "/header.php"; + +$imagesHandler = xoops_getModuleHandler('images', basename(dirname(__DIR__))); +$criteria = new Criteria('checked', time(), "<="); +foreach($imagesHandler->getObjects($criteria) as $image) + $image->check(); + +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/crons/refresh-images.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/crons/refresh-users-avatar.php =================================================================== --- XoopsModules/images/trunk/modules/images/crons/refresh-users-avatar.php (rev 0) +++ XoopsModules/images/trunk/modules/images/crons/refresh-users-avatar.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -0,0 +1,57 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + +global $imagesConfigList; + +include_once dirname(__DIR__) . "/header.php"; + +$userHandler = xoops_getHandler('users'); +$imagesHandler = xoops_getModuleHandler('images', basename(dirname(__DIR__))); +$profileHandler = xoops_getModuleHandler('profile', 'profile'); + +foreach($imageConfigList['avatar_fields'] as $field) +{ + $criteria = new CriteriaCompo(new Criteria($field, "('" . implode("', '", $imagesHandler->getFieldArray($field, 'url')) . "')", "NOT IN")); + foreach($profileHandler->getObjects($criteria) as $profile) + { + $populate = false; + if ($user = $userHandler->get($profile->getVar('profile_id'))) + { + foreach($user->getGroups() as $groupid) + if (in_array($groupid, $imageConfigList['populate_groups'])) + { + $populate = true; + continue; + } + } + if ($populate == true) + { + $image = $imagesHandler->create(); + $image->setVar('uid', $profile->getVar('profile_id')); + $image->setVar('field', $field); + $image->setVar('url', $profile->getVar($field)); + $imagesHandler->insert($image, true); + } + } +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/crons/refresh-users-avatar.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/crons/refresh-users-icons.php =================================================================== --- XoopsModules/images/trunk/modules/images/crons/refresh-users-icons.php (rev 0) +++ XoopsModules/images/trunk/modules/images/crons/refresh-users-icons.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -0,0 +1,58 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + +global $imagesConfigList; + +include_once dirname(__DIR__) . "/header.php"; + +$userHandler = xoops_getHandler('users'); +$imagesHandler = xoops_getModuleHandler('images', basename(dirname(__DIR__))); +$profileHandler = xoops_getModuleHandler('profile', 'profile'); + +foreach($imageConfigList['icons_fields'] as $field) +{ + $criteria = new CriteriaCompo(new Criteria($field, "('" . implode("', '", $imagesHandler->getFieldArray($field, 'url')) . "')", "NOT IN")); + foreach($profileHandler->getObjects($criteria) as $profile) + { + $populate = false; + if ($user = $userHandler->get($profile->getVar('profile_id'))) + { + foreach($user->getGroups() as $groupid) + if (in_array($groupid, $imageConfigList['populate_groups'])) + { + $populate = true; + continue; + } + } + if ($populate == true) + { + $image = $imagesHandler->create(); + $image->setVar('uid', $profile->getVar('profile_id')); + $image->setVar('field', $field); + $image->setVar('url', $profile->getVar($field)); + $imagesHandler->insert($image, true); + } + } + +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/crons/refresh-users-icons.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/crons/refresh-users-logo.php =================================================================== --- XoopsModules/images/trunk/modules/images/crons/refresh-users-logo.php (rev 0) +++ XoopsModules/images/trunk/modules/images/crons/refresh-users-logo.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -0,0 +1,58 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + +global $imagesConfigList; + +include_once dirname(__DIR__) . "/header.php"; + +$userHandler = xoops_getHandler('users'); +$imagesHandler = xoops_getModuleHandler('images', basename(dirname(__DIR__))); +$profileHandler = xoops_getModuleHandler('profile', 'profile'); + +foreach($imageConfigList['logo_fields'] as $field) +{ + $criteria = new CriteriaCompo(new Criteria($field, "('" . implode("', '", $imagesHandler->getFieldArray($field, 'url')) . "')", "NOT IN")); + foreach($profileHandler->getObjects($criteria) as $profile) + { + $populate = false; + if ($user = $userHandler->get($profile->getVar('profile_id'))) + { + foreach($user->getGroups() as $groupid) + if (in_array($groupid, $imageConfigList['populate_groups'])) + { + $populate = true; + continue; + } + } + if ($populate == true) + { + $image = $imagesHandler->create(); + $image->setVar('uid', $profile->getVar('profile_id')); + $image->setVar('field', $field); + $image->setVar('url', $profile->getVar($field)); + $imagesHandler->insert($image, true); + } + } + +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/crons/refresh-users-logo.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/crons/refresh-users-photo.php =================================================================== --- XoopsModules/images/trunk/modules/images/crons/refresh-users-photo.php (rev 0) +++ XoopsModules/images/trunk/modules/images/crons/refresh-users-photo.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -0,0 +1,58 @@ +<?php +/** + * XOOPS Remote Images URL Cache and Management in Profile Module + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license General Public License version 3 + * @author Simon Roberts <wis...@us...> + * @subpackage images + * @description Module for importing image URL listed in profile module + * @version 1.0.1 + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.5/Modules/images + * @link https://sourceforge.net/projects/chronolabs/files/XOOPS%202.6/Modules/images + * @link https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/images + * @link http://internetfounder.wordpress.com + */ + +global $imagesConfigList; + +include_once dirname(__DIR__) . "/header.php"; + +$userHandler = xoops_getHandler('users'); +$imagesHandler = xoops_getModuleHandler('images', basename(dirname(__DIR__))); +$profileHandler = xoops_getModuleHandler('profile', 'profile'); + +foreach($imageConfigList['photo_fields'] as $field) +{ + $criteria = new CriteriaCompo(new Criteria($field, "('" . implode("', '", $imagesHandler->getFieldArray($field, 'url')) . "')", "NOT IN")); + foreach($profileHandler->getObjects($criteria) as $profile) + { + $populate = false; + if ($user = $userHandler->get($profile->getVar('profile_id'))) + { + foreach($user->getGroups() as $groupid) + if (in_array($groupid, $imageConfigList['populate_groups'])) + { + $populate = true; + continue; + } + } + if ($populate == true) + { + $image = $imagesHandler->create(); + $image->setVar('uid', $profile->getVar('profile_id')); + $image->setVar('field', $field); + $image->setVar('url', $profile->getVar($field)); + $imagesHandler->insert($image, true); + } + } + +} +?> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/crons/refresh-users-photo.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/images/trunk/modules/images/image.php =================================================================== --- XoopsModules/images/trunk/modules/images/image.php 2017-08-30 22:08:50 UTC (rev 13289) +++ XoopsModules/images/trunk/modules/images/image.php 2017-08-30 23:20:53 UTC (rev 13290) @@ -21,6 +21,7 @@ * @link http://internetfounder.wordpress.com */ +global $imagesConfigList; include_once __DIR__ . "/header.php"; @@ -36,14 +37,16 @@ { if ($image = $imagesHandler->getByHash($_REQUEST['hash'], $field->getVar('field'))) { - if (isset($_REQUEST['width']) && !empty($_REQUEST['width'])) - $width = $_REQUEST['width']; - if (isset($_REQUEST['height']) && !empty($_REQUEST['height'])) - $height = $_REQUEST['height']; + if (isset($_REQUEST['width']) && !empty($_REQUEST['width']) && ((integer)$_REQUEST['width'] > $image->getMinimumWidth() && (integer)$_REQUEST['width'] < $image->getMaximumWidth())) + $width = (integer)$_REQUEST['width']; else - $height = $width; + $width = $image->getWidth(); + if (isset($_REQUEST['height']) && !empty($_REQUEST['height']) && ((integer)$_REQUEST['height'] > $image->getMinimumHeight() && (integer)$_REQUEST['height'] < $image->getMaximumHeight())) + $height = (integer)$_REQUEST['height']; + else + $height = $image->getHeight(); - switch((isset($_REQUEST['format']) && !empty($_REQUEST['format'])?$_REQUEST['format']:'default')) + switch((isset($_REQUEST['format']) && !empty($_REQUEST['format'])?$_REQUEST['format']:$imagesConfigList['png'])) { default: case $imagesConfigList['png']: |
From: <wis...@us...> - 2017-08-31 04:47:38
|
Revision: 13291 http://sourceforge.net/p/xoops/svn/13291 Author: wishcraft Date: 2017-08-31 04:47:34 +0000 (Thu, 31 Aug 2017) Log Message: ----------- :: Completing Statistian System of Images for releases.xoops.org! Modified Paths: -------------- XoopsModules/images/trunk/modules/images/class/fields.php XoopsModules/images/trunk/modules/images/class/images.php XoopsModules/images/trunk/modules/images/include/functions.php XoopsModules/images/trunk/modules/images/sql/mysql.sql XoopsModules/images/trunk/modules/images/xoops_version.php Added Paths: ----------- XoopsModules/images/trunk/modules/images/class/ascii/index.html XoopsModules/images/trunk/modules/images/class/ascii/php7.0/index.html XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/index.html XoopsModules/images/trunk/modules/images/class/index.html XoopsModules/images/trunk/modules/images/class/statistics.php XoopsModules/images/trunk/modules/images/class/xcp/index.html XoopsModules/images/trunk/modules/images/crons/index.html XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-biweekly.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-daily.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-hourly.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-monthly.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-quarterly.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-weekly.php XoopsModules/images/trunk/modules/images/crons/stats-fields-ending-yearly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-biweekly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-daily.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-hourly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-monthly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-quarterly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-weekly.php XoopsModules/images/trunk/modules/images/crons/stats-images-ending-yearly.php XoopsModules/images/trunk/modules/images/images/blacklist/ XoopsModules/images/trunk/modules/images/images/blacklist/permanent-avatar.png XoopsModules/images/trunk/modules/images/images/blacklist/permanent-icons.png XoopsModules/images/trunk/modules/images/images/blacklist/permanent-logo.png XoopsModules/images/trunk/modules/images/images/blacklist/permanent-photo.png XoopsModules/images/trunk/modules/images/images/blacklist/temporary-avatar.png XoopsModules/images/trunk/modules/images/images/blacklist/temporary-icons.png XoopsModules/images/trunk/modules/images/images/blacklist/temporary-logo.png XoopsModules/images/trunk/modules/images/images/blacklist/temporary-photo.png XoopsModules/images/trunk/modules/images/images/index.html XoopsModules/images/trunk/modules/images/include/data/ XoopsModules/images/trunk/modules/images/include/data/timezones.diz XoopsModules/images/trunk/modules/images/include/enumerators/blacklisted__images.diz XoopsModules/images/trunk/modules/images/include/enumerators/day-name__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/mode__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/segment-hour__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/segment-minute__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/segment-month__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/typal__statistics.diz XoopsModules/images/trunk/modules/images/include/enumerators/type__statistics.diz Added: XoopsModules/images/trunk/modules/images/class/ascii/index.html =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/index.html (rev 0) +++ XoopsModules/images/trunk/modules/images/class/ascii/index.html 2017-08-31 04:47:34 UTC (rev 13291) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/ascii/index.html ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/class/ascii/php7.0/index.html =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/php7.0/index.html (rev 0) +++ XoopsModules/images/trunk/modules/images/class/ascii/php7.0/index.html 2017-08-31 04:47:34 UTC (rev 13291) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/ascii/php7.0/index.html ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/index.html =================================================================== --- XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/index.html (rev 0) +++ XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/index.html 2017-08-31 04:47:34 UTC (rev 13291) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/ascii/text-image.com/index.html ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/images/trunk/modules/images/class/fields.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/fields.php 2017-08-30 23:20:53 UTC (rev 13290) +++ XoopsModules/images/trunk/modules/images/class/fields.php 2017-08-31 04:47:34 UTC (rev 13291) @@ -42,10 +42,52 @@ $this->initVar("field", XOBJ_DTYPE_TXTBOX, null, false, 64); $this->initVar("typal", XOBJ_DTYPE_ENUM, 'unknown', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'typal')); $this->initVar("views", XOBJ_DTYPE_INT, null, false); - $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); $this->initVar("images", XOBJ_DTYPE_INT, null, false); $this->initVar("errors", XOBJ_DTYPE_INT, null, false); $this->initVar("megabytes", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_hourly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_daily", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_weekly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_biweekly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_monthly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_quarterly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("images_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_yearly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("start_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); $this->initVar("created", XOBJ_DTYPE_INT, null, false); $this->initVar("errored", XOBJ_DTYPE_INT, null, false); } @@ -79,6 +121,13 @@ /** + * Variables that comprise of statistic indicies + * + * @var array + */ + var $_statistian_fields = array('views','images','errors','megabytes'); + + /** * Constructor * * @param object $db reference to the {@link XoopsDatabase} object @@ -175,7 +224,7 @@ */ function addImages($field = '', $typal = '', $number = 1) { - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `images` = `images` + '$number' WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `images` = `images` + '$number', `images_hourly` = `images_hourly` + '$number', `images_daily` = `images_daily` + '$number', `images_weekly` = `images_weekly` + '$number', `images_biweekly` = `images_biweekly` + '$number', `images_monthly` = `images_monthly` + '$number', `images_quarterly` = `images_quarterly` + '$number', `images_yearly` = `images_yearly` + '$number' WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; @$GLOBALS['xoopsDB']->queryF($sql); } @@ -189,7 +238,7 @@ */ function addErrors($field = '', $typal = '', $number = 1) { - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `errors` = `errors` + '$number', `errored` = UNIX_TIMESTAMP() WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `errors` = `errors` + '$number', `errors_hourly` = `errors_hourly` + '$number', `errors_daily` = `errors_daily` + '$number', `errors_weekly` = `errors_weekly` + '$number', `errors_biweekly` = `errors_biweekly` + '$number', `errors_monthly` = `errors_monthly` + '$number', `errors_quarterly` = `errors_quarterly` + '$number', `errors_yearly` = `errors_yearly` + '$number', `errored` = UNIX_TIMESTAMP() WHERE `field` = '" . $field . "' AND `typal` = '" . $typal . "'"; @$GLOBALS['xoopsDB']->queryF($sql); } } Modified: XoopsModules/images/trunk/modules/images/class/images.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/images.php 2017-08-30 23:20:53 UTC (rev 13290) +++ XoopsModules/images/trunk/modules/images/class/images.php 2017-08-31 04:47:34 UTC (rev 13291) @@ -41,28 +41,72 @@ */ function __construct($id = null) { - $this->initVar("id", XOBJ_DTYPE_INT, null, false); - $this->initVar("uid", XOBJ_DTYPE_INT, null, false); - $this->initVar("hash", XOBJ_DTYPE_TXTBOX, null, false, 16); - $this->initVar("field", XOBJ_DTYPE_TXTBOX, null, false, 64); - $this->initVar("type", XOBJ_DTYPE_ENUM, 'unknown', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'type')); - $this->initVar("storage", XOBJ_DTYPE_ENUM, 'files', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'storage')); - $this->initVar("md5", XOBJ_DTYPE_TXTBOX, null, false, 32); - $this->initVar("url", XOBJ_DTYPE_TXTBOX, null, false, 255); - $this->initVar("width", XOBJ_DTYPE_INT, null, false); - $this->initVar("height", XOBJ_DTYPE_INT, null, false); - $this->initVar("bytes", XOBJ_DTYPE_INT, null, false); - $this->initVar("views", XOBJ_DTYPE_INT, null, false); - $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); - $this->initVar("updates", XOBJ_DTYPE_INT, null, false); - $this->initVar("errors", XOBJ_DTYPE_INT, null, false); - $this->initVar("megabytes", XOBJ_DTYPE_FLOAT, null, false); - $this->initVar("updated", XOBJ_DTYPE_INT, null, false); - $this->initVar("created", XOBJ_DTYPE_INT, null, false); - $this->initVar("checked", XOBJ_DTYPE_INT, null, false); - $this->initVar("errored", XOBJ_DTYPE_INT, null, false); - $this->initVar("emailed", XOBJ_DTYPE_INT, null, false); - $this->initVar("data", XOBJ_DTYPE_OTHER, null, false); + $this->initVar("id", XOBJ_DTYPE_INT, null, false); + $this->initVar("fieldid", XOBJ_DTYPE_INT, null, false); + $this->initVar("uid", XOBJ_DTYPE_INT, null, false); + $this->initVar("hash", XOBJ_DTYPE_TXTBOX, null, false, 16); + $this->initVar("field", XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar("type", XOBJ_DTYPE_ENUM, 'unknown', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'type')); + $this->initVar("storage", XOBJ_DTYPE_ENUM, 'files', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'storage')); + $this->initVar("blacklisted", XOBJ_DTYPE_ENUM, 'none', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'storage')); + $this->initVar("md5", XOBJ_DTYPE_TXTBOX, null, false, 32); + $this->initVar("url", XOBJ_DTYPE_TXTBOX, null, false, 255); + $this->initVar("width", XOBJ_DTYPE_INT, null, false); + $this->initVar("height", XOBJ_DTYPE_INT, null, false); + $this->initVar("bytes", XOBJ_DTYPE_INT, null, false); + $this->initVar("views", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_hourly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_daily", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_weekly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_biweekly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_monthly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_quarterly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("views_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("updates_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("errors_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("megabytes_yearly", XOBJ_DTYPE_FLOAT, null, false); + $this->initVar("start_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_hourly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_daily", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_weekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_biweekly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_monthly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_quarterly", XOBJ_DTYPE_INT, null, false); + $this->initVar("start_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("ended_yearly", XOBJ_DTYPE_INT, null, false); + $this->initVar("viewed", XOBJ_DTYPE_INT, null, false); + $this->initVar("updated", XOBJ_DTYPE_INT, null, false); + $this->initVar("created", XOBJ_DTYPE_INT, null, false); + $this->initVar("checked", XOBJ_DTYPE_INT, null, false); + $this->initVar("errored", XOBJ_DTYPE_INT, null, false); + $this->initVar("emailed", XOBJ_DTYPE_INT, null, false); + $this->initVar("data", XOBJ_DTYPE_OTHER, null, false); } /** @@ -123,6 +167,20 @@ } /** + * Checks for ending of a statistic time cursor + * + * @param unknown $case + */ + public function isStatistianEnding($case = '') + { + if (in_array($case, imagesEnumeratorValues('statistics.php', 'mode'))) + { + return (self::getVar("ended_$case") < time()); + } + return false; + } + + /** * Adds View(s) count to object * * @param number $number @@ -130,9 +188,9 @@ */ public function addViews($number = 1) { - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `views` = `views` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `views` = `views` + $number, `views_hourly` = `views_hourly` + $number, `views_daily` = `views_daily` + $number, `views_weekly` = `views_weekly` + $number, `views_biweekly` = `views_biweekly` + $number, `views_monthly` = `views_monthly` + $number, `views_quarterly` = `views_quarterly` + $number, `views_yearly` = `views_yearly` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); @$GLOBALS['xoopsDB']->queryF($sql); - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `views` = `views` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `field` = '" . self::getVar('field') . "'"; + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `views` = `views` + $number, `views_hourly` = `views_hourly` + $number, `views_daily` = `views_daily` + $number, `views_weekly` = `views_weekly` + $number, `views_biweekly` = `views_biweekly` + $number, `views_monthly` = `views_monthly` + $number, `views_quarterly` = `views_quarterly` + $number, `views_yearly` = `views_yearly` + $number, `viewed` = UNIX_TIMESTAMP() WHERE `field` = '" . self::getVar('field') . "'"; @$GLOBALS['xoopsDB']->queryF($sql); } @@ -146,9 +204,9 @@ public function addMegabytes($bytes = 0) { $megabytes = $bytes / 1024 / 1024; - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `megabytes` = `megabytes` + '$megabytes', `updated` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_images") . "` SET `megabytes` = `megabytes` + '$megabytes', `megabytes_hourly` = `megabytes_hourly` + '$megabytes', `megabytes_daily` = `megabytes_daily` + '$megabytes', `megabytes_weekly` = `megabytes_weekly` + '$megabytes', `megabytes_biweekly` = `megabytes_biweekly` + '$megabytes', `megabytes_monthly` = `megabytes_monthly` + '$megabytes', `megabytes_quarterly` = `megabytes_quarterly` + '$megabytes', `megabytes_yearly` = `megabytes_yearly` + '$megabytes', `updated` = UNIX_TIMESTAMP() WHERE `id` = " . self::getVar('id'); @$GLOBALS['xoopsDB']->queryF($sql); - $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `megabytes` = `megabytes` + '$megabytes' WHERE `field` = '" . self::getVar('field') . "'"; + $sql = "UPDATE `" . $GLOBALS['xoopsDB']->prefix("images_fields") . "` SET `megabytes` = `megabytes` + '$megabytes', `megabytes_hourly` = `megabytes_hourly` + '$megabytes', `megabytes_daily` = `megabytes_daily` + '$megabytes', `megabytes_weekly` = `megabytes_weekly` + '$megabytes', `megabytes_biweekly` = `megabytes_biweekly` + '$megabytes', `megabytes_monthly` = `megabytes_monthly` + '$megabytes', `megabytes_quarterly` = `megabytes_quarterly` + '$megabytes', `megabytes_yearly` = `megabytes_yearly` + '$megabytes' WHERE `field` = '" . self::getVar('field') . "'"; @$GLOBALS['xoopsDB']->queryF($sql); } @@ -686,6 +744,12 @@ class ImagesImagesHandler extends ImagesXoopsPersistableObjectHandler { + /** + * Variables that comprise of statistic indicies + * + * @var array + */ + var $_statistian_fields = array('views','updates','errors','megabytes'); /** * Constructor @@ -715,9 +779,10 @@ $field = $fieldsHandler->create(); $field->setVar('field', $object->getVar('field')); $field->setVar('typal', $object->getFieldTypal()); + $field->setVars(imagesStatisticalTiming(array())); if (!$field = $fieldsHandler->get($fieldsHandler->insert($field, true))) return false; - + $object->setVar('fieldid', $field->getVar('id')); if ($object->getVar('uid')==0 && is_object($GLOBALS['xoopsUser'])) $object->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); $object->setVar('created', time()); @@ -729,6 +794,7 @@ $crc = new xcp($data = $field->getVar('hash').$object->getVar('uid').$imagesConfigList['format'].microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); $object->setVar('hash', $crc->crc); } + $object->setVars(imagesStatisticalTiming(array())); $criteria = new CriteriaCompo(new Criteria('uid', $object->getVar('uid'))); $criteria->add(new Criteria('field', $object->getVar('field'))); if (!in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) @@ -748,7 +814,6 @@ } return $id; } else { - if (in_array($object->getVar('field'), $imagesConfigList['ascii_fields'])) { $crc = new xcp($data = $object->getVar('uid').'ascii'.microtime().$object->getVar('url'), mt_rand(0,255), mt_rand(5,14)); Added: XoopsModules/images/trunk/modules/images/class/index.html =================================================================== --- XoopsModules/images/trunk/modules/images/class/index.html (rev 0) +++ XoopsModules/images/trunk/modules/images/class/index.html 2017-08-31 04:47:34 UTC (rev 13291) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsModules/images/trunk/modules/images/class/index.html ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/images/trunk/modules/images/class/statistics.php =================================================================== --- XoopsModules/images/trunk/modules/images/class/statistics.php (rev 0) +++ XoopsModules/images/trunk/modules/images/class/statistics.php 2017-08-31 04:47:34 UTC (rev 13291) @@ -0,0 +1,603 @@ +<?php +/** + * Legal Consent is a module for obtain legal guardianship Images + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * 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. + * + * @copyright The XOOPS Project http://fonts2web.org.uk + * @license General Public License version 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) + * @author Simon Roberts (wishcraft) <wis...@us...> + * @subpackage Images + * @description Legal Consent is a module for obtain legal guardianship Images + * @version 1.0.1 + * @link http://internetfounder.wordpress.com + */ + +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { + return false; +} + +//* +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'objects.php'); + +/** + * Database Table for Statistics in Legal Consent Module + * + * For Table:- + * <code> + * CREATE TABLE `images_statistics` ( + `id` mediumint(32) NOT NULL AUTO_INCREMENT, + `mode` enum('hourly','daily','weekly','biweekly','monthly','quarterly','yearly') NOT NULL DEFAULT '', + `typal` enum('icons','logo','photo','avatar') NOT NULL DEFAULT '', + `type` enum('fields','images') NOT NULL DEFAULT '', + `typeid` mediumint(15) NOT NULL DEFAULT '0', + `hash` varchar(18) NOT NULL DEFAULT '', + `key` varchar(64) NOT NULL DEFAULT '', + `timezone` varchar(128) NOT NULL DEFAULT '', + `commence` int(13) NOT NULL DEFAULT '0', + `finished` int(13) NOT NULL DEFAULT '0', + `year` int(4) NOT NULL DEFAULT '0', + `month` int(2) NOT NULL DEFAULT '0', + `day` int(2) NOT NULL DEFAULT '0', + `week` int(2) NOT NULL DEFAULT '0', + `hour` int(2) NOT NULL DEFAULT '0', + `minute` int(2) NOT NULL DEFAULT '0', + `seconds` int(2) NOT NULL DEFAULT '0', + `segment-month` enum('0-3','3-6','6-9','9-12') NOT NULL DEFAULT '0-3', + `segment-hour` enum('0-3','3-6','6-9','9-12','12-15','15-18','18-21','21-24') NOT NULL DEFAULT '0-3', + `segment-minute` enum('0-15','15-30','30-45','45-60') NOT NULL DEFAULT '0-15', + `day-name` enum('Sun','Sat','Mon','Tue','Wed','Thu','Fri') NOT NULL DEFAULT 'Sun', + `stat` float(22,9) NOT NULL DEFAULT '0.000000000', + `sum_item_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_hourly` int(13) NOT NULL DEFAULT '0', + `sum_item_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_daily` int(13) NOT NULL DEFAULT '0', + `sum_item_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_weekly` int(13) NOT NULL DEFAULT '0', + `sum_item_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_biweekly` int(13) NOT NULL DEFAULT '0', + `sum_item_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_monthly` int(13) NOT NULL DEFAULT '0', + `sum_item_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_quarterly` int(13) NOT NULL DEFAULT '0', + `sum_item_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_item_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_item_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_item_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_item_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_item_yearly` int(13) NOT NULL DEFAULT '0', + `sum_key_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_hourly` int(13) NOT NULL DEFAULT '0', + `sum_key_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_daily` int(13) NOT NULL DEFAULT '0', + `sum_key_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_weekly` int(13) NOT NULL DEFAULT '0', + `sum_key_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_biweekly` int(13) NOT NULL DEFAULT '0', + `sum_key_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_monthly` int(13) NOT NULL DEFAULT '0', + `sum_key_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_quarterly` int(13) NOT NULL DEFAULT '0', + `sum_key_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_key_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_key_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_key_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_key_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_key_yearly` int(13) NOT NULL DEFAULT '0', + `sum_typal_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_hourly` int(13) NOT NULL DEFAULT '0', + `sum_typal_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_daily` int(13) NOT NULL DEFAULT '0', + `sum_typal_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_weekly` int(13) NOT NULL DEFAULT '0', + `sum_typal_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_biweekly` int(13) NOT NULL DEFAULT '0', + `sum_typal_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_monthly` int(13) NOT NULL DEFAULT '0', + `sum_typal_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_quarterly` int(13) NOT NULL DEFAULT '0', + `sum_typal_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_typal_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_typal_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_typal_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_typal_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_typal_yearly` int(13) NOT NULL DEFAULT '0', + `sum_type_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_hourly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_hourly` int(13) NOT NULL DEFAULT '0', + `sum_type_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_daily` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_daily` int(13) NOT NULL DEFAULT '0', + `sum_type_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_weekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_weekly` int(13) NOT NULL DEFAULT '0', + `sum_type_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_biweekly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_biweekly` int(13) NOT NULL DEFAULT '0', + `sum_type_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_monthly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_monthly` int(13) NOT NULL DEFAULT '0', + `sum_type_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_quarterly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_quarterly` int(13) NOT NULL DEFAULT '0', + `sum_type_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `max_type_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `min_type_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `adv_type_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `std_type_yearly` float(22,9) NOT NULL DEFAULT '0.000000000', + `end_type_yearly` int(13) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `SEARCH` (`key`,`year`,`month`,`day`,`week`,`hour`,`minute`,`segment-month`,`segment-hour`,`segment-minute`,`day-name`) USING BTREE KEY_BLOCK_SIZE=32, + KEY `PERIODICS` (`commence`,`finished`,`mode`,`typal`,`type`,`typeid`), + KEY `INDICATING` (`mode`,`typal`,`type`,`typeid`,`hash`(11),`key`(16)), +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + * </code> + * @author Simon Roberts (wis...@us...) + * @copyright copyright (c) 2015 labs.coop + */ +class ImagesStatistics extends ImagesXoopsObject +{ + + var $handler = 'ImagesStatisticsHandler'; + + function __construct($id = null) + { + + self::initVar('id', XOBJ_DTYPE_INT, null, false); + self::initVar("mode", XOBJ_DTYPE_ENUM, '', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'mode')); + self::initVar("typal", XOBJ_DTYPE_ENUM, '', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'typal')); + self::initVar("type", XOBJ_DTYPE_ENUM, '', false, false, false, imagesEnumeratorValues(basename(__FILE__), 'type')); + self::initVar('typeid', XOBJ_DTYPE_INT, null, false); + self::initVar('hash', XOBJ_DTYPE_TXTBOX, null, false, 18); + self::initVar('key', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('timezone', XOBJ_DTYPE_TXTBOX, null, false, 128); + self::initVar('commence', XOBJ_DTYPE_INT, null, false); + self::initVar('finished', XOBJ_DTYPE_INT, null, false); + self::initVar('year', XOBJ_DTYPE_INT, null, false); + self::initVar('month', XOBJ_DTYPE_INT, null, false); + self::initVar('day', XOBJ_DTYPE_INT, null, false); + self::initVar('week', XOBJ_DTYPE_INT, null, false); + self::initVar('hour', XOBJ_DTYPE_INT, null, false); + self::initVar('minute', XOBJ_DTYPE_INT, null, false); + self::initVar('seconds', XOBJ_DTYPE_INT, null, false); + self::initVar('segment-month', XOBJ_DTYPE_ENUM, 'Both', false, false, false, ImagesEnumeratorValues(basename(__FILE__), 'segment-month')); + self::initVar('segment-hour', XOBJ_DTYPE_ENUM, 'Both', false, false, false, ImagesEnumeratorValues(basename(__FILE__), 'segment-hour')); + self::initVar('segment-minute', XOBJ_DTYPE_ENUM, 'Both', false, false, false, ImagesEnumeratorValues(basename(__FILE__), 'segment-minute')); + self::initVar('day-name', XOBJ_DTYPE_ENUM, 'Both', false, false, false, ImagesEnumeratorValues(basename(__FILE__), 'day-name')); + self::initVar('stat', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('sum_item_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_hourly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_daily', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_weekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_biweekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_monthly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_quarterly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_item_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_item_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_item_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_item_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_item_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_item_yearly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_hourly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_daily', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_weekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_biweekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_quarterly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_quarterly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_key_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_key_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_key_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_key_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_key_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_key_yearly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_hourly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_daily', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_weekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_biweekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_monthly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_quarterly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_typal_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_typal_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_typal_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_typal_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_typal_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_typal_yearly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_hourly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_hourly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_daily', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_daily', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_weekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_weekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_biweekly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_biweekly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_monthly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_monthly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_quarterly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_quarterly', XOBJ_DTYPE_INT, null, false); + self::initVar('sum_type_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('max_type_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('min_type_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('adv_type_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('std_type_yearly', XOBJ_DTYPE_FLOAT, null, false); + self::initVar('end_type_yearly', XOBJ_DTYPE_INT, null, false); + + if (!empty($id) && !is_null($id)) + { + $handler = new $this->handler; + self::assignVars($handler->get($id)->getValues(array_keys($this->vars))); + } + + } + +} + + +/** + * Handler Class for Statistics + * @author Simon Roberts (wis...@us...) + * @copyright copyright (c) 2015 labs.coop + */ +class ImagesStatisticsHandler extends ImagesXoopsPersistableObjectHandler +{ + + /** + * + * @var array + */ + var $_periodics = array(); + + /** + * Table Name without prefix used + * + * @var string + */ + var $tbl = 'images_statistics'; + + /** + * Child Object Handling Class + * + * @var string + */ + var $child = 'ImagesStatistics'; + + /** + * Child Object Identity Key + * + * @var string + */ + var $identity = 'id'; + + /** + * Child Object Default Envaluing Costs + * + * @var string + */ + var $envalued = 'value'; + + function __construct(&$db) + { + self::$_periodics = array( 'hourly' => 3600, 'daily' => 3600 * 24, 'weekly' => 3600 * 24 * 7, 'biweekly' => 3600 * 24 * 7 * 2, + 'monthly' => 3600 * 24 * 7 * 4, 'quarterly' => 3600 * 24 * 7 * 4 * 4, 'yearly' => 3600 * 24 * 7 * 4 * 12 ); + if (!is_object($db)) + $db = $GLOBAL["xoopsDB"]; + parent::__construct($db, $this->tbl, $this->child, $this->identity, $this->envalued); + } + + /** + * Creates a ImagesStatistic Object for new + * + * {@inheritDoc} + * @see XoopsPersistableObjectHandler::create() + */ + function create($commence = 0) + { + if ($commence == 0) + $commence = time(); + $object = parent::create(true); + $object->setVar('timezone', date_default_timezone_get()); + $object->setVar('commence', $commence); + $object->setVar('year', date('Y', $object->getVar('commence'))); + $object->setVar('month', date('m', $object->getVar('commence'))); + $object->setVar('day', date('d', $object->getVar('commence'))); + $object->setVar('week', date('W', $object->getVar('commence'))); + $object->setVar('hour', date('H', $object->getVar('commence'))); + $object->setVar('minute', date('i', $object->getVar('commence'))); + $object->setVar('seconds', date('s', $object->getVar('commence'))); + $segments = ImagesEnumeratorValues(basename(__FILE__), 'segment-month'); + $object->setVar('segment-month', $segments[floor((date('m', $object->getVar('commence'))-1) / count($segments))]); + $segments = ImagesEnumeratorValues(basename(__FILE__), 'segment-hour'); + $object->setVar('segment-hour', $segments[floor((date('H', $object->getVar('commence'))-1) / count($segments))]); + $segments = ImagesEnumeratorValues(basename(__FILE__), 'segment-minute'); + $object->setVar('segment-minute', $segments[floor((date('i', $object->getVar('commence'))-1) / count($segments))]); + $object->setVar('day-name', date('D', $object->getVar('commence'))); + return $object; + } + + /** + * inserts a new record into the database + * + * {@inheritDoc} + * @see XoopsPersistableObjectHandler::insert() + */ + function insert(ImagesStatistics $object, $force = true) + { + if ($object->isNew()) + { + foreach(imagesEnumeratorValues(basename(__FILE__), 'mode') as $mode) + { + foreach(array('item','key','typal','type') as $state) + { + switch ($state) + { + case 'item': + $criteria = new CriteriaCompo(new Criteria('typal', $object->getVar('typal'))); + $criteria->add(new Criteria('mode', $object->getVar('mode'))); + $criteria->add(new Criteria('type', $object->getVar('type'))); + $criteria->add(new Criteria('commence', time() - self::$_periodics[$mode], "<=")); + $criteria->add(new Criteria('finished', time(), ">=")); + foreach(self::getStatisticArray($criteria) as $key => $value) + $object->setVar("$key_$state_$mode", $value); + break; + case 'key': + $criteria = new CriteriaCompo(new Criteria('key', $object->getVar('key'))); + $criteria->add(new Criteria('mode', $object->getVar('mode'))); + $criteria->add(new Criteria('type', $object->getVar('type'))); + $criteria->add(new Criteria('commence', time() - self::$_periodics[$mode], "<=")); + $criteria->add(new Criteria('finished', time(), ">=")); + foreach(self::getStatisticArray($criteria) as $key => $value) + $object->setVar("$key_$state_$mode", $value); + break; + case 'typal': + $criteria = new CriteriaCompo(new Criteria('typal', $object->getVar('typal'))); + $criteria->add(new Criteria('commence', time() - self::$_periodics[$mode], "<=")); + $criteria->add(new Criteria('finished', time(), ">=")); + foreach(self::getStatisticArray($criteria) as $key => $value) + $object->setVar("$key_$state_$mode", $value); + break; + case 'type': + $criteria = new CriteriaCompo(new Criteria('key', $object->getVar('key'))); + $criteria->add(new Criteria('commence', time() - self::$_periodics[$mode], "<=")); + $criteria->add(new Criteria('finished', t... [truncated message content] |