├── .gitattributes ├── .gitignore ├── Backup.php ├── LICENSE ├── README.md ├── Restore.php ├── Superfecta.class.php ├── agi └── superfecta.agi ├── assets ├── images │ ├── bottom.gif │ ├── copy.gif │ ├── delete.gif │ ├── loading.gif │ ├── logo.gif │ ├── off.gif │ ├── on.gif │ ├── on_off.gif │ ├── revert.gif │ ├── top.gif │ └── update.png ├── js │ ├── jquery.form.js │ └── superfecta.js └── less │ └── bootstrap.less ├── functions.inc.php ├── i18n ├── de_DE │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po ├── es_ES │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po ├── fr_FR │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po ├── pl │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po ├── pt_BR │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po ├── superfecta.pot ├── vi │ └── LC_MESSAGES │ │ ├── superfecta.mo │ │ └── superfecta.po └── zh_CN │ └── LC_MESSAGES │ ├── superfecta.mo │ └── superfecta.po ├── includes ├── JSON │ └── JSON.php ├── oauth-google │ ├── Adding Google Contact Lookup to FreePBX CIDSuperfecta.pdf │ ├── Google │ │ ├── Auth │ │ │ ├── Abstract.php │ │ │ ├── AppIdentity.php │ │ │ ├── AssertionCredentials.php │ │ │ ├── Exception.php │ │ │ ├── LoginTicket.php │ │ │ ├── OAuth2.php │ │ │ └── Simple.php │ │ ├── Cache │ │ │ ├── Abstract.php │ │ │ ├── Apc.php │ │ │ ├── Exception.php │ │ │ ├── File.php │ │ │ ├── Memcache.php │ │ │ └── Null.php │ │ ├── Client.php │ │ ├── Collection.php │ │ ├── Config.php │ │ ├── Exception.php │ │ ├── Http │ │ │ ├── Batch.php │ │ │ ├── CacheParser.php │ │ │ ├── MediaFileUpload.php │ │ │ ├── REST.php │ │ │ └── Request.php │ │ ├── IO │ │ │ ├── Abstract.php │ │ │ ├── Curl.php │ │ │ ├── Exception.php │ │ │ ├── Stream.php │ │ │ └── cacerts.pem │ │ ├── Model.php │ │ ├── Service.php │ │ ├── Service │ │ │ ├── Exception.php │ │ │ └── Resource.php │ │ ├── Signer │ │ │ ├── Abstract.php │ │ │ └── P12.php │ │ ├── Utils.php │ │ ├── Utils │ │ │ └── URITemplate.php │ │ └── Verifier │ │ │ ├── Abstract.php │ │ │ └── Pem.php │ ├── GoogleAuthManager.php │ ├── Google_Service_ReadContacts.php │ └── oauth2callback.php ├── oauth-php │ ├── LICENSE │ ├── README │ ├── example │ │ ├── client │ │ │ ├── googledocs.php │ │ │ ├── twolegged.php │ │ │ ├── twoleggedtest.php │ │ │ └── twoleggedtwitter.php │ │ └── server │ │ │ ├── INSTALL │ │ │ ├── core │ │ │ ├── init.php │ │ │ └── templates │ │ │ │ ├── inc │ │ │ │ ├── footer.tpl │ │ │ │ └── header.tpl │ │ │ │ ├── index.tpl │ │ │ │ ├── logon.tpl │ │ │ │ └── register.tpl │ │ │ └── www │ │ │ ├── hello.php │ │ │ ├── index.php │ │ │ ├── logon.php │ │ │ ├── oauth.php │ │ │ ├── register.php │ │ │ └── services.xrds.php │ ├── library │ │ ├── OAuthDiscovery.php │ │ ├── OAuthException2.php │ │ ├── OAuthRequest.php │ │ ├── OAuthRequestLogger.php │ │ ├── OAuthRequestSigner.php │ │ ├── OAuthRequestVerifier.php │ │ ├── OAuthRequester.php │ │ ├── OAuthServer.php │ │ ├── OAuthSession.php │ │ ├── OAuthStore.php │ │ ├── body │ │ │ ├── OAuthBodyContentDisposition.php │ │ │ └── OAuthBodyMultipartFormdata.php │ │ ├── discovery │ │ │ ├── xrds_parse.php │ │ │ └── xrds_parse.txt │ │ ├── session │ │ │ ├── OAuthSessionAbstract.class.php │ │ │ └── OAuthSessionSESSION.php │ │ ├── signature_method │ │ │ ├── OAuthSignatureMethod.class.php │ │ │ ├── OAuthSignatureMethod_HMAC_SHA1.php │ │ │ ├── OAuthSignatureMethod_MD5.php │ │ │ ├── OAuthSignatureMethod_PLAINTEXT.php │ │ │ └── OAuthSignatureMethod_RSA_SHA1.php │ │ └── store │ │ │ ├── OAuthStore2Leg.php │ │ │ ├── OAuthStoreAbstract.class.php │ │ │ ├── OAuthStoreAnyMeta.php │ │ │ ├── OAuthStoreMySQL.php │ │ │ ├── OAuthStoreMySQLi.php │ │ │ ├── OAuthStoreOracle.php │ │ │ ├── OAuthStorePDO.php │ │ │ ├── OAuthStorePostgreSQL.php │ │ │ ├── OAuthStoreSQL.php │ │ │ ├── OAuthStoreSession.php │ │ │ ├── mysql │ │ │ ├── install.php │ │ │ └── mysql.sql │ │ │ ├── oracle │ │ │ ├── OracleDB │ │ │ │ ├── 1_Tables │ │ │ │ │ └── TABLES.sql │ │ │ │ ├── 2_Sequences │ │ │ │ │ └── SEQUENCES.sql │ │ │ │ └── 3_Procedures │ │ │ │ │ ├── SP_ADD_CONSUMER_REQUEST_TOKEN.prc │ │ │ │ │ ├── SP_ADD_LOG.prc │ │ │ │ │ ├── SP_ADD_SERVER_TOKEN.prc │ │ │ │ │ ├── SP_AUTH_CONSUMER_REQ_TOKEN.prc │ │ │ │ │ ├── SP_CHECK_SERVER_NONCE.prc │ │ │ │ │ ├── SP_CONSUMER_STATIC_SAVE.prc │ │ │ │ │ ├── SP_COUNT_CONSUMER_ACCESS_TOKEN.prc │ │ │ │ │ ├── SP_COUNT_SERVICE_TOKENS.prc │ │ │ │ │ ├── SP_DELETE_CONSUMER.prc │ │ │ │ │ ├── SP_DELETE_SERVER.prc │ │ │ │ │ ├── SP_DELETE_SERVER_TOKEN.prc │ │ │ │ │ ├── SP_DEL_CONSUMER_ACCESS_TOKEN.prc │ │ │ │ │ ├── SP_DEL_CONSUMER_REQUEST_TOKEN.prc │ │ │ │ │ ├── SP_EXCH_CONS_REQ_FOR_ACC_TOKEN.prc │ │ │ │ │ ├── SP_GET_CONSUMER.prc │ │ │ │ │ ├── SP_GET_CONSUMER_ACCESS_TOKEN.prc │ │ │ │ │ ├── SP_GET_CONSUMER_REQUEST_TOKEN.prc │ │ │ │ │ ├── SP_GET_CONSUMER_STATIC_SELECT.prc │ │ │ │ │ ├── SP_GET_SECRETS_FOR_SIGNATURE.prc │ │ │ │ │ ├── SP_GET_SECRETS_FOR_VERIFY.prc │ │ │ │ │ ├── SP_GET_SERVER.prc │ │ │ │ │ ├── SP_GET_SERVER_FOR_URI.prc │ │ │ │ │ ├── SP_GET_SERVER_TOKEN.prc │ │ │ │ │ ├── SP_GET_SERVER_TOKEN_SECRETS.prc │ │ │ │ │ ├── SP_LIST_CONSUMERS.prc │ │ │ │ │ ├── SP_LIST_CONSUMER_TOKENS.prc │ │ │ │ │ ├── SP_LIST_LOG.prc │ │ │ │ │ ├── SP_LIST_SERVERS.prc │ │ │ │ │ ├── SP_LIST_SERVER_TOKENS.prc │ │ │ │ │ ├── SP_SET_CONSUMER_ACC_TOKEN_TTL.prc │ │ │ │ │ ├── SP_SET_SERVER_TOKEN_TTL.prc │ │ │ │ │ ├── SP_UPDATE_CONSUMER.prc │ │ │ │ │ └── SP_UPDATE_SERVER.prc │ │ │ └── install.php │ │ │ └── postgresql │ │ │ └── pgsql.sql │ └── test │ │ ├── discovery │ │ ├── xrds-fireeagle.xrds │ │ ├── xrds-getsatisfaction.xrds │ │ └── xrds-magnolia.xrds │ │ └── oauth_test.php ├── pear │ └── Net │ │ ├── Growl.php │ │ └── Growl │ │ ├── Application.php │ │ ├── Autoload.php │ │ ├── Exception.php │ │ ├── Gntp.php │ │ ├── GntpMock.php │ │ ├── Response.php │ │ └── Udp.php ├── processors │ ├── superfecta_multi.php │ └── superfecta_single.php └── superfecta_base.php ├── install.php ├── module.xml ├── page.superfecta.php ├── sources ├── source-Abandon_lookup.module ├── source-Allowlist.module ├── source-Asteridex.module ├── source-Asterisk_Phonebook.module ├── source-BulkCNAM.module ├── source-CNAM_RF.module ├── source-CallWithUs.module ├── source-CallerID_Service.module ├── source-Can411.module ├── source-CapsuleCRM.module ├── source-CidnameCom.module ├── source-ConnectWise.module ├── source-DasTelefonBuch_Germany.module ├── source-DeTeMedien_DE.module ├── source-EZCNAM.module ├── source-EnumQuery.module ├── source-FNS_RF.module ├── source-FOP2_Phonebook.module ├── source-FccComplaints.module ├── source-FreeCNAM.module ├── source-FreePBX_Contactmanager.module ├── source-FreePBX_User_Mgr.module ├── source-GevondenCC_NL.module ├── source-GlipMe.module ├── source-GoogleContacts.module ├── source-Herold_Austria.module ├── source-Infobel.module ├── source-Klicktel_DE.module ├── source-LDAP.module ├── source-LocalTel_CH.module ├── source-NextCaller.module ├── source-Open79XX.module ├── source-OpenCNAM.module ├── source-OpenEMR.module ├── source-Paginasblancas_AR.module ├── source-PhoneSpamFilter.module ├── source-PhoneSpamFilter_UK.module ├── source-Regular_Expressions_1.module ├── source-Regular_Expressions_2.module ├── source-Responder_o_No.module ├── source-ReverseAustralia_AU.module ├── source-ReversePhoneBooks_UK.module ├── source-Reversephones_AU.module ├── source-SE_118100_HE.module ├── source-SE_118700_HE.module ├── source-SE_clearsearch_HE.module ├── source-SE_eniro_HE.module ├── source-SE_missatsamtal_HE.module ├── source-SE_vemringde_HE.module ├── source-SFDatabase.module ├── source-Say_No_To_0870_UK.module ├── source-Send_to_Dreambox.module ├── source-Send_to_Growl.module ├── source-Send_to_IFTTT.module ├── source-Send_to_MQTT.module ├── source-Send_to_MythTV.module ├── source-Send_to_NeutrinoHD.module ├── source-Send_to_NotifyMyAndroid.module ├── source-Send_to_PushBullet.module ├── source-Send_to_Pushover.module ├── source-Send_to_Soundbridge.module ├── source-Send_to_Squeezebox_Server.module ├── source-Send_to_Telegram.module ├── source-Send_to_URL.module ├── source-Send_to_Winunciator.module ├── source-Send_to_XBMC.module ├── source-Send_to_YAC.module ├── source-Send_to_Yo.module ├── source-Send_to_email.module ├── source-SugarCRM.module ├── source-Superfecta_Cache.module ├── source-TAB_Reloaded.module ├── source-Telco_Data.module ├── source-TelefonABC_Austria.module ├── source-Telepest_UK.module ├── source-TellowsAPI.module ├── source-Telnyx.module ├── source-Theaddressbook.module ├── source-TrueCNAM.module ├── source-Trunk_Provided.module ├── source-Twilio.module ├── source-UKPhoneInfo_UK.module ├── source-UK_0870_me.module ├── source-VOIP_Innovations_Apidaze.module ├── source-VoIPCNAM.module ├── source-WhoCalled_UK.module ├── source-Who_Called.module └── source-iAddressBook.module ├── uninstall.php ├── utests ├── source-CapsuleCRMTest.php ├── source-DasTelefonBuch_GermanyTest.php ├── source-FccComplaintsTest.php ├── source-FreePBX_ContactmanagerTest.php ├── source-Herold_AustriaTest.php ├── source-TelefonABC_AustriaTest.php └── source-Who_CalledTest.php └── views ├── add_scheme.php ├── footer.php ├── header.php ├── main.php └── scheme.php /.gitattributes: -------------------------------------------------------------------------------- 1 | amp_conf/htdocs/admin/assets/js/pbxlib.js merge=ours 2 | module.xml merge=ours 3 | *.po merge=merge-gettext-po 4 | *.pot merge=merge-gettext-po 5 | *.mo merge=ours 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | views/compiled/ 2 | assets/less/cache/** 3 | module.sig 4 | log 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /Backup.php: -------------------------------------------------------------------------------- 1 | $this->dumpTables(), 8 | 'kvstore' => $this->dumpKVStore() 9 | ]; 10 | $this->addConfigs($configs); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | ______ _____ ______ __ 3 | | ____| | __ \| _ \ \ / / 4 | | |__ _ __ ___ ___| |__) | |_) \ V / 5 | | __| '__/ _ \/ _ \ ___/| _ < > < 6 | | | | | | __/ __/ | | |_) / . \ 7 | |_| |_| \___|\___|_| |____/_/ \_\ 8 | Your Open Source Asterisk PBX GUI Solution 9 | ``` 10 | ### What? 11 | superfecta 12 | This is a module for [FreePBX©](http://www.freepbx.org/ "FreePBX Home Page"). [FreePBX](http://www.freepbx.org/ "FreePBX Home Page") is an open source GUI (graphical user interface) that controls and manages [Asterisk©](http://www.asterisk.org/ "Asterisk Home Page") (PBX). FreePBX is licensed under GPL. 13 | [FreePBX](http://www.freepbx.org/ "FreePBX Home Page") is a completely modular GUI for Asterisk written in PHP and Javascript. Meaning you can easily write any module you can think of and distribute it free of cost to your clients so that they can take advantage of beneficial features in [Asterisk](http://www.asterisk.org/ "Asterisk Home Page") 14 | 15 | ### Setting up a FreePBX system 16 | [See our WIKI](http://wiki.freepbx.org/display/FOP/Install+FreePBX) 17 | ### License 18 | [This modules code is licensed as GPLv2+](httpS://www.gnu.org/licenses/gpl-2.0.txt) 19 | ### Contributing 20 | To contribute code or modules back into the [FreePBX](http://www.freepbx.org/ "FreePBX Home Page") ecosystem you must fully read our Code License Agreement. We are not able to look at or accept patches or code of any kind until this document is filled out. Please take a look at [http://wiki.freepbx.org/display/DC/Code+License+Agreement](http://wiki.freepbx.org/display/DC/Code+License+Agreement) for more information 21 | ### Issues 22 | Please file bug reports at http://issues.freepbx.org -------------------------------------------------------------------------------- /Restore.php: -------------------------------------------------------------------------------- 1 | getConfigs(); 7 | $this->importTables($configs['tables']); 8 | } 9 | 10 | public function processLegacy($pdo, $data, $tables, $unknownTables){ 11 | $this->restoreLegacyDatabase($pdo); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /agi/superfecta.agi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php -q 2 | get('ASTAGIDIR'); 6 | require_once $agidir."/phpagi.php"; 7 | 8 | $base_dir = dirname(dirname(__FILE__)); 9 | $agi = new AGI(); 10 | $scheme_return = $agi->get_variable("CIDSFSCHEME"); 11 | 12 | if (($scheme_return['result']) && (trim(base64_decode($scheme_return['data'])) != '')) { 13 | $scheme = base64_decode($scheme_return['data']); 14 | } else { 15 | $scheme = 'base_Default'; 16 | } 17 | 18 | if ($scheme == 'ALL|ALL') { 19 | $sn[1] = 'ALL'; 20 | } else { 21 | $sn = explode("_", $scheme, 2); 22 | } 23 | 24 | if (!empty($agi->request['agi_callerid'])) { 25 | $agi->verbose("Executing Scheme.."); 26 | $superfecta = FreePBX::Superfecta(); 27 | $superfecta->setAgi($agi); 28 | $callerid = $superfecta->execute($sn[1], $agi->request); 29 | $agi->set_variable("SUPERFECTA_NEW", trim($callerid)); 30 | $agi->set_variable("SUPERFECTA_OLD", trim($agi->request['agi_calleridname'])); 31 | $superfecta_new = $agi->get_variable("SUPERFECTA_NEW"); 32 | $superfecta_old = $agi->get_variable("SUPERFECTA_OLD"); 33 | $agi->verbose("Setting channel variable SUPERFECTA_NEW: ".trim($superfecta_new['data'])); 34 | $agi->verbose("Setting channel variable SUPERFECTA_OLD: ".trim($superfecta_old['data'])); 35 | 36 | $dest = $superfecta->getDest(); 37 | if(!empty($dest)) { 38 | $agi->verbose("CID Determined to be: '" . trim($callerid) . "'"); 39 | $agi->verbose("SPAM Score was ".$superfecta->getSpamScore()); 40 | $agi->verbose("Sending call to ".$dest[0]); 41 | $agi->set_variable("CALLERID(name)", trim($callerid)); 42 | $agi->set_variable("lookupcid", trim($callerid));//because we could bounce back here 43 | $agi->goto_dest($dest[0], $dest[1], $dest[2]); 44 | exit(); 45 | } 46 | if(!empty($callerid)) { 47 | $agi->verbose("CID Determined to be: '" . trim($callerid) . "'"); 48 | $agi->verbose("Attempting to set lookupcid"); 49 | $agi->set_variable("lookupcid", trim($callerid)); 50 | exit(); 51 | } 52 | } else { 53 | $agi->verbose("Not a valid number"); 54 | } 55 | -------------------------------------------------------------------------------- /assets/images/bottom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/bottom.gif -------------------------------------------------------------------------------- /assets/images/copy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/copy.gif -------------------------------------------------------------------------------- /assets/images/delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/delete.gif -------------------------------------------------------------------------------- /assets/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/loading.gif -------------------------------------------------------------------------------- /assets/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/logo.gif -------------------------------------------------------------------------------- /assets/images/off.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/off.gif -------------------------------------------------------------------------------- /assets/images/on.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/on.gif -------------------------------------------------------------------------------- /assets/images/on_off.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/on_off.gif -------------------------------------------------------------------------------- /assets/images/revert.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/revert.gif -------------------------------------------------------------------------------- /assets/images/top.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/top.gif -------------------------------------------------------------------------------- /assets/images/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/assets/images/update.png -------------------------------------------------------------------------------- /i18n/de_DE/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/de_DE/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/es_ES/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/es_ES/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/fr_FR/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/fr_FR/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/pl/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/pl/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/pt_BR/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/pt_BR/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/vi/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/vi/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /i18n/zh_CN/LC_MESSAGES/superfecta.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/i18n/zh_CN/LC_MESSAGES/superfecta.mo -------------------------------------------------------------------------------- /includes/oauth-google/Adding Google Contact Lookup to FreePBX CIDSuperfecta.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/includes/oauth-google/Adding Google Contact Lookup to FreePBX CIDSuperfecta.pdf -------------------------------------------------------------------------------- /includes/oauth-google/Google/Auth/Abstract.php: -------------------------------------------------------------------------------- 1 | 22 | * 23 | */ 24 | abstract class Google_Auth_Abstract 25 | { 26 | /** 27 | * An utility function that first calls $this->auth->sign($request) and then 28 | * executes makeRequest() on that signed request. Used for when a request 29 | * should be authenticated 30 | * @param Google_Http_Request $request 31 | * @return Google_Http_Request $request 32 | */ 33 | abstract public function authenticatedRequest(Google_Http_Request $request); 34 | abstract public function sign(Google_Http_Request $request); 35 | } 36 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Auth/Exception.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class Google_Auth_LoginTicket 26 | { 27 | const USER_ATTR = "sub"; 28 | 29 | // Information from id token envelope. 30 | private $envelope; 31 | 32 | // Information from id token payload. 33 | private $payload; 34 | 35 | /** 36 | * Creates a user based on the supplied token. 37 | * 38 | * @param string $envelope Header from a verified authentication token. 39 | * @param string $payload Information from a verified authentication token. 40 | */ 41 | public function __construct($envelope, $payload) 42 | { 43 | $this->envelope = $envelope; 44 | $this->payload = $payload; 45 | } 46 | 47 | /** 48 | * Returns the numeric identifier for the user. 49 | * @throws Google_Auth_Exception 50 | * @return 51 | */ 52 | public function getUserId() 53 | { 54 | if (array_key_exists(self::USER_ATTR, $this->payload)) { 55 | return $this->payload[self::USER_ATTR]; 56 | } 57 | throw new Google_Auth_Exception("No user_id in token"); 58 | } 59 | 60 | /** 61 | * Returns attributes from the login ticket. This can contain 62 | * various information about the user session. 63 | * @return array 64 | */ 65 | public function getAttributes() 66 | { 67 | return array("envelope" => $this->envelope, "payload" => $this->payload); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Auth/Simple.php: -------------------------------------------------------------------------------- 1 | 26 | * @author Chirag Shah 27 | */ 28 | class Google_Auth_Simple extends Google_Auth_Abstract 29 | { 30 | private $key = null; 31 | private $client; 32 | 33 | public function __construct(Google_Client $client, $config = null) 34 | { 35 | $this->client = $client; 36 | } 37 | 38 | /** 39 | * Perform an authenticated / signed apiHttpRequest. 40 | * This function takes the apiHttpRequest, calls apiAuth->sign on it 41 | * (which can modify the request in what ever way fits the auth mechanism) 42 | * and then calls apiCurlIO::makeRequest on the signed request 43 | * 44 | * @param Google_Http_Request $request 45 | * @return Google_Http_Request The resulting HTTP response including the 46 | * responseHttpCode, responseHeaders and responseBody. 47 | */ 48 | public function authenticatedRequest(Google_Http_Request $request) 49 | { 50 | $request = $this->sign($request); 51 | return $this->io->makeRequest($request); 52 | } 53 | 54 | public function sign(Google_Http_Request $request) 55 | { 56 | $key = $this->client->getClassConfig($this, 'developer_key'); 57 | if ($key) { 58 | $request->setQueryParam('key', $key); 59 | } 60 | return $request; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Cache/Abstract.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | abstract class Google_Cache_Abstract 24 | { 25 | 26 | abstract public function __construct(Google_Client $client); 27 | 28 | /** 29 | * Retrieves the data for the given key, or false if they 30 | * key is unknown or expired 31 | * 32 | * @param String $key The key who's data to retrieve 33 | * @param boolean|int $expiration Expiration time in seconds 34 | * 35 | */ 36 | abstract public function get($key, $expiration = false); 37 | 38 | /** 39 | * Store the key => $value set. The $value is serialized 40 | * by this function so can be of any type 41 | * 42 | * @param string $key Key of the data 43 | * @param string $value data 44 | */ 45 | abstract public function set($key, $value); 46 | 47 | /** 48 | * Removes the key/data pair for the given $key 49 | * 50 | * @param String $key 51 | */ 52 | abstract public function delete($key); 53 | } 54 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Cache/Apc.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | class Google_Cache_Apc extends Google_Cache_Abstract 30 | { 31 | public function __construct(Google_Client $client) 32 | { 33 | if (! function_exists('apc_add') ) { 34 | throw new Google_Cache_Exception("Apc functions not available"); 35 | } 36 | } 37 | 38 | /** 39 | * @inheritDoc 40 | */ 41 | public function get($key, $expiration = false) 42 | { 43 | $ret = apc_fetch($key); 44 | if ($ret === false) { 45 | return false; 46 | } 47 | if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { 48 | $this->delete($key); 49 | return false; 50 | } 51 | return $ret['data']; 52 | } 53 | 54 | /** 55 | * @inheritDoc 56 | */ 57 | public function set($key, $value) 58 | { 59 | $rc = apc_store($key, array('time' => time(), 'data' => $value)); 60 | if ($rc == false) { 61 | throw new Google_Cache_Exception("Couldn't store data"); 62 | } 63 | } 64 | 65 | /** 66 | * @inheritDoc 67 | * @param String $key 68 | */ 69 | public function delete($key) 70 | { 71 | apc_delete($key); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Cache/Exception.php: -------------------------------------------------------------------------------- 1 | client = $client; 29 | } 30 | 31 | /** 32 | * Return the associated Google_Client class. 33 | * @return Google_Client 34 | */ 35 | public function getClient() 36 | { 37 | return $this->client; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Service/Exception.php: -------------------------------------------------------------------------------- 1 | = 0) { 28 | parent::__construct($message, $code, $previous); 29 | } else { 30 | parent::__construct($message, $code); 31 | } 32 | 33 | $this->errors = $errors; 34 | } 35 | 36 | /** 37 | * An example of the possible errors returned. 38 | * 39 | * { 40 | * "domain": "global", 41 | * "reason": "authError", 42 | * "message": "Invalid Credentials", 43 | * "locationType": "header", 44 | * "location": "Authorization", 45 | * } 46 | * 47 | * @return [{string, string}] List of errors return in an HTTP response or []. 48 | */ 49 | public function getErrors() 50 | { 51 | return $this->errors; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Signer/Abstract.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | abstract class Google_Signer_Abstract 24 | { 25 | /** 26 | * Signs data, returns the signature as binary data. 27 | */ 28 | abstract public function sign($data); 29 | } 30 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Verifier/Abstract.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | abstract class Google_Verifier_Abstract 24 | { 25 | /** 26 | * Checks a signature, returns true if the signature is correct, 27 | * false otherwise. 28 | */ 29 | abstract public function verify($data, $signature); 30 | } 31 | -------------------------------------------------------------------------------- /includes/oauth-google/Google/Verifier/Pem.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | class Google_Verifier_Pem extends Google_Verifier_Abstract 27 | { 28 | private $publicKey; 29 | 30 | /** 31 | * Constructs a verifier from the supplied PEM-encoded certificate. 32 | * 33 | * $pem: a PEM encoded certificate (not a file). 34 | * @param $pem 35 | * @throws Google_Auth_Exception 36 | * @throws Google_Exception 37 | */ 38 | public function __construct($pem) 39 | { 40 | if (!function_exists('openssl_x509_read')) { 41 | throw new Google_Exception('Google API PHP client needs the openssl PHP extension'); 42 | } 43 | $this->publicKey = openssl_x509_read($pem); 44 | if (!$this->publicKey) { 45 | throw new Google_Auth_Exception("Unable to parse PEM: $pem"); 46 | } 47 | } 48 | 49 | public function __destruct() 50 | { 51 | if ($this->publicKey) { 52 | openssl_x509_free($this->publicKey); 53 | } 54 | } 55 | 56 | /** 57 | * Verifies the signature on data. 58 | * 59 | * Returns true if the signature is valid, false otherwise. 60 | * @param $data 61 | * @param $signature 62 | * @throws Google_Auth_Exception 63 | * @return bool 64 | */ 65 | public function verify($data, $signature) 66 | { 67 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; 68 | $status = openssl_verify($data, $signature, $this->publicKey, $hash); 69 | if ($status === -1) { 70 | throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string()); 71 | } 72 | return $status === 1; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /includes/oauth-google/oauth2callback.php: -------------------------------------------------------------------------------- 1 | $value) { 4 | if ($key != 'code') 5 | continue; 6 | $code=$value; 7 | break; 8 | } 9 | 10 | echo sprintf(' 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 26 | 27 | 28 |
%s%s
21 | %s 22 | 24 | 25 |
29 | 30 |
  • %s
  • 31 |
  • %s"
  • 32 |
      33 |
    1. %s
    2. 34 |
    3. %s
    4. 35 |
    5. %s
    6. 36 |
    37 |
  • 38 | 39 | 53 | ', 54 | _('Google Code'), 55 | _('Actions'), 56 | $code, 57 | _('Copy'), 58 | _('Copy the Google Code.'), 59 | _('Go back to configure Google Contacts Caller-ID Lookup in FreePBX.'), 60 | _('Paste this Google Code into the Google Code box replacing the XXX.'), 61 | _('Hit Save.'), 62 | _('Now run debug again and it should work.'), 63 | _('Close'), 64 | $code, 65 | _('Google Code copied: ')); 66 | ?> 67 | -------------------------------------------------------------------------------- /includes/oauth-php/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2007-2009 Mediamatic Lab 4 | Copyright (c) 2010 Corollarium Technologies 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /includes/oauth-php/README: -------------------------------------------------------------------------------- 1 | Please see http://code.google.com/p/oauth-php/ for documentation and help. 2 | -------------------------------------------------------------------------------- /includes/oauth-php/example/client/twolegged.php: -------------------------------------------------------------------------------- 1 | $key, 'consumer_secret' => $secret); 44 | OAuthStore::instance("2Leg", $options); 45 | 46 | $method = "GET"; 47 | $params = null; 48 | 49 | try 50 | { 51 | // Obtain a request object for the request we want to make 52 | $request = new OAuthRequester($url, $method, $params); 53 | 54 | // Sign the request, perform a curl request and return the results, 55 | // throws OAuthException2 exception on an error 56 | // $result is an array of the form: array ('code'=>int, 'headers'=>array(), 'body'=>string) 57 | $result = $request->doRequest(); 58 | 59 | $response = $result['body']; 60 | var_dump($response); 61 | } 62 | catch(OAuthException2 $e) 63 | { 64 | echo "Exception"; 65 | } 66 | 67 | ?> 68 | -------------------------------------------------------------------------------- /includes/oauth-php/example/client/twoleggedtest.php: -------------------------------------------------------------------------------- 1 | $key, 'consumer_secret' => $secret); 45 | OAuthStore::instance("2Leg", $options); 46 | 47 | $method = "GET"; 48 | $params = null; 49 | 50 | try 51 | { 52 | // Obtain a request object for the request we want to make 53 | $request = new OAuthRequester($url, $method, $params); 54 | 55 | // Sign the request, perform a curl request and return the results, 56 | // throws OAuthException2 exception on an error 57 | // $result is an array of the form: array ('code'=>int, 'headers'=>array(), 'body'=>string) 58 | $result = $request->doRequest(); 59 | 60 | $response = $result['body']; 61 | 62 | if ($response != 'oauth_token=requestkey&oauth_token_secret=requestsecret') 63 | { 64 | echo 'Error! $response ' . $response; 65 | } 66 | else 67 | { 68 | } 69 | 70 | 71 | var_dump($response); 72 | } 73 | catch(OAuthException2 $e) 74 | { 75 | echo "Exception" . $e->getMessage(); 76 | } 77 | 78 | ?> 79 | -------------------------------------------------------------------------------- /includes/oauth-php/example/client/twoleggedtwitter.php: -------------------------------------------------------------------------------- 1 | TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET); 49 | OAuthStore::instance("2Leg", $options); 50 | 51 | try 52 | { 53 | // Obtain a request object for the request we want to make 54 | $request = new OAuthRequester(TWITTER_REQUEST_TOKEN_URL, "POST"); 55 | $result = $request->doRequest(0); 56 | parse_str($result['body'], $params); 57 | 58 | echo "aa"; 59 | 60 | // now make the request. 61 | $request = new OAuthRequester(TWITTER_PUBLIC_TIMELINE_API, 'GET', $params); 62 | $result = $request->doRequest(); 63 | } 64 | catch(OAuthException2 $e) 65 | { 66 | echo "Exception" . $e->getMessage(); 67 | } 68 | 69 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/example/server/INSTALL: -------------------------------------------------------------------------------- 1 | In this example I assume that oauth-php lives in /home/john/src/oauth-php 2 | 3 | 4 | 1) Create a virtual host and set the DB_DSN VARIABLE to the DSN of your (mysql) database. 5 | 6 | Example 7 | 8 | ServerAdmin admin@localhost 9 | ServerName hello.local 10 | DocumentRoot /home/john/src/oauth-php/example/server/www 11 | 12 | UseCanonicalName Off 13 | ServerSignature On 14 | 15 | SetEnv DB_DSN mysql://foo:bar@localhost/oauth_example_server_db 16 | 17 | 18 | Options Indexes FollowSymLinks MultiViews 19 | AllowOverride None 20 | Order allow,deny 21 | Allow from all 22 | 23 | 24 | php_value magic_quotes_gpc 0 25 | php_value register_globals 0 26 | php_value session.auto_start 0 27 | 28 | 29 | 30 | 31 | 32 | 33 | 2) Create the database structure for the server: 34 | 35 | # mysql -u foo -p bar -h localhost < /home/john/src/oauth-php/library/store/mysql/mysql.sql 36 | 37 | 38 | 39 | 3) Download and install smarty into the smarty/core/smarty directory: 40 | 41 | # cd /home/john/src/oauth-php/example/server/core 42 | # wget 'http://www.smarty.net/do_download.php?download_file=Smarty-2.6.19.tar.gz' 43 | # tar zxf Smarty-2.6.19.tar.gz 44 | # mv Smarty-2.6.19 smarty 45 | 46 | 47 | 4) That's it! Point your browser to 48 | 49 | http://hello.local/ 50 | 51 | To get started. 52 | 53 | Arjan Scherpenisse , July 2008 54 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/core/templates/inc/footer.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/core/templates/inc/header.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/core/templates/index.tpl: -------------------------------------------------------------------------------- 1 | {include file='inc/header.tpl'} 2 | 3 |

    OAuth server

    4 | Go to: 5 | 6 | 10 | 11 | Afterwards, make an OAuth test request to http://{$smarty.server.name}/hello to test your connection.

    12 | 13 | {include file='inc/footer.tpl'} 14 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/core/templates/logon.tpl: -------------------------------------------------------------------------------- 1 | {include file='inc/header.tpl'} 2 | 3 |

    Login

    4 | 5 |
    6 | 7 | 8 |
    9 | 10 | 11 |

    12 | 13 |
    14 | 15 | 16 |

    17 | 18 | 19 |
    20 | 21 | {include file='inc/footer.tpl'} 22 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/core/templates/register.tpl: -------------------------------------------------------------------------------- 1 | {include file='inc/header.tpl'} 2 | 3 |

    Register server

    4 | 5 |

    Register a server which is gonna act as an identity client.

    6 | 7 |
    8 | 9 |
    10 | About You 11 | 12 |

    13 |
    14 | 15 |

    16 | 17 |

    18 |
    19 | 20 |

    21 |
    22 | 23 |
    24 | Location Of Your Application Or Site 25 | 26 |

    27 |
    28 | 29 |

    30 | 31 |

    32 |
    33 | 34 |

    35 |
    36 | 37 |
    38 | 39 |
    40 | 41 | {include file='inc/footer.tpl'} 42 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/www/hello.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * 13 | * The MIT License 14 | * 15 | * Copyright (c) 2007-2008 Mediamatic Lab 16 | * 17 | * Permission is hereby granted, free of charge, to any person obtaining a copy 18 | * of this software and associated documentation files (the "Software"), to deal 19 | * in the Software without restriction, including without limitation the rights 20 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | * copies of the Software, and to permit persons to whom the Software is 22 | * furnished to do so, subject to the following conditions: 23 | * 24 | * The above copyright notice and this permission notice shall be included in 25 | * all copies or substantial portions of the Software. 26 | * 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | * THE SOFTWARE. 34 | */ 35 | 36 | require_once '../core/init.php'; 37 | 38 | $authorized = false; 39 | $server = new OAuthServer(); 40 | try 41 | { 42 | if ($server->verifyIfSigned()) 43 | { 44 | $authorized = true; 45 | } 46 | } 47 | catch (OAuthException2 $e) 48 | { 49 | } 50 | 51 | if (!$authorized) 52 | { 53 | header('HTTP/1.1 401 Unauthorized'); 54 | header('Content-Type: text/plain'); 55 | 56 | echo "OAuth Verification Failed: " . $e->getMessage(); 57 | die; 58 | } 59 | 60 | // From here on we are authenticated with OAuth. 61 | 62 | header('Content-type: text/plain'); 63 | echo 'Hello, world!'; 64 | 65 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/example/server/www/index.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * 9 | * The MIT License 10 | * 11 | * Copyright (c) 2007-2008 Mediamatic Lab 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | 32 | require '../core/init.php'; 33 | 34 | $smarty = session_smarty(); 35 | $smarty->display('index.tpl'); 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /includes/oauth-php/example/server/www/logon.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * 11 | * The MIT License 12 | * 13 | * Copyright (c) 2007-2008 Mediamatic Lab 14 | * 15 | * Permission is hereby granted, free of charge, to any person obtaining a copy 16 | * of this software and associated documentation files (the "Software"), to deal 17 | * in the Software without restriction, including without limitation the rights 18 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | * copies of the Software, and to permit persons to whom the Software is 20 | * furnished to do so, subject to the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be included in 23 | * all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | * THE SOFTWARE. 32 | */ 33 | 34 | require_once '../core/init.php'; 35 | 36 | if (isset($_POST['username']) && isset($_POST['password'])) 37 | { 38 | if ($_POST['username'] == USERNAME && $_POST['password'] == PASSWORD) 39 | { 40 | $_SESSION['authorized'] = true; 41 | if (!empty($_REQUEST['goto'])) 42 | { 43 | header('Location: ' . $_REQUEST['goto']); 44 | die; 45 | } 46 | 47 | echo "Logon succesfull."; 48 | die; 49 | } 50 | } 51 | 52 | $smarty = session_smarty(); 53 | $smarty->display('logon.tpl'); 54 | 55 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/example/server/www/oauth.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | * 14 | * The MIT License 15 | * 16 | * Copyright (c) 2007-2008 Mediamatic Lab 17 | * 18 | * Permission is hereby granted, free of charge, to any person obtaining a copy 19 | * of this software and associated documentation files (the "Software"), to deal 20 | * in the Software without restriction, including without limitation the rights 21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | * copies of the Software, and to permit persons to whom the Software is 23 | * furnished to do so, subject to the following conditions: 24 | * 25 | * The above copyright notice and this permission notice shall be included in 26 | * all copies or substantial portions of the Software. 27 | * 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | * THE SOFTWARE. 35 | */ 36 | 37 | require_once '../core/init.php'; 38 | 39 | $server = new OAuthServer(); 40 | 41 | switch($_SERVER['PATH_INFO']) 42 | { 43 | case '/request_token': 44 | $server->requestToken(); 45 | exit; 46 | 47 | case '/access_token': 48 | $server->accessToken(); 49 | exit; 50 | 51 | case '/authorize': 52 | # logon 53 | 54 | assert_logged_in(); 55 | 56 | try 57 | { 58 | $server->authorizeVerify(); 59 | $server->authorizeFinish(true, 1); 60 | } 61 | catch (OAuthException2 $e) 62 | { 63 | header('HTTP/1.1 400 Bad Request'); 64 | header('Content-Type: text/plain'); 65 | 66 | echo "Failed OAuth Request: " . $e->getMessage(); 67 | } 68 | exit; 69 | 70 | 71 | default: 72 | header('HTTP/1.1 500 Internal Server Error'); 73 | header('Content-Type: text/plain'); 74 | echo "Unknown request"; 75 | } 76 | 77 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/example/server/www/register.php: -------------------------------------------------------------------------------- 1 | updateConsumer($_POST, $user_id, true); 14 | 15 | $c = $store->getConsumer($key, $user_id); 16 | echo 'Your consumer key is: ' . $c['consumer_key'] . '
    '; 17 | echo 'Your consumer secret is: ' . $c['consumer_secret'] . '
    '; 18 | } 19 | catch (OAuthException2 $e) 20 | { 21 | echo 'Error: ' . $e->getMessage() . '
    '; 22 | } 23 | } 24 | 25 | 26 | $smarty = session_smarty(); 27 | $smarty->display('register.tpl'); 28 | 29 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/OAuthException2.php: -------------------------------------------------------------------------------- 1 | 8 | * @date Nov 29, 2007 5:33:54 PM 9 | * 10 | * The MIT License 11 | * 12 | * Copyright (c) 2007-2008 Mediamatic Lab 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | */ 32 | 33 | // TODO: something with the HTTP return code matching to the problem 34 | 35 | require_once dirname(__FILE__) . '/OAuthRequestLogger.php'; 36 | 37 | class OAuthException2 extends Exception 38 | { 39 | function __construct ( $message ) 40 | { 41 | Exception::__construct($message); 42 | OAuthRequestLogger::addNote('OAuthException2: '.$message); 43 | } 44 | 45 | } 46 | 47 | 48 | /* vi:set ts=4 sts=4 sw=4 binary noeol: */ 49 | 50 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/OAuthSession.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/oauth-php/library/OAuthStore.php: -------------------------------------------------------------------------------- 1 | 9 | * @date Nov 16, 2007 4:03:30 PM 10 | * 11 | * 12 | * The MIT License 13 | * 14 | * Copyright (c) 2007-2008 Mediamatic Lab 15 | * 16 | * Permission is hereby granted, free of charge, to any person obtaining a copy 17 | * of this software and associated documentation files (the "Software"), to deal 18 | * in the Software without restriction, including without limitation the rights 19 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | * copies of the Software, and to permit persons to whom the Software is 21 | * furnished to do so, subject to the following conditions: 22 | * 23 | * The above copyright notice and this permission notice shall be included in 24 | * all copies or substantial portions of the Software. 25 | * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | * THE SOFTWARE. 33 | */ 34 | 35 | require_once dirname(__FILE__) . '/OAuthException2.php'; 36 | 37 | class OAuthStore 38 | { 39 | static private $instance = false; 40 | 41 | /** 42 | * Request an instance of the OAuthStore 43 | */ 44 | public static function instance ( $store = 'MySQL', $options = array() ) 45 | { 46 | if (!OAuthStore::$instance) 47 | { 48 | // Select the store you want to use 49 | if (strpos($store, '/') === false) 50 | { 51 | $class = 'OAuthStore'.$store; 52 | $file = dirname(__FILE__) . '/store/'.$class.'.php'; 53 | } 54 | else 55 | { 56 | $file = $store; 57 | $store = basename($file, '.php'); 58 | $class = $store; 59 | } 60 | 61 | if (is_file($file)) 62 | { 63 | require_once $file; 64 | 65 | if (class_exists($class)) 66 | { 67 | OAuthStore::$instance = new $class($options); 68 | } 69 | else 70 | { 71 | throw new OAuthException2('Could not find class '.$class.' in file '.$file); 72 | } 73 | } 74 | else 75 | { 76 | throw new OAuthException2('No OAuthStore for '.$store.' (file '.$file.')'); 77 | } 78 | } 79 | return OAuthStore::$instance; 80 | } 81 | } 82 | 83 | 84 | /* vi:set ts=4 sts=4 sw=4 binary noeol: */ 85 | 86 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/session/OAuthSessionAbstract.class.php: -------------------------------------------------------------------------------- 1 | 8 | * 9 | * The MIT License 10 | * 11 | * Copyright (c) 2010 Corollarium Technologies 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | 32 | /** 33 | * This class is used to store Session information on the server. Most 34 | * people will use the $_SESSION based implementation, but you may prefer 35 | * a SQL, Memcache or other implementation. 36 | * 37 | */ 38 | abstract class OAuthSessionAbstract 39 | { 40 | abstract public function get ( $key ); 41 | abstract public function set ( $key, $data ); 42 | } 43 | 44 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/session/OAuthSessionSESSION.php: -------------------------------------------------------------------------------- 1 | 8 | * 9 | * The MIT License 10 | * 11 | * Copyright (c) 2010 Corollarium Technologies 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | 32 | require_once dirname(__FILE__) . '/OAuthSessionAbstract.class.php'; 33 | 34 | class OAuthSessionSESSION extends OAuthSessionAbstract 35 | { 36 | public function __construct( $options = array() ) 37 | { 38 | } 39 | 40 | /** 41 | * Gets a variable value 42 | * 43 | * @param string $key 44 | * @return The value or null if not set. 45 | */ 46 | public function get ( $key ) 47 | { 48 | return @$_SESSION[$key]; 49 | } 50 | 51 | /** 52 | * Sets a variable value 53 | * 54 | * @param string $key The key 55 | * @param any $data The data 56 | */ 57 | public function set ( $key, $data ) 58 | { 59 | $_SESSION[$key] = $data; 60 | } 61 | } 62 | 63 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/signature_method/OAuthSignatureMethod.class.php: -------------------------------------------------------------------------------- 1 | 8 | * @date Sep 8, 2008 12:04:35 PM 9 | * 10 | * The MIT License 11 | * 12 | * Copyright (c) 2007-2008 Mediamatic Lab 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | */ 32 | 33 | abstract class OAuthSignatureMethod 34 | { 35 | /** 36 | * Return the name of this signature 37 | * 38 | * @return string 39 | */ 40 | abstract public function name(); 41 | 42 | /** 43 | * Return the signature for the given request 44 | * 45 | * @param OAuthRequest request 46 | * @param string base_string 47 | * @param string consumer_secret 48 | * @param string token_secret 49 | * @return string 50 | */ 51 | abstract public function signature ( $request, $base_string, $consumer_secret, $token_secret ); 52 | 53 | /** 54 | * Check if the request signature corresponds to the one calculated for the request. 55 | * 56 | * @param OAuthRequest request 57 | * @param string base_string data to be signed, usually the base string, can be a request body 58 | * @param string consumer_secret 59 | * @param string token_secret 60 | * @param string signature from the request, still urlencoded 61 | * @return string 62 | */ 63 | abstract public function verify ( $request, $base_string, $consumer_secret, $token_secret, $signature ); 64 | } 65 | 66 | 67 | /* vi:set ts=4 sts=4 sw=4 binary noeol: */ 68 | 69 | ?> -------------------------------------------------------------------------------- /includes/oauth-php/library/store/mysql/install.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/2_Sequences/SEQUENCES.sql: -------------------------------------------------------------------------------- 1 | CREATE SEQUENCE SEQ_OCT_ID NOCACHE; 2 | 3 | CREATE SEQUENCE SEQ_OCR_ID NOCACHE; 4 | 5 | CREATE SEQUENCE SEQ_OSR_ID NOCACHE; 6 | 7 | CREATE SEQUENCE SEQ_OSN_ID NOCACHE; 8 | 9 | CREATE SEQUENCE SEQ_OLG_ID NOCACHE; 10 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_ADD_CONSUMER_REQUEST_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_ADD_CONSUMER_REQUEST_TOKEN 2 | ( 3 | P_TOKEN_TTL IN NUMBER, -- IN SECOND 4 | P_CONSUMER_KEY IN VARCHAR2, 5 | P_TOKEN IN VARCHAR2, 6 | P_TOKEN_SECRET IN VARCHAR2, 7 | P_CALLBACK_URL IN VARCHAR2, 8 | P_RESULT OUT NUMBER 9 | ) 10 | AS 11 | 12 | -- PROCEDURE TO Add an unautorized request token to our server. 13 | 14 | V_OSR_ID NUMBER; 15 | V_OSR_ID_REF NUMBER; 16 | 17 | V_EXC_NO_SERVER_EXIST EXCEPTION; 18 | BEGIN 19 | 20 | P_RESULT := 0; 21 | 22 | BEGIN 23 | SELECT OSR_ID INTO V_OSR_ID 24 | FROM OAUTH_SERVER_REGISTRY 25 | WHERE OSR_CONSUMER_KEY = P_CONSUMER_KEY 26 | AND OSR_ENABLED = 1; 27 | EXCEPTION 28 | WHEN NO_DATA_FOUND THEN 29 | RAISE V_EXC_NO_SERVER_EXIST; 30 | END; 31 | 32 | 33 | BEGIN 34 | SELECT OST_OSR_ID_REF INTO V_OSR_ID_REF 35 | FROM OAUTH_SERVER_TOKEN 36 | WHERE OST_OSR_ID_REF = V_OSR_ID; 37 | 38 | UPDATE OAUTH_SERVER_TOKEN 39 | SET OST_OSR_ID_REF = V_OSR_ID, 40 | OST_USA_ID_REF = 1, 41 | OST_TOKEN = P_TOKEN, 42 | OST_TOKEN_SECRET = P_TOKEN_SECRET, 43 | OST_TOKEN_TYPE = 'REQUEST', 44 | OST_TOKEN_TTL = SYSDATE + (P_TOKEN_TTL/(24*60*60)), 45 | OST_CALLBACK_URL = P_CALLBACK_URL, 46 | OST_TIMESTAMP = SYSDATE 47 | WHERE OST_OSR_ID_REF = V_OSR_ID_REF; 48 | 49 | 50 | EXCEPTION 51 | WHEN NO_DATA_FOUND THEN 52 | 53 | INSERT INTO OAUTH_SERVER_TOKEN 54 | (OST_ID, OST_OSR_ID_REF, OST_USA_ID_REF, OST_TOKEN, OST_TOKEN_SECRET, OST_TOKEN_TYPE, 55 | OST_TOKEN_TTL, OST_CALLBACK_URL) 56 | VALUES 57 | (SEQ_OCT_ID.NEXTVAL, V_OSR_ID, 1, P_TOKEN, P_TOKEN_SECRET, 'REQUEST', SYSDATE + (P_TOKEN_TTL/(24*60*60)), 58 | P_CALLBACK_URL); 59 | 60 | END; 61 | 62 | 63 | EXCEPTION 64 | WHEN V_EXC_NO_SERVER_EXIST THEN 65 | P_RESULT := 2; -- NO_SERVER_EXIST 66 | WHEN OTHERS THEN 67 | -- CALL THE FUNCTION TO LOG ERRORS 68 | ROLLBACK; 69 | P_RESULT := 1; -- ERROR 70 | END; 71 | / 72 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_ADD_LOG.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_ADD_LOG 2 | ( 3 | P_RECEIVED IN VARCHAR2, 4 | P_SENT IN VARCHAR2, 5 | P_BASE_STRING IN VARCHAR2, 6 | P_NOTES IN VARCHAR2, 7 | P_USA_ID_REF IN NUMBER, 8 | P_REMOTE_IP IN VARCHAR2, 9 | P_RESULT OUT NUMBER 10 | ) 11 | AS 12 | 13 | -- PROCEDURE TO Add an entry to the log table 14 | 15 | BEGIN 16 | 17 | P_RESULT := 0; 18 | 19 | INSERT INTO oauth_log 20 | (OLG_ID, olg_received, olg_sent, olg_base_string, olg_notes, olg_usa_id_ref, olg_remote_ip) 21 | VALUES 22 | (SEQ_OLG_ID.NEXTVAL, P_RECEIVED, P_SENT, P_BASE_STRING, P_NOTES, NVL(P_USA_ID_REF, 0), P_REMOTE_IP); 23 | 24 | 25 | EXCEPTION 26 | WHEN OTHERS THEN 27 | -- CALL THE FUNCTION TO LOG ERRORS 28 | ROLLBACK; 29 | P_RESULT := 1; -- ERROR 30 | END; 31 | / 32 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_ADD_SERVER_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_ADD_SERVER_TOKEN 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_NAME IN VARCHAR2, 6 | P_TOKEN_TYPE IN VARCHAR2, 7 | P_TOKEN IN VARCHAR2, 8 | P_TOKEN_SECRET IN VARCHAR2, 9 | P_TOKEN_INTERVAL_IN_SEC IN NUMBER, 10 | P_RESULT OUT NUMBER 11 | ) 12 | AS 13 | 14 | -- Add a request token we obtained from a server. 15 | V_OCR_ID NUMBER; 16 | V_TOKEN_TTL DATE; 17 | 18 | V_EXC_INVALID_CONSUMER_KEY EXCEPTION; 19 | BEGIN 20 | P_RESULT := 0; 21 | 22 | BEGIN 23 | SELECT OCR_ID INTO V_OCR_ID FROM OAUTH_CONSUMER_REGISTRY 24 | WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY AND OCR_USA_ID_REF = P_USER_ID; 25 | EXCEPTION 26 | WHEN NO_DATA_FOUND THEN 27 | RAISE V_EXC_INVALID_CONSUMER_KEY; 28 | END; 29 | 30 | DELETE FROM OAUTH_CONSUMER_TOKEN 31 | WHERE OCT_OCR_ID_REF = V_OCR_ID 32 | AND OCT_USA_ID_REF = P_USER_ID 33 | AND UPPER(OCT_TOKEN_TYPE) = UPPER(P_TOKEN_TYPE) 34 | AND OCT_NAME = P_NAME; 35 | 36 | IF P_TOKEN_INTERVAL_IN_SEC IS NOT NULL THEN 37 | V_TOKEN_TTL := SYSDATE + (P_TOKEN_INTERVAL_IN_SEC/(24*60*60)); 38 | ELSE 39 | V_TOKEN_TTL := TO_DATE('9999.12.31', 'yyyy.mm.dd'); 40 | END IF; 41 | 42 | INSERT INTO OAUTH_CONSUMER_TOKEN 43 | (OCT_ID, OCT_OCR_ID_REF,OCT_USA_ID_REF, OCT_NAME, OCT_TOKEN, OCT_TOKEN_SECRET, OCT_TOKEN_TYPE, OCT_TIMESTAMP, OCT_TOKEN_TTL) 44 | VALUES 45 | (SEQ_OCT_ID.NEXTVAL, V_OCR_ID, P_USER_ID, P_NAME, P_TOKEN, P_TOKEN_SECRET, UPPER(P_TOKEN_TYPE), SYSDATE, V_TOKEN_TTL); 46 | 47 | EXCEPTION 48 | WHEN V_EXC_INVALID_CONSUMER_KEY THEN 49 | P_RESULT := 2; -- INVALID_CONSUMER_KEY 50 | WHEN OTHERS THEN 51 | -- CALL THE FUNCTION TO LOG ERRORS 52 | ROLLBACK; 53 | P_RESULT := 1; -- ERROR 54 | END; 55 | / 56 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_AUTH_CONSUMER_REQ_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_AUTH_CONSUMER_REQ_TOKEN 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_REFERRER_HOST IN VARCHAR2, 5 | P_VERIFIER IN VARCHAR2, 6 | P_TOKEN IN VARCHAR2, 7 | P_RESULT OUT NUMBER 8 | ) 9 | AS 10 | 11 | -- PROCEDURE TO Fetch the consumer request token, by request token. 12 | BEGIN 13 | P_RESULT := 0; 14 | 15 | 16 | UPDATE OAUTH_SERVER_TOKEN 17 | SET OST_AUTHORIZED = 1, 18 | OST_USA_ID_REF = P_USER_ID, 19 | OST_TIMESTAMP = SYSDATE, 20 | OST_REFERRER_HOST = P_REFERRER_HOST, 21 | OST_VERIFIER = P_VERIFIER 22 | WHERE OST_TOKEN = P_TOKEN 23 | AND OST_TOKEN_TYPE = 'REQUEST'; 24 | 25 | 26 | EXCEPTION 27 | WHEN OTHERS THEN 28 | -- CALL THE FUNCTION TO LOG ERRORS 29 | ROLLBACK; 30 | P_RESULT := 1; -- ERROR 31 | END; 32 | / 33 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_CHECK_SERVER_NONCE.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_CHECK_SERVER_NONCE 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_TOKEN IN VARCHAR2, 5 | P_TIMESTAMP IN NUMBER, 6 | P_MAX_TIMESTAMP_SKEW IN NUMBER, 7 | P_NONCE IN VARCHAR2, 8 | P_RESULT OUT NUMBER 9 | ) 10 | AS 11 | 12 | -- PROCEDURE TO Check an nonce/timestamp combination. Clears any nonce combinations 13 | -- that are older than the one received. 14 | V_IS_MAX NUMBER; 15 | V_MAX_TIMESTAMP NUMBER; 16 | V_IS_DUPLICATE_TIMESTAMP NUMBER; 17 | 18 | V_EXC_INVALID_TIMESTAMP EXCEPTION; 19 | V_EXC_DUPLICATE_TIMESTAMP EXCEPTION; 20 | BEGIN 21 | 22 | P_RESULT := 0; 23 | 24 | BEGIN 25 | SELECT MAX(OSN_TIMESTAMP), 26 | CASE 27 | WHEN MAX(OSN_TIMESTAMP) > (P_TIMESTAMP + P_MAX_TIMESTAMP_SKEW) THEN 1 ELSE 0 28 | END "IS_MAX" INTO V_MAX_TIMESTAMP, V_IS_MAX 29 | FROM OAUTH_SERVER_NONCE 30 | WHERE OSN_CONSUMER_KEY = P_CONSUMER_KEY 31 | AND OSN_TOKEN = P_TOKEN; 32 | 33 | IF V_IS_MAX = 1 THEN 34 | RAISE V_EXC_INVALID_TIMESTAMP; 35 | END IF; 36 | 37 | EXCEPTION 38 | WHEN NO_DATA_FOUND THEN 39 | NULL; 40 | END; 41 | 42 | BEGIN 43 | SELECT 1 INTO V_IS_DUPLICATE_TIMESTAMP FROM DUAL WHERE EXISTS 44 | (SELECT OSN_ID FROM OAUTH_SERVER_NONCE 45 | WHERE OSN_CONSUMER_KEY = P_CONSUMER_KEY 46 | AND OSN_TOKEN = P_TOKEN 47 | AND OSN_TIMESTAMP = P_TIMESTAMP 48 | AND OSN_NONCE = P_NONCE); 49 | 50 | IF V_IS_DUPLICATE_TIMESTAMP = 1 THEN 51 | RAISE V_EXC_DUPLICATE_TIMESTAMP; 52 | END IF; 53 | EXCEPTION 54 | WHEN NO_DATA_FOUND THEN 55 | NULL; 56 | END; 57 | 58 | -- Insert the new combination 59 | INSERT INTO OAUTH_SERVER_NONCE 60 | (OSN_ID, OSN_CONSUMER_KEY, OSN_TOKEN, OSN_TIMESTAMP, OSN_NONCE) 61 | VALUES 62 | (SEQ_OSN_ID.NEXTVAL, P_CONSUMER_KEY, P_TOKEN, P_TIMESTAMP, P_NONCE); 63 | 64 | -- Clean up all timestamps older than the one we just received 65 | DELETE FROM OAUTH_SERVER_NONCE 66 | WHERE OSN_CONSUMER_KEY = P_CONSUMER_KEY 67 | AND OSN_TOKEN = P_TOKEN 68 | AND OSN_TIMESTAMP < (P_TIMESTAMP - P_MAX_TIMESTAMP_SKEW); 69 | 70 | 71 | EXCEPTION 72 | WHEN V_EXC_INVALID_TIMESTAMP THEN 73 | P_RESULT := 2; -- INVALID_TIMESTAMP 74 | WHEN V_EXC_DUPLICATE_TIMESTAMP THEN 75 | P_RESULT := 3; -- DUPLICATE_TIMESTAMP 76 | WHEN OTHERS THEN 77 | -- CALL THE FUNCTION TO LOG ERRORS 78 | ROLLBACK; 79 | P_RESULT := 1; -- ERROR 80 | END; 81 | / 82 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_CONSUMER_STATIC_SAVE.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_CONSUMER_STATIC_SAVE 2 | ( 3 | P_OSR_CONSUMER_KEY IN VARCHAR2, 4 | P_RESULT OUT NUMBER 5 | ) 6 | AS 7 | 8 | -- PROCEDURE TO Fetch the static consumer key for this provider. 9 | BEGIN 10 | P_RESULT := 0; 11 | 12 | 13 | INSERT INTO OAUTH_SERVER_REGISTRY 14 | (OSR_ID, OSR_ENABLED, OSR_STATUS, OSR_USA_ID_REF, OSR_CONSUMER_KEY, OSR_CONSUMER_SECRET, OSR_REQUESTER_NAME, OSR_REQUESTER_EMAIL, OSR_CALLBACK_URI, 15 | OSR_APPLICATION_URI, OSR_APPLICATION_TITLE, OSR_APPLICATION_DESCR, OSR_APPLICATION_NOTES, 16 | OSR_APPLICATION_TYPE, OSR_APPLICATION_COMMERCIAL, OSR_TIMESTAMP,OSR_ISSUE_DATE) 17 | VALUES 18 | (SEQ_OSR_ID.NEXTVAL, 1, 'ACTIVE', NULL, P_OSR_CONSUMER_KEY, '\', '\', '\', '\', '\', 19 | 'STATIC SHARED CONSUMER KEY', '\', 'STATIC SHARED CONSUMER KEY', '\', 0, SYSDATE, SYSDATE); 20 | 21 | 22 | EXCEPTION 23 | WHEN OTHERS THEN 24 | -- CALL THE FUNCTION TO LOG ERRORS 25 | ROLLBACK; 26 | P_RESULT := 1; -- ERROR 27 | END; 28 | / 29 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_COUNT_CONSUMER_ACCESS_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_COUNT_CONSUMER_ACCESS_TOKEN 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_COUNT OUT NUMBER, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | -- PROCEDURE TO Count the consumer access tokens for the given consumer. 9 | BEGIN 10 | P_RESULT := 0; 11 | 12 | SELECT COUNT(OST_ID) INTO P_COUNT 13 | FROM OAUTH_SERVER_TOKEN 14 | JOIN OAUTH_SERVER_REGISTRY 15 | ON OST_OSR_ID_REF = OSR_ID 16 | WHERE OST_TOKEN_TYPE = 'ACCESS' 17 | AND OSR_CONSUMER_KEY = P_CONSUMER_KEY 18 | AND OST_TOKEN_TTL >= SYSDATE; 19 | 20 | 21 | EXCEPTION 22 | WHEN OTHERS THEN 23 | -- CALL THE FUNCTION TO LOG ERRORS 24 | ROLLBACK; 25 | P_RESULT := 1; -- ERROR 26 | END; 27 | / 28 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_COUNT_SERVICE_TOKENS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_COUNT_SERVICE_TOKENS 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_COUNT OUT NUMBER, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Count how many tokens we have for the given server 10 | BEGIN 11 | P_RESULT := 0; 12 | 13 | SELECT COUNT(OCT_ID) INTO P_COUNT 14 | FROM OAUTH_CONSUMER_TOKEN 15 | JOIN OAUTH_CONSUMER_REGISTRY 16 | ON OCT_OCR_ID_REF = OCR_ID 17 | WHERE OCT_TOKEN_TYPE = 'ACCESS' 18 | AND OCR_CONSUMER_KEY = P_CONSUMER_KEY 19 | AND OCT_TOKEN_TTL >= SYSDATE; 20 | 21 | 22 | EXCEPTION 23 | WHEN OTHERS THEN 24 | -- CALL THE FUNCTION TO LOG ERRORS 25 | ROLLBACK; 26 | P_RESULT := 1; -- ERROR 27 | END; 28 | / 29 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_DELETE_CONSUMER.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_DELETE_CONSUMER 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_USER_IS_ADMIN IN NUMBER, --0:NO; 1:YES 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- Delete a consumer key. This removes access to our site for all applications using this key. 11 | 12 | BEGIN 13 | P_RESULT := 0; 14 | 15 | IF P_USER_IS_ADMIN = 1 THEN 16 | 17 | DELETE FROM OAUTH_SERVER_REGISTRY 18 | WHERE OSR_CONSUMER_KEY = P_CONSUMER_KEY 19 | AND (OSR_USA_ID_REF = P_USER_ID OR OSR_USA_ID_REF IS NULL); 20 | 21 | ELSIF P_USER_IS_ADMIN = 0 THEN 22 | 23 | DELETE FROM OAUTH_SERVER_REGISTRY 24 | WHERE OSR_CONSUMER_KEY = P_CONSUMER_KEY 25 | AND OSR_USA_ID_REF = P_USER_ID; 26 | 27 | END IF; 28 | 29 | EXCEPTION 30 | WHEN OTHERS THEN 31 | -- CALL THE FUNCTION TO LOG ERRORS 32 | ROLLBACK; 33 | P_RESULT := 1; -- ERROR 34 | END; 35 | / 36 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_DELETE_SERVER.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_DELETE_SERVER 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_USER_IS_ADMIN IN NUMBER, --0:NO; 1:YES 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- Delete a server key. This removes access to that site. 11 | 12 | BEGIN 13 | P_RESULT := 0; 14 | 15 | IF P_USER_IS_ADMIN = 1 THEN 16 | 17 | DELETE FROM OAUTH_CONSUMER_REGISTRY 18 | WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY 19 | AND (OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL); 20 | 21 | ELSIF P_USER_IS_ADMIN = 0 THEN 22 | 23 | DELETE FROM OAUTH_CONSUMER_REGISTRY 24 | WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY 25 | AND OCR_USA_ID_REF = P_USER_ID; 26 | 27 | END IF; 28 | 29 | EXCEPTION 30 | WHEN OTHERS THEN 31 | -- CALL THE FUNCTION TO LOG ERRORS 32 | ROLLBACK; 33 | P_RESULT := 1; -- ERROR 34 | END; 35 | / 36 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_DELETE_SERVER_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_DELETE_SERVER_TOKEN 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_TOKEN IN VARCHAR2, 6 | P_USER_IS_ADMIN IN NUMBER, --0:NO; 1:YES 7 | P_RESULT OUT NUMBER 8 | ) 9 | AS 10 | 11 | -- Delete a token we obtained from a server. 12 | 13 | BEGIN 14 | P_RESULT := 0; 15 | 16 | IF P_USER_IS_ADMIN = 1 THEN 17 | 18 | DELETE FROM OAUTH_CONSUMER_TOKEN 19 | WHERE OCT_TOKEN = P_TOKEN 20 | AND OCT_OCR_ID_REF IN (SELECT OCR_ID FROM OAUTH_CONSUMER_REGISTRY WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY); 21 | 22 | ELSIF P_USER_IS_ADMIN = 0 THEN 23 | 24 | DELETE FROM OAUTH_CONSUMER_TOKEN 25 | WHERE OCT_TOKEN = P_TOKEN 26 | AND OCT_USA_ID_REF = P_USER_ID 27 | AND OCT_OCR_ID_REF IN (SELECT OCR_ID FROM OAUTH_CONSUMER_REGISTRY WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY); 28 | 29 | END IF; 30 | 31 | EXCEPTION 32 | WHEN OTHERS THEN 33 | -- CALL THE FUNCTION TO LOG ERRORS 34 | ROLLBACK; 35 | P_RESULT := 1; -- ERROR 36 | END; 37 | / 38 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_DEL_CONSUMER_ACCESS_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_DEL_CONSUMER_ACCESS_TOKEN 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_TOKEN IN VARCHAR2, 5 | P_USER_IS_ADMIN IN NUMBER, -- 1:YES; 0:NO 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- PROCEDURE TO Delete a consumer access token. 11 | 12 | BEGIN 13 | 14 | P_RESULT := 0; 15 | 16 | IF P_USER_IS_ADMIN = 1 THEN 17 | DELETE FROM OAUTH_SERVER_TOKEN 18 | WHERE OST_TOKEN = P_TOKEN 19 | AND OST_TOKEN_TYPE = 'ACCESS'; 20 | ELSE 21 | DELETE FROM OAUTH_SERVER_TOKEN 22 | WHERE OST_TOKEN = P_TOKEN 23 | AND OST_TOKEN_TYPE = 'ACCESS' 24 | AND OST_USA_ID_REF = P_USER_ID; 25 | END IF; 26 | 27 | EXCEPTION 28 | WHEN OTHERS THEN 29 | -- CALL THE FUNCTION TO LOG ERRORS 30 | ROLLBACK; 31 | P_RESULT := 1; -- ERROR 32 | END; 33 | / 34 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_DEL_CONSUMER_REQUEST_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_DEL_CONSUMER_REQUEST_TOKEN 2 | ( 3 | P_TOKEN IN VARCHAR2, 4 | P_RESULT OUT NUMBER 5 | ) 6 | AS 7 | 8 | -- PROCEDURE TO Delete a consumer token. The token must be a request or authorized token. 9 | 10 | BEGIN 11 | 12 | P_RESULT := 0; 13 | 14 | DELETE FROM OAUTH_SERVER_TOKEN 15 | WHERE OST_TOKEN = P_TOKEN 16 | AND OST_TOKEN_TYPE = 'REQUEST'; 17 | 18 | 19 | EXCEPTION 20 | WHEN OTHERS THEN 21 | -- CALL THE FUNCTION TO LOG ERRORS 22 | ROLLBACK; 23 | P_RESULT := 1; -- ERROR 24 | END; 25 | / 26 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_CONSUMER.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_CONSUMER 2 | ( 3 | P_CONSUMER_KEY IN STRING, 4 | P_ROWS OUT TYPES.REF_CURSOR, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Fetch a consumer of this server, by consumer_key. 10 | BEGIN 11 | P_RESULT := 0; 12 | 13 | OPEN P_ROWS FOR 14 | SELECT OSR_ID "osr_id", 15 | OSR_USA_ID_REF "osr_usa_id_ref", 16 | OSR_CONSUMER_KEY "osr_consumer_key", 17 | OSR_CONSUMER_SECRET "osr_consumer_secret", 18 | OSR_ENABLED "osr_enabled", 19 | OSR_STATUS "osr_status", 20 | OSR_REQUESTER_NAME "osr_requester_name", 21 | OSR_REQUESTER_EMAIL "osr_requester_email", 22 | OSR_CALLBACK_URI "osr_callback_uri", 23 | OSR_APPLICATION_URI "osr_application_uri", 24 | OSR_APPLICATION_TITLE "osr_application_title", 25 | OSR_APPLICATION_DESCR "osr_application_descr", 26 | OSR_APPLICATION_NOTES "osr_application_notes", 27 | OSR_APPLICATION_TYPE "osr_application_type", 28 | OSR_APPLICATION_COMMERCIAL "osr_application_commercial", 29 | OSR_ISSUE_DATE "osr_issue_date", 30 | OSR_TIMESTAMP "osr_timestamp" 31 | FROM OAUTH_SERVER_REGISTRY 32 | WHERE OSR_CONSUMER_KEY = P_CONSUMER_KEY; 33 | 34 | 35 | EXCEPTION 36 | WHEN OTHERS THEN 37 | -- CALL THE FUNCTION TO LOG ERRORS 38 | ROLLBACK; 39 | P_RESULT := 1; -- ERROR 40 | END; 41 | / 42 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_CONSUMER_ACCESS_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_CONSUMER_ACCESS_TOKEN 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_TOKEN IN VARCHAR2, 5 | P_ROWS OUT TYPES.REF_CURSOR, 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- PROCEDURE TO Fetch the consumer access token, by access token. 11 | 12 | BEGIN 13 | 14 | P_RESULT := 0; 15 | 16 | 17 | OPEN P_ROWS FOR 18 | SELECT OST_TOKEN "token", 19 | OST_TOKEN_SECRET "token_secret", 20 | OST_REFERRER_HOST "token_referrer_host", 21 | OSR_CONSUMER_KEY "consumer_key", 22 | OSR_CONSUMER_SECRET "consumer_secret", 23 | OSR_APPLICATION_URI "application_uri", 24 | OSR_APPLICATION_TITLE "application_title", 25 | OSR_APPLICATION_DESCR "application_descr", 26 | OSR_CALLBACK_URI "callback_uri" 27 | FROM OAUTH_SERVER_TOKEN 28 | JOIN OAUTH_SERVER_REGISTRY 29 | ON OST_OSR_ID_REF = OSR_ID 30 | WHERE OST_TOKEN_TYPE = 'ACCESS' 31 | AND OST_TOKEN = P_TOKEN 32 | AND OST_USA_ID_REF = P_USER_ID 33 | AND OST_TOKEN_TTL >= SYSDATE; 34 | 35 | 36 | 37 | EXCEPTION 38 | WHEN OTHERS THEN 39 | -- CALL THE FUNCTION TO LOG ERRORS 40 | ROLLBACK; 41 | P_RESULT := 1; -- ERROR 42 | END; 43 | / 44 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_CONSUMER_REQUEST_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_CONSUMER_REQUEST_TOKEN 2 | ( 3 | P_TOKEN IN VARCHAR2, 4 | P_ROWS OUT TYPES.REF_CURSOR, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Fetch the consumer request token, by request token. 10 | BEGIN 11 | P_RESULT := 0; 12 | 13 | OPEN P_ROWS FOR 14 | 15 | SELECT OST_TOKEN "token", 16 | OST_TOKEN_SECRET "token_secret", 17 | OSR_CONSUMER_KEY "consumer_key", 18 | OSR_CONSUMER_SECRET "consumer_secret", 19 | OST_TOKEN_TYPE "token_type", 20 | OST_CALLBACK_URL "callback_url", 21 | OSR_APPLICATION_TITLE "application_title", 22 | OSR_APPLICATION_DESCR "application_descr", 23 | OSR_APPLICATION_URI "application_uri" 24 | FROM OAUTH_SERVER_TOKEN 25 | JOIN OAUTH_SERVER_REGISTRY 26 | ON OST_OSR_ID_REF = OSR_ID 27 | WHERE OST_TOKEN_TYPE = 'REQUEST' 28 | AND OST_TOKEN = P_TOKEN 29 | AND OST_TOKEN_TTL >= SYSDATE; 30 | 31 | 32 | 33 | 34 | 35 | EXCEPTION 36 | WHEN OTHERS THEN 37 | -- CALL THE FUNCTION TO LOG ERRORS 38 | ROLLBACK; 39 | P_RESULT := 1; -- ERROR 40 | END; 41 | / 42 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_CONSUMER_STATIC_SELECT.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_CONSUMER_STATIC_SELECT 2 | ( 3 | P_OSR_CONSUMER_KEY OUT VARCHAR2, 4 | P_RESULT OUT NUMBER 5 | ) 6 | AS 7 | 8 | -- PROCEDURE TO Fetch the static consumer key for this provider. 9 | BEGIN 10 | P_RESULT := 0; 11 | 12 | 13 | SELECT OSR_CONSUMER_KEY INTO P_OSR_CONSUMER_KEY 14 | FROM OAUTH_SERVER_REGISTRY 15 | WHERE OSR_CONSUMER_KEY LIKE 'sc-%%' 16 | AND OSR_USA_ID_REF IS NULL; 17 | 18 | 19 | EXCEPTION 20 | WHEN OTHERS THEN 21 | -- CALL THE FUNCTION TO LOG ERRORS 22 | ROLLBACK; 23 | P_RESULT := 1; -- ERROR 24 | END; 25 | / 26 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SECRETS_FOR_SIGNATURE.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SECRETS_FOR_SIGNATURE 2 | ( 3 | P_HOST IN VARCHAR2, 4 | P_PATH IN VARCHAR2, 5 | P_USER_ID IN NUMBER, 6 | P_NAME IN VARCHAR2, 7 | P_ROWS OUT TYPES.REF_CURSOR, 8 | P_RESULT OUT NUMBER 9 | ) 10 | AS 11 | 12 | -- PROCEDURE TO Find the server details for signing a request, always looks for an access token. 13 | -- The returned credentials depend on which local user is making the request. 14 | BEGIN 15 | P_RESULT := 0; 16 | 17 | OPEN P_ROWS FOR 18 | SELECT * FROM ( 19 | SELECT OCR_CONSUMER_KEY "consumer_key", 20 | OCR_CONSUMER_SECRET "consumer_secret", 21 | OCT_TOKEN "token", 22 | OCT_TOKEN_SECRET "token_secret", 23 | OCR_SIGNATURE_METHODS "signature_methods" 24 | FROM OAUTH_CONSUMER_REGISTRY 25 | JOIN OAUTH_CONSUMER_TOKEN ON OCT_OCR_ID_REF = OCR_ID 26 | WHERE OCR_SERVER_URI_HOST = P_HOST 27 | AND OCR_SERVER_URI_PATH = SUBSTR(P_PATH, 1, LENGTH(OCR_SERVER_URI_PATH)) 28 | AND (OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL) 29 | AND OCT_USA_ID_REF = P_USER_ID 30 | AND OCT_TOKEN_TYPE = 'ACCESS' 31 | AND OCT_NAME = P_NAME 32 | AND OCT_TOKEN_TTL >= SYSDATE 33 | ORDER BY OCR_USA_ID_REF DESC, OCR_CONSUMER_SECRET DESC, LENGTH(OCR_SERVER_URI_PATH) DESC 34 | ) WHERE ROWNUM<=1; 35 | 36 | 37 | EXCEPTION 38 | WHEN OTHERS THEN 39 | -- CALL THE FUNCTION TO LOG ERRORS 40 | ROLLBACK; 41 | P_RESULT := 1; -- ERROR 42 | END; 43 | / 44 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SECRETS_FOR_VERIFY.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SECRETS_FOR_VERIFY 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_TOKEN IN VARCHAR2, 5 | P_TOKEN_TYPE IN VARCHAR2, 6 | P_ROWS OUT TYPES.REF_CURSOR, 7 | P_RESULT OUT NUMBER 8 | ) 9 | AS 10 | 11 | -- PROCEDURE to Find stored credentials for the consumer key and token. Used by an OAuth server 12 | -- when verifying an OAuth request. 13 | 14 | BEGIN 15 | P_RESULT := 0; 16 | 17 | IF P_TOKEN_TYPE IS NULL THEN 18 | OPEN P_ROWS FOR 19 | SELECT OSR.OSR_ID "osr_id", 20 | OSR.OSR_CONSUMER_KEY "consumer_key", 21 | OSR.OSR_CONSUMER_SECRET "consumer_secret" 22 | FROM OAUTH_SERVER_REGISTRY OSR 23 | WHERE OSR.OSR_CONSUMER_KEY = P_CONSUMER_KEY 24 | AND OSR.OSR_ENABLED = 1; 25 | ELSE 26 | OPEN P_ROWS FOR 27 | SELECT OSR.OSR_ID "osr_id", 28 | OST.OST_ID "ost_id", 29 | OST.OST_USA_ID_REF "user_id", 30 | OSR.OSR_CONSUMER_KEY "consumer_key", 31 | OSR.OSR_CONSUMER_SECRET "consumer_secret", 32 | OST.OST_TOKEN "token", 33 | OST.OST_TOKEN_SECRET "token_secret" 34 | FROM OAUTH_SERVER_REGISTRY OSR, OAUTH_SERVER_TOKEN OST 35 | WHERE OST.OST_OSR_ID_REF = OSR.OSR_ID 36 | AND upper(OST.OST_TOKEN_TYPE) = upper(P_TOKEN_TYPE) 37 | AND OSR.OSR_CONSUMER_KEY = P_CONSUMER_KEY 38 | AND OST.OST_TOKEN = P_TOKEN 39 | AND OSR.OSR_ENABLED = 1 40 | AND OST.OST_TOKEN_TTL >= SYSDATE; 41 | 42 | END IF; 43 | 44 | 45 | 46 | EXCEPTION 47 | WHEN OTHERS THEN 48 | -- CALL THE FUNCTION TO LOG ERRORS 49 | ROLLBACK; 50 | P_RESULT := 1; -- ERROR 51 | END; 52 | / 53 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SERVER.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SERVER 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_ROWS OUT TYPES.REF_CURSOR, 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- PROCEDURE TO Get a server from the consumer registry using the consumer key 11 | BEGIN 12 | P_RESULT := 0; 13 | 14 | OPEN P_ROWS FOR 15 | SELECT OCR_ID "id", 16 | OCR_USA_ID_REF "user_id", 17 | OCR_CONSUMER_KEY "consumer_key", 18 | OCR_CONSUMER_SECRET "consumer_secret", 19 | OCR_SIGNATURE_METHODS "signature_methods", 20 | OCR_SERVER_URI "server_uri", 21 | OCR_REQUEST_TOKEN_URI "request_token_uri", 22 | OCR_AUTHORIZE_URI "authorize_uri", 23 | OCR_ACCESS_TOKEN_URI "access_token_uri" 24 | FROM OAUTH_CONSUMER_REGISTRY 25 | WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY 26 | AND (OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL); 27 | 28 | 29 | EXCEPTION 30 | WHEN OTHERS THEN 31 | -- CALL THE FUNCTION TO LOG ERRORS 32 | ROLLBACK; 33 | P_RESULT := 1; -- ERROR 34 | END; 35 | / 36 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SERVER_FOR_URI.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SERVER_FOR_URI 2 | ( 3 | P_HOST IN VARCHAR2, 4 | P_PATH IN VARCHAR2, 5 | P_USER_ID IN NUMBER, 6 | P_ROWS OUT TYPES.REF_CURSOR, 7 | P_RESULT OUT NUMBER 8 | ) 9 | AS 10 | 11 | -- PROCEDURE TO Find the server details that might be used for a request 12 | BEGIN 13 | P_RESULT := 0; 14 | 15 | OPEN P_ROWS FOR 16 | SELECT * FROM ( 17 | SELECT OCR_ID "id", 18 | OCR_USA_ID_REF "user_id", 19 | OCR_CONSUMER_KEY "consumer_key", 20 | OCR_CONSUMER_SECRET "consumer_secret", 21 | OCR_SIGNATURE_METHODS "signature_methods", 22 | OCR_SERVER_URI "server_uri", 23 | OCR_REQUEST_TOKEN_URI "request_token_uri", 24 | OCR_AUTHORIZE_URI "authorize_uri", 25 | OCR_ACCESS_TOKEN_URI "access_token_uri" 26 | FROM OAUTH_CONSUMER_REGISTRY 27 | WHERE OCR_SERVER_URI_HOST = P_HOST 28 | AND OCR_SERVER_URI_PATH = SUBSTR(P_PATH, 1, LENGTH(OCR_SERVER_URI_PATH)) 29 | AND (OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL) 30 | ORDER BY ocr_usa_id_ref DESC, OCR_CONSUMER_KEY DESC, LENGTH(ocr_server_uri_path) DESC 31 | ) WHERE ROWNUM<=1; 32 | 33 | 34 | 35 | EXCEPTION 36 | WHEN OTHERS THEN 37 | -- CALL THE FUNCTION TO LOG ERRORS 38 | ROLLBACK; 39 | P_RESULT := 1; -- ERROR 40 | END; 41 | / 42 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SERVER_TOKEN.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SERVER_TOKEN 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_TOKEN IN VARCHAR2, 6 | P_ROWS OUT TYPES.REF_CURSOR, 7 | P_RESULT OUT NUMBER 8 | ) 9 | AS 10 | 11 | -- PROCEDURE TO Get a specific server token for the given user 12 | BEGIN 13 | P_RESULT := 0; 14 | 15 | OPEN P_ROWS FOR 16 | SELECT OCR_CONSUMER_KEY "consumer_key", 17 | OCR_CONSUMER_SECRET "consumer_secret", 18 | OCT_TOKEN "token", 19 | OCT_TOKEN_SECRET "token_secret", 20 | OCT_USA_ID_REF "usr_id", 21 | OCR_SIGNATURE_METHODS "signature_methods", 22 | OCR_SERVER_URI "server_uri", 23 | OCR_SERVER_URI_HOST "server_uri_host", 24 | OCR_SERVER_URI_PATH "server_uri_path", 25 | OCR_REQUEST_TOKEN_URI "request_token_uri", 26 | OCR_AUTHORIZE_URI "authorize_uri", 27 | OCR_ACCESS_TOKEN_URI "access_token_uri", 28 | OCT_TIMESTAMP "timestamp" 29 | FROM OAUTH_CONSUMER_REGISTRY 30 | JOIN OAUTH_CONSUMER_TOKEN 31 | ON OCT_OCR_ID_REF = OCR_ID 32 | WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY 33 | AND OCT_USA_ID_REF = P_USER_ID 34 | AND OCT_TOKEN_TYPE = 'ACCESS' 35 | AND OCT_TOKEN = P_TOKEN 36 | AND OCT_TOKEN_TTL >= SYSDATE; 37 | 38 | 39 | EXCEPTION 40 | WHEN OTHERS THEN 41 | -- CALL THE FUNCTION TO LOG ERRORS 42 | ROLLBACK; 43 | P_RESULT := 1; -- ERROR 44 | END; 45 | / 46 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_GET_SERVER_TOKEN_SECRETS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_GET_SERVER_TOKEN_SECRETS 2 | ( 3 | P_CONSUMER_KEY IN VARCHAR2, 4 | P_TOKEN IN VARCHAR2, 5 | P_TOKEN_TYPE IN VARCHAR2, 6 | P_USER_ID IN NUMBER, 7 | P_ROWS OUT TYPES.REF_CURSOR, 8 | P_RESULT OUT NUMBER 9 | ) 10 | AS 11 | 12 | -- Get the token and token secret we obtained from a server. 13 | 14 | BEGIN 15 | P_RESULT := 0; 16 | 17 | 18 | OPEN P_ROWS FOR 19 | SELECT OCR.OCR_CONSUMER_KEY "consumer_key", 20 | OCR.OCR_CONSUMER_SECRET "consumer_secret", 21 | OCT.OCT_TOKEN "token", 22 | OCT.OCT_TOKEN_SECRET "token_secret", 23 | OCT.OCT_NAME "token_name", 24 | OCR.OCR_SIGNATURE_METHODS "signature_methods", 25 | OCR.OCR_SERVER_URI "server_uri", 26 | OCR.OCR_REQUEST_TOKEN_URI "request_token_uri", 27 | OCR.OCR_AUTHORIZE_URI "authorize_uri", 28 | OCR.OCR_ACCESS_TOKEN_URI "access_token_uri", 29 | CASE WHEN OCT.OCT_TOKEN_TTL >= TO_DATE('9999.12.31', 'yyyy.mm.dd') THEN NULL 30 | ELSE OCT.OCT_TOKEN_TTL - SYSDATE 31 | END "token_ttl" 32 | FROM OAUTH_CONSUMER_REGISTRY OCR, OAUTH_CONSUMER_TOKEN OCT 33 | WHERE OCT.OCT_OCR_ID_REF = OCR_ID 34 | AND OCR.OCR_CONSUMER_KEY = P_CONSUMER_KEY 35 | AND upper(OCT.OCT_TOKEN_TYPE) = upper(P_TOKEN_TYPE) 36 | AND OCT.OCT_TOKEN = P_TOKEN 37 | AND OCT.OCT_USA_ID_REF = P_USER_ID 38 | AND OCT.OCT_TOKEN_TTL >= SYSDATE; 39 | 40 | 41 | EXCEPTION 42 | WHEN OTHERS THEN 43 | -- CALL THE FUNCTION TO LOG ERRORS 44 | ROLLBACK; 45 | P_RESULT := 1; -- ERROR 46 | END; 47 | / 48 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_LIST_CONSUMERS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_LIST_CONSUMERS 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_ROWS OUT TYPES.REF_CURSOR, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Fetch a list of all consumer keys, secrets etc. 10 | -- Returns the public (user_id is null) and the keys owned by the user 11 | 12 | BEGIN 13 | 14 | P_RESULT := 0; 15 | 16 | OPEN P_ROWS FOR 17 | SELECT OSR_ID "id", 18 | OSR_USA_ID_REF "user_id", 19 | OSR_CONSUMER_KEY "consumer_key", 20 | OSR_CONSUMER_SECRET "consumer_secret", 21 | OSR_ENABLED "enabled", 22 | OSR_STATUS "status", 23 | OSR_ISSUE_DATE "issue_date", 24 | OSR_APPLICATION_URI "application_uri", 25 | OSR_APPLICATION_TITLE "application_title", 26 | OSR_APPLICATION_DESCR "application_descr", 27 | OSR_REQUESTER_NAME "requester_name", 28 | OSR_REQUESTER_EMAIL "requester_email", 29 | OSR_CALLBACK_URI "callback_uri" 30 | FROM OAUTH_SERVER_REGISTRY 31 | WHERE (OSR_USA_ID_REF = P_USER_ID OR OSR_USA_ID_REF IS NULL) 32 | ORDER BY OSR_APPLICATION_TITLE; 33 | 34 | 35 | EXCEPTION 36 | WHEN OTHERS THEN 37 | -- CALL THE FUNCTION TO LOG ERRORS 38 | ROLLBACK; 39 | P_RESULT := 1; -- ERROR 40 | END; 41 | / 42 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_LIST_CONSUMER_TOKENS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_LIST_CONSUMER_TOKENS 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_ROWS OUT TYPES.REF_CURSOR, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Fetch a list of all consumer tokens accessing the account of the given user. 10 | 11 | BEGIN 12 | 13 | P_RESULT := 0; 14 | 15 | OPEN P_ROWS FOR 16 | SELECT OSR_CONSUMER_KEY "consumer_key", 17 | OSR_CONSUMER_SECRET "consumer_secret", 18 | OSR_ENABLED "enabled", 19 | OSR_STATUS "status", 20 | OSR_APPLICATION_URI "application_uri", 21 | OSR_APPLICATION_TITLE "application_title", 22 | OSR_APPLICATION_DESCR "application_descr", 23 | OST_TIMESTAMP "timestamp", 24 | OST_TOKEN "token", 25 | OST_TOKEN_SECRET "token_secret", 26 | OST_REFERRER_HOST "token_referrer_host", 27 | OSR_CALLBACK_URI "callback_uri" 28 | FROM OAUTH_SERVER_REGISTRY 29 | JOIN OAUTH_SERVER_TOKEN 30 | ON OST_OSR_ID_REF = OSR_ID 31 | WHERE OST_USA_ID_REF = P_USER_ID 32 | AND OST_TOKEN_TYPE = 'ACCESS' 33 | AND OST_TOKEN_TTL >= SYSDATE 34 | ORDER BY OSR_APPLICATION_TITLE; 35 | 36 | 37 | EXCEPTION 38 | WHEN OTHERS THEN 39 | -- CALL THE FUNCTION TO LOG ERRORS 40 | ROLLBACK; 41 | P_RESULT := 1; -- ERROR 42 | END; 43 | / 44 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_LIST_LOG.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_LIST_LOG 2 | ( 3 | P_OPTION_FLAG IN NUMBER, -- 0:NULL; 1:OTHERWISE 4 | P_USA_ID IN NUMBER, 5 | P_OSR_CONSUMER_KEY IN VARCHAR2, 6 | P_OCR_CONSUMER_KEY IN VARCHAR2, 7 | P_OST_TOKEN IN VARCHAR2, 8 | P_OCT_TOKEN IN VARCHAR2, 9 | P_ROWS OUT TYPES.REF_CURSOR, 10 | P_RESULT OUT NUMBER 11 | ) 12 | AS 13 | 14 | -- PROCEDURE TO Get a page of entries from the log. Returns the last 100 records 15 | -- matching the options given. 16 | 17 | BEGIN 18 | 19 | P_RESULT := 0; 20 | 21 | IF P_OPTION_FLAG IS NULL OR P_OPTION_FLAG = 0 THEN 22 | OPEN P_ROWS FOR 23 | SELECT * FROM ( 24 | SELECT OLG_ID "olg_id", 25 | OLG_OSR_CONSUMER_KEY "osr_consumer_key", 26 | OLG_OST_TOKEN "ost_token", 27 | OLG_OCR_CONSUMER_KEY "ocr_consumer_key", 28 | OLG_OCT_TOKEN "oct_token", 29 | OLG_USA_ID_REF "user_id", 30 | OLG_RECEIVED "received", 31 | OLG_SENT "sent", 32 | OLG_BASE_STRING "base_string", 33 | OLG_NOTES "notes", 34 | OLG_TIMESTAMP "timestamp", 35 | -- INET_NTOA(OLG_REMOTE_IP) "remote_ip" 36 | OLG_REMOTE_IP "remote_ip" 37 | FROM OAUTH_LOG 38 | WHERE OLG_USA_ID_REF = P_USA_ID 39 | ORDER BY OLG_ID DESC 40 | ) WHERE ROWNUM<=100; 41 | ELSE 42 | OPEN P_ROWS FOR 43 | SELECT * FROM ( 44 | SELECT OLG_ID "olg_id", 45 | OLG_OSR_CONSUMER_KEY "osr_consumer_key", 46 | OLG_OST_TOKEN "ost_token", 47 | OLG_OCR_CONSUMER_KEY "ocr_consumer_key", 48 | OLG_OCT_TOKEN "oct_token", 49 | OLG_USA_ID_REF "user_id", 50 | OLG_RECEIVED "received", 51 | OLG_SENT "sent", 52 | OLG_BASE_STRING "base_string", 53 | OLG_NOTES "notes", 54 | OLG_TIMESTAMP "timestamp", 55 | -- INET_NTOA(OLG_REMOTE_IP) "remote_ip" 56 | OLG_REMOTE_IP "remote_ip" 57 | FROM OAUTH_LOG 58 | WHERE OLG_OSR_CONSUMER_KEY = P_OSR_CONSUMER_KEY 59 | AND OLG_OCR_CONSUMER_KEY = P_OCR_CONSUMER_KEY 60 | AND OLG_OST_TOKEN = P_OST_TOKEN 61 | AND OLG_OCT_TOKEN = P_OCT_TOKEN 62 | AND (OLG_USA_ID_REF IS NULL OR OLG_USA_ID_REF = P_USA_ID) 63 | ORDER BY OLG_ID DESC 64 | ) WHERE ROWNUM<=100; 65 | 66 | END IF; 67 | 68 | 69 | EXCEPTION 70 | WHEN OTHERS THEN 71 | -- CALL THE FUNCTION TO LOG ERRORS 72 | ROLLBACK; 73 | P_RESULT := 1; -- ERROR 74 | END; 75 | / 76 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_LIST_SERVERS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_LIST_SERVERS 2 | ( 3 | P_Q IN VARCHAR2, 4 | P_USER_ID IN NUMBER, 5 | P_ROWS OUT TYPES.REF_CURSOR, 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- PROCEDURE TO Get a list of all consumers from the consumer registry. 11 | BEGIN 12 | P_RESULT := 0; 13 | 14 | IF P_Q IS NOT NULL THEN 15 | 16 | OPEN P_ROWS FOR 17 | SELECT OCR_ID "id", 18 | OCR_USA_ID_REF "user_id", 19 | OCR_CONSUMER_KEY "consumer_key", 20 | OCR_CONSUMER_SECRET "consumer_secret", 21 | OCR_SIGNATURE_METHODS "signature_methods", 22 | OCR_SERVER_URI "server_uri", 23 | OCR_SERVER_URI_HOST "server_uri_host", 24 | OCR_SERVER_URI_PATH "server_uri_path", 25 | OCR_REQUEST_TOKEN_URI "request_token_uri", 26 | OCR_AUTHORIZE_URI "authorize_uri", 27 | OCR_ACCESS_TOKEN_URI "access_token_uri" 28 | FROM OAUTH_CONSUMER_REGISTRY 29 | WHERE ( OCR_CONSUMER_KEY LIKE '%'|| P_Q ||'%' 30 | OR OCR_SERVER_URI LIKE '%'|| P_Q ||'%' 31 | OR OCR_SERVER_URI_HOST LIKE '%'|| P_Q ||'%' 32 | OR OCR_SERVER_URI_PATH LIKE '%'|| P_Q ||'%') 33 | AND (OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL) 34 | ORDER BY OCR_SERVER_URI_HOST, OCR_SERVER_URI_PATH; 35 | 36 | ELSE 37 | 38 | OPEN P_ROWS FOR 39 | SELECT OCR_ID "id", 40 | OCR_USA_ID_REF "user_id", 41 | OCR_CONSUMER_KEY "consumer_key", 42 | OCR_CONSUMER_SECRET "consumer_secret", 43 | OCR_SIGNATURE_METHODS "signature_methods", 44 | OCR_SERVER_URI "server_uri", 45 | OCR_SERVER_URI_HOST "server_uri_host", 46 | OCR_SERVER_URI_PATH "server_uri_path", 47 | OCR_REQUEST_TOKEN_URI "request_token_uri", 48 | OCR_AUTHORIZE_URI "authorize_uri", 49 | OCR_ACCESS_TOKEN_URI "access_token_uri" 50 | FROM OAUTH_CONSUMER_REGISTRY 51 | WHERE OCR_USA_ID_REF = P_USER_ID OR OCR_USA_ID_REF IS NULL 52 | ORDER BY OCR_SERVER_URI_HOST, OCR_SERVER_URI_PATH; 53 | 54 | END IF; 55 | 56 | 57 | 58 | 59 | 60 | EXCEPTION 61 | WHEN OTHERS THEN 62 | -- CALL THE FUNCTION TO LOG ERRORS 63 | ROLLBACK; 64 | P_RESULT := 1; -- ERROR 65 | END; 66 | / 67 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_LIST_SERVER_TOKENS.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_LIST_SERVER_TOKENS 2 | ( 3 | P_USER_ID IN NUMBER, 4 | P_ROWS OUT TYPES.REF_CURSOR, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Find the server details that might be used for a request 10 | BEGIN 11 | P_RESULT := 0; 12 | 13 | OPEN P_ROWS FOR 14 | SELECT OCR_CONSUMER_KEY "consumer_key", 15 | OCR_CONSUMER_SECRET "consumer_secret", 16 | OCT_ID "token_id", 17 | OCT_TOKEN "token", 18 | OCT_TOKEN_SECRET "token_secret", 19 | OCT_USA_ID_REF "user_id", 20 | OCR_SIGNATURE_METHODS "signature_methods", 21 | OCR_SERVER_URI "server_uri", 22 | OCR_SERVER_URI_HOST "server_uri_host", 23 | OCR_SERVER_URI_PATH "server_uri_path", 24 | OCR_REQUEST_TOKEN_URI "request_token_uri", 25 | OCR_AUTHORIZE_URI "authorize_uri", 26 | OCR_ACCESS_TOKEN_URI "access_token_uri", 27 | OCT_TIMESTAMP "timestamp" 28 | FROM OAUTH_CONSUMER_REGISTRY 29 | JOIN OAUTH_CONSUMER_TOKEN 30 | ON OCT_OCR_ID_REF = OCR_ID 31 | WHERE OCT_USA_ID_REF = P_USER_ID 32 | AND OCT_TOKEN_TYPE = 'ACCESS' 33 | AND OCT_TOKEN_TTL >= SYSDATE 34 | ORDER BY OCR_SERVER_URI_HOST, OCR_SERVER_URI_PATH; 35 | 36 | 37 | 38 | 39 | EXCEPTION 40 | WHEN OTHERS THEN 41 | -- CALL THE FUNCTION TO LOG ERRORS 42 | ROLLBACK; 43 | P_RESULT := 1; -- ERROR 44 | END; 45 | / 46 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_SET_CONSUMER_ACC_TOKEN_TTL.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_SET_CONSUMER_ACC_TOKEN_TTL 2 | ( 3 | P_TOKEN IN VARCHAR2, 4 | P_TOKEN_TTL IN NUMBER, 5 | P_RESULT OUT NUMBER 6 | ) 7 | AS 8 | 9 | -- PROCEDURE TO Set the ttl of a consumer access token. This is done when the 10 | -- server receives a valid request with a xoauth_token_ttl parameter in it. 11 | 12 | BEGIN 13 | 14 | P_RESULT := 0; 15 | 16 | UPDATE OAUTH_SERVER_TOKEN 17 | SET OST_TOKEN_TTL = SYSDATE + (P_TOKEN_TTL/(24*60*60)) 18 | WHERE OST_TOKEN = P_TOKEN 19 | AND OST_TOKEN_TYPE = 'ACCESS'; 20 | 21 | 22 | EXCEPTION 23 | WHEN OTHERS THEN 24 | -- CALL THE FUNCTION TO LOG ERRORS 25 | ROLLBACK; 26 | P_RESULT := 1; -- ERROR 27 | END; 28 | / 29 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_SET_SERVER_TOKEN_TTL.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_SET_SERVER_TOKEN_TTL 2 | ( 3 | P_TOKEN_TTL IN NUMBER, -- IN SECOND 4 | P_CONSUMER_KEY IN VARCHAR2, 5 | P_TOKEN IN VARCHAR2, 6 | P_RESULT OUT NUMBER 7 | ) 8 | AS 9 | 10 | -- PROCEDURE TO Set the ttl of a server access token. 11 | 12 | BEGIN 13 | 14 | P_RESULT := 0; 15 | 16 | 17 | UPDATE OAUTH_CONSUMER_TOKEN 18 | SET OCT_TOKEN_TTL = SYSDATE + (P_TOKEN_TTL/(24*60*60)) -- DATE_ADD(NOW(), INTERVAL %D SECOND) 19 | WHERE OCT_TOKEN = P_TOKEN 20 | AND OCT_OCR_ID_REF IN (SELECT OCR_ID FROM OAUTH_CONSUMER_REGISTRY WHERE OCR_CONSUMER_KEY = P_CONSUMER_KEY); 21 | 22 | 23 | EXCEPTION 24 | WHEN OTHERS THEN 25 | -- CALL THE FUNCTION TO LOG ERRORS 26 | ROLLBACK; 27 | P_RESULT := 1; -- ERROR 28 | END; 29 | / 30 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/OracleDB/3_Procedures/SP_UPDATE_CONSUMER.prc: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE SP_UPDATE_CONSUMER 2 | ( 3 | P_OSR_USA_ID_REF IN NUMBER, 4 | P_OSR_CONSUMER_KEY IN VARCHAR2, 5 | P_OSR_CONSUMER_SECRET IN VARCHAR2, 6 | P_OSR_REQUESTER_NAME IN VARCHAR2, 7 | P_OSR_REQUESTER_EMAIL IN VARCHAR2, 8 | P_OSR_CALLBACK_URI IN VARCHAR2, 9 | P_OSR_APPLICATION_URI IN VARCHAR2, 10 | P_OSR_APPLICATION_TITLE IN VARCHAR2, 11 | P_OSR_APPLICATION_DESCR IN VARCHAR2, 12 | P_OSR_APPLICATION_NOTES IN VARCHAR2, 13 | P_OSR_APPLICATION_TYPE IN VARCHAR2, 14 | P_OSR_APPLICATION_COMMERCIAL IN INTEGER, 15 | P_RESULT OUT NUMBER 16 | ) 17 | AS 18 | 19 | -- PROCEDURE TO Insert a new consumer with this server (we will be the server) 20 | BEGIN 21 | P_RESULT := 0; 22 | 23 | 24 | INSERT INTO OAUTH_SERVER_REGISTRY 25 | ( OSR_ID, OSR_ENABLED, OSR_STATUS,OSR_USA_ID_REF,OSR_CONSUMER_KEY, OSR_CONSUMER_SECRET,OSR_REQUESTER_NAME, 26 | OSR_REQUESTER_EMAIL, OSR_CALLBACK_URI, OSR_APPLICATION_URI, OSR_APPLICATION_TITLE, OSR_APPLICATION_DESCR, 27 | OSR_APPLICATION_NOTES, OSR_APPLICATION_TYPE, OSR_APPLICATION_COMMERCIAL, OSR_TIMESTAMP, OSR_ISSUE_DATE) 28 | VALUES 29 | ( SEQ_OSR_ID.NEXTVAL, 1, 'ACTIVE', P_OSR_USA_ID_REF, P_OSR_CONSUMER_KEY, P_OSR_CONSUMER_SECRET,P_OSR_REQUESTER_NAME, 30 | P_OSR_REQUESTER_EMAIL, P_OSR_CALLBACK_URI, P_OSR_APPLICATION_URI, P_OSR_APPLICATION_TITLE, P_OSR_APPLICATION_DESCR, 31 | P_OSR_APPLICATION_NOTES, P_OSR_APPLICATION_TYPE, P_OSR_APPLICATION_COMMERCIAL, SYSDATE, SYSDATE); 32 | 33 | 34 | EXCEPTION 35 | WHEN OTHERS THEN 36 | -- CALL THE FUNCTION TO LOG ERRORS 37 | ROLLBACK; 38 | P_RESULT := 1; -- ERROR 39 | END; 40 | / 41 | -------------------------------------------------------------------------------- /includes/oauth-php/library/store/oracle/install.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/oauth-php/test/discovery/xrds-getsatisfaction.xrds: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | xri://$xrds*simple 6 | 2008-04-30T23:59:59Z 7 | 8 | 9 | 10 | http://oauth.net/core/1.0/endpoint/request 11 | 12 | http://oauth.net/core/1.0/parameters/auth-header 13 | http://oauth.net/core/1.0/signature/HMAC-SHA1 14 | 15 | http://getsatisfaction.com/api/request_token 16 | 17 | 18 | 19 | http://oauth.net/core/1.0/endpoint/authorize 20 | 21 | http://oauth.net/core/1.0/parameters/uri-query 22 | 23 | http://getsatisfaction.com/api/authorize 24 | 25 | 26 | 27 | 28 | http://oauth.net/core/1.0/endpoint/access 29 | 30 | http://oauth.net/core/1.0/parameters/auth-header 31 | http://oauth.net/core/1.0/signature/HMAC-SHA1 32 | 33 | http://getsatisfaction.com/api/access_token 34 | 35 | 36 | 37 | 45 | 46 | http://oauth.net/core/1.0/endpoint/resource 47 | 48 | http://oauth.net/core/1.0/parameters/auth-header 49 | http://oauth.net/core/1.0/signature/HMAC-SHA1 50 | 51 | 52 | 53 | 54 | 55 | 56 | http://oauth.net/discovery/1.0/consumer-identity/oob 57 | http://getsatisfaction.com/me/extensions/new 58 | 59 | 60 | 61 | 62 | 63 | 64 | xri://$xrds*simple 65 | 66 | 67 | 68 | http://oauth.net/discovery/1.0 69 | #oauth 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /includes/pear/Net/Growl/Exception.php: -------------------------------------------------------------------------------- 1 | 10 | * @license http://www.opensource.org/licenses/bsd-license.php BSD 11 | * @version SVN: $Id: Exception.php 324805 2012-04-04 16:05:33Z farell $ 12 | * @link http://growl.laurent-laville.org/ 13 | * @link http://pear.php.net/package/Net_Growl 14 | * @since File available since Release 0.9.0 15 | */ 16 | 17 | /** 18 | * Dedicated Exception for {@link Net_Growl} 19 | * 20 | * @category Networking 21 | * @package Net_Growl 22 | * @author Laurent Laville 23 | * @license http://www.opensource.org/licenses/bsd-license.php BSD 24 | * @version Release: 2.6.0 25 | * @link http://growl.laurent-laville.org/ 26 | * @link http://pear.php.net/package/Net_Growl 27 | * @since Class available since Release 0.9.0 28 | */ 29 | class Net_Growl_Exception extends Exception 30 | { 31 | } 32 | -------------------------------------------------------------------------------- /install.php: -------------------------------------------------------------------------------- 1 | "; 9 | } 10 | } 11 | 12 | if (! function_exists("outn")) { 13 | function outn($text) { 14 | echo $text; 15 | } 16 | } 17 | 18 | // Set execute permissions for AGI script 19 | #@chmod(dirname(__FILE__) . '/agi/superfecta.agi', 0755); 20 | try { 21 | $fs->chmod(__DIR__.'/agi/superfecta.agi', 0755); 22 | } catch (IOExceptionInterface $e) { 23 | out(sprintf("Couldn't set permissions on %s please run fwconsole chown from the command line",__DIR__.'/agi/superfecta.agi')); 24 | } 25 | 26 | global $db; 27 | // Remove entries from Caller ID Lookup sources left by legacy Superfecta Installs 28 | $sql = "SELECT * FROM `cidlookup` WHERE `description` = 'Caller ID Superfecta'"; 29 | $res = $db->query($sql); 30 | if ( !DB::IsError($res) && $res->numRows() != 0 ) { 31 | echo "Cleaning up remnants of legacy Superfecta installation.

    "; 32 | $sql = "DELETE FROM cidlookup WHERE description = 'Caller ID Superfecta'"; 33 | $res = $db->query($sql); 34 | } 35 | 36 | // remove spurious superfecta cache entries caused by previous versions of Trunk Provided module: 37 | $sql = "select * from superfectacache where `callerid` like 'CID Superfecta!'"; 38 | $res = $db->query($sql); 39 | if ( !DB::IsError($res) && $res->numRows() != 0 ) { 40 | echo "Cleaning up Superfecta Cache pollution from Trunk Provided module.

    "; 41 | $sql = "DELETE FROM superfectacache where `callerid` like 'CID Superfecta!'"; 42 | $res = $db->query($sql); 43 | } -------------------------------------------------------------------------------- /sources/source-Abandon_lookup.module: -------------------------------------------------------------------------------- 1 | description = _("Artificially sets the CNAM to a user defined value so that no further lookups will be performed"); 11 | $this->source_param = array( 12 | 'Artificial_CNAM' => array( 13 | 'description' => _('URL, use $thenumber as the substitution string for the inbound number'), 14 | 'type' => 'text', 15 | 'default' => 'unknown' 16 | ), 17 | 'Use_CID' => array( 18 | 'description' => _('Substitute CID for CNAM, text above will be ignored'), 19 | 'type' => 'checkbox', 20 | 'default' => 'off' 21 | ) 22 | ); 23 | } 24 | 25 | function get_caller_id($thenumber, $run_param=array()) { 26 | 27 | $caller_id = null; 28 | 29 | if ($run_param['Artificial_CNAM'] == NULL) { 30 | $run_param['Artificial_CNAM'] = $this->source_param['Artificial_CNAM']['default']; 31 | } 32 | if (isset($run_param['Use_CID']) && $run_param['Use_CID'] == 'on') { 33 | $run_param['Artificial_CNAM'] = $thenumber; 34 | } 35 | 36 | $this->DebugPrint("Setting CNAM to:".$run_param['Artificial_CNAM']." ..."); 37 | 38 | return(trim($run_param['Artificial_CNAM'])); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sources/source-Allowlist.module: -------------------------------------------------------------------------------- 1 | description = _("Searches the Asterisk AstDB entries from FreePBX Allowlist module for caller ID information."); 17 | } 18 | 19 | function get_caller_id($thenumber, $run_param=array()) { 20 | $caller_id = null; 21 | 22 | $this->DebugPrint("Searching Allowlist Database ... "); 23 | 24 | $name = strip_tags($this->astman->database_get('allowlist', $thenumber)); 25 | 26 | // If we found a match, return it 27 | if (strlen($name) > 1) { 28 | $caller_id = $name; 29 | } else { 30 | $this->DebugPrint("not found"); 31 | } 32 | 33 | return $caller_id; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sources/source-Asterisk_Phonebook.module: -------------------------------------------------------------------------------- 1 | description = _("Searches the built in Asterisk Phonebook for caller ID information. This is a very fast source of information.
    If you are caching to the phonebook, this should be the first lookup source."); 12 | } 13 | 14 | function get_caller_id($thenumber, $run_param=array()) { 15 | $caller_id = null; 16 | 17 | $this->DebugPrint("Searching Asterisk Phonebook ... "); 18 | 19 | $name = strip_tags($this->astman->database_get('cidname', $thenumber)); 20 | 21 | // If we found a match, return it 22 | if (strlen($name) > 1) { 23 | $caller_id = $name; 24 | } else { 25 | $this->DebugPrint("not found"); 26 | } 27 | 28 | return $caller_id; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sources/source-BulkCNAM.module: -------------------------------------------------------------------------------- 1 | description = "http://www.bulkcnam.com - "._("This module provides lookups from the AsteriskCNAM.com lookup service."); 12 | $this->source_param = array( 13 | 'API_Key' => array( 14 | 'description' => sprintf(_('API Key gotten from %s'),"bulkcnam.com"), 15 | 'type' => 'text' 16 | ) 17 | ); 18 | } 19 | 20 | function get_caller_id($thenumber, $run_param=array()) { 21 | 22 | $caller_id = null; 23 | 24 | if (!$this->IsValidNumber(array('US', 'CA'), $thenumber)) { 25 | $this->DebugPrint(_("Skipping Source - Not a valid US/CAN number: ") . $thenumber); 26 | } else { 27 | $this->DebugPrint(_("Searching BulkCNAM...")); 28 | 29 | $url = "http://cnam.bulkcnam.com/query-simple.php?id=" . $run_param['API_Key'] . "&did=$thenumber"; 30 | $sname = $this->get_url_contents($url); 31 | 32 | if (strlen($sname) > 1) { 33 | $caller_id = strip_tags($sname); 34 | } else { 35 | $this->DebugPrint(_("Not Found")); 36 | } 37 | } 38 | return($caller_id); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /sources/source-CNAM_RF.module: -------------------------------------------------------------------------------- 1 | array( 9 | 'description' => 'API key is available in your account at the website: http://cnamrf.ru/cabinet/', 10 | 'type' => 'text' 11 | ) 12 | ); 13 | 14 | function get_caller_id($thenumber, $run_param = array()) 15 | { 16 | $caller_id = null; 17 | 18 | if (!$this->IsValidNumber('RU', $thenumber)) { 19 | $this->DebugPrint('Skipping Source - Not a valid RU number: ' . $thenumber); 20 | } else { 21 | $this->DebugPrint('Searching in CNAM RF database ... '); 22 | 23 | $url = "http://api.cnamrf.ru/getName/{$thenumber}/?apikey={$run_param['API_Key']}&client=FreePBX"; 24 | $aname = json_decode($this->get_url_contents($url)); 25 | 26 | if (!$aname->error) { 27 | $caller_id = $aname->translit; 28 | } else { 29 | $this->DebugPrint($aname->message); 30 | } 31 | 32 | } 33 | return($caller_id); 34 | } 35 | } -------------------------------------------------------------------------------- /sources/source-Can411.module: -------------------------------------------------------------------------------- 1 | IsValidNumber('CA', $thenumber, $npa, $nxx, $station)) { 29 | $this->DebugPrint(_("Skipping Source - Non Canadian number: ") . $thenumber); 30 | } else { 31 | $this->DebugPrint(sprintf(_("Searching www.411.ca - (%s) %s-%s..."),$npa,$nxx,$station)); 32 | 33 | // By default, there is no match 34 | $name = ""; 35 | 36 | $url = "https://411.ca/search/?q=$thenumber&st=reverse"; //working May 20, 2015 37 | 38 | // Patterns to search for 39 | $regexp = array( 40 | '/itemprop=\"name\">(.+?)<\/h4/i', // working 2022-12-04 41 | ); 42 | 43 | if ($this->SearchURL($url, $regexp, $match, NULL, TRUE)) { 44 | $caller_id = $this->ExtractMatch($match); 45 | } 46 | } 47 | return($caller_id); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /sources/source-CidnameCom.module: -------------------------------------------------------------------------------- 1 | description = "https://www.cidname.com "._("Formats accepted by the API are: 5554441212, 15554441212, +5554441212, +15554441212"); 19 | $this->source_param = array( 20 | 'Use_IP_Authentication' => array( 21 | 'description' => _('Enable to use IP authentication for CNAM dips.'), 22 | 'type' => 'checkbox', 23 | ), 24 | 'Auth_Token' => array( 25 | 'description' => _('Auth Token from Cidname.com Dashboard, required if not using IP authentication.'), 26 | 'type' => 'textarea', 27 | ), 28 | 'Ignore_Keywords' => array( 29 | 'description' => _('If this source provides CNAM including any of the keywords listed here, the CNAM will be ignored and other sources will be used to find the value.
    Separate keywords with commas.'), 30 | 'type' => 'textarea', 31 | 'default' => 'Unavailable, Wireless caller', 32 | ), 33 | ); 34 | } 35 | 36 | function get_caller_id($thenumber, $run_param=array()) { 37 | 38 | $caller_id = null; 39 | $this->DebugPrint(sprintf(_("Searching %s..."),"Cidname.com")); 40 | if ($run_param['Use_IP_Authentication'] == 'on') { 41 | $url = 'http://dip.cidname.com/'. $thenumber . '/'; 42 | } else { 43 | $url = "https://dip.cidname.com/" . $thenumber . "/" .$run_param['Auth_Token']; 44 | } 45 | $url = 'http://dip.cidname.com/'. $thenumber . '/'; 46 | $sname = $this->get_url_contents($url); 47 | 48 | if (strlen($sname) > 1) { 49 | // convert list of ignore keywords into array 50 | $key_words = array(); 51 | $temp_array = explode(',',(isset($run_param['Ignore_Keywords'])?$run_param['Ignore_Keywords']:$source_param['Ignore_Keywords']['default'])); 52 | foreach($temp_array as $val) { 53 | $key_words[] = trim($val); 54 | } 55 | 56 | // Remove all ignore keywords from the retuned CNAM string and compare the before and after. 57 | $test_string = str_ireplace($key_words,'',$sname); 58 | if($test_string == $sname) { 59 | $caller_id = $sname; 60 | $this->DebugPrint(_("CNAM determined good.")); 61 | } else { 62 | $this->DebugPrint(_("CNAM contains flagged key words, returning nothing.")); 63 | } 64 | } else { 65 | $this->DebugPrint(_("CNAM not found.")); 66 | } 67 | return($caller_id); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /sources/source-DasTelefonBuch_Germany.module: -------------------------------------------------------------------------------- 1 | description = "https://www.dastelefonbuch.de - "._("These listings include data for dastelefonbuch in Germany."); 25 | } 26 | 27 | function get_caller_id($thenumber, $run_param=array()) { 28 | $this->DebugPrint(_("Searching"). "https://www.dastelefonbuch.de ... "); 29 | 30 | 31 | if($thenumber !== 'anonymous' && $thenumber !== 'unknown' && $thenumber !== ''){ 32 | 33 | if (substr($thenumber, 0, 1) ==! '0') { 34 | $thenumber=trim($thenumber,' '); 35 | $thenumber="00" . $thenumber; 36 | } 37 | if (substr($thenumber, 0, 2) === '00') { 38 | $thenumber=trim($thenumber,' '); 39 | } 40 | 41 | 42 | // Set the url we're searching for 43 | $res_rul = "https://www.dastelefonbuch.de/Suche/" . $thenumber;// url for searching persons 44 | 45 | // regex patterns to search for 46 | $regexp = array( 47 | '~
    ~', 48 | ); 49 | // search for persons match 50 | if ($this->SearchURL($res_rul, $regexp, $match)) { 51 | $caller_id = $this->ExtractMatch($match); 52 | } 53 | $caller_id = isset($caller_id)?$caller_id:''; 54 | 55 | return($caller_id); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /sources/source-DeTeMedien_DE.module: -------------------------------------------------------------------------------- 1 | DebugPrint(sprintf(_("Searching http://www.detemedien.de/ for %s..."),$thenumber)); 23 | 24 | // url from ver. 2.2.x still working 2014-01-08 25 | $url = "http://www.dasoertliche.de/Controller?context=4&form_name=search_inv&action=43&page=5&ph=". $thenumber; 26 | 27 | // Patterns to search for 28 | $regexp = array( 29 | // '/arkey=.*>(.*) /', // old regex from ver 2.2.x occasionally gives bad result 30 | // '/class="preview iname">(.*?)<\/span><\/a> <\/span>/', // working 2014-01-08 31 | // '/class="preview iname" onmouseover="" onMouseOut="">(.*?)<\/span>/', // working 2014-07-23 32 | '/class="name " onmouseover="" onMouseOut="">(.*?)<\/span>/', // working 2014-07-23 33 | '/class="name ">(.*?)<\/span>/', // working 2014-07-23 34 | '/class="name " onmouseover="" onmouseout="">(.*?)<\/span>/', // working 2014-07-23 35 | ); 36 | 37 | if ($this->SearchURL($url, $regexp, $match, NULL, TRUE)) { 38 | $caller_id = $this->ExtractMatch($match); 39 | } 40 | 41 | return(str_replace(" ", '', $caller_id)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /sources/source-EnumQuery.module: -------------------------------------------------------------------------------- 1 | description = "http://www.enumquery.com "._("This data source returns the user provided extended CNAM data listed in their ENUM (e164) registrations. Registrants must have specified CNAM data in one of the supported e164 registries for this data source to return a value.
    See www.enumquery.com for list of supported registries."); 12 | } 13 | 14 | function get_caller_id($thenumber, $run_param=array()) { 15 | 16 | $caller_id = null; 17 | 18 | if (!$this->IsValidNumber('US,CA', $thenumber)) { 19 | $this->DebugPrint(sprintf(_("Skipping Source - Non US/CAN number: %s"),$thenumber)); 20 | } else { 21 | $this->DebugPrint(sprintf(_("Searching EnumQuery - %s..."),$thenumber)); 22 | 23 | $url = "http://enumquery.com/lookup?e164=1{$thenumber}"; 24 | 25 | $pattern = '/CN=(.*);/isU'; 26 | 27 | if ($this->SearchURL($url, $pattern, $match)) { 28 | $caller_id = $this->ExtractMatch($match); 29 | } 30 | } 31 | 32 | return($caller_id); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /sources/source-FNS_RF.module: -------------------------------------------------------------------------------- 1 | description = _("Search over Federal Tax Service of Russia"); 9 | 10 | $this->source_param = [ 11 | 'API_Key' => [ 12 | 'description' => _('Enter API Key from FNS (Registration on https://api-fns.ru/index)'), 13 | 'type' => 'text', 14 | 'default' => '' 15 | ] 16 | ]; 17 | } 18 | 19 | function get_caller_id($thenumber, $run_param = []) { 20 | $caller_id = null; 21 | 22 | $url = "https://api-fns.ru/api/search?q={$thenumber}&filter=active&key={$run_param['API_Key']}"; 23 | 24 | $content = $this->get_url_contents($url); 25 | $value = json_decode($content); 26 | 27 | if(count($value->items) > 0) { 28 | $caller_id = str_replace('"', "", $value->items[0]->ЮЛ->НаимСокрЮЛ); 29 | } 30 | 31 | return($caller_id); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sources/source-FccComplaints.module: -------------------------------------------------------------------------------- 1 | description = "https://opendata.fcc.gov - "._("This module checks for complaints to the fcc against a given phone number"); 10 | $this->source_param = array( 11 | 'SPAM_Threshold' => array( 12 | 'description' => _('Specify the number of listings required to mark a call as spam.'), 13 | 'type' => 'number', 14 | 'default' => 2 15 | ), 16 | 'API_KEY' => array( 17 | 'description' => _('Optional API token to allow throttling by app rather than IP'), 18 | 'type' => 'text', 19 | 'default' => '' 20 | ), 21 | 'Whitelist' => array( 22 | 'description' => _('Whitelist of numbers to consider neverspam. One per line in the format NPA-NPX-XXXX'), 23 | 'type' => 'textarea', 24 | 'default' => '' 25 | ) 26 | ); 27 | } 28 | 29 | function get_caller_id($thenumber, $run_param=array()) { 30 | $apikey = isset($run_param['API_KEY'])?$run_param['API_KEY']:''; 31 | $spamcount = isset($run_param['SPAM_Threshold'])?$run_param['SPAM_Threshold']:1; 32 | $whitelist = isset($run_param['Whitelist'])?explode("\n",trim($run_param['Whitelist'])):array(); 33 | $caller_id = null; 34 | //http://stackoverflow.com/a/10741461 phone number normalization 35 | $thenumber = preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~', '$1-$2-$3', $thenumber); 36 | if (!$this->IsValidNumber("US,CA", $thenumber)) { 37 | $this->DebugPrint(_("Skipping Source - Non US/CAN number").": {$thenumber}"); 38 | } else { 39 | $this->DebugPrint(_("Searching FCC Data source...")); 40 | if(in_array($thenumber, $whitelist)){ 41 | $this->DebugPrint(sprintf(_("The number %s is in the whitelist, skipping"),$thenumber)); 42 | $this->spam = false; 43 | return $caller_id; 44 | } 45 | $url = "https://opendata.fcc.gov/resource/sr6c-syda.json?caller_id_number=".$thenumber; 46 | if(!empty($apikey)){ 47 | $url .= '&$$app_token='.$apikey; 48 | } 49 | $value = $this->get_url_contents($url); 50 | $data = json_decode($value,true); 51 | $score = count($data); 52 | if ($score >= $spamcount) { 53 | $this->spam = true; 54 | $this->DebugPrint(" "._("$score reports found, determined to be SPAM. You can lower the spam threshold in settings.")); 55 | } else { 56 | $this->DebugPrint(_("$score reports found, Not a SPAM caller. You can raise the spam threshold in settings.")); 57 | } 58 | } 59 | 60 | return($caller_id); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /sources/source-FreeCNAM.module: -------------------------------------------------------------------------------- 1 | description = _("Caller ID name from https://freecnam.org. Free community service with low rate limits to prevent abuse."); 27 | } 28 | 29 | function get_caller_id($thenumber, $run_param = array()) 30 | { 31 | $caller_id = null; 32 | $url = "https://freecnam.org/dip?q="; 33 | 34 | if ($this->isDebug()) 35 | $this->DebugPrint(_('Running FreeCNAM scheme.')); 36 | $this->DebugPrint(_('If requested URL returns 429, rate limit exceeded.')); 37 | 38 | //retrieve url contents 39 | $caller_id = $this->get_url_contents($url.$thenumber); 40 | 41 | if ($caller_id) { 42 | if ($caller_id=="Error: Rate limit exceeded") { 43 | if (!$this->isDebug()) 44 | $this->DebugPrint(_('FreeCNAM rate limit exceeded, returning null.')); 45 | return; 46 | } 47 | 48 | } 49 | return (strip_tags(trim($caller_id))); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sources/source-FreePBX_Contactmanager.module: -------------------------------------------------------------------------------- 1 | array( 11 | 'description' => 'The format to return any found caller ID in.', 12 | 'type' => 'select', 13 | 'option' => array ( 14 | '1' => 'Display Name', 15 | '2' => 'Company', 16 | '3' => 'Last First', 17 | '4' => 'First Last', 18 | ), 19 | 'default' => '4', 20 | ), 21 | ); 22 | 23 | public function __construct() { 24 | $this->description = _("Searches FreePBX Contact manager for name."); 25 | } 26 | 27 | function get_caller_id($thenumber, $run_param=array()) { 28 | $caller_id = null; 29 | $data = FreePBX::Contactmanager()->lookupByUserID(-1, $thenumber,"/\D/"); 30 | if(empty($data)){ 31 | return null; 32 | } 33 | $first = !empty($data['fname'])?$data['fname']:''; 34 | $last = !empty($data['lname'])?$data['lname']:''; 35 | $company = !empty($data['company'])?$data['company']:'Unknown'; 36 | $displayname = !empty($data['displayname'])?$data['displayname']:'Unknown'; 37 | 38 | if(empty($first) && empty($last)){ 39 | $first = 'Unknown'; 40 | } 41 | $format = isset($run_param['Return_Format'])?$run_param['Return_Format']:'4'; 42 | switch($format){ 43 | case '1': 44 | $caller_id = $displayname; 45 | break; 46 | case '2': 47 | $caller_id = $company; 48 | break; 49 | case '3': 50 | $caller_id = $last .' ' .$first; 51 | break; 52 | case '4': 53 | default: 54 | $caller_id = $first .' ' .$last; 55 | break; 56 | } 57 | 58 | return $caller_id; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /sources/source-GevondenCC_NL.module: -------------------------------------------------------------------------------- 1 | description = "http://www.gevonden.cc - "._("This source includes business and residential data for The Netherlands"); 12 | } 13 | 14 | function get_caller_id($thenumber, $run_param=array()) { 15 | 16 | $caller_id = null; 17 | $name = ""; 18 | 19 | $this->DebugPrint("Searching gevonden.cc - {$thenumber} ... "); 20 | 21 | // Test for NL 22 | $loc_number = $thenumber; 23 | if (strlen($loc_number) > 10) 24 | { 25 | if (substr($loc_number,0,2)=='31') 26 | { 27 | $loc_number = '0'.substr($loc_number,2); 28 | } 29 | else if (substr($loc_number,0,4)=='0031') 30 | { 31 | $loc_number = '0'.substr($loc_number,4); 32 | } 33 | else if (substr($loc_number,0,5)=='01131') 34 | { 35 | $loc_number = '0'.substr($loc_number,5); 36 | } 37 | } 38 | 39 | if (strlen($loc_number) == 10) 40 | { 41 | // Search gevonden.ccm 42 | $url = "http://www.gevonden.cc/telefoonnummer/" . $thenumber . "/lastname/"; 43 | $this->DebugPrint("URL: " . $url); 44 | $result = $this->get_url_contents($url); 45 | 46 | $expr = '=]*>(.*)[0-9]{5,}=siU'; 47 | preg_match_all($expr, $result, $name); 48 | if (count($name[1]) > 0) 49 | { 50 | $name = trim($name[1][0]); 51 | $name = strip_tags($name); 52 | } 53 | } 54 | else 55 | { 56 | $this->DebugPrint($thenumber . " is not a Dutch number"); 57 | } 58 | 59 | // If we found a match, return it 60 | if (is_string($name) && strlen($name) > 1) 61 | { 62 | $caller_id = $name; 63 | } else { 64 | $this->DebugPrint("not found"); 65 | } 66 | 67 | return($caller_id); 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /sources/source-GlipMe.module: -------------------------------------------------------------------------------- 1 | description = _("Your GlipMe (www.glipme.com) private company address book"); 16 | $this->source_param = array( 17 | 'Security_key' => array( 18 | 'description' => _('Specify your GlipMe PBX security key'), 19 | 'type' => 'text', 20 | 'default' => '' 21 | ) 22 | ); 23 | } 24 | 25 | function get_caller_id($thenumber, $run_param=array()) { 26 | 27 | $url = 'https://service.glipme.com/api/1.0/pbx/[KEY]/asterisklookup/[NUMBER]'; 28 | $url = str_replace('[KEY]', $run_param['Security_key'], $url); 29 | $url = str_replace('[NUMBER]', $thenumber, $url); 30 | // $url = urlencode($url); 31 | 32 | $this->DebugPrint(_("Sent GlipMe key").": ".$run_param['Security_key']); 33 | 34 | $value = $this->get_url_contents($url); 35 | 36 | $this->DebugPrint(_("GlipMe reported").": {$value}"); 37 | return ($value); 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /sources/source-Klicktel_DE.module: -------------------------------------------------------------------------------- 1 | DebugPrint("Searching http://www.klicktel.de for $thenumber..."); 21 | 22 | // url updated and working 2014-01-09 23 | $url = "http://www.klicktel.de/rueckwaertssuche/". $thenumber; 24 | 25 | // Patterns to search for 26 | $regexp = array( 27 | // '/.html">(.*)<\/strong>/', // old regex from ver 2.2.x not working 28 | // '/

    .*?\. (.*?)<\/a><\/h4>/', // working 2014-01-09 29 | // '/

    .*?\. (.*?)<\/a><\/h3>/', 30 | '/

    (.*?)<\/h1>/', // working 2016-04-01 31 | ); 32 | 33 | if ($this->SearchURL($url, $regexp, $match, NULL, TRUE)) { 34 | $caller_id = $this->ExtractMatch($match); 35 | } 36 | 37 | return($caller_id); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sources/source-NextCaller.module: -------------------------------------------------------------------------------- 1 | array( 19 | 'description' => 'Username from NextCaller Dashboard', 20 | 'type' => 'text' 21 | ), 22 | 'password' => array( 23 | 'description' => 'Password from NextCaller Dashboard', 24 | 'type' => 'password' 25 | ) 26 | ); 27 | 28 | public function get_caller_id($thenumber, $run_param=array()) { 29 | $this->DebugPrint("Searching NextCaller.."); 30 | $run_param['username'] = isset($run_param['username'])?$run_param['username']:false; 31 | $run_param['password'] = isset($run_param['password'])?$run_param['password']:false; 32 | $thenumber=urlencode($thenumber); 33 | $caller_id = null; 34 | if (!$run_param['username'] || !$run_param['password']) { 35 | $this->DebugPrint("You did not specify a valid username or password."); 36 | } else { 37 | $url = "https://".$run_param['username'].":".$run_param['password']."@api.nextcaller.com/v2/records/?format=json&phone=$thenumber"; 38 | $sresult = $this->get_url_contents($url); 39 | $result = json_decode($sresult, true); 40 | $name = isset($result['records']['0']['name'])?$result['records']['0']['name']:''; 41 | // If we found a match, return it 42 | if (strlen($name) > 1) { 43 | $caller_id = $name; 44 | } else { 45 | $this->DebugPrint("not found"); 46 | } 47 | return($caller_id); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sources/source-Paginasblancas_AR.module: -------------------------------------------------------------------------------- 1 | IsValidNumber('AR', $this->thenumber, $areacode, $number2, $number3) 7 | * but this did not appear to be working properly and requires maintenance of the AR area code list. This check 8 | * abandoned on July 29, 2013 9 | * 10 | * Change log: 11 | * 2013-07-29 - remove valid number check, update URL and update regex 12 | * 2014-04-07 - Update URL and regex 13 | * 2014-07-11 - Add regex for business name matching 14 | * 2014-08-05 - Updated URL 15 | * 16 | * 17 | **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****/ 18 | 19 | class Paginasblancas_AR extends superfecta_base { 20 | 21 | public $description; 22 | public $version_requirement = "2.11"; 23 | 24 | public function __construct() { 25 | $this->description = _("Searches")." Argentina http://www.paginasblancas.com.ar/"; 26 | } 27 | 28 | function get_caller_id($thenumber, $run_param=array()) { 29 | 30 | $this->DebugPrint("Searching www.paginasblancas.com.ar for number: $thenumber"); 31 | 32 | $url = "http://www.paginasblancas.com.ar/telefono/".$thenumber; //updated 2014-08-05 33 | $pattern = array( 34 | '/(.*?)<\/a>/', //updated 2016-07-14 for residential 35 | '~

    .*?(.+?).*?

    ~s', // added 2014-07-11 for business 36 | ); 37 | 38 | if ($this->SearchURL($url, $pattern, $match)) { 39 | $caller_id = $this->ExtractMatch($match); 40 | } 41 | return($caller_id); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /sources/source-PhoneSpamFilter.module: -------------------------------------------------------------------------------- 1 | description = "http://www.phonespamfilter.com - "._("A datasource devoted to identifying telemarketers. These listings are provided by other users of this service."); 10 | $this->source_param = array( 11 | 'SPAM_Threshold' => array( 12 | 'description' => _('Specify the number of listings required to mark a call as spam.'), 13 | 'type' => 'number', 14 | 'default' => 10 15 | ) 16 | ); 17 | } 18 | 19 | function get_caller_id($thenumber, $run_param=array()) { 20 | 21 | $caller_id = null; 22 | 23 | if (!$this->IsValidNumber("US,CA", $thenumber)) { 24 | $this->DebugPrint(_("Skipping Source - Non US/CAN number").": {$thenumber}"); 25 | } else { 26 | $this->DebugPrint(_("Searching PhoneSpamFilter...")); 27 | 28 | $url = "http://www.phonespamfilter.com/check.php?phone=$thenumber"; 29 | $value = $this->get_url_contents($url); 30 | 31 | if (is_numeric($value)) { 32 | $this->DebugPrint(_('Found')." ".$value); 33 | 34 | $score = $value; 35 | if ($score > $run_param['SPAM_Threshold']) { 36 | $this->spam = true; 37 | $this->DebugPrint(" "._("determined to be SPAM")); 38 | } else { 39 | $this->DebugPrint(_("Not a SPAM caller")); 40 | } 41 | } else { 42 | $this->DebugPrint(_("not found")); 43 | } 44 | } 45 | 46 | return($caller_id); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /sources/source-PhoneSpamFilter_UK.module: -------------------------------------------------------------------------------- 1 | description = "http://www.phonespamfilter.co.uk - "._("A datasource devoted to identifying telemarketers. These listings are provided by other users of this service."); 12 | $this->source_param = array( 13 | 'SPAM_Threshold' => array( 14 | 'description' => _('Specify the number of listings required to mark a call as spam.'), 15 | 'type' => 'number', 16 | 'default' => 10 17 | ) 18 | ); 19 | } 20 | 21 | function get_caller_id($thenumber, $run_param=array()) { 22 | $caller_id = null; 23 | 24 | if (!$this->IsValidNumber('UK', $thenumber)) { 25 | $this->DebugPrint("Skipping Source - Non UK number: {$thenumber}"); 26 | } else { 27 | $this->DebugPrint("Searching PhoneSpamFilter (UK) ... "); 28 | 29 | $url = "http://www.phonespamfilter.co.uk/check.php?phone=$thenumber"; 30 | $value = $this->get_url_contents($url); 31 | 32 | if (is_numeric($value)) { 33 | $this->DebugPrint(' value of ' . $value . ' returned ... '); 34 | 35 | $score = $value; 36 | $threshold = array_key_exists('SPAM_Threshold', $run_param) ? $run_param['SPAM_Threshold'] : 0; 37 | if ($score > $threshold) { 38 | $this->spam = true; 39 | $this->DebugPrint(" determined to be SPAM"); 40 | } else { 41 | $this->DebugPrint("Not a SPAM caller"); 42 | } 43 | } else { 44 | $this->DebugPrint("not found"); 45 | } 46 | } 47 | 48 | return($caller_id); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /sources/source-Regular_Expressions_1.module: -------------------------------------------------------------------------------- 1 | description = _("Regular Expression Website Parser. Use http://regexpal.com/ to generate your own regular expressions
    The Regular Expression Textbox can contain multiple expressions to match, separated by a new line. THe first to match from top to bottom will be returned as the answer"); 11 | $this->source_param = array( 12 | 'url' => array( 13 | 'description' => _('URL, use $thenumber as the substitution string for the inbound number'), 14 | 'type' => 'text' 15 | ), 16 | 'reg_exp' => array( 17 | 'description' => _('Regular Expressions
    One Per Line. First Match Wins'), 18 | 'type' => 'textarea' 19 | ), 20 | 'reg_exp_ops' => array( 21 | 'description' => _('Regular Expression Options. One Per Line, will line up with above in order. EX: im
    • i - Case insensitive match
    • m - Treat string as multiple lines. ^ and $ will match at start and end of internal lines, as well as at beginning and end of whole string. Use \A and \Z to match beginning and end of whole string when this is turned on.
    • s - Treat string as a single line. "." will match any character at all, including newline.
    • x - Allow extra whitespace and comments in pattern.
    '), 22 | 'type' => 'textarea' 23 | ) 24 | ); 25 | } 26 | 27 | function get_caller_id($thenumber, $run_param=array()) { 28 | 29 | $caller_id = null; 30 | 31 | if(!empty($run_param['url']) && !empty($run_param['reg_exp'])) { 32 | $run_param['url'] = str_replace('$thenumber',$thenumber,$run_param['url']); 33 | 34 | $this->DebugPrint(sprintf(_("Searching %s with regular expressions..."),$run_param['url'])); 35 | 36 | $reg = explode("\n",$run_param['reg_exp']); 37 | $reg_ops = explode("\n",$run_param['reg_exp_ops']); 38 | 39 | $exps = array(); 40 | foreach($reg as $i => $rx) { 41 | $opts = !empty($reg_ops) && isset($reg_ops[$i]) ? $reg_ops[$i] : ''; 42 | $exps[] = '/'.str_replace('/', '\\/',$rx).'/'.$opts; 43 | } 44 | 45 | if($this->SearchURL($run_param['url'],$exps,$matches)) { 46 | $caller_id = $this->html2text($matches[1]); 47 | } 48 | } else { 49 | $this->DebugPrint(_("Empty Query. Skipping")); 50 | } 51 | 52 | return(strip_tags(trim($caller_id))); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /sources/source-Responder_o_No.module: -------------------------------------------------------------------------------- 1 | description = "http://www.responderono.es - "._("A datasource devoted to identifying telemarketers. These listings are provided by other users of this service."); 17 | $this->source_param = array( 18 | 'SPAM_Threshold' => array( 19 | 'description' => _('Specify the number of listings required to mark a call as spam.'), 20 | 'type' => 'number', 21 | 'default' => 10 22 | ) 23 | ); 24 | } 25 | 26 | function get_caller_id($thenumber, $run_param=array()) 27 | { 28 | // Get Config 29 | $SPAM_Threshold = isset($run_param['SPAM_Threshold']) ? $run_param['SPAM_Threshold'] : $this->source_param['SPAM_Threshold']['default']; 30 | 31 | //Test Number: 623422576 -> SPAM = YES 32 | $url = sprintf("https://www.responderono.es/numero-de-telefono/%s", $thenumber); 33 | 34 | // regex patterns to search for 35 | $regexp = array('~
  • (.+?)x negativa
  • ~'); 36 | 37 | // search for persons match 38 | if ($this->SearchURL($url, $regexp, $match)) { 39 | $score = $this->ExtractMatch($match); 40 | if ((! empty($score)) && (is_numeric($score))) 41 | { 42 | $this->DebugEcho( sprintf(_('Value of %s returned...'), $score)); 43 | if ($score > $SPAM_Threshold) 44 | { 45 | $this->spam = true; 46 | $this->DebugPrint(_(" determined to be SPAM")); 47 | } 48 | else 49 | { 50 | $this->DebugPrint(_(" not a SPAM caller")); 51 | } 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /sources/source-ReverseAustralia_AU.module: -------------------------------------------------------------------------------- 1 | description = "http://www.reverseaustralia.com - "._("Phone listings for Australia"); 21 | $this->source_param = array( 22 | 'API_Key' => array( 23 | 'description' => _('Your API key from:'). "http://www.reverseaustralia.com/developer/", 24 | 'type' => 'text', 25 | 'default' => '' 26 | ), 27 | 'Spam_Threshold' => array( 28 | 'description' => _('How sensitive of a spam score to use 1-100, 0 to disable'), 29 | 'type' => 'number', 30 | 'default' => '40' 31 | ) 32 | ); 33 | } 34 | 35 | function get_caller_id($thenumber, $run_param=array()) { 36 | $run_param['API_Key'] = isset($run_param['API_Key'])?$run_param['API_Key']:false; 37 | $run_param['Spam_Threshold'] = isset($run_param['Spam_Threshold'])?$run_param['Spam_Threshold']:40; 38 | $thenumber = urlencode($thenumber); 39 | $caller_id = null; 40 | $name = ""; 41 | $spam = ""; 42 | 43 | if (!$run_param['API_Key']) { 44 | $this->DebugPrint(_("A valid API Key is required to use this lookup source")); 45 | } else { 46 | 47 | $this->DebugPrint("Searching reverseaustralia.com - {$thenumber} ... "); 48 | 49 | if ($run_param['Spam_Threshold']) { 50 | $spam = "&spamthreshold=".$run_param['Spam_Threshold']; 51 | } 52 | 53 | $url = 'http://api.reverseaustralia.com/cidlookup.php?format=json&key='.$run_param['API_Key'].'&q='.$thenumber.$spam; 54 | // $this->DebugPrint($url); // for debug 55 | 56 | $value = $this->get_url_contents($url); 57 | // $value = '{"name":"Australian Communications Authority (aca)"}'; // For debug 58 | 59 | $result = (array)json_decode($value); 60 | if (isset($result['error'])) { 61 | if ($result['error'] == 'Not found') { 62 | //record not found 63 | } 64 | } else { 65 | $name = isset($result['name'])?$result['name']:''; 66 | } 67 | 68 | // If we found a match, return it 69 | if (strlen($name) > 1) { 70 | $caller_id = $name; 71 | } else { 72 | $this->DebugPrint(_("not found")); 73 | } 74 | 75 | return($caller_id); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /sources/source-ReversePhoneBooks_UK.module: -------------------------------------------------------------------------------- 1 | description = "http://www.reversephonebooks.co.uk - "._("A datasource devoted to identifying telemarketers. These listings are provided by other users of this service."); 20 | $this->source_param = array( 21 | 'SPAM_Threshold' => array( 22 | 'description' => _('Specify the number of listings required to mark a call as spam.'), 23 | 'type' => 'number', 24 | 'default' => 10 25 | ) 26 | ); 27 | } 28 | 29 | function get_caller_id($thenumber, $run_param=array()) { 30 | $caller_id = NULL; 31 | 32 | if (!$this->IsValidNumber('UK', $thenumber)) { 33 | $this->DebugPrint("Skipping Source - Non UK number: $thenumber"); 34 | } else { 35 | $this->DebugPrint("Searching ReversePhoneBooks.co.uk..."); 36 | 37 | $url = "http://www.reversephonebooks.co.uk/$thenumber-phone-number"; 38 | $value = $this->get_url_contents($url); 39 | 40 | $pattern = "/

    There are (\d+) reported complaint([s]*) for phone number/"; 41 | 42 | if ($this->SearchURL($url, $pattern, $match)) { 43 | $value = $this->ExtractMatch($match); 44 | if (is_numeric($value)) { 45 | $this->DebugPrint(sprintf(_("value of %s returned..."),$value)); 46 | 47 | $score = $value; 48 | $threshold = array_key_exists('SPAM_Threshold', $run_param) ? $run_param['SPAM_Threshold'] : 0; 49 | if ($score > $threshold) { 50 | $this->spam = true; 51 | $this->DebugPrint(" "._("determined to be SPAM")); 52 | } else { 53 | $this->DebugPrint(_("Not a SPAM caller")); 54 | } 55 | } 56 | } else { 57 | $this->DebugPrint(_("not found")); 58 | } 59 | } 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sources/source-SE_118100_HE.module: -------------------------------------------------------------------------------- 1 | description = "http://www.118100.se - "._("This listing include data from the Swedish 118100.se directory."); 19 | } 20 | 21 | function get_caller_id($thenumber, $run_param=array()) { 22 | $debug = $this->debug; 23 | $this->DebugPrint("Searching www.118100.se ... "); 24 | $number_error = false; 25 | 26 | //check for the correct digits for Sweden in international format. 27 | // international dialing prefix + country code + number 28 | 29 | if (strlen($thenumber) > 8) { 30 | if (substr($thenumber,0,2) == '46') { 31 | $thenumber = '0'.substr($thenumber, 2); 32 | } else { 33 | if (substr($thenumber,0,4) == '0046') { 34 | $thenumber = '0'.substr($thenumber, 4); 35 | } else { 36 | if (substr($thenumber,0,5) == '01146') { 37 | $thenumber = '0'.substr($thenumber,5); 38 | } else { 39 | $number_error = true; 40 | } 41 | } 42 | } 43 | } 44 | 45 | // number 46 | if(strlen($thenumber) < 11) { 47 | if (substr($thenumber,0,1) == '0') { 48 | $number_error = false; 49 | } else { 50 | $number_error = true; 51 | } 52 | } 53 | 54 | if(!$number_error) { 55 | $this->DebugPrint("Numret ar svenskt, slar nu upp numret."); 56 | $this->DebugPrint("Search in 118100.se... "); 57 | 58 | $url="http://www.118100.se/sok/$thenumber"; 59 | $value = $this->get_url_contents($url); 60 | 61 | $notfound = strpos($value, "Hoppsan!"); //No hit. 62 | $notfound = ($notfound < 1) ? strpos($value, "Hoppsan!") : $notfound; 63 | if($notfound) { 64 | $value = ""; 65 | $this->DebugPrint("www.118100.se reports number not found!
    \n"); 66 | } else { 67 | $start = strpos($value, "nameBlock\">"); 68 | $value = substr($value,$start+12); 69 | $end = strpos($value, ""); 70 | $value = substr($value,0,$end); 71 | } 72 | if (strlen($value) > 1) { 73 | $caller_id = strip_tags($value); 74 | return($caller_id); 75 | } else { 76 | $this->DebugPrint("www.118100.se returns no data!
    \n"); 77 | } 78 | } else { 79 | $this->DebugPrint("Skipping Source - Non Swedish number: ".$thenumber."
    \n"); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /sources/source-SE_missatsamtal_HE.module: -------------------------------------------------------------------------------- 1 | array ( 10 | 'description' => 'Specify the number of listings required to mark a call as spam.', 11 | 'type' => 'number', 12 | 'default' => 3 13 | ), 14 | 'API_Key' => ARRAY ( 15 | 'description' => 'API Key is not yet available from missatsamtal.se (not needed)', 16 | 'type' => 'text' 17 | ) 18 | ); 19 | 20 | function get_caller_id($thenumber, $run_param=array()) { 21 | $caller_id = null; 22 | 23 | $this->DebugPrint("Searching missatsamtal.se... "); 24 | $url = "http://api.missatsamtal.se/?action=search&number=$thenumber&numberOfCompanies=1"; 25 | $value = $this->get_url_contents($url); 26 | 27 | // $VALUE = NAMNET PA FORETAGET 28 | // $spamcalls = antalet ganger som spamnumret ar listat 29 | 30 | $start = strpos($value, "comments"); // STARTPOS is position for the first char in "comments" 31 | 32 | $value = substr($value,$start+11); // Skip text "comments" 33 | $this->DebugPrint("NEWVAULE=".$value."\n"); 34 | 35 | $end = strpos($value, "\""); // Look for next ["] indication the end of the number 36 | $spamcalls = substr($value,0,$end); // Save result in $spamcalls 37 | 38 | $start = strpos($value, "name"); 39 | $value = substr($value,$start+7); // Skip text "name" 40 | 41 | $end = strpos($value, "\""); // Look for next ["] indication the end of the name 42 | $value = substr($value,0,$end); // Save result in $value from startpost 0 to endpos $end 43 | 44 | $SPAM_threshold = intval($spamcalls); 45 | $this->DebugPrint("SPAMVALUE RECEIVED=".$SPAM_threshold."\n"); 46 | 47 | if ($value != "0" ) { 48 | $this->spam = true; 49 | $this->DebugPrint(" determined to be SPAM"); 50 | } else { 51 | $this->DebugPrint("Not a SPAM caller"); 52 | return(""); 53 | } 54 | return("SPAM:".$value); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /sources/source-SE_vemringde_HE.module: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreePBX/superfecta/5f5a5b243a15b205bd10eae0115671aba1eda3f0/sources/source-SE_vemringde_HE.module -------------------------------------------------------------------------------- /sources/source-Say_No_To_0870_UK.module: -------------------------------------------------------------------------------- 1 | description = "http://www.saynoto0870.com - "._("These listings include Non-Geographical Alternative Business Telephone Numbers for the UK."); 24 | } 25 | 26 | function get_caller_id($thenumber, $run_param=array()) { 27 | 28 | $caller_id = null; 29 | 30 | if (!$this->IsValidNumber('UK', $thenumber)) { 31 | $this->DebugPrint("Skipping Source - Non UK number: {$thenumber}"); 32 | } else { 33 | $this->DebugPrint("Searching SayNoTo0870 for number: {$thenumber}"); 34 | 35 | // By default, the found name is empty 36 | $name = ""; 37 | 38 | // numbersearch.php requires data to be posted 39 | $url = "https://www.saynoto0870.com/numbersearch.php"; 40 | $PostData = array("number" => $thenumber); 41 | 42 | // Grab the first result that matches our phone number 43 | $pattern = '/\s*(.*)<\/a><\/td>/U'; 44 | 45 | if ($this->SearchURL($url, $pattern, $match, $PostData)) { 46 | $caller_id = $this->ExtractMatch($match); 47 | } 48 | } 49 | return($caller_id); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /sources/source-Send_to_Dreambox.module: -------------------------------------------------------------------------------- 1 | Enter the URL to the destination dreambox in the format `http://url:port`.
    This datasource should be one of the last data sources on your list, as it does not provide any data of its own, and can only send what information has been collected before it is run."; 6 | public $version_requirement = "2.11"; 7 | public $source_param = array( 8 | 'URL_address' => array( 9 | 'description' => 'Specify the URL:Port to the dreambox installation. (Example: http://script.somewhere.com:80)', 10 | 'type' => 'text', 11 | 'default' => "http://url:80" 12 | ), 13 | 'Display_Setting' => array( 14 | 'description' => 'Specify the way you want the number to be displayed on your dreambox', 15 | 'type' => 'select', 16 | 'option' => array( 17 | 1 => '(132) 456-7890', 18 | 2 => '132-456-7890', 19 | 3 => '12 34 56 78 90', 20 | 4 => 'No Formatting', 21 | ), 22 | 'default' => 4 23 | ) 24 | ); 25 | 26 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 27 | if ($run_param['URL_Address'] && $run_param['URL_Port'] != '') { 28 | $thenumberformated = $thenumber; 29 | switch ($run_param['Display_Setting']) { 30 | case 1: 31 | case 2: 32 | case 3: 33 | $settings = $this->settings(); 34 | $thenumberformated = $this->FormatNumber($thenumber, $settings["source_param"]['Format_Incomming_Number']['option'][$run_param['Format_Incomming_Number']]); 35 | break; 36 | } 37 | 38 | $cliddreambox = urlencode($first_caller_id . ',' . $thenumberformated); 39 | $url = $run_param['URL_address'] . '/cgi-bin/message?message=' . $cliddreambox; 40 | 41 | $this->DebugPrint("Send to dreambox: " . $run_param['URL_address']); 42 | $value = get_url_contents($url); 43 | 44 | return($thenumber); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /sources/source-Send_to_IFTTT.module: -------------------------------------------------------------------------------- 1 | array( 26 | 'description' => 'Webhook Token for Webhook event', 27 | 'type' => 'text', 28 | 'default' => null, 29 | ), 30 | 'Event_Name' => array( 31 | 'description' => 'Event name for your IFTTT Webhook {{value1}} and {{value2}} are CID name and CID number respectively.', 32 | 'type' => 'text', 33 | 'default' => 'superfecta', 34 | ), 35 | ); 36 | 37 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 38 | $this->DebugPrint("Loading IFTTT event ".$run_param['Event_Name']); 39 | $curl = curl_init(); 40 | $url = 'https://maker.ifttt.com/trigger/'.$run_param['Event_Name'].'/with/key/'.$run_param['Token']; 41 | curl_setopt($curl, CURLOPT_URL, $url); 42 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); 43 | $queryData['value1'] = $first_caller_id; 44 | $queryData['value2'] = $thenumber; 45 | $data = json_encode($queryData); 46 | curl_setopt($curl, CURLOPT_HTTPHEADER, array( 47 | 'Content-Type: application/json', 48 | 'Content-Length: ' . strlen($data) 49 | )); 50 | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 51 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 52 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 53 | $response = curl_exec($curl); 54 | curl_close($curl); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /sources/source-Send_to_NotifyMyAndroid.module: -------------------------------------------------------------------------------- 1 | 10 | valid keys will return this: 11 | 12 | 13 | 14 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/ 15 | 16 | class Send_to_NotifyMyAndroid extends superfecta_base { 17 | 18 | public $description = "This source will send the CID number and the CID name to Notify My Android. You must register at notifymyandroid.com and get an API then install the ap and login on your Android device."; 19 | public $version_requirement = "2.11"; 20 | public $source_param = array ( 21 | 'API' => array( 22 | 'description' => 'Unique user API key from notifymyandroid.com. Separate multiple APIs with a comma.', 23 | 'type' => 'textarea', 24 | ) 25 | ); 26 | 27 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 28 | if (($run_param['API'] != '') && ($first_caller_id != '')) { 29 | $count = 0; 30 | $apis=explode(',',$run_param['API']); 31 | foreach ( $apis as $api ){ 32 | $count = $count+1; 33 | $api=trim($api); 34 | 35 | if($api){ 36 | $url = "https://www.notifymyandroid.com/publicapi/notify?apikey=". $api ."&application=Superfecta&event=Incoming%20Call&description=Call%20from%20".urlencode($first_caller_id)."%20at%20".urlencode($thenumber); 37 | // $this->DebugPrint("Sent to NotifyMyAndroid $url"); 38 | $this->DebugPrint("Sent to NotifyMyAndroid api#$count"); 39 | $value = $this->get_url_contents($url); 40 | preg_match("/code=\"(.+?)\"/",$value,$match); 41 | if ($match[1] == 200) { 42 | $this->DebugPrint("NotifiyMyAndroid response api#$count: success"); 43 | } else { 44 | $this->DebugPrint("NotifiyMyAndroid response api#$count: error"); 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /sources/source-Send_to_URL.module: -------------------------------------------------------------------------------- 1 | array( 17 | 'description' => 'Specify A URL to send CID/CNAM data to. Use the format \'http://url.org?thenumber=[NUMBER]&CLID=[NAME]\' where [NAME] and [NUMBER] will have actual values substituted', 18 | 'type' => 'textarea', 19 | 'default' => "http://10.0.0.10?thenumber=[NUMBER]&CLID=[NAME]" 20 | ) 21 | ); 22 | 23 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 24 | 25 | if (($run_param['URL_address'] != '') && ($first_caller_id != '')) { 26 | 27 | // replace [NAME] and [NUMBER] placeholders with actual urlencoded values 28 | $url = $run_param['URL_address']; 29 | $url = str_replace('[NAME]', urlencode($first_caller_id), $url); 30 | $url = str_replace('[NUMBER]', urlencode($thenumber), $url); 31 | $url = str_replace('[name]', urlencode($first_caller_id), $url); 32 | $url = str_replace('[number]', urlencode($thenumber), $url); 33 | $this->DebugPrint("Send to URL: {$url}"); 34 | 35 | $value = $this->get_url_contents($url); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sources/source-Send_to_Winunciator.module: -------------------------------------------------------------------------------- 1 | You may configure up to 5 Winunciator installations at once.
    This datasource should be one of the last data sources on your list, as it does not provide any data of its own, and can only send what information has been collected before it is run."; 11 | public $version_requirement = "2.11"; 12 | public $source_param = array(); 13 | 14 | function __construct() { 15 | for ($client = 1; $client <= MAX_WINUNCIATORS; $client++) { 16 | $this->source_param["URL_address_{$client}"]['desc'] = 'Specify the Enter the IP/machine name/FQDN of the windows machine running Winunciator. (Example: 192.168.0.99)'; 17 | $this->source_param["URL_address_{$client}"]['type'] = 'text'; 18 | $this->source_param["URL_address_{$client}"]['default'] = ''; 19 | $this->source_param["URL_port_{$client}"]['desc'] = 'Specify the PORT to the Winunciator installation. (Example: 8080)'; 20 | $this->source_param["URL_port_{$client}"]['type'] = 'text'; 21 | $this->source_param["URL_port_{$client}"]['default'] = '8080'; 22 | } 23 | } 24 | 25 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 26 | for ($client = 1; $client <= MAX_WINUNCIATORS; $client++) { 27 | if ($run_param["URL_address_{$client}"] && $run_param["URL_port_{$client}"] != '') { 28 | $value = $this->get_url_contents($run_param["URL_address_{$client}"] . ':' . $run_param["URL_port_{$client}"] . '/' . $first_caller_id . '|' . $thenumber); 29 | $this->DebugPrint("Send to Winunciator-{$client}: " . $run_param["URL_address_{$client}"] . ':' . $run_param["URL_port_{$client}"] . '/' . $first_caller_id . '|' . $thenumber); 30 | } 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sources/source-Send_to_YAC.module: -------------------------------------------------------------------------------- 1 | The message will be sent as a Call notification
    This datasource should be one of the last data sources on your list, as it does not provide any data of its own, and can only send what information has been collected before it is run.
    This data source requires Superfecta Module version 2.11 or higher."; 6 | public $version_requirement = "2.11"; 7 | public $source_param = array( 8 | 'Server_address' => array( 9 | 'description' => 'Specify the server IP or domain name address to call after a CLID was found.', 10 | 'type' => 'text' 11 | ), 12 | 'Server_TCP_Port' => array( 13 | 'description' => 'Specify the TCP port to be used (default for YAC is 10629).', 14 | 'type' => 'number', 15 | 'default' => '10629' 16 | ), 17 | 'Default_CNAM' => array( 18 | 'description' => 'Text to push if no CNAM is found. Leave blank to prevent Superfecta from sending anything if no CNAM is found.', 19 | 'type' => 'text', 20 | 'default' => 'Unknown' 21 | ) 22 | ); 23 | 24 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 25 | $yac_cnam = ""; 26 | 27 | if ($first_caller_id != "") { 28 | $yac_cnam = $first_caller_id; 29 | } else if ($run_param['Default_CNAM'] != "") { 30 | $yac_cnam = $run_param['Default_CNAM']; 31 | } 32 | 33 | if (($run_param['Server_address'] != '') && ($yac_cnam != '')) { 34 | $yac_text = $yac_cnam . '~' . $thenumber; 35 | shell_exec('/bin/echo -e -n "@CALL' . $yac_text . '"|nc -w 1 ' . $run_param['Server_address'] . ' ' . $run_param['Server_TCP_Port'] . ''); 36 | 37 | $this->DebugPrint("Send to YAC: ${yac_text}"); 38 | } 39 | 40 | return($thenumber); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /sources/source-Send_to_Yo.module: -------------------------------------------------------------------------------- 1 | array( 19 | 'description' => 'Enter User or App API Key https://dashboard.justyo.co', 20 | 'type' => 'text', 21 | 'default' => null 22 | ), 23 | 'User' => array( 24 | 'description' => 'Enter a specific Username or \'all\' to Yo all subscribers', 25 | 'type' => 'text', 26 | 'default' => 'all' 27 | ), 28 | ); 29 | 30 | function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { 31 | $this->DebugPrint("Sending Yo"); 32 | if(($run_param['API_Token'] == null) || ($run_param['User'] == null)){ 33 | $this->DebugPrint("Failed: Missing one or more required values"); 34 | return; 35 | } 36 | $curl = curl_init(); 37 | $user = strtolower($run_param['User']); 38 | if ($user == 'all') { 39 | $url = 'https://api.justyo.co/yoall/'; 40 | } else { 41 | $url = 'https://api.justyo.co/yo/'; 42 | } 43 | curl_setopt($curl, CURLOPT_URL, $url); 44 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); 45 | $queryData['api_token'] = $run_param['API_Token']; 46 | if ($user != 'all') { 47 | $queryData['username'] = $run_param['User']; 48 | } 49 | $queryData['text'] = "Call from: ".$thenumber; 50 | curl_setopt($curl, CURLOPT_POSTFIELDS, $queryData); 51 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 52 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 53 | curl_setopt($curl, CURLOPT_SAFE_UPLOAD, TRUE); 54 | $response = curl_exec($curl); 55 | curl_close($curl); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /sources/source-TelefonABC_Austria.module: -------------------------------------------------------------------------------- 1 | description = "http://www.telefonabc.at - "._("These listings include data for TelefonABC in Austria."); 25 | } 26 | 27 | function get_caller_id($thenumber, $run_param=array()) { 28 | $this->DebugPrint(_("Searching"). "http://www.telefonabc.at ... "); 29 | 30 | if($thenumber !== 'anonymous' && $thenumber !== 'unknown' && $thenumber !== ''){ 31 | 32 | if (substr($thenumber, 0, 1) ==! '0') { 33 | $thenumber=trim($thenumber,' '); 34 | $thenumber="00" . $thenumber; 35 | } 36 | if (substr($thenumber, 0, 2) === '00') { 37 | $thenumber=trim($thenumber,' '); 38 | } 39 | 40 | // Set the url we're searching for 41 | $res_rul = "http://www.telefonabc.at/result.aspx?what=".$thenumber."&where=&exact=False&firstname=&lastname=&appendix=&branch=&p=0&sid=&did=&cc=";// url for searching persons 42 | 43 | // regex patterns to search for 44 | $regexp = array( 45 | '#

    (.+?)

    #s', 46 | ); 47 | // search for persons match 48 | if ($this->SearchURL($res_rul, $regexp, $match)) { 49 | $caller_id = $this->ExtractMatch($match); 50 | } 51 | $caller_id = isset($caller_id)?$caller_id:''; 52 | 53 | return($caller_id); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /sources/source-TellowsAPI.module: -------------------------------------------------------------------------------- 1 | description = "https://www.tellows.de/ - "._("A datasource devoted to identifying spam callers."); 10 | $this->source_param = array( 11 | 'SPAM_Threshold' => array( 12 | 'description' => _('Specify the score from which a call is considered spam.'), 13 | 'type' => 'number', 14 | 'default' => 7 15 | ), 16 | 'COMMENTS_Threshold' => array( 17 | 'description' => _('Specify the number of comments which are needed for spam classification.'), 18 | 'type' => 'number', 19 | 'default' => 2 20 | ), 21 | 'SEARCHES_Threshold' => array( 22 | 'description' => _('Specify the number of searches which are needed for spam classification.'), 23 | 'type' => 'number', 24 | 'default' => 5 25 | ), 26 | 'Tellows_Key' => array( 27 | 'description' => _('Tellows API key (MD5 Hash).'), 28 | 'type' => 'text', 29 | 'default' => '' 30 | ) 31 | ); 32 | } 33 | 34 | function get_caller_id($thenumber, $run_param=array()) { 35 | // $thuenumber must be in E164 format: [+][country code][subscriber number including area code] 36 | 37 | $apihash = $run_param['Tellows_Key']; 38 | if ($apihash <> '') { 39 | $url = "https://www.tellows.de/basic/num/$thenumber?json=1&partner=tellowskey&apikey=$apihash"; 40 | $this->DebugPrint(_('Request with API key')." ".$apihash); 41 | } else { 42 | $url = "https://www.tellows.de/basic/num/$thenumber?json=1"; 43 | $this->DebugPrint(_('Request without API key')); 44 | } 45 | $json = $this->get_url_contents($url); 46 | $errchk = strpos(strtolower($json),"error"); 47 | if ($errchk > 0) { 48 | $this->DebugPrint(_("Invalid request format")); 49 | } else { 50 | $result = json_decode($json,true); 51 | $value = $result['tellows']['score']; 52 | $comments = $result['tellows']['comments']; 53 | $searches = $result['tellows']['searches']; 54 | 55 | if (is_numeric($value)) { 56 | $this->DebugPrint(_('Found')." score ".$value." (".$run_param['SPAM_Threshold'].") with ".$comments." (".$run_param['COMMENTS_Threshold'].") comments and ".$searches." (".$run_param['SEARCHES_Threshold'].") searches"); 57 | 58 | $score = $value; 59 | if ($score >= $run_param['SPAM_Threshold'] AND $comments >= $run_param['COMMENTS_Threshold'] AND $searches >= $run_param['SEARCHES_Threshold']) { 60 | $this->spam = true; 61 | $this->DebugPrint(" "._("determined to be SPAM")); 62 | } else { 63 | $this->DebugPrint(_("Not a SPAM caller")); 64 | } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /sources/source-Twilio.module: -------------------------------------------------------------------------------- 1 | . 19 | * 20 | * 04.28.2016 initial release by James Finstrom jfinstrom@sangoma.com 21 | * 05.19.2025 Fix oops error caused by misformatted numbers 22 | */ 23 | 24 | class Twilio extends superfecta_base{ 25 | public $description = "Twilio Cnam Lookup"; 26 | public $version_requirement = "2.11"; 27 | public $source_param = array( 28 | 'AccountSid' => array( 29 | 'description' => "AccountSID - Can be obtained from https://www.twilio.com/user/account/messaging/dev-tools/api-keys", 30 | 'type' => 'text' 31 | ), 32 | 'AuthToken' => array( 33 | 'description' => "AuthToken - Can be obtained from https://www.twilio.com/user/account/messaging/dev-tools/api-keys", 34 | 'type' => 'text' 35 | ) 36 | ); 37 | function get_caller_id($thenumber, $run_param=array()) { 38 | $run_param['AccountSid'] = isset($run_param['AccountSid'])?$run_param['AccountSid']:''; 39 | $run_param['AuthToken'] = isset($run_param['AuthToken'])?$run_param['AuthToken']:''; 40 | $debug = $this->debug; 41 | if(empty($run_param['AccountSid']) || empty($run_param['AuthToken'])) { 42 | $this->DebugPrint("Twilio requires a registered account."); 43 | return ''; 44 | } 45 | $url = sprintf("https://%s:%s@lookups.twilio.com/v1/PhoneNumbers/%s?Type=caller-name",$run_param['AccountSid'],$run_param['AuthToken'],$thenumber); 46 | $ret = $this->get_url_contents($url); 47 | $data = json_decode($ret, true); 48 | if(isset($data['status']) && $data['status'] == 404){ 49 | $this->DebugPrint("Lookup Error"); 50 | $this->DebugPrint($data['message']); 51 | } 52 | if(isset($data['caller_name']) ){ 53 | return($data['caller_name']['caller_name']); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /sources/source-UKPhoneInfo_UK.module: -------------------------------------------------------------------------------- 1 | Because the data provided is less specific than other sources, this data source is usually configured near the bottom of the list of active data sources."; 17 | public $version_requirement = "2.11"; 18 | 19 | function get_caller_id($thenumber, $run_param=array()) { 20 | $caller_id = null; 21 | $name = ""; 22 | 23 | // Validate number 24 | if (!$this->IsValidNumber('UK', $thenumber)) { 25 | $this->DebugPrint("Skipping Source - Non UK number: {$thenumber}"); 26 | } else { 27 | $this->DebugPrint('Searching UKPhoneInfo ...'); 28 | $url = "https://www.ukphoneinfo.com/search?q={$thenumber}"; 29 | if ($this->SearchURL($url, "=]*>(.*)

    =siU", $match)) { 30 | $caller_id = $this->ExtractMatch($match); 31 | } 32 | } 33 | return($caller_id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sources/source-UK_0870_me.module: -------------------------------------------------------------------------------- 1 | DebugPrint("Searching 0870.me - $thenumber ... "); 24 | 25 | // Search 0870.me 26 | $url = "http://0870.me/get/json/$thenumber"; 27 | $this->DebugPrint($url); // for debug 28 | 29 | $value = $this->get_url_contents($url); 30 | //$value = '{"number":{"original_number":"08442411653","replacement_number":"02071267020","company":" Sky (BSkyB)"}}'; // For debug 31 | $result = (array)json_decode($value,true); 32 | 33 | 34 | if (isset($result['number']['company'])) { 35 | if ($result['number']['company'] == 'Not Found') { 36 | //record not found 37 | } else { 38 | $name = trim($result['number']['company']); 39 | } 40 | } 41 | // If we found a match, return it 42 | if (strlen($name) > 1) { 43 | $caller_id = $name; 44 | } else { 45 | $this->DebugPrint("not found"); 46 | } 47 | 48 | return($caller_id); 49 | } 50 | } -------------------------------------------------------------------------------- /sources/source-VoIPCNAM.module: -------------------------------------------------------------------------------- 1 | -- 5 | //This module was modified from the original Google Module for Superfecta 2.0 to work with the VoIPCNAM.com 6 | //lookup service. I take no responsibilities for anything that may go wrong with this script or your PBX. 7 | //If the internet crashes or the earth caves in on itself as a direct result of running this script, please 8 | //do not hold me responsible. 9 | //INSTALLATION INSTRUCTIONS 10 | // 11 | // 1. Open FreePBX and goto the CID Superfecta Module. You can get this API Key from here: http://www.voipcnam.com/index.php?page=account_api 12 | // 13 | // 2. Check the 'Check for Data Source File updates online', and choose this source in dropdown list. 14 | // 15 | // 3. Enter your API key. You can get it from here: http://www.voipcnam.com/index.php?page=account_api 16 | // 17 | // 4. Enable the service and set the priority you want to use it. I have mine set as the last item as 18 | // I want to exaust all other searches before using this service. 19 | // 20 | // 5. Test it in the debug window. Please note that this will charge your VoIPCNAM account even when 21 | // using the test number provided by VoIPCNAM. It will also use your credits with VoIPCNAM everytime 22 | // you test any other number in the debug window. I recommend disabling it while testing other providers 23 | // and then enabling it when you are ready to use it. 24 | // 25 | // Enjoy and drop me a note if you have any other questions. 26 | 27 | class VoIPCNAM extends superfecta_base { 28 | 29 | public $description = "http://www.voipcnam.com - This module provides lookups from the VoIPCNAM.com lookup service."; 30 | public $version_requirement = "2.11"; 31 | public $source_param = array( 32 | 'API_Key' => array( 33 | 'description' => 'API Key REQUIRED. Get it from voipcnam.com.', 34 | 'type' => 'text' 35 | ) 36 | ); 37 | 38 | function get_caller_id($thenumber, $run_param=array()) { 39 | 40 | $caller_id = null; 41 | 42 | if (!$this->IsValidNumber('US,CA', $this->thenumber)) { 43 | $this->DebugPrint("Skipping Source - Non US/CAN number: {$this->thenumber}"); 44 | } else { 45 | $this->DebugPrint("Searching VoIPCNAM - {$this->thenumber} ... "); 46 | 47 | $url = "http://query.voipcnam.com/query.php?api_key=" . $run_param['API_Key'] . "&number=1$this->thenumber"; 48 | $value = $this->get_url_contents($url); 49 | 50 | if (strlen($value) > 1) { 51 | $caller_id = strip_tags($value); 52 | } else { 53 | $this->DebugPrint("not found"); 54 | } 55 | } 56 | 57 | return($caller_id); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 | Caller ID Superfecta is being uninstalled.
    2 | "; 12 | } 13 | } 14 | 15 | if (! function_exists("outn")) { 16 | function outn($text) { 17 | echo $text; 18 | } 19 | } 20 | 21 | // drop the tables 22 | $sql = "DROP TABLE IF EXISTS superfectaconfig"; 23 | $check = $db->query($sql); 24 | if (DB::IsError($check)) 25 | { 26 | die_freepbx( "Can not delete superfectaconfig table: " . $check->getMessage() . "\n"); 27 | } 28 | 29 | $sql = "DROP TABLE IF EXISTS superfectacache"; 30 | $check = $db->query($sql); 31 | if (DB::IsError($check)) 32 | { 33 | die_freepbx( "Can not delete superfectacache table: " . $check->getMessage() . "\n"); 34 | } 35 | 36 | $sql = "DROP TABLE IF EXISTS superfecta_to_incoming"; 37 | $check = $db->query($sql); 38 | if (DB::IsError($check)) 39 | { 40 | die_freepbx( "Can not delete superfecta_to_incoming table: " . $check->getMessage() . "\n"); 41 | } 42 | 43 | $sql = "DROP TABLE IF EXISTS superfecta_mf"; 44 | $check = $db->query($sql); 45 | if (DB::IsError($check)) 46 | { 47 | die_freepbx( "Can not delete superfecta_mf table: " . $check->getMessage() . "\n"); 48 | } 49 | 50 | $sql = "DROP TABLE IF EXISTS superfecta_mf_child"; 51 | $check = $db->query($sql); 52 | if (DB::IsError($check)) 53 | { 54 | die_freepbx( "Can not delete superfecta_mf_child table: " . $check->getMessage() . "\n"); 55 | } 56 | ?> 57 | -------------------------------------------------------------------------------- /utests/source-CapsuleCRMTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('CapsuleCRM') 22 | ->setMethods(['queryCapsuleCrm']) 23 | ->getMock(); 24 | 25 | // Data CapsuleCRM docs 26 | $mock->expects($this->any()) 27 | ->method('queryCapsuleCrm') 28 | ->willReturn('{"parties":[{"id":11587,"type":"person","about":null,"title":null,"firstName":"Scott","lastName":"Spacey","jobTitle":"Creative Director","createdAt":"2015-09-15T10:43:23Z","updatedAt":"2015-09-15T10:43:23Z","organisation":null,"lastContactedAt":null,"owner":null,"team":null,"addresses":[{"id":12135,"type":null,"city":"Chicago","country":"United States","street":"847 North Rush Street","state":"IL","zip":"65629"}],"phoneNumbers":[{"id":12133,"type":null,"number":"773-338-7786"}],"websites":[],"emailAddresses":[{"id":12134,"type":"Work","address":"scott@homestyleshop.co"}],"pictureURL":"https://capsulecrm.com/theme/default/images/person_avatar_70.png"}]}'); 29 | 30 | $this->assertEquals('Scott Spacey', $mock->get_caller_id('+447000000000', [])); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /utests/source-DasTelefonBuch_GermanyTest.php: -------------------------------------------------------------------------------- 1 | get_caller_id('+4998315050'); 18 | $this->assertEquals("Hetzner Online AG Internetdienstleistungen", $cnam, "The lookup returned an unexpected result for +4998315050"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /utests/source-FccComplaintsTest.php: -------------------------------------------------------------------------------- 1 | get_caller_id('6305424316'); 19 | $this->assertEquals("Schaumburg%2C+IL", $cnam, "The lookup returned an unexpected result for 6305434316"); 20 | */ 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /utests/source-FreePBX_ContactmanagerTest.php: -------------------------------------------------------------------------------- 1 | addGroup("testgroup","external"); 30 | FreePBX::Contactmanager()->addEntryByGroupID($group['id'], array( 31 | 'user' => -1, 32 | 'displayname' => self::$randdisplayname, 33 | 'fname' => self::$randfname, 34 | 'lname' => self::$randlname, 35 | 'company' => self::$randcompany, 36 | 'numbers' => array( 37 | array( 38 | 'number' => self::$randnum 39 | ) 40 | ) 41 | )); 42 | self::$gid = $group['id']; 43 | } 44 | 45 | public function testFormat1(){ 46 | $cnam = self::$o->get_caller_id(self::$randnum,array('Return_Format' => 1)); 47 | $this->assertEquals(self::$randdisplayname, $cnam, "The lookup returned an unexpected result for ".self::$randnum); 48 | } 49 | 50 | public function testFormat2(){ 51 | $cnam = self::$o->get_caller_id(self::$randnum,array('Return_Format' => 2)); 52 | $this->assertEquals(self::$randcompany, $cnam, "The lookup returned an unexpected result for ".self::$randnum); 53 | } 54 | 55 | public function testFormat3(){ 56 | $cnam = self::$o->get_caller_id(self::$randnum,array('Return_Format' => 3)); 57 | $this->assertEquals(self::$randlname." ".self::$randfname, $cnam, "The lookup returned an unexpected result for ".self::$randnum); 58 | } 59 | 60 | public function testFormat4(){ 61 | $cnam = self::$o->get_caller_id(self::$randnum,array('Return_Format' => 4)); 62 | $this->assertEquals(self::$randfname." ".self::$randlname, $cnam, "The lookup returned an unexpected result for ".self::$randnum); 63 | } 64 | 65 | public function tearDown() { 66 | FreePBX::Contactmanager()->deleteGroupByID(self::$gid); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /utests/source-Herold_AustriaTest.php: -------------------------------------------------------------------------------- 1 | get_caller_id('+437252799'); 18 | $this->assertEquals("Mitterhuemer MENSCH | ENERGIE | TECHNIK", $cnam, "The lookup returned an unexpected result for +437252799"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /utests/source-TelefonABC_AustriaTest.php: -------------------------------------------------------------------------------- 1 | get_caller_id('+43727727729'); 18 | $this->assertEquals("Mayr Barbara", $cnam, "The lookup returned an unexpected result for +43727727729"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /utests/source-Who_CalledTest.php: -------------------------------------------------------------------------------- 1 | get_caller_id('6305424316',self::$o->getRunParams(array('CNAM_Lookup' => true))); 18 | $this->assertEquals("Schaumburg%2C+IL", $cnam, "The lookup returned an unexpected result for 6305434316"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /views/footer.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /views/header.php: -------------------------------------------------------------------------------- 1 |
    2 |
      3 |
    • 4 | 5 |
    • 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    • 13 | 14 |
    15 |
    16 |

    17 |
    18 | -------------------------------------------------------------------------------- /views/main.php: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |    
    5 |
    6 | 7 |
    8 | 9 |
    10 |
    11 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | $scheme) {?> 30 | 31 | 32 | 35 | 42 | 43 | 44 | 45 |
    33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 |
    46 | --------------------------------------------------------------------------------