From: <wis...@us...> - 2015-12-07 13:42:47
|
Revision: 13178 http://sourceforge.net/p/xoops/svn/13178 Author: wishcraft Date: 2015-12-07 13:42:44 +0000 (Mon, 07 Dec 2015) Log Message: ----------- PingTrax Pre-alpha :: More done\!\!\! Modified Paths: -------------- XoopsModules/pingtrax/trunk/api/index.php XoopsModules/pingtrax/trunk/class/items.php XoopsModules/pingtrax/trunk/class/plugins.php XoopsModules/pingtrax/trunk/sql/mysql.sql Modified: XoopsModules/pingtrax/trunk/api/index.php =================================================================== --- XoopsModules/pingtrax/trunk/api/index.php 2015-12-07 13:02:52 UTC (rev 13177) +++ XoopsModules/pingtrax/trunk/api/index.php 2015-12-07 13:42:44 UTC (rev 13178) @@ -1 +1,50 @@ <?php + +require_once dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . "mainfile.php"; +require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . "class". DIRECTORY_SEPARATOR . "trackback.php"; + +$trackback = new PingtraxTrackback($GLOBALS['xoopsConfig']['sitename'], $GLOBALS['xoopsConfig']['sitename'], 'UTF-8'); + +if (!isset($_GET['referer'])) + die($trackback->recieve(false, "\$_GET['referer'] not specified and is required for trackback API!")); + +xoops_load("XoopsUserUtility"); +$moduleHandler = xoops_gethandler('module'); +$commentHandler = xoops_gethandler('comment'); +$itemsHandler = xoops_getmodulehandler('items', 'pingtrax'); +$item = $itemsHandler->getByReferer($_GET['referer']); + +if (!is_a($item, "PingtraxItems")) + die($trackback->recieve(false, $_GET['referer'] . " does not match any recorded item on the trackback API!")); + +$url = $_REQUEST["url"]; +if ($url) { + $excerpt = $_REQUEST["excerpt"]; + $name = ($_REQUEST["blog_name"]) ? $_REQUEST["blog_name"] : $url; + $subject = ($_REQUEST["title"]) ? $_REQUEST["title"] : $url; + $comment = "<strong> TrackBack from <a href=\"$url\">$name</a>:</strong><br />"; + $comment .= "<blockquote>$excerpt</blockquote>"; + + $pluginHandler = xoops_getmodulehandler('plugins', 'pingtrax'); + $remoteitem = $pluginHandler->getRemoteObject($item, $url, $name, $subject, $comment); + if (is_a($remoteitem, "PingtraxItems")) + { + $comment = $commentHandler->create(); + $comment->setVar('com_modid', $moduleHandler->getByDirname('pingtrax')->getVar('mid')); + $comment->setVar('com_title', $subject); + $comment->setVar('com_text', $comment); + $comment->setVar('com_created', time()); + $comment->setVar('com_url', $url); + $comment->setVar('com_ip', XoopsUserUtility::getIP(true)); + $comment->setVar('com_itemid', $item->getVar('id')); + $comment->setVar('dohtml', true); + $comment->setVar('dosmiley', true); + $comment->setVar('doxcode', true); + $comment->setVar('doimage', true); + $comment->setVar('dobr', true); + $commentHandler->insert($comment); + } +} else { + die($trackback->recieve(false, "Missing URL for trackback API!")); +} +die($trackback->recieve(true, "")); Modified: XoopsModules/pingtrax/trunk/class/items.php =================================================================== --- XoopsModules/pingtrax/trunk/class/items.php 2015-12-07 13:02:52 UTC (rev 13177) +++ XoopsModules/pingtrax/trunk/class/items.php 2015-12-07 13:42:44 UTC (rev 13178) @@ -30,6 +30,7 @@ * * CREATE TABLE `pingtrax_items` ( * `id` mediumint(20) NOT NULL AUTO_INCREMENT, + * `parent-id` mediumint(20) NOT NULL DEFAULT '0', * `referer` varchar(44) NOT NULL DEFAULT '', * `type` enum('local','remote','unknown') NOT NULL DEFAULT 'unknown', * `module-dirname` varchar(30) NOT NULL DEFAULT '', @@ -78,6 +79,7 @@ $this->XoopsObject(); $this->initVar('id', XOBJ_DTYPE_INT, null, false); + $this->initVar('parent-id', XOBJ_DTYPE_INT, null, false); $this->initVar('referer', XOBJ_DTYPE_OTHER, sha1(NULL), false, 44); $this->initVar('type', XOBJ_DTYPE_ENUM, 'unknown', true, false, false, false, array('local','remote','unknown')); $this->initVar('module-dirname', XOBJ_DTYPE_OTHER, '', false, 30); @@ -87,6 +89,7 @@ $this->initVar('module-get', XOBJ_DTYPE_ARRAY, array(), false); $this->initVar('item-author-uid', XOBJ_DTYPE_INT, 0, false); $this->initVar('item-author-name', XOBJ_DTYPE_TXTBOX, '', false, 64); + $this->initVar('item-category-id', XOBJ_DTYPE_INT, null, false); $this->initVar('item-title', XOBJ_DTYPE_TXTBOX, '', false, 180); $this->initVar('item-description', XOBJ_DTYPE_TXTBOX, '', false, 250); $this->initVar('item-protocol', XOBJ_DTYPE_ENUM, XOOPS_PROT, true, false, false, false, array('https://','http://')); Modified: XoopsModules/pingtrax/trunk/class/plugins.php =================================================================== --- XoopsModules/pingtrax/trunk/class/plugins.php 2015-12-07 13:02:52 UTC (rev 13177) +++ XoopsModules/pingtrax/trunk/class/plugins.php 2015-12-07 13:42:44 UTC (rev 13178) @@ -385,6 +385,55 @@ parent::__construct($db); } + + function getRemoteObject(PingtraxItems $item, $url = '', $name = '', $subject = '', $comment = '') + { + $ret = array(); + + if (file_exists($file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . ($dirname = $item->getVar('module-dirname')) . '.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['type'] = 'remote'; + $ret['module-dirname'] = 'pingtrax'; + $ret['module-class'] = 'items'; + $ret['module-item-id'] = $item->getVar('id'); + $ret['parent-id'] = $item->getVar('id'); + $ret['item-author-name'] = $name; + $ret['item-title'] = $subject; + $ret['item-description'] = $comment; + $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['feed-protocol'] = $this->_plugins[$dirname]->getFeedProtocol(); + $ret['feed-domain'] = $this->_plugins[$dirname]->getFeedDomain(); + $ret['feed-referer-uri'] = $this->_plugins[$dirname]->getFeedRefererURI(); + $ret['item-php-self'] = $this->_plugins[$dirname]->getItemPHPSelf(); + $ret['referer'] = $this->getReferer($ret); + } + if (!empty($ret)) + { + $itemsHandler = xoops_getmodulehandler('items', 'pingtrax'); + $item = $itemsHandler->create(true); + $item->setVars($ret); + $ret = $itemsHandler->get($itemsHandler->insert($item)); + } + return $ret; + } + function getItemObject() { $ret = array(); Modified: XoopsModules/pingtrax/trunk/sql/mysql.sql =================================================================== --- XoopsModules/pingtrax/trunk/sql/mysql.sql 2015-12-07 13:02:52 UTC (rev 13177) +++ XoopsModules/pingtrax/trunk/sql/mysql.sql 2015-12-07 13:42:44 UTC (rev 13178) @@ -1,6 +1,7 @@ CREATE TABLE `pingtrax_items` ( `id` mediumint(20) NOT NULL AUTO_INCREMENT, + `parent-id` mediumint(20) NOT NULL DEFAULT '0' `referer` varchar(44) NOT NULL DEFAULT '', `type` enum('local','remote','unknown') NOT NULL DEFAULT 'unknown', `module-dirname` varchar(30) NOT NULL DEFAULT '', @@ -10,7 +11,6 @@ `module-get` tinytext, `item-author-uid` int(13) NOT NULL DEFAULT '0', `item-author-name` varchar(64) NOT NULL DEFAULT '', - `item-id` int(20) NOT NULL DEFAULT '0', `item-category-id` int(20) NOT NULL DEFAULT '0', `item-title` varchar(180) NOT NULL DEFAULT '', `item-description` varchar(250) NOT NULL DEFAULT '', |