From: <chr...@us...> - 2018-04-29 13:13:13
|
Revision: 13355 http://sourceforge.net/p/xoops/svn/13355 Author: chronolabscoop Date: 2018-04-29 13:12:22 +0000 (Sun, 29 Apr 2018) Log Message: ----------- myip.xoops.org ~ new IP returning REST API Added Paths: ----------- *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiformloader.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilists.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiload.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilocal.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apisecurity.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/apc.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/apicache.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/file.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/memcache.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/model.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/cache/xcache.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/database.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/databasefactory.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/mysqldatabase.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/mysqlidatabase.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/database/sqlutility.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/file/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/file/apifile.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/file/file.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/file/folder.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/file/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger/apilogger.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger/render.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/logger_render.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/mimetypes.inc.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/module.textsanitizer.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/myip.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/preload.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/userutility.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/xcp.base.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/xcp.class.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/xcp.enumerator.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/xcp/xcp.leaver.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/include/common.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/include/functions.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/include/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/include/version.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/LICENSE *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/bootstrap.css *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/bootstrap.min.css *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/reset.css *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/css/style.css *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/glyphicons-halflings-regular.eot *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/glyphicons-halflings-regular.svg *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/glyphicons-halflings-regular.ttf *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/glyphicons-halflings-regular.woff *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/fonts/glyphicons-halflings-regular.woff2 *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/img/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/img/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/img/logo_small.png *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/img/wizard_bg.png *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/bootstrap.js *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/bootstrap.min.js *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/jquery.js *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/xo-installer.js *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/zxcvbn.js *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/assets/js/zxcvbn.js.map *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/class/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/class/dbmanager.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/class/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/class/installwizard.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/class/pathcontroller.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/cleanup.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/common.inc.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/config.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/createconfigform.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/dbconfig.dist.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/functions.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/install_tpl.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/license.dist.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/mainfile.dist.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/makedata.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/page.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/include/servers.diz *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/index.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/json.createdatabase.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/finish.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/install.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/install2.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/mysql.lang.data.sql *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/style.css *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/support.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/support.png *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/english/welcome.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/language/index.html *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_configsave.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_dbconnection.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_dbsettings.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_end.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_langselect.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_modcheck.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_pathsettings.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_siteinit.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_start.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_tablescreate.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/page_tablesfill.php *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/sql/ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/sql/mysql.history.sql *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/install/sql/mysql.structure.sql Added: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiformloader.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiformloader.php (rev 0) +++ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiformloader.php 2018-04-29 13:12:22 UTC (rev 13355) @@ -0,0 +1,61 @@ +<?php +/** + * My IPv4 or IPv6 REST Services API + * + * 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://syd.au.snails.email + * @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/) + * @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html) + * @package myip-api + * @since 1.0.1 + * @author Dr. Simon Antony Roberts <simon@snails.email> + * @version 1.0.3 + * @description A REST Services API that returns either or both or all IPv4, IPv6 addresses of a caller! + * @link http://internetfounder.wordpress.com + * @link https://github.com/Chronolabs-Cooperative/MyIP-API-PHP + * @link https://sourceforge.net/p/chronolabs-cooperative + * @link https://facebook.com/ChronolabsCoop + * @link https://twitter.com/ChronolabsCoop + * + */ + + +api_load('APIForm'); +api_load('APIThemeForm'); +api_load('APISimpleForm'); +api_load('APIFormElement'); +api_load('APIFormElementTray'); +api_load('APIFormLabel'); +api_load('APIFormCheckBox'); +api_load('APIFormPassword'); +api_load('APIFormButton'); +api_load('APIFormButtonTray'); // To be cleaned +api_load('APIFormHidden'); +api_load('APIFormFile'); +api_load('APIFormRadio'); +api_load('APIFormRadioYN'); +api_load('APIFormSelect'); +api_load('APIFormSelectGroup'); +api_load('APIFormSelectCheckGroup'); // To be cleaned +api_load('APIFormSelectUser'); +api_load('APIFormSelectTheme'); +api_load('APIFormSelectMatchOption'); +api_load('APIFormSelectCountry'); +api_load('APIFormSelectTimeZone'); +api_load('APIFormSelectLang'); +api_load('APIFormSelectEditor'); +api_load('APIFormText'); +api_load('APIFormTextArea'); +api_load('APIFormTextDateSelect'); +api_load('APIFormDhtmlTextArea'); +api_load('APIFormDateTime'); +api_load('APIFormHiddenToken'); +api_load('APIFormColorPicker'); +api_load('APIFormCaptcha'); +api_load('APIFormEditor'); Property changes on: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiformloader.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilists.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilists.php (rev 0) +++ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilists.php 2018-04-29 13:12:22 UTC (rev 13355) @@ -0,0 +1,645 @@ +<?php +/** + * My IPv4 or IPv6 REST Services API + * + * 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://syd.au.snails.email + * @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/) + * @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html) + * @package myip-api + * @since 1.0.1 + * @author Dr. Simon Antony Roberts <simon@snails.email> + * @version 1.0.3 + * @description A REST Services API that returns either or both or all IPv4, IPv6 addresses of a caller! + * @link http://internetfounder.wordpress.com + * @link https://github.com/Chronolabs-Cooperative/MyIP-API-PHP + * @link https://sourceforge.net/p/chronolabs-cooperative + * @link https://facebook.com/ChronolabsCoop + * @link https://twitter.com/ChronolabsCoop + * + */ + + +defined('API_ROOT_PATH') || exit('Restricted access'); + +if (!defined('API_LISTS_INCLUDED')) { + define('API_LISTS_INCLUDED', 1); + + /** + * APILists + * + * @author John Neill <cat...@ap...> + * @copyright (c) 2000-2016 API Project (www.api.org) + * @package kernel + * @subpackage form + * @access public + */ + class APILists + { + /** + * @return array + */ + public static function getTimeZoneList() + { + api_loadLanguage('timezone'); + + $time_zone_list = array( + '-12' => _TZ_GMTM12, + '-11' => _TZ_GMTM11, + '-10' => _TZ_GMTM10, + '-9' => _TZ_GMTM9, + '-8' => _TZ_GMTM8, + '-7' => _TZ_GMTM7, + '-6' => _TZ_GMTM6, + '-5' => _TZ_GMTM5, + '-4' => _TZ_GMTM4, + '-3.5' => _TZ_GMTM35, + '-3' => _TZ_GMTM3, + '-2' => _TZ_GMTM2, + '-1' => _TZ_GMTM1, + '0' => _TZ_GMT0, + '1' => _TZ_GMTP1, + '2' => _TZ_GMTP2, + '3' => _TZ_GMTP3, + '3.5' => _TZ_GMTP35, + '4' => _TZ_GMTP4, + '4.5' => _TZ_GMTP45, + '5' => _TZ_GMTP5, + '5.5' => _TZ_GMTP55, + '6' => _TZ_GMTP6, + '7' => _TZ_GMTP7, + '8' => _TZ_GMTP8, + '9' => _TZ_GMTP9, + '9.5' => _TZ_GMTP95, + '10' => _TZ_GMTP10, + '11' => _TZ_GMTP11, + '12' => _TZ_GMTP12); + + return $time_zone_list; + } + + /** + * gets list of themes folder from themes directory + */ + public static function getThemesList() + { + return APILists::getDirListAsArray(API_THEME_PATH . '/'); + } + + /** + * gets a list of module folders from the modules directory + */ + public static function getModulesList() + { + return APILists::getDirListAsArray(API_ROOT_PATH . '/modules/'); + } + + /** + * gets list of editors folder from apieditor directory + */ + public static function getEditorList() + { + return APILists::getDirListAsArray(API_ROOT_PATH . '/class/apieditor/'); + } + + /** + * gets list of name of directories inside a directory + * @param $dirname + * @return array + */ + public static function getDirListAsArray($dirname) + { + $ignored = array( + 'cvs', + '_darcs'); + $list = array(); + if (substr($dirname, -1) !== '/') { + $dirname .= '/'; + } + if ($handle = opendir($dirname)) { + while ($file = readdir($handle)) { + if (substr($file, 0, 1) === '.' || in_array(strtolower($file), $ignored)) { + continue; + } + if (is_dir($dirname . $file)) { + $list[$file] = $file; + } + } + closedir($handle); + asort($list); + reset($list); + } + + return $list; + } + + /** + * gets list of all files in a directory + * @param $dirname + * @param string $prefix + * @return array + */ + public static function getFileListAsArray($dirname, $prefix = '') + { + $filelist = array(); + if (substr($dirname, -1) === '/') { + $dirname = substr($dirname, 0, -1); + } + if (is_dir($dirname) && $handle = opendir($dirname)) { + while (false !== ($file = readdir($handle))) { + if (!preg_match('/^[\.]{1,2}$/', $file) && is_file($dirname . '/' . $file)) { + $file = $prefix . $file; + $filelist[$file] = $file; + } + } + closedir($handle); + asort($filelist); + reset($filelist); + } + + return $filelist; + } + + /** + * gets list of image file names in a directory + * @param $dirname + * @param string $prefix + * @return array + */ + public static function getImgListAsArray($dirname, $prefix = '') + { + $filelist = array(); + if ($handle = opendir($dirname)) { + while (false !== ($file = readdir($handle))) { + if (preg_match('/(\.gif|\.jpg|\.png)$/i', $file)) { + $file = $prefix . $file; + $filelist[$file] = $file; + } + } + closedir($handle); + asort($filelist); + reset($filelist); + } + + return $filelist; + } + + /** + * gets list of html file names in a certain directory + * @param $dirname + * @param string $prefix + * @return array + */ + public static function getHtmlListAsArray($dirname, $prefix = '') + { + $filelist = array(); + if ($handle = opendir($dirname)) { + while (false !== ($file = readdir($handle))) { + if (preg_match('/(\.htm|\.html|\.xhtml|\.tpl)$/i', $file) && !is_dir($file)) { + $file = $prefix . $file; + $filelist[$file] = $prefix . $file; + } + } + closedir($handle); + asort($filelist); + reset($filelist); + } + + return $filelist; + } + + /** + * gets list of avatar file names in a certain directory + * if directory is not specified, default directory will be searched + * @param string $avatar_dir + * @return array + */ + public static function getAvatarsList($avatar_dir = '') + { + $avatars = array(); + if ($avatar_dir != '') { + $avatars = APILists::getImgListAsArray(API_ROOT_PATH . '/images/avatar/' . $avatar_dir . '/', $avatar_dir . '/'); + } else { + $avatars = APILists::getImgListAsArray(API_ROOT_PATH . '/images/avatar/'); + } + + return $avatars; + } + + /** + * gets list of all avatar image files inside default avatars directory + */ + public static function getAllAvatarsList() + { + $avatars = array(); + $dirlist = array(); + $dirlist = APILists::getDirListAsArray(API_ROOT_PATH . '/images/avatar/'); + if (count($dirlist) > 0) { + foreach ($dirlist as $dir) { + $avatars[$dir] = &APILists::getImgListAsArray(API_ROOT_PATH . '/images/avatar/' . $dir . '/', $dir . '/'); + } + } else { + return false; + } + + return $avatars; + } + + /** + * gets list of subject icon image file names in a certain directory + * if directory is not specified, default directory will be searched + * @param string $sub_dir + * @return array + */ + public static function getSubjectsList($sub_dir = '') + { + $subjects = array(); + if ($sub_dir != '') { + $subjects = APILists::getImgListAsArray(API_ROOT_PATH . '/images/subject/' . $sub_dir, $sub_dir . '/'); + } else { + $subjects = APILists::getImgListAsArray(API_ROOT_PATH . '/images/subject/'); + } + + return $subjects; + } + + /** + * gets list of language folders inside default language directory + */ + public static function getLangList() + { + $lang_list = array(); + $lang_list = APILists::getDirListAsArray(API_ROOT_PATH . '/language/'); + + return $lang_list; + } + + /** + * APILists::getCountryList() + * + * @return array + */ + public static function getCountryList() + { + api_loadLanguage('countries'); + $country_list = array( + '' => '-', + 'AD' => _COUNTRY_AD, + 'AE' => _COUNTRY_AE, + 'AF' => _COUNTRY_AF, + 'AG' => _COUNTRY_AG, + 'AI' => _COUNTRY_AI, + 'AL' => _COUNTRY_AL, + 'AM' => _COUNTRY_AM, + 'AN' => _COUNTRY_AN, + 'AO' => _COUNTRY_AO, + 'AQ' => _COUNTRY_AQ, + 'AR' => _COUNTRY_AR, + 'AS' => _COUNTRY_AS, + 'AT' => _COUNTRY_AT, + 'AU' => _COUNTRY_AU, + 'AW' => _COUNTRY_AW, + 'AX' => _COUNTRY_AX, + 'AZ' => _COUNTRY_AZ, + 'BA' => _COUNTRY_BA, + 'BB' => _COUNTRY_BB, + 'BD' => _COUNTRY_BD, + 'BE' => _COUNTRY_BE, + 'BF' => _COUNTRY_BF, + 'BG' => _COUNTRY_BG, + 'BH' => _COUNTRY_BH, + 'BI' => _COUNTRY_BI, + 'BJ' => _COUNTRY_BJ, + 'BL' => _COUNTRY_BL, + 'BM' => _COUNTRY_BM, + 'BN' => _COUNTRY_BN, + 'BO' => _COUNTRY_BO, + 'BR' => _COUNTRY_BR, + 'BS' => _COUNTRY_BS, + 'BT' => _COUNTRY_BT, + 'BV' => _COUNTRY_BV, + 'BW' => _COUNTRY_BW, + 'BY' => _COUNTRY_BY, + 'BZ' => _COUNTRY_BZ, + 'CA' => _COUNTRY_CA, + 'CC' => _COUNTRY_CC, + 'CD' => _COUNTRY_CD, + 'CF' => _COUNTRY_CF, + 'CG' => _COUNTRY_CG, + 'CH' => _COUNTRY_CH, + 'CI' => _COUNTRY_CI, + 'CK' => _COUNTRY_CK, + 'CL' => _COUNTRY_CL, + 'CM' => _COUNTRY_CM, + 'CN' => _COUNTRY_CN, + 'CO' => _COUNTRY_CO, + 'CR' => _COUNTRY_CR, + 'CS' => _COUNTRY_CS, // Not listed in ISO 3166, former Serbia & Montenegro + 'CU' => _COUNTRY_CU, + 'CV' => _COUNTRY_CV, + 'CX' => _COUNTRY_CX, + 'CY' => _COUNTRY_CY, + 'CZ' => _COUNTRY_CZ, + 'DE' => _COUNTRY_DE, + 'DJ' => _COUNTRY_DJ, + 'DK' => _COUNTRY_DK, + 'DM' => _COUNTRY_DM, + 'DO' => _COUNTRY_DO, + 'DZ' => _COUNTRY_DZ, + 'EC' => _COUNTRY_EC, + 'EE' => _COUNTRY_EE, + 'EG' => _COUNTRY_EG, + 'EH' => _COUNTRY_EH, + 'ER' => _COUNTRY_ER, + 'ES' => _COUNTRY_ES, + 'ET' => _COUNTRY_ET, + 'FI' => _COUNTRY_FI, + 'FJ' => _COUNTRY_FJ, + 'FK' => _COUNTRY_FK, + 'FM' => _COUNTRY_FM, + 'FO' => _COUNTRY_FO, + 'FR' => _COUNTRY_FR, + 'FX' => _COUNTRY_FX, // Not listed in ISO 3166 + 'GA' => _COUNTRY_GA, + 'GB' => _COUNTRY_GB, + 'GD' => _COUNTRY_GD, + 'GE' => _COUNTRY_GE, + 'GF' => _COUNTRY_GF, + 'GG' => _COUNTRY_GG, + 'GH' => _COUNTRY_GH, + 'GI' => _COUNTRY_GI, + 'GL' => _COUNTRY_GL, + 'GM' => _COUNTRY_GM, + 'GN' => _COUNTRY_GN, + 'GP' => _COUNTRY_GP, + 'GQ' => _COUNTRY_GQ, + 'GR' => _COUNTRY_GR, + 'GS' => _COUNTRY_GS, + 'GT' => _COUNTRY_GT, + 'GU' => _COUNTRY_GU, + 'GW' => _COUNTRY_GW, + 'GY' => _COUNTRY_GY, + 'HK' => _COUNTRY_HK, + 'HM' => _COUNTRY_HM, + 'HN' => _COUNTRY_HN, + 'HR' => _COUNTRY_HR, + 'HT' => _COUNTRY_HT, + 'HU' => _COUNTRY_HU, + 'ID' => _COUNTRY_ID, + 'IE' => _COUNTRY_IE, + 'IL' => _COUNTRY_IL, + 'IM' => _COUNTRY_IM, + 'IN' => _COUNTRY_IN, + 'IO' => _COUNTRY_IO, + 'IQ' => _COUNTRY_IQ, + 'IR' => _COUNTRY_IR, + 'IS' => _COUNTRY_IS, + 'IT' => _COUNTRY_IT, + 'JM' => _COUNTRY_JM, + 'JO' => _COUNTRY_JO, + 'JP' => _COUNTRY_JP, + 'KE' => _COUNTRY_KE, + 'KG' => _COUNTRY_KG, + 'KH' => _COUNTRY_KH, + 'KI' => _COUNTRY_KI, + 'KM' => _COUNTRY_KM, + 'KN' => _COUNTRY_KN, + 'KP' => _COUNTRY_KP, + 'KR' => _COUNTRY_KR, + 'KW' => _COUNTRY_KW, + 'KY' => _COUNTRY_KY, + 'KZ' => _COUNTRY_KZ, + 'LA' => _COUNTRY_LA, + 'LB' => _COUNTRY_LB, + 'LC' => _COUNTRY_LC, + 'LI' => _COUNTRY_LI, + 'LK' => _COUNTRY_LK, + 'LR' => _COUNTRY_LR, + 'LS' => _COUNTRY_LS, + 'LT' => _COUNTRY_LT, + 'LU' => _COUNTRY_LU, + 'LV' => _COUNTRY_LV, + 'LY' => _COUNTRY_LY, + 'MA' => _COUNTRY_MA, + 'MC' => _COUNTRY_MC, + 'MD' => _COUNTRY_MD, + 'ME' => _COUNTRY_ME, + 'MF' => _COUNTRY_MF, + 'MG' => _COUNTRY_MG, + 'MH' => _COUNTRY_MH, + 'MK' => _COUNTRY_MK, + 'ML' => _COUNTRY_ML, + 'MM' => _COUNTRY_MM, + 'MN' => _COUNTRY_MN, + 'MO' => _COUNTRY_MO, + 'MP' => _COUNTRY_MP, + 'MQ' => _COUNTRY_MQ, + 'MR' => _COUNTRY_MR, + 'MS' => _COUNTRY_MS, + 'MT' => _COUNTRY_MT, + 'MU' => _COUNTRY_MU, + 'MV' => _COUNTRY_MV, + 'MW' => _COUNTRY_MW, + 'MX' => _COUNTRY_MX, + 'MY' => _COUNTRY_MY, + 'MZ' => _COUNTRY_MZ, + 'NA' => _COUNTRY_NA, + 'NC' => _COUNTRY_NC, + 'NE' => _COUNTRY_NE, + 'NF' => _COUNTRY_NF, + 'NG' => _COUNTRY_NG, + 'NI' => _COUNTRY_NI, + 'NL' => _COUNTRY_NL, + 'NO' => _COUNTRY_NO, + 'NP' => _COUNTRY_NP, + 'NR' => _COUNTRY_NR, + 'NT' => _COUNTRY_NT, // Not listed in ISO 3166 + 'NU' => _COUNTRY_NU, + 'NZ' => _COUNTRY_NZ, + 'OM' => _COUNTRY_OM, + 'PA' => _COUNTRY_PA, + 'PE' => _COUNTRY_PE, + 'PF' => _COUNTRY_PF, + 'PG' => _COUNTRY_PG, + 'PH' => _COUNTRY_PH, + 'PK' => _COUNTRY_PK, + 'PL' => _COUNTRY_PL, + 'PM' => _COUNTRY_PM, + 'PN' => _COUNTRY_PN, + 'PR' => _COUNTRY_PR, + 'PS' => _COUNTRY_PS, + 'PT' => _COUNTRY_PT, + 'PW' => _COUNTRY_PW, + 'PY' => _COUNTRY_PY, + 'QA' => _COUNTRY_QA, + 'RE' => _COUNTRY_RE, + 'RO' => _COUNTRY_RO, + 'RS' => _COUNTRY_RS, + 'RU' => _COUNTRY_RU, + 'RW' => _COUNTRY_RW, + 'SA' => _COUNTRY_SA, + 'SB' => _COUNTRY_SB, + 'SC' => _COUNTRY_SC, + 'SD' => _COUNTRY_SD, + 'SE' => _COUNTRY_SE, + 'SG' => _COUNTRY_SG, + 'SH' => _COUNTRY_SH, + 'SI' => _COUNTRY_SI, + 'SJ' => _COUNTRY_SJ, + 'SK' => _COUNTRY_SK, + 'SL' => _COUNTRY_SL, + 'SM' => _COUNTRY_SM, + 'SN' => _COUNTRY_SN, + 'SO' => _COUNTRY_SO, + 'SR' => _COUNTRY_SR, + 'ST' => _COUNTRY_ST, + 'SU' => _COUNTRY_SU, // Not listed in ISO 3166 + 'SV' => _COUNTRY_SV, + 'SY' => _COUNTRY_SY, + 'SZ' => _COUNTRY_SZ, + 'TC' => _COUNTRY_TC, + 'TD' => _COUNTRY_TD, + 'TF' => _COUNTRY_TF, + 'TG' => _COUNTRY_TG, + 'TH' => _COUNTRY_TH, + 'TJ' => _COUNTRY_TJ, + 'TK' => _COUNTRY_TK, + 'TL' => _COUNTRY_TL, + 'TM' => _COUNTRY_TM, + 'TN' => _COUNTRY_TN, + 'TO' => _COUNTRY_TO, + 'TP' => _COUNTRY_TP, // Not listed in ISO 3166, has changed to TL + 'TR' => _COUNTRY_TR, + 'TT' => _COUNTRY_TT, + 'TV' => _COUNTRY_TV, + 'TW' => _COUNTRY_TW, + 'TZ' => _COUNTRY_TZ, + 'UA' => _COUNTRY_UA, + 'UG' => _COUNTRY_UG, + //"UK" => _COUNTRY_UK, // Not listed in ISO 3166 + 'UM' => _COUNTRY_UM, + 'US' => _COUNTRY_US, + 'UY' => _COUNTRY_UY, + 'UZ' => _COUNTRY_UZ, + 'VA' => _COUNTRY_VA, + 'VC' => _COUNTRY_VC, + 'VE' => _COUNTRY_VE, + 'VG' => _COUNTRY_VG, + 'VI' => _COUNTRY_VI, + 'VN' => _COUNTRY_VN, + 'VU' => _COUNTRY_VU, + 'WF' => _COUNTRY_WF, + 'WS' => _COUNTRY_WS, + 'YE' => _COUNTRY_YE, + 'YT' => _COUNTRY_YT, + 'YU' => _COUNTRY_YU, // Not listed in ISO 3166, former Yugoslavia + 'ZA' => _COUNTRY_ZA, + 'ZM' => _COUNTRY_ZM, + 'ZR' => _COUNTRY_ZR, // Not listed in ISO 3166 + 'ZW' => _COUNTRY_ZW); + asort($country_list); + reset($country_list); + + return $country_list; + } + + /** + * APILists::getHtmlList() + * + * This Function is no longer being used by the core + * + * @return array + */ + public static function getHtmlList() + { + $html_list = array( + 'a' => '<a>', + 'abbr' => '<abbr>', + 'acronym' => '<acronym>', + 'address' => '<address>', + 'b' => '<b>', + 'bdo' => '<bdo>', + 'big' => '<big>', + 'blockquote' => '<blockquote>', + 'br' => '<br>', + 'caption' => '<caption>', + 'cite' => '<cite>', + 'code' => '<code>', + 'col' => '<col>', + 'colgroup' => '<colgroup>', + 'dd' => '<dd>', + 'del' => '<del>', + 'dfn' => '<dfn>', + 'div' => '<div>', + 'dl' => '<dl>', + 'dt' => '<dt>', + 'em' => '<em>', + 'font' => '<font>', + 'h1' => '<h1>', + 'h2' => '<h2>', + 'h3' => '<h3>', + 'h4' => '<h4>', + 'h5' => '<h5>', + 'h6' => '<h6>', + 'hr' => '<hr>', + 'i' => '<i>', + 'img' => '<img>', + 'ins' => '<ins>', + 'kbd' => '<kbd>', + 'li' => '<li>', + 'map' => '<map>', + 'object' => '<object>', + 'ol' => '<ol>', + 'p' => '<p>', + 'pre' => '<pre>', + 's' => '<s>', + 'samp' => '<samp>', + 'small' => '<small>', + 'span' => '<span>', + 'strike' => '<strike>', + 'strong' => '<strong>', + 'sub' => '<sub>', + 'sup' => '<sup>', + 'table' => '<table>', + 'tbody' => '<tbody>', + 'td' => '<td>', + 'tfoot' => '<tfoot>', + 'th' => '<th>', + 'thead' => '<thead>', + 'tr' => '<tr>', + 'tt' => '<tt>', + 'u' => '<u>', + 'ul' => '<ul>', + 'var' => '<var>'); + asort($html_list); + reset($html_list); + + return $html_list; + } + + /** + * APILists::getUserRankList() + * + * @return array + */ + public static function getUserRankList() + { + $db = APIDatabaseFactory::getDatabaseConnection(); + $myts = MyTextSanitizer::getInstance(); + $sql = sprintf('SELECT rank_id, rank_title FROM ' . $db->prefix('ranks') . ' WHERE rank_special = %u', 1); + $ret = array(); + $result = $db->query($sql); + while ($myrow = $db->fetchArray($result)) { + $ret[$myrow['rank_id']] = $myts->htmlspecialchars($myrow['rank_title']); + } + + return $ret; + } + } +} Property changes on: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilists.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiload.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiload.php (rev 0) +++ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiload.php 2018-04-29 13:12:22 UTC (rev 13355) @@ -0,0 +1,274 @@ +<?php +/** + * My IPv4 or IPv6 REST Services API + * + * 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://syd.au.snails.email + * @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/) + * @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html) + * @package myip-api + * @since 1.0.1 + * @author Dr. Simon Antony Roberts <simon@snails.email> + * @version 1.0.3 + * @description A REST Services API that returns either or both or all IPv4, IPv6 addresses of a caller! + * @link http://internetfounder.wordpress.com + * @link https://github.com/Chronolabs-Cooperative/MyIP-API-PHP + * @link https://sourceforge.net/p/chronolabs-cooperative + * @link https://facebook.com/ChronolabsCoop + * @link https://twitter.com/ChronolabsCoop + * + */ + +defined('API_ROOT_PATH') || exit('Restricted access'); + +/** + * Class APILoad + */ +class APILoad +{ + //static $loaded; + //static $configs; + + /** + * @param $name + * @param string $type + * + * @return bool + */ + public static function load($name, $type = 'core') + { + static $loaded; + static $deprecated; + + if (!isset($deprecated)) { + $deprecated = array( + 'uploader' => 'apimediauploader', + 'utility' => 'apiutility', + 'captcha' => 'apicaptcha', + 'cache' => 'apicache', + 'file' => 'apifile', + 'model' => 'apimodelfactory', + 'calendar' => 'apicalendar', + 'userutility' => 'apiuserutility'); + } + $name = strtolower($name); + if (in_array($type, array('core', 'class')) && array_key_exists($name, $deprecated)) { + if (isset($GLOBALS['apiLogger'])) { + $GLOBALS['apiLogger']->addDeprecated("api_load('{$name}') is deprecated, use api_load('{$deprecated[$name]}')"); + } else { + trigger_error("api_load('{$name}') is deprecated, use api_load('{$deprecated[$name]}')", E_USER_WARNING); + } + $name = $deprecated[$name]; + } + + $type = empty($type) ? 'core' : $type; + if (isset($loaded[$type][$name])) { + return $loaded[$type][$name]; + } + + if (class_exists($name, false)) { + $loaded[$type][$name] = true; + + return true; + } + $isloaded = false; + switch ($type) { + case 'framework': + $isloaded = APILoad::loadFramework($name); + break; + case 'class': + case 'core': + $type = 'core'; + $isloaded = APILoad::loadCore($name); + break; + default: + $isloaded = APILoad::loadModule($name, $type); + break; + } + $loaded[$type][$name] = $isloaded; + + return $loaded[$type][$name]; + } + + /** + * Load core class + * + * @access private + * @param $name + * @return bool|string + */ + public static function loadCore($name) + { + static $configs; + + if (!isset($configs)) { + $configs = APILoad::loadCoreConfig(); + } + if (isset($configs[$name])) { + require_once $configs[$name]; + if (class_exists($name) && method_exists($name, '__autoload')) { + call_user_func(array($name, '__autoload')); + } + + return true; + } elseif (file_exists($file = API_ROOT_PATH . '/class/' . $name . '.php')) { + include_once $file; + $class = 'API' . ucfirst($name); + if (class_exists($class)) { + return $class; + } else { + trigger_error('Class ' . $name . ' not found in file ' . __FILE__ . 'at line ' . __LINE__, E_USER_WARNING); + } + } + + return false; + } + + /** + * Load Framework class + * + * @access private + * @param $name + * @return bool|string + */ + public static function loadFramework($name) + { + if (!file_exists($file = API_ROOT_PATH . '/Frameworks/' . $name . '/api' . $name . '.php')) { + trigger_error('File ' . str_replace(API_ROOT_PATH, '', $file) . ' not found in file ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING); + + return false; + } + include_once $file; + $class = 'API' . ucfirst($name); + if (class_exists($class)) { + return $class; + } + return null; + } + + /** + * Load module class + * + * @access private + * @param string $name class file name + * @param string|null $dirname module directory name + * @return bool + */ + public static function loadModule($name, $dirname = null) + { + if (empty($dirname)) { + return false; + } + if (file_exists($file = API_ROOT_PATH . '/modules/' . $dirname . '/class/' . $name . '.php')) { + include_once $file; + if (class_exists(ucfirst($dirname) . ucfirst($name))) { + return true; + } + } + + return false; + } + + /** + * APILoad::loadCoreConfig() + * + * @return array + */ + public static function loadCoreConfig() + { + return $configs = array( + 'apiuserutility' => API_ROOT_PATH . '/class/userutility.php', + 'apimediauploader' => API_ROOT_PATH . '/class/uploader.php', + 'apiutility' => API_ROOT_PATH . '/class/utility/apiutility.php', + 'apicaptcha' => API_ROOT_PATH . '/class/captcha/apicaptcha.php', + 'apicache' => API_ROOT_PATH . '/class/cache/apicache.php', + 'apifile' => API_ROOT_PATH . '/class/file/apifile.php', + 'apimodelfactory' => API_ROOT_PATH . '/class/model/apimodel.php', + 'apicalendar' => API_ROOT_PATH . '/class/calendar/apicalendar.php', + 'apikernel' => API_ROOT_PATH . '/class/apikernel.php', + 'apisecurity' => API_ROOT_PATH . '/class/apisecurity.php', + 'apilogger' => API_ROOT_PATH . '/class/logger/apilogger.php', + 'apipagenav' => API_ROOT_PATH . '/class/pagenav.php', + 'apilists' => API_ROOT_PATH . '/class/apilists.php', + 'apilocal' => API_ROOT_PATH . '/include/apilocal.php', + 'apilocalabstract' => API_ROOT_PATH . '/class/apilocal.php', + 'apieditor' => API_ROOT_PATH . '/class/apieditor/apieditor.php', + 'apieditorhandler' => API_ROOT_PATH . '/class/apieditor/apieditor.php', + 'apiformloader' => API_ROOT_PATH . '/class/apiformloader.php', + 'apiformelement' => API_ROOT_PATH . '/class/apiform/formelement.php', + 'apiform' => API_ROOT_PATH . '/class/apiform/form.php', + 'apiformlabel' => API_ROOT_PATH . '/class/apiform/formlabel.php', + 'apiformselect' => API_ROOT_PATH . '/class/apiform/formselect.php', + 'apiformpassword' => API_ROOT_PATH . '/class/apiform/formpassword.php', + 'apiformbutton' => API_ROOT_PATH . '/class/apiform/formbutton.php', + 'apiformbuttontray' => API_ROOT_PATH . '/class/apiform/formbuttontray.php', + 'apiformcheckbox' => API_ROOT_PATH . '/class/apiform/formcheckbox.php', + 'apiformselectcheckgroup' => API_ROOT_PATH . '/class/apiform/formselectcheckgroup.php', + 'apiformhidden' => API_ROOT_PATH . '/class/apiform/formhidden.php', + 'apiformfile' => API_ROOT_PATH . '/class/apiform/formfile.php', + 'apiformradio' => API_ROOT_PATH . '/class/apiform/formradio.php', + 'apiformradioyn' => API_ROOT_PATH . '/class/apiform/formradioyn.php', + 'apiformselectcountry' => API_ROOT_PATH . '/class/apiform/formselectcountry.php', + 'apiformselecttimezone' => API_ROOT_PATH . '/class/apiform/formselecttimezone.php', + 'apiformselectlang' => API_ROOT_PATH . '/class/apiform/formselectlang.php', + 'apiformselectgroup' => API_ROOT_PATH . '/class/apiform/formselectgroup.php', + 'apiformselectuser' => API_ROOT_PATH . '/class/apiform/formselectuser.php', + 'apiformselecttheme' => API_ROOT_PATH . '/class/apiform/formselecttheme.php', + 'apiformselectmatchoption' => API_ROOT_PATH . '/class/apiform/formselectmatchoption.php', + 'apiformtext' => API_ROOT_PATH . '/class/apiform/formtext.php', + 'apiformtextarea' => API_ROOT_PATH . '/class/apiform/formtextarea.php', + 'apiformdhtmltextarea' => API_ROOT_PATH . '/class/apiform/formdhtmltextarea.php', + 'apiformelementtray' => API_ROOT_PATH . '/class/apiform/formelementtray.php', + 'apithemeform' => API_ROOT_PATH . '/class/apiform/themeform.php', + 'apisimpleform' => API_ROOT_PATH . '/class/apiform/simpleform.php', + 'apiformtextdateselect' => API_ROOT_PATH . '/class/apiform/formtextdateselect.php', + 'apiformdatetime' => API_ROOT_PATH . '/class/apiform/formdatetime.php', + 'apiformhiddentoken' => API_ROOT_PATH . '/class/apiform/formhiddentoken.php', + 'apiformcolorpicker' => API_ROOT_PATH . '/class/apiform/formcolorpicker.php', + 'apiformcaptcha' => API_ROOT_PATH . '/class/apiform/formcaptcha.php', + 'apiformeditor' => API_ROOT_PATH . '/class/apiform/formeditor.php', + 'apiformselecteditor' => API_ROOT_PATH . '/class/apiform/formselecteditor.php', + 'apiformcalendar' => API_ROOT_PATH . '/class/apiform/formcalendar.php', + 'apiformrenderer' => API_ROOT_PATH . '/class/apiform/renderer/APIFormRenderer.php', + 'apiformrendererinterface' => API_ROOT_PATH . '/class/apiform/renderer/APIFormRendererInterface.php', + 'apiformrendererlegacy' => API_ROOT_PATH . '/class/apiform/renderer/APIFormRendererLegacy.php', + 'apiformrendererbootstrap3'=> API_ROOT_PATH . '/class/apiform/renderer/APIFormRendererBootstrap3.php', + 'apifilterinput' => API_ROOT_PATH . '/class/apifilterinput.php', + 'apirequest' => API_ROOT_PATH . '/class/apirequest.php'); + } + + /** + * APILoad::loadConfig() + * + * @param mixed $data + * + * @return array|bool + */ + public function loadConfig($data = null) + { + if (is_array($data)) { + $configs = $data; + } else { + if (!empty($data)) { + $dirname = $data; + } elseif (is_object($GLOBALS['apiModule'])) { + $dirname = $GLOBALS['apiModule']->getVar('dirname', 'n'); + } else { + return false; + } + if (file_exists($file = API_ROOT_PATH . '/modules/' . $dirname . '/include/autoload.php')) { + if (!$configs = include $file) { + return false; + } + } + } + + return $configs = array_merge(APILoad::loadCoreConfig(), $configs); + } +} Property changes on: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apiload.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilocal.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilocal.php (rev 0) +++ *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilocal.php 2018-04-29 13:12:22 UTC (rev 13355) @@ -0,0 +1,269 @@ +<?php +/** + * My IPv4 or IPv6 REST Services API + * + * 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://syd.au.snails.email + * @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/) + * @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html) + * @package myip-api + * @since 1.0.1 + * @author Dr. Simon Antony Roberts <simon@snails.email> + * @version 1.0.3 + * @description A REST Services API that returns either or both or all IPv4, IPv6 addresses of a caller! + * @link http://internetfounder.wordpress.com + * @link https://github.com/Chronolabs-Cooperative/MyIP-API-PHP + * @link https://sourceforge.net/p/chronolabs-cooperative + * @link https://facebook.com/ChronolabsCoop + * @link https://twitter.com/ChronolabsCoop + * + */ + + +defined('API_ROOT_PATH') || exit('Restricted access'); + +/** + * Class APILocalAbstract + */ +class APILocalAbstract +{ + /** + * APILocalAbstract::substr() + * + * @param mixed $str + * @param mixed $start + * @param mixed $length + * @param string $trimmarker + * + * @return mixed|string + */ + public static function substr($str, $start, $length, $trimmarker = '...') + { + if (!API_USE_MULTIBYTES) { + return (strlen($str) - $start <= $length) ? substr($str, $start, $length) : substr($str, $start, $length - strlen($trimmarker)) . $trimmarker; + } + if (function_exists('mb_internal_encoding') && @mb_internal_encoding(_CHARSET)) { + $str2 = mb_strcut($str, $start, $length - strlen($trimmarker)); + + return $str2 . (mb_strlen($str) != mb_strlen($str2) ? $trimmarker : ''); + } + + return $str; + } + // Each local language should define its own equalient utf8_encode + /** + * APILocalAbstract::utf8_encode() + * + * @param mixed $text + * @return string + */ + public static function utf8_encode($text) + { + if (API_USE_MULTIBYTES == 1) { + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($text, 'UTF-8', 'auto'); + } + } + + return utf8_encode($text); + } + + /** + * APILocalAbstract::convert_encoding() + * + * @param mixed $text + * @param string $to + * @param string $from + * @return mixed|string + */ + public static function convert_encoding($text, $to = 'utf-8', $from = '') + { + if (empty($text)) { + return $text; + } + if (empty($from)) { + $from = empty($GLOBALS['xlanguage']['charset_base']) ? _CHARSET : $GLOBALS['xlanguage']['charset_base']; + } + if (empty($to) || !strcasecmp($to, $from)) { + return $text; + } + + if (API_USE_MULTIBYTES && function_exists('mb_convert_encoding')) { + $converted_text = @mb_convert_encoding($text, $to, $from); + } elseif (function_exists('iconv')) { + $converted_text = @iconv($from, $to . '//TRANSLIT', $text); + } elseif ('utf-8' === $to) { + $converted_text = utf8_encode($text); + } + $text = empty($converted_text) ? $text : $converted_text; + + return $text; + } + + /** + * APILocalAbstract::trim() + * + * @param mixed $text + * @return string + */ + public static function trim($text) + { + $ret = trim($text); + + return $ret; + } + + /** + * Get description for setting time format + */ + public static function getTimeFormatDesc() + { + return _TIMEFORMAT_DESC; + } + + /** + * Function to display formatted times in user timezone + * + * Setting $timeoffset to null (by default) will skip timezone calculation for user, using default timezone instead, which is a MUST for cached contents + * @param $time + * @param string $format + * @param null|string $timeoffset + * @return string + */ + public static function formatTimestamp($time, $format = 'l', $timeoffset = null) + { + global $apiConfig, $apiUser; + + $format_copy = $format; + $format = strtolower($format); + + if ($format === 'rss' || $format === 'r') { + $TIME_ZONE = ''; + if (isset($GLOBALS['apiConfig']['server_TZ'])) { + $server_TZ = abs((int)($GLOBALS['apiConfig']['server_TZ'] * 3600.0)); + $prefix = ($GLOBALS['apiConfig']['server_TZ'] < 0) ? ' -' : ' +'; + $TIME_ZONE = $prefix . date('Hi', $server_TZ); + } + $date = gmdate('D, d M Y H:i:s', (int)$time) . $TIME_ZONE; + + return $date; + } + + if (($format === 'elapse' || $format === 'e') && $time < time()) { + $elapse = time() - $time; + if ($days = floor($elapse / (24 * 3600))) { + $num = $days > 1 ? sprintf(_DAYS, $days) : _DAY; + } elseif ($hours = floor(($elapse % (24 * 3600)) / 3600)) { + $num = $hours > 1 ? sprintf(_HOURS, $hours) : _HOUR; + } elseif ($minutes = floor(($elapse % 3600) / 60)) { + $num = $minutes > 1 ? sprintf(_MINUTES, $minutes) : _MINUTE; + } else { + $seconds = $elapse % 60; + $num = $seconds > 1 ? sprintf(_SECONDS, $seconds) : _SECOND; + } + $ret = sprintf(_ELAPSE, $num); + + return $ret; + } + // disable user timezone calculation and use default timezone, + // for cache consideration + if ($timeoffset === null) { + $timeoffset = ($apiConfig['default_TZ'] == '') ? '0.0' : $apiConfig['default_TZ']; + } + $usertimestamp = api_getUserTimestamp($time, $timeoffset); + switch ($format) { + case 's': + $datestring = _SHORTDATESTRING; + break; + + case 'm': + $datestring = _MEDIUMDATESTRING; + break; + + case 'mysql': + $datestring = 'Y-m-d H:i:s'; + break; + + case 'l': + $datestring = _DATESTRING; + break; + + case 'c': + case 'custom': + static $current_timestamp, $today_timestamp, $monthy_timestamp; + if (!isset($current_timestamp)) { + $current_timestamp = api_getUserTimestamp(time(), $timeoffset); + } + if (!isset($today_timestamp)) { + $today_timestamp = mktime(0, 0, 0, date('m', $current_timestamp), date('d', $current_timestamp), date('Y', $current_timestamp)); + } + + if (abs($elapse_today = $usertimestamp - $today_timestamp) < 24 * 60 * 60) { + $datestring = ($elapse_today > 0) ? _TODAY : _YESTERDAY; + } else { + if (!isset($monthy_timestamp)) { + $monthy_timestamp[0] = mktime(0, 0, 0, 0, 0, date('Y', $current_timestamp)); + $monthy_timestamp[1] = mktime(0, 0, 0, 0, 0, date('Y', $current_timestamp) + 1); + } + $datestring = _YEARMONTHDAY; + if ($usertimestamp >= $monthy_timestamp[0] && $usertimestamp < $monthy_timestamp[1]) { + $datestring = _MONTHDAY; + } + } + break; + + default: + $datestring = _DATESTRING; + if ($format != '') { + $datestring = $format_copy; + } + break; + } + + return ucfirst(date($datestring, $usertimestamp)); + } + + /** + * APILocalAbstract::number_format() + * + * @param mixed $number + * @return mixed + */ + public function number_format($number) + { + return $number; + } + + /** + * APILocalAbstract::money_format() + * + * @param mixed $format + * @param mixed $number + * @return mixed + */ + public function money_format($format, $number) + { + return $number; + } + + /** + * APILocalAbstract::__call() + * + * @param mixed $name + * @param mixed $args + * @return mixed + */ + public function __call($name, $args) + { + if (function_exists($name)) { + return call_user_func_array($name, $args); + } + return null; + } +} Property changes on: *.xoops.org (Subdomain APIs & Sites)/myip.xoops.org/class/apilocal.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 #... [truncated message content] |