function getBearer() { $project = ""; $protocol = "https://"; $auth = "auth.sphere.io/oauth/token"; $clientID = ""; $clientSecret = ""; $postFields = "grant_type=client_credentials&scope=manage_project:"; $url = $protocol . $clientID . ":" . $clientSecret . "@" . $auth; $pf = $postFields . $project; $ch = curl_init($url); logMe("Initiated curl session."); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $pf); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); logMe("Set options for curl session."); $result = curl_exec($ch); logMe("Executed curl session. Saved result."); curl_close($ch); logMe("Closed curl session."); return $result; }
function majStatus($a_matos, $a_action) { $qry = "Select groupe from materiel where materielID = {$a_matos}"; $sqlCmdMatos = "update materiel set etat='{$a_action}' where materielID={$a_matos}"; $sqlCmdGroupe = "update materiel set etat='{$a_action}' where groupe={$a_matos}"; try { $db = new sqlite3($GLOBALS['dbaseName']); $result = $db->query($qry); $row = $result->fetchArray(); $group = $row[0]; if ($group == $a_matos) { $sqlCmd = $sqlCmdGroupe; } else { $sqlCmd = $sqlCmdMatos; } logMe("LIB : majStatus(\"{$sqlCmd}\")"); $db->exec($sqlCmd); $db->close(); } catch (Exception $e) { logme("ERROR : {$e}"); return; } }
} Minz_Request::_param('url', $self); $nb = 0; foreach ($users as $userFilename) { $username = basename($userFilename, '.txt'); if (!file_exists(USERS_PATH . '/' . $username . '/config.php')) { break; } try { Minz_Session::_param('currentUser', $username); Minz_Configuration::register('user', join_path(USERS_PATH, $username, 'config.php'), join_path(USERS_PATH, '_', 'config.default.php')); FreshRSS_Context::init(); if ($feedController->actualizeAction($simplePie) > 0) { $nb++; } } catch (Exception $e) { logMe('Error: ' . $e->getMessage()); } } $simplePie->__destruct(); unset($simplePie); if ($nb === 0) { header('HTTP/1.1 410 Gone'); logMe('Error: Nobody is subscribed to this feed anymore after all!: ' . $self); die('Nobody is subscribed to this feed anymore after all!'); } elseif (!empty($hubJson['error'])) { $hubJson['error'] = false; file_put_contents('./!hub.json', json_encode($hubJson)); } logMe('PubSubHubbub ' . $self . ' done: ' . $nb); exit('Done: ' . $nb . "\n");
function markAllAsRead($streamId, $olderThanId) { logMe("markAllAsRead({$streamId}, {$olderThanId})\n"); $entryDAO = FreshRSS_Factory::createEntryDao(); if (strpos($streamId, 'feed/') === 0) { $f_id = basename($streamId); $entryDAO->markReadFeed($f_id, $olderThanId); } elseif (strpos($streamId, 'user/-/label/') === 0) { $c_name = basename($streamId); $categoryDAO = new FreshRSS_CategoryDAO(); $cat = $categoryDAO->searchByName($c_name); $entryDAO->markReadCat($cat === null ? -1 : $cat->id(), $olderThanId); } elseif ($streamId === 'user/-/state/com.google/reading-list') { $entryDAO->markReadEntries($olderThanId, false, -1); } echo 'OK'; exit; }
<?php include "domotix.cfg"; include "domotix.lib.php"; // Recherche des actions à réaliser sur les matériels // indiqués dans la table 'planning' de la base de données // pour le critère jour heure minute du moment while (true) { $tabActions = getActions(); foreach ($tabActions as $ligne) { logMe("SRV : Materiel : {$ligne}"); list($materiel, $action) = explode("&", $ligne); $res = executer($materiel, $action); $ret = majStatus($materiel, $action); } sleep(20); }
function authorizationToUser() { $headerAuth = headerVariable('Authorization', 'GoogleLogin_auth'); //Input is 'GoogleLogin auth', but PHP replaces spaces by '_' http://php.net/language.variables.external if ($headerAuth != '') { $headerAuthX = explode('/', $headerAuth, 2); if (count($headerAuthX) === 2) { $user = $headerAuthX[0]; if (ctype_alnum($user)) { $conf = get_user_configuration($user); if (is_null($conf)) { Minz_Log::warning('Invalid API user ' . $user . ': configuration cannot be found.'); unauthorized(); } $system_conf = Minz_Configuration::get('system'); if ($headerAuthX[1] === sha1($system_conf->salt . $user . $conf->apiPasswordHash)) { return $user; } else { logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]); Minz_Log::warning('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]); unauthorized(); } } else { badRequest(); } } } return ''; }