From: <wis...@us...> - 2015-12-01 13:25:03
|
Revision: 13171 http://sourceforge.net/p/xoops/svn/13171 Author: wishcraft Date: 2015-12-01 13:25:01 +0000 (Tue, 01 Dec 2015) Log Message: ----------- Pingtrax -- the Pinglist and Trackback Automated module -- Pre-alpha 1.01 -- Planning Modified Paths: -------------- XoopsModules/pingtrax/trunk/class/items.php XoopsModules/pingtrax/trunk/class/items_pings.php XoopsModules/pingtrax/trunk/class/items_sitemaps.php XoopsModules/pingtrax/trunk/class/pings.php XoopsModules/pingtrax/trunk/class/pings_sitemaps.php XoopsModules/pingtrax/trunk/class/plugins.php XoopsModules/pingtrax/trunk/class/sitemaps.php XoopsModules/pingtrax/trunk/sql/mysql.sql Added Paths: ----------- XoopsModules/pingtrax/trunk/include/category-id-names.txt XoopsModules/pingtrax/trunk/include/exclude-names.txt XoopsModules/pingtrax/trunk/include/item-id-names.txt XoopsModules/pingtrax/trunk/preloads/items.php Modified: XoopsModules/pingtrax/trunk/class/items.php =================================================================== --- XoopsModules/pingtrax/trunk/class/items.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/items.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxItems + * Class PingtraxItems * * @subpackage pingtrax * @@ -97,9 +97,9 @@ } /** - * Class PintraxItemsHandler + * Class PingtraxItemsHandler */ -class PintraxItemsHandler extends XoopsPersistableObjectHandler +class PingtraxItemsHandler extends XoopsPersistableObjectHandler { /** @@ -110,5 +110,37 @@ parent::__construct($db, "pingtrax_items", 'PingtraxItems', 'id', 'referer'); } + + function insert($object = NULL, $force = true) + { + if ($object->isNew()) + { + $object->setVar('created', time()); + } else { + $object->setVar('updated', time()); + } + switch ($object->getVar('user-session')) + { + default: + case 'unknown': + if (is_object($GLOBALS['xoopsUser'])) + { + if ($GLOBALS['xoopsUser']->isAdmin()) + $object->setVar('user-session', 'admin'); + } + case 'admin': + if (is_object($GLOBALS['xoopsUser'])) + { + if (!$GLOBALS['xoopsUser']->isAdmin()) + $object->setVar('user-session', 'user'); + } + case 'user': + if (!is_object($GLOBALS['xoopsUser'])) + $object->setVar('user-session', 'guest'); + case 'guest': + break; + } + return parent::insert($object, $force); + } } Modified: XoopsModules/pingtrax/trunk/class/items_pings.php =================================================================== --- XoopsModules/pingtrax/trunk/class/items_pings.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/items_pings.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxItems_pings + * Class PingtraxItems_pings * * @subpackage itemtrax * @@ -56,9 +56,9 @@ } /** - * Class PintraxItems_pingsHandler + * Class PingtraxItems_pingsHandler */ -class PintraxItems_pingsHandler extends XoopsPersistableObjectHandler +class PingtraxItems_pingsHandler extends XoopsPersistableObjectHandler { /** Modified: XoopsModules/pingtrax/trunk/class/items_sitemaps.php =================================================================== --- XoopsModules/pingtrax/trunk/class/items_sitemaps.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/items_sitemaps.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxItems_sitemaps + * Class PingtraxItems_sitemaps * * @subpackage itemtrax * @@ -56,9 +56,9 @@ } /** - * Class PintraxItems_sitemapsHandler + * Class PingtraxItems_sitemapsHandler */ -class PintraxItems_sitemapsHandler extends XoopsPersistableObjectHandler +class PingtraxItems_sitemapsHandler extends XoopsPersistableObjectHandler { /** Modified: XoopsModules/pingtrax/trunk/class/pings.php =================================================================== --- XoopsModules/pingtrax/trunk/class/pings.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/pings.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxPings + * Class PingtraxPings * * @subpackage pingtrax * @@ -66,7 +66,6 @@ $this->initVar('sleep-till', XOBJ_DTYPE_INT, 0, false); $this->initVar('success-time', XOBJ_DTYPE_INT, 0, false); $this->initVar('failure-time', XOBJ_DTYPE_INT, 0, false); - $this->initVar('written', XOBJ_DTYPE_INT, 0, false); $this->initVar('created', XOBJ_DTYPE_INT, 0, false); $this->initVar('updated', XOBJ_DTYPE_INT, 0, false); $this->initVar('offline', XOBJ_DTYPE_INT, 0, false); @@ -75,18 +74,48 @@ } /** - * Class PintraxPingsHandler + * Class PingtraxPingsHandler */ -class PintraxPingsHandler extends XoopsPersistableObjectHandler +class PingtraxPingsHandler extends XoopsPersistableObjectHandler { + /** + * var string URL of JSON Resource for Install + */ + var $_resource = "https://sourceforge.net/p/xoops/svn/HEAD/tree/XoopsModules/pingtrax/data/ping-resources.json?format=raw"; + /** * @param null|object $db */ function __construct(&$db) { parent::__construct($db, "pingtrax_pings", 'PingtraxPings', 'id', 'referer'); + + $criteria = new Criteria('id',0,"<>"); + if ($this->getCount($criteria)==0) + { + $data = json_decode(file_get_contents($this->_resource), true); + foreach($data as $referer => $values) + { + $obj = $this->create(true); + $obj->setVar('referer', $referer); + $obj->setVar('type', $values['type']); + $obj->setVar('uri', $values['uri']); + $this->insert($obj); + } + } } + + function insert($object = NULL, $force = true) + { + if ($object->isNew()) + { + $object->setVar('created', time()); + } else { + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } } Modified: XoopsModules/pingtrax/trunk/class/pings_sitemaps.php =================================================================== --- XoopsModules/pingtrax/trunk/class/pings_sitemaps.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/pings_sitemaps.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxPings_sitemaps + * Class PingtraxPings_sitemaps * * @subpackage pingtrax * @@ -56,9 +56,9 @@ } /** - * Class PintraxPings_sitemapsHandler + * Class PingtraxPings_sitemapsHandler */ -class PintraxPings_sitemapsHandler extends XoopsPersistableObjectHandler +class PingtraxPings_sitemapsHandler extends XoopsPersistableObjectHandler { /** Modified: XoopsModules/pingtrax/trunk/class/plugins.php =================================================================== --- XoopsModules/pingtrax/trunk/class/plugins.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/plugins.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -23,29 +23,235 @@ defined('XOOPS_ROOT_PATH') || die('XOOPS root path not defined'); /** - * Class PingtraxPluginsDefault + * Class PingtraxPlugins */ -class PingtraxPlugins +class PingtraxPlugins extends XoopsObject { - /** - * @param $args - - function eventCoreIncludeFunctionsRedirectheader($args) - { - $context = stream_context_create(array('http' => array( - 'method' => "POST", - 'header' => "Content-Type: text/xml\r\n", - 'content' => $xml - ))); - $file = @file_get_contents($post_to, false, $context); - if ($file === false) { echo '<p>Couldn\'t connect!</p>'; } - elseif ($file) { - echo '<p>The following response was returned:</p>'; - echo '<pre>'.htmlspecialchars($file).'</pre>'; - } else { - echo '<p>Empty response!</p>'; - } - } - */ - + + /** + * + */ + function __construct() + { + $this->XoopsObject(); + } + + /** + * + */ + function getModuleDirname() + { + if (is_a($GLOBALS['xoopsModule'], 'XoopsModule')) + { + return $GLOBALS['xoopsModule']->getVar('dirname'); + } + } + + /** + * + */ + function getModuleClass() + { + switch ($this->getModulePHPSelf()) + { + default: + + foreach(get_declared_classes() as $class) + { + if (substr(strtolower($class), 0, strlen($this->getModuleDirname()))==strtolower($this->getModuleDirname()) && (!strpos(strtolower($class), 'categor') && !strpos(strtolower($this->getModulePHPSelf()), 'categor'))) + { + if (is_a(new $class(), "XoopsPersistableObjectHandler")) + return $class; + } + } + + break; + } + } + + /** + * + */ + function getModuleItemID() + { + $id = 0; + switch ($this->getModulePHPSelf()) + { + default: + + $idnaming = explode(array("\n", "\n\r", "\r\n"), file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'item-id-names.txt')); + foreach($_GET as $key => $value) + { + if (!is_array($value)) + { + foreach($idnaming as $idname) + { + if (strpos($key, $idname) && is_numeric($_GET[$key])) + $id = $_GET[$key]; + elseif (is_numeric($_GET[$key]) && !in_array($key, explode(array("\n", "\n\r", "\r\n"), file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'exclude-names.txt')))) + $id = $_GET[$key]; + } + } + } + } + return $id; + } + + /** + * + */ + function getModulePHPSelf() + { + $parts = explode(DIRECTORY_SEPARATOR, $this->getItemPHPSelf()); + $found = false; + foreach($parts as $id => $value) + { + if ($found == false) + unset($parts[$id]); + if ($value == 'modules') + $found = true; + } + return implode(DIRECTORY_SEPARATOR, $parts); + } + + /** + * + */ + function getModuleGet() + { + return $_GET; + } + + + /** + * + */ + function getItemCategoryID() + { + $id = 0; + switch ($this->getModulePHPSelf()) + { + default: + + $idnaming = explode(array("\n", "\n\r", "\r\n"), file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'category-id-names.txt')); + foreach($_GET as $key => $value) + { + if (!is_array($value)) + { + foreach($idnaming as $idname) + { + if (strpos($key, $idname) && is_numeric($_GET[$key])) + $id = $_GET[$key]; + elseif ($id = 0 && is_numeric($_GET[$key]) && !in_array($key, explode(array("\n", "\n\r", "\r\n"), file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'exclude-names.txt')))) + $id = $_GET[$key]; + } + } + } + } + return $id; + } + + /** + * + */ + function getItemProtocol() + { + return strtolower(XOOPS_PROT); + } + + /** + * + */ + function getItemDomain() + { + return parse_url(strtolower(XOOPS_URL), PHP_URL_HOST); + } + + /** + * + */ + function getItemRefererURI() + { + if (parse_url(strtolower(XOOPS_URL), PHP_URL_PATH) == substr(strtolower($_SERVER["REQUEST_URI"]), 0, strlen(parse_url(strtolower(XOOPS_URL), PHP_URL_PATH)))) + return substr($_SERVER["REQUEST_URI"], strlen(parse_url(strtolower(XOOPS_URL), PHP_URL_PATH))-1); + return $_SERVER["REQUEST_URI"]; + } + + /** + * + */ + function getItemPHPSelf() + { + if (XOOPS_ROOT_PATH == substr(strtolower($_SERVER["REQUEST_URI"]), 0, strlen(XOOPS_ROOT_PATH))) + return substr($_SERVER["PHP_SELF"], strlen(XOOPS_ROOT_PATH)-1); + return $_SERVER["PHP_SELF"]; + } } + + +/** + * Class PingtraxPluginsHandler + */ +class PingtraxPluginsHandler extends XoopsPersistableObjectHandler +{ + + /** + * @var string + */ + var $_default = 'default'; + + /** + * @var array + */ + var $_plugins = array(); + + /** + * @param null|object $db + */ + function __construct(&$db) + { + parent::__construct($db); + } + + function getIntialItemArray() + { + $ret = array(); + if (is_a($GLOBALS['xoopsModule'], 'XoopsModule')) + { + if (file_exists($file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . ($dirname = $GLOBALS['xoopsModule']->getVar('dirname')) . '.php')) + { + require_once $file; + } elseif (file_exists($file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . ($dirname = $this->_default) . '.php')) + { + require_once $file; + } + } elseif (file_exists($file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . ($dirname = $this->_default) . '.php')) + { + require_once $file; + } + if (class_exists($class = "PingtraxPlugins".ucfirst(strtolower($dirname))) && empty($this->_plugins[$dirname])) + { + $this->_plugins[$dirname] = new $class(); + } + if (is_object($this->_plugins[$dirname])) + { + $ret['module-dirname'] = $this->_plugins[$dirname]->getModuleDirname(); + $ret['module-class'] = $this->_plugins[$dirname]->getModuleClass(); + $ret['module-item-id'] = $this->_plugins[$dirname]->getModuleItemID(); + $ret['module-php-self'] = $this->_plugins[$dirname]->getModulePHPSelf(); + $ret['module-get'] = $this->_plugins[$dirname]->getModuleGet(); + $ret['item-category-id'] = $this->_plugins[$dirname]->getItemCategoryID(); + $ret['item-protocol'] = $this->_plugins[$dirname]->getItemProtocol(); + $ret['item-domain'] = $this->_plugins[$dirname]->getItemDomain(); + $ret['item-referer-uri'] = $this->_plugins[$dirname]->getItemRefererURI(); + $ret['item-php-self'] = $this->_plugins[$dirname]->getItemPHPSelf(); + $ret['referer'] = $this->getReferer($ret); + } + return $ret; + } + + function getReferer($ret = array()) + { + return sha1($ret['item-php-self'] . $ret['item-referer-uri'] . $ret['module-dirname'] . $ret['module-class'] . $ret['item-category-id'] . $ret['module-item-id'] . $ret['module-php-self'] . json_encode($ret['module-get'], true) . $ret['item-protocol'] . $ret['item-domain']); + } +} Modified: XoopsModules/pingtrax/trunk/class/sitemaps.php =================================================================== --- XoopsModules/pingtrax/trunk/class/sitemaps.php 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/class/sitemaps.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,6 @@ <?php /** - * Pintrax Database Class Handler module + * Pingtrax Database Class Handler 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 @@ -22,7 +22,7 @@ /** - * Class PintraxSitemaps + * Class PingtraxSitemaps * * Database MySQL Table:- * @@ -81,9 +81,9 @@ } /** - * Class PintraxSitemapsHandler + * Class PingtraxSitemapsHandler */ -class PintraxSitemapsHandler extends XoopsPersistableObjectHandler +class PingtraxSitemapsHandler extends XoopsPersistableObjectHandler { /** @@ -94,5 +94,16 @@ parent::__construct($db, "pingtrax_sitemaps", 'PingtraxSitemaps', 'id', 'referer'); } + + function insert($object = NULL, $force = true) + { + if ($object->isNew()) + { + $object->setVar('created', time()); + } else { + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } } Added: XoopsModules/pingtrax/trunk/include/category-id-names.txt =================================================================== --- XoopsModules/pingtrax/trunk/include/category-id-names.txt (rev 0) +++ XoopsModules/pingtrax/trunk/include/category-id-names.txt 2015-12-01 13:25:01 UTC (rev 13171) @@ -0,0 +1,3 @@ +id +cat +category \ No newline at end of file Added: XoopsModules/pingtrax/trunk/include/exclude-names.txt =================================================================== --- XoopsModules/pingtrax/trunk/include/exclude-names.txt (rev 0) +++ XoopsModules/pingtrax/trunk/include/exclude-names.txt 2015-12-01 13:25:01 UTC (rev 13171) @@ -0,0 +1,3 @@ +start +num +weight \ No newline at end of file Added: XoopsModules/pingtrax/trunk/include/item-id-names.txt =================================================================== --- XoopsModules/pingtrax/trunk/include/item-id-names.txt (rev 0) +++ XoopsModules/pingtrax/trunk/include/item-id-names.txt 2015-12-01 13:25:01 UTC (rev 13171) @@ -0,0 +1,2 @@ +id +item \ No newline at end of file Added: XoopsModules/pingtrax/trunk/preloads/items.php =================================================================== --- XoopsModules/pingtrax/trunk/preloads/items.php (rev 0) +++ XoopsModules/pingtrax/trunk/preloads/items.php 2015-12-01 13:25:01 UTC (rev 13171) @@ -0,0 +1,41 @@ +<?php +/** + * PingTrax Preloads + * + * 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 Chronolabs Cooperative http://sourceforge.net/projects/chronolabs/ + * @license GNU GPL 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) + * @author Simon Antony Roberts <wis...@us...> + * @see http://sourceforge.net/projects/xoops/ + * @see http://sourceforge.net/projects/chronolabs/ + * @see http://sourceforge.net/projects/chronolabsapi/ + * @see http://labs.coop + * @version 1.0.1 + * @since 1.0.1 + */ + +defined('XOOPS_ROOT_PATH') || die('XOOPS root path not defined'); + +/** + * Class PingtraxPingPreload + */ +class PingtraxItemsPreload extends XoopsPreloadItem +{ + + /** + * @param $args + */ + function eventCoreIncludeCommonEnd($args) + { + global $moduleitem; + $pluginHandler = xoops_getmodulehandler('plugins', 'pingtrax'); + $moduleitem = $pluginHandler->getIntialItemArray(); + } + +} Modified: XoopsModules/pingtrax/trunk/sql/mysql.sql =================================================================== --- XoopsModules/pingtrax/trunk/sql/mysql.sql 2015-12-01 11:48:27 UTC (rev 13170) +++ XoopsModules/pingtrax/trunk/sql/mysql.sql 2015-12-01 13:25:01 UTC (rev 13171) @@ -1,6 +1,4 @@ -DROP TABLE IF EXISTS `pingtrax_items`; - CREATE TABLE `pingtrax_items` ( `id` mediumint(20) NOT NULL AUTO_INCREMENT, `referer` varchar(44) NOT NULL DEFAULT '', @@ -34,8 +32,6 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=16; -DROP TABLE IF EXISTS `pingtrax_items_pings`; - CREATE TABLE `pingtrax_items_pings` ( `id` mediumint(32) NOT NULL AUTO_INCREMENT, `ping-referer` varchar(44) NOT NULL DEFAULT '', @@ -46,8 +42,6 @@ KEY `CHRONOLOGISTICS` (`ping-referer`,`item-referer`,`when`) USING BTREE KEY_BLOCK_SIZE=64 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=8; -DROP TABLE IF EXISTS `pingtrax_items_sitemaps`; - CREATE TABLE `pingtrax_items_sitemaps` ( `id` mediumint(32) NOT NULL AUTO_INCREMENT, `map-referer` varchar(44) NOT NULL DEFAULT '', @@ -58,8 +52,6 @@ KEY `CHRONOLOGISTICS` (`map-referer`,`item-referer`,`when`) USING BTREE KEY_BLOCK_SIZE=64 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=8; -DROP TABLE IF EXISTS `pingtrax_pings`; - CREATE TABLE `pingtrax_pings` ( `id` int(14) NOT NULL AUTO_INCREMENT, `referer` varchar(44) NOT NULL DEFAULT '', @@ -79,8 +71,6 @@ KEY `CHRONOLOGISTICS` (`id`,`referer`,`created`,`updated`,`offlined`,`failure-time`,`success-time`,`sleep-till`) USING BTREE KEY_BLOCK_SIZE=128 ) ENGINE=InnoDB AUTO_INCREMENT=150 DEFAULT CHARSET=utf8 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=16; -DROP TABLE IF EXISTS `pingtrax_pings_sitemaps`; - CREATE TABLE `pingtrax_pings_sitemaps` ( `id` mediumint(32) NOT NULL AUTO_INCREMENT, `map-referer` varchar(44) NOT NULL DEFAULT '', @@ -91,8 +81,6 @@ KEY `CHRONOLOGISTICS` (`map-referer`,`ping-referer`,`when`) USING BTREE KEY_BLOCK_SIZE=64 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=8; -DROP TABLE IF EXISTS `pingtrax_sitemaps`; - CREATE TABLE `pingtrax_sitemaps` ( `id` int(10) NOT NULL AUTO_INCREMENT, `referer` varchar(44) NOT NULL DEFAULT '', |