From: <wis...@us...> - 2012-01-04 12:55:21
|
Revision: 8635 http://xoops.svn.sourceforge.net/xoops/?rev=8635&view=rev Author: wishcraft Date: 2012-01-04 12:55:10 +0000 (Wed, 04 Jan 2012) Log Message: ----------- X-REST 1.50 - Rest API for XOOPS 2.x - JSON, Serialisation, XML output, with reserved words ?restplugin= & &outputmode= - use http://yoursite.com/module/xrest/plugin/?var1=example&var2=example2 to access API Modified Paths: -------------- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/admin_header.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/index.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/permissions.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/common.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/functions.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/server.php XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/xoops_version.php Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/admin_header.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/admin_header.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/admin_header.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -17,7 +17,7 @@ include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; if (is_object($xoopsUser)) { - $xoopsModule = XoopsModule::getByDirname("xjson"); + $xoopsModule = XoopsModule::getByDirname("xrest"); if (!$xoopsUser->isAdmin($xoopsModule->mid())) { redirect_header(XOOPS_URL . "/", 3, _NOPERM); exit(); Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/index.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/index.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/index.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -26,7 +26,7 @@ if (!$tbl_id) $tbl_id=1; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." where view = '0'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." where view = '0'"; $ret = $xoopsDB->queryF($sql); $form_sel = new XoopsThemeForm(_XC_SELECTTABLE, "seltable", $_SERVER['PHP_SELF'] .""); @@ -194,11 +194,11 @@ $tt++; switch ($f){ case "new": - $sql = "INSERT INTO ".$xoopsDB->prefix('json_fields')." (tbl_id, fieldname, allowpost, allowretrieve, allowupdate, visible, `key`, `string`, `int`, `float`, `text`, `other`, `crc`) VALUES ('$tbl_id','".addslashes($fieldname[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','".intval($key[$tt])."','".intval($string[$tt])."','".intval($int[$tt])."','".intval($float[$tt])."','".intval($text[$tt])."','".intval($other[$tt])."','".intval($crc[$tt])."')"; + $sql = "INSERT INTO ".$xoopsDB->prefix('rest_fields')." (tbl_id, fieldname, allowpost, allowretrieve, allowupdate, visible, `key`, `string`, `int`, `float`, `text`, `other`, `crc`) VALUES ('$tbl_id','".addslashes($fieldname[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','".intval($key[$tt])."','".intval($string[$tt])."','".intval($int[$tt])."','".intval($float[$tt])."','".intval($text[$tt])."','".intval($other[$tt])."','".intval($crc[$tt])."')"; $ty=$xoopsDB->queryF($sql); break; default: - $sql = "UPDATE ".$xoopsDB->prefix('json_fields')." SET allowpost ='".intval($post[$tt])."', allowupdate ='".intval($update[$tt])."',allowretrieve = '".intval($retrieve[$tt])."', visible='".intval($visible[$tt])."',`key` ='".intval($key[$tt])."', `string` = '".intval($string[$tt])."', `int`='".intval($int[$tt])."',`float` ='".intval($float[$tt])."', `text` = '".intval($text[$tt])."', `other`='".intval($other[$tt])."', crc = '".intval($crc[$tt])."' WHERE fld_id = ".$id[$tt]. " and tbl_id = ".$tbl_id; + $sql = "UPDATE ".$xoopsDB->prefix('rest_fields')." SET allowpost ='".intval($post[$tt])."', allowupdate ='".intval($update[$tt])."',allowretrieve = '".intval($retrieve[$tt])."', visible='".intval($visible[$tt])."',`key` ='".intval($key[$tt])."', `string` = '".intval($string[$tt])."', `int`='".intval($int[$tt])."',`float` ='".intval($float[$tt])."', `text` = '".intval($text[$tt])."', `other`='".intval($other[$tt])."', crc = '".intval($crc[$tt])."' WHERE fld_id = ".$id[$tt]. " and tbl_id = ".$tbl_id; $ty=$xoopsDB->queryF($sql); } @@ -213,11 +213,11 @@ $tt++; switch ($f){ case "new": - $sql = "INSERT INTO ".$xoopsDB->prefix('json_tables')." (tablename, allowpost, allowretrieve, allowupdate, visible, view) VALUES ('".addslashes($tablename[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','0')"; + $sql = "INSERT INTO ".$xoopsDB->prefix('rest_tables')." (tablename, allowpost, allowretrieve, allowupdate, visible, view) VALUES ('".addslashes($tablename[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','0')"; $ty=$xoopsDB->queryF($sql); break; default: - $sql = "UPDATE ".$xoopsDB->prefix('json_tables')." SET allowpost ='".intval($post[$tt])."', allowretrieve = '".intval($retrieve[$tt])."', allowupdate = '".intval($update[$tt])."', visible='".intval($visible[$tt])."' WHERE tbl_id = ".$id[$tt]; + $sql = "UPDATE ".$xoopsDB->prefix('rest_tables')." SET allowpost ='".intval($post[$tt])."', allowretrieve = '".intval($retrieve[$tt])."', allowupdate = '".intval($update[$tt])."', visible='".intval($visible[$tt])."' WHERE tbl_id = ".$id[$tt]; $ty=$xoopsDB->queryF($sql); } @@ -231,11 +231,11 @@ $tt++; switch ($f){ case "new": - $sql = "INSERT INTO ".$xoopsDB->prefix('json_tables')." (tablename, allowpost, allowretrieve, allowupdate, visible, view) VALUES ('".addslashes($tablename[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','1')"; + $sql = "INSERT INTO ".$xoopsDB->prefix('rest_tables')." (tablename, allowpost, allowretrieve, allowupdate, visible, view) VALUES ('".addslashes($tablename[$tt])."','".intval($post[$tt])."','".intval($retrieve[$tt])."','".intval($update[$tt])."','".intval($visible[$tt])."','1')"; $ty=$xoopsDB->queryF($sql); break; default: - $sql = "UPDATE ".$xoopsDB->prefix('json_tables')." SET allowpost ='".intval($post[$tt])."', allowretrieve = '".intval($retrieve[$tt])."', allowupdate = '".intval($update[$tt])."', visible='".intval($visible[$tt])."' WHERE tbl_id = ".$id[$tt]; + $sql = "UPDATE ".$xoopsDB->prefix('rest_tables')." SET allowpost ='".intval($post[$tt])."', allowretrieve = '".intval($retrieve[$tt])."', allowupdate = '".intval($update[$tt])."', visible='".intval($visible[$tt])."' WHERE tbl_id = ".$id[$tt]; $ty=$xoopsDB->queryF($sql); } @@ -312,11 +312,11 @@ $tt++; switch ($f){ case "new": - $sql = "INSERT INTO ".$xoopsDB->prefix('json_plugins')." (plugin_name, plugin_file, active) VALUES ('".addslashes($functionname[$tt])."','".addslashes($filename[$tt])."','".intval($active[$tt])."')"; + $sql = "INSERT INTO ".$xoopsDB->prefix('rest_plugins')." (plugin_name, plugin_file, active) VALUES ('".addslashes($functionname[$tt])."','".addslashes($filename[$tt])."','".intval($active[$tt])."')"; $ty=$xoopsDB->queryF($sql); break; default: - $sql = "UPDATE ".$xoopsDB->prefix('json_plugins')." SET active ='".intval($active[$tt])."' WHERE plugin_id = ".$id[$tt]; + $sql = "UPDATE ".$xoopsDB->prefix('rest_plugins')." SET active ='".intval($active[$tt])."' WHERE plugin_id = ".$id[$tt]; $ty=$xoopsDB->queryF($sql); } @@ -332,7 +332,7 @@ $FunctionDefine = array(); foreach($funct->GetServerExtensions() as $extension){ - $phpcode= file_get_contents(XOOPS_ROOT_PATH.'/modules/xjson/plugins/'.$extension); + $phpcode= file_get_contents(XOOPS_ROOT_PATH.'/modules/xrest/plugins/'.$extension); ob_start(); $r=eval("?>".$phpcode."<?php "); @@ -476,7 +476,7 @@ function get_tableconfig($raw_tablename){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." WHERE tablename = '".strip_prefix($raw_tablename)."'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." WHERE tablename = '".strip_prefix($raw_tablename)."'"; $ret = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($ret)){ return $xoopsDB->fetchArray($ret); @@ -486,7 +486,7 @@ } function get_functionconfig($plugin_filename){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_plugins')." WHERE plugin_file = '".addslashes($plugin_filename)."'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_plugins')." WHERE plugin_file = '".addslashes($plugin_filename)."'"; $ret = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($ret)){ return $xoopsDB->fetchArray($ret); @@ -497,7 +497,7 @@ function get_fieldconfig($raw_fieldname, $tbl_id){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_fields')." WHERE fieldname = '$raw_fieldname' and tbl_id = $tbl_id"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_fields')." WHERE fieldname = '$raw_fieldname' and tbl_id = $tbl_id"; $ret = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($ret)){ return $xoopsDB->fetchArray($ret); @@ -507,7 +507,7 @@ } function get_tableid($tablename){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." WHERE tablename = '$tablename'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." WHERE tablename = '$tablename'"; $ret = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($ret); return $row['tbl_id']; @@ -515,7 +515,7 @@ function get_tablename($tableid){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." WHERE tbl_id = '$tableid'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." WHERE tbl_id = '$tableid'"; $ret = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($ret); return $row['tablename']; Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/permissions.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/permissions.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/admin/permissions.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -19,7 +19,7 @@ global $xoopsDB, $xoopsModule; $module_handler = xoops_gethandler('module'); - $xoModule = $module_handler->getByDirname('xjson'); + $xoModule = $module_handler->getByDirname('xrest'); xoops_cp_header(); adminmenu(5); @@ -27,7 +27,7 @@ $item_list_view = array(); $block_view = array(); - $result_view = $xoopsDB->query("SELECT plugin_id, plugin_name FROM " . $xoopsDB->prefix("json_plugins") . " "); + $result_view = $xoopsDB->query("SELECT plugin_id, plugin_name FROM " . $xoopsDB->prefix("rest_plugins") . " "); if ($xoopsDB->getRowsNum($result_view)) { while ($myrow_view = $xoopsDB->fetcharray($result_view)) { $item_list_view['cid'] = $myrow_view['plugin_id']; Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/common.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/common.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/common.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -24,14 +24,14 @@ function validate($tbl_id, $data, $function){ global $xoopsDB; - $sql = "select * from ".$xoopsDB->prefix('json_tables'). " WHERE tablename = '".get_tablename($tbl_id)."' and $function = 1"; + $sql = "select * from ".$xoopsDB->prefix('rest_tables'). " WHERE tablename = '".get_tablename($tbl_id)."' and $function = 1"; $ret = $xoopsDB->query($sql); $pass=true; if (!$xoopsDB->getRowsNum($ret)) { $pass=false; } else { foreach($data as $row){ - $sql = "select * from ".$xoopsDB->prefix('json_fields'). " WHERE tbl_id = '$tbl_id' and $function = 1 and fieldname = '".$row['field']."'"; + $sql = "select * from ".$xoopsDB->prefix('rest_fields'). " WHERE tbl_id = '$tbl_id' and $function = 1 and fieldname = '".$row['field']."'"; $ret = $xoopsDB->query($sql); if (!$xoopsDB->getRowsNum($ret)&&!is_fieldkey($row['field'],$tbl_id)) { $pass=false; @@ -45,13 +45,13 @@ function checkright($function_file, $username, $password){ $uid = user_uid($username,$password); $module_handler = xoops_gethandler('module'); - $xoModule = $module_handler->getByDirname('xjson'); + $xoModule = $module_handler->getByDirname('xrest'); if ($uid <> 0){ global $xoopsDB, $xoopsModule; $rUser = new XoopsUser($uid); $gperm_handler =& xoops_gethandler('groupperm'); $groups = is_object($rUser) ? $rUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); - $sql = "select plugin_id from ".$xoopsDB->prefix('json_plugins')." where plugin_file = '".addslashes($function_file)."'"; + $sql = "select plugin_id from ".$xoopsDB->prefix('rest_plugins')." where plugin_file = '".addslashes($function_file)."'"; $ret = $xoopsDB->queryF($sql); $row = $xoopsDB->fetchArray($ret); $item_id = $row['plugin_id']; @@ -71,7 +71,7 @@ global $xoopsDB, $xoopsModule; $gperm_handler =& xoops_gethandler('groupperm'); $groups = array(XOOPS_GROUP_ANONYMOUS); - $sql = "select plugin_id from ".$xoopsDB->prefix('json_plugins')." where plugin_file = '".addslashes($function_file)."'"; + $sql = "select plugin_id from ".$xoopsDB->prefix('rest_plugins')." where plugin_file = '".addslashes($function_file)."'"; $ret = $xoopsDB->queryF($sql); $row = $xoopsDB->fetchArray($ret); $item_id = $row['plugin_id']; @@ -82,7 +82,7 @@ function get_tableid($tablename){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." WHERE tablename = '$tablename'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." WHERE tablename = '$tablename'"; $ret = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($ret); return $row['tbl_id']; @@ -90,7 +90,7 @@ function get_tablename($tableid){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_tables')." WHERE tbl_id = '$tableid'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_tables')." WHERE tbl_id = '$tableid'"; $ret = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($ret); return $row['tablename']; @@ -98,7 +98,7 @@ function get_fieldname($fld_id, $tbl_id){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_fields')." WHERE tbl_id = '$tbl_id' and fld_id = '$fld_id'"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_fields')." WHERE tbl_id = '$tbl_id' and fld_id = '$fld_id'"; $ret = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($ret); return $row['fieldname']; @@ -107,7 +107,7 @@ function is_fieldkey($fieldname, $tbl_id){ global $xoopsDB; - $sql = "SELECT * FROM ".$xoopsDB->prefix('json_fields')." WHERE tbl_id = '$tbl_id' and fieldname = '$fieldname' and `key` = 1"; + $sql = "SELECT * FROM ".$xoopsDB->prefix('rest_fields')." WHERE tbl_id = '$tbl_id' and fieldname = '$fieldname' and `key` = 1"; //echo $sql."\n"; $ret = $xoopsDB->query($sql); if (!$xoopsDB->getRowsNum($ret)){ Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/functions.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/functions.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/functions.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -73,7 +73,7 @@ /* Nice buttons styles */ global $xoopsConfig,$xoopsModule; $module_handler =& xoops_gethandler('module'); - $xoModule = $module_handler->getByDirname('xjson'); + $xoModule = $module_handler->getByDirname('xrest'); $dirname=$xoModule->getVar('dirname'); echo " <style type='text/css'> Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/server.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/server.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/include/server.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -134,11 +134,16 @@ } } } -$mode = (isset($_REQUEST['mode'])?(string)$_REQUEST['mode']:'json'); +$mode = (isset($_REQUEST['outputmode'])?(string)$_REQUEST['outputmode']:'json'); switch ($mode) { default: case 'json': echo json_encode($ttlresult); + case 'serial': + echo serialize($ttlresult); + case 'xml': + echo xrest_toXml($ttlresult, strtolower($_REQUEST['xrestplugin'])); + } exit(0); ?> \ No newline at end of file Modified: XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/xoops_version.php =================================================================== --- XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/xoops_version.php 2012-01-04 12:46:39 UTC (rev 8634) +++ XoopsModules/xrest/releases/1.50/htdocs/modules/xrest/xoops_version.php 2012-01-04 12:55:10 UTC (rev 8635) @@ -27,12 +27,12 @@ $modversion['name'] = 'X-REST API Server'; $modversion['version'] = 1.50; -$modversion['releasedate'] = "Wednesday: 4 January 2012"; +$modversion['releasedate'] = "Friday: 18 Feburary 2011"; $modversion['status'] = "Mature"; $modversion['author'] = "Chronolabs Australia"; $modversion['credits'] = "Simon Roberts"; $modversion['teammembers'] = "Wishcraft"; -$modversion['license'] = "GPL2.0"; +$modversion['license'] = "GPL"; $modversion['official'] = 1; $modversion['description'] = 'REST API Service to exchange JSON, Serialised or XML Packages with external server.'; $modversion['help'] = ""; @@ -43,15 +43,15 @@ $modversion['sqlfile']['mysql'] = "sql/mysql.sql"; $modversion['author_realname'] = "Simon Roberts"; -$modversion['author_website_url'] = "http://www.chronolabs.org.au"; +$modversion['author_website_url'] = "http://www.chronolabs.coop"; $modversion['author_website_name'] = "Chronolabs International"; -$modversion['author_email'] = "si...@ch..."; +$modversion['author_email'] = "si...@ch..."; $modversion['demo_site_url'] = ""; $modversion['demo_site_name'] = ""; -$modversion['support_site_url'] = "http://www.chronolabs.org.au/forums/x-rest/0,10,0,0,100,0,DESC,0"; +$modversion['support_site_url'] = "http://www.chronolabs.coop/forums/x-rest/0,10,0,0,100,0,DESC,0"; $modversion['support_site_name'] = "x-rest"; -$modversion['submit_bug'] = "http://www.chronolabs.org.au/forums/x-rest/0,10,0,0,100,0,DESC,0"; -$modversion['submit_feature'] = "http://www.chronolabs.org.au/forums/x-rest/0,10,0,0,100,0,DESC,0"; +$modversion['submit_bug'] = "http://www.chronolabs.coop/forums/x-rest/0,10,0,0,100,0,DESC,0"; +$modversion['submit_feature'] = "http://www.chronolabs.coop/forums/x-rest/0,10,0,0,100,0,DESC,0"; $modversion['usenet_group'] = "sci.chronolabs"; $modversion['maillist_announcements'] = ""; $modversion['maillist_bugs'] = ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |