function isLoggedIn($touch_updated_date = TRUE) { global $authentication, $config_vars; $session_id = getSessionID(); if ($session_id != '') { $authentication = new Authentication(); Debug::text('AMF Session ID: ' . $session_id . ' Source IP: ' . $_SERVER['REMOTE_ADDR'], __FILE__, __LINE__, __METHOD__, 10); if (isset($config_vars['other']['web_session_timeout']) and $config_vars['other']['web_session_timeout'] != '') { $authentication->setIdle((int) $config_vars['other']['web_session_timeout']); } if ($authentication->Check($session_id, $touch_updated_date) === TRUE) { return TRUE; } } return FALSE; }
/** * logging出力 */ function logging($arglog, $argLogName = NULL, $argConsolEchoFlag = FALSE) { static $pdate = NULL; static $phour = NULL; static $loggingLineNum = 1; $logpath = dirname(dirname(dirname(dirname(__FILE__)))) . '/log/'; if (class_exists('Configure', FALSE) && NULL !== constant('Configure::LOG_PATH')) { $logpath = Configure::LOG_PATH; } if (class_exists('Configure', FALSE) && NULL !== constant('Configure::DEBUG_ENABLED')) { $debugFlag = Configure::DEBUG_ENABLED; } // XXX ログローテートの実行 if (NULL === $argLogName) { $argLogName = 'process'; } if (NULL === $pdate) { $deftimezone = @date_default_timezone_get(); date_default_timezone_set('Asia/Tokyo'); $dateins = new DateTime(); $pdate = $dateins->format('Y-m-d H:i:s') . ' [UDate:' . microtime(TRUE) . ']'; $phour = $dateins->format('H'); date_default_timezone_set($deftimezone); } if (is_array($arglog) || is_object($arglog)) { $arglog = var_export($arglog, TRUE); } if (isset($_SERVER['REQUEST_URI'])) { $arglog = '[URI:' . $_SERVER['REQUEST_URI'] . ']' . $arglog; } $logstr = $pdate . '[logging' . $loggingLineNum . '][SID:' . getSessionID() . '][UID:' . getUID() . ']' . $arglog; // 改行コードは\rだけにして、一行で表現出来るようにする $logstr = str_replace(PHP_CR, '[EOL]', $logstr); $logstr = str_replace(PHP_LF, '[EOL]', $logstr); if ('process' !== $argLogName) { // process_logは常に出す if (!is_file($logpath . 'process_log')) { @touch($logpath . 'process_log'); @chmod($logpath . 'process_log', 0666); } if (!is_file($logpath . 'process_' . $phour . '.log')) { @touch($logpath . 'process_' . $phour . '.log'); @chmod($logpath . 'process_' . $phour . '.log', 0666); } @file_put_contents($logpath . 'process_log', $logstr . PHP_EOL, FILE_APPEND); @file_put_contents($logpath . 'process_' . $phour . '.log', $logstr . PHP_EOL, FILE_APPEND); } if (!is_file($logpath . $argLogName . '_log')) { @touch($logpath . $argLogName . '_log'); @chmod($logpath . $argLogName . '_log', 0666); } if (!is_file($logpath . $argLogName . '_' . $phour . '.log')) { @touch($logpath . $argLogName . '_' . $phour . '.log'); @chmod($logpath . $argLogName . '_' . $phour . '.log', 0666); } @file_put_contents($logpath . $argLogName . '_log', $logstr . PHP_EOL, FILE_APPEND); @file_put_contents($logpath . $argLogName . '_' . $phour . '.log', $logstr . PHP_EOL, FILE_APPEND); // $debugFlagが有効だったらdebugログに必ず出力 if (isset($debugFlag) && 1 === (int) $debugFlag && isset($_SERVER['REQUEST_URI']) && 'debug' != $argLogName) { debug($arglog); } // XXX consolは画面に出力 if (TRUE === $argConsolEchoFlag && isset($debugFlag) && TRUE == $debugFlag && !isset($_SERVER['REQUEST_URI'])) { echo $logstr . PHP_EOL; } $loggingLineNum++; }
$accountID = 403651; $username = null; $password = null; $error = null; if (isset($_GET["username"])) { $username = $_GET["username"]; } else { $error = "USERNAME NOT SET"; } if (isset($_GET["password"])) { $password = $_GET["password"]; } else { $error = "PASSWORD NOT SET"; } $sessionID = getSessionID($username, $password, $accountID); $eventID = getEventID($sessionID, $accountID); $info = getUserInfo($sessionID, $eventID); if (isset($error)) { } else { echo json_encode($info); } function getSessionID($username, $password, $accountID) { $url = "https://www.kintera.org/api/Authentication/Login.ashx?accountid=" . $accountID; $data = array('username' => $username, 'password' => $password); $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data))); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); $xml = simplexml_load_string($result); if (isset($xml->ErrorMessage)) {
function saveUser($data) { if (getSessionID() != null) { $result = mysql_query("SELECT profil FROM USER WHERE id = '" . getSessionID() . "'"); $row = mysql_fetch_assoc($result); if ($row['profil'] == 0) { //BelBin foreach ($data["belbin"] as $belbin) { // president,coequipier,eclaireur,faiseur,organisateur,evaluateur,creatif,finisseur $id_belbin = mysql_fetch_assoc(mysql_query("SELECT id FROM BELBIN WHERE name = '" . $belbin["name"] . "' limit 1")); mysql_query("INSERT INTO USER_BELBIN(user_id, belbin_id,value) VALUES ('" . getSessionID() . "','" . $id_belbin["id"] . "','" . $belbin["value"] . "')"); } //Skills foreach ($data["skills"] as $skill) { // web,bdd,programmation,metier,marketing $id_skill = mysql_fetch_assoc(mysql_query("SELECT id FROM SKILL WHERE name = '" . $skill["name"] . "' limit 1")); mysql_query("INSERT INTO USER_SKILL(user_id, skill_id,value) VALUES ('" . getSessionID() . "','" . $id_skill["id"] . "','" . $skill["value"] . "')"); } //Incompatibility foreach ($data["incompatibility"] as $user_id_uncompatibility) { mysql_query("INSERT INTO USER_UNCOMPATIBILITY(user_id, user_id_uncompatibility) VALUES ('" . getSessionID() . "','" . $user_id_uncompatibility["id"] . "')"); } mysql_query("UPDATE USER SET profil=true WHERE id='" . getSessionID() . "'"); $_SESSION['profil'] = 1; $response = getJSONFromCodeError(200); return $response; } else { $response = getJSONFromCodeError(305); return $response; } } $response = getJSONFromCodeError(304); return $response; }
echo "Getting Vechicle List...\n"; $vehicles = getVehicles($sessionID); echo count($vehicles->Devices) . " vehicle(s) available. \n"; $vehicleID = getVehicleID(0); print_r(getAvailableActions(0)); echo "Enter Command: "; $handle = fopen("php://stdin", "r"); $line = fgets($handle); $result = json_decode(sendCommandToVehicle($vehicleID, $sessionID, trim($line))); if ($result->Return->ResponseSummary->StatusCode == 0) { echo "Command received successfully.\n"; } else { echo "Error: " . $result->Return->ResponseSummary->ErrorMessage; } } else { $sessionID = getSessionID($smartstart_username, $smartstart_password); $vehicles = getVehicles($sessionID); $vehicleID = getVehicleID(0); //print_r(getAvailableActions(0)); //print_r($vehicles); echo sendCommandToVehicle($vehicleID, $sessionID, $action); } function curlGet($url, $referer = null, $headers = null) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"); if (!is_null($referer)) {
Debug::Arr($backtrace, 'FAILED CALL... Service: ' . $serviceName . ' Method: ' . $methodName . ' Class: ' . $className . ' Message: ' . $e->getMessage(), __FILE__, __LINE__, __METHOD__, 10); throw new Exception('ERROR: Failed calling method: ' . $methodName . ' as part of serivce: ' . $serviceName . '! Exception: ' . $e->getMessage() . ' Arguments: ' . $argument_var_dump . ' BackTrace: ' . $backtrace); unset($argument_var_dump, $backtrace); return FALSE; } //Debug::Arr($retval, 'RetVal: ', __FILE__, __LINE__, __METHOD__, 10); Debug::text('Returning ' . strlen(serialize($retval)) . ' bytes of data... Response Time: ' . ((double) microtime(TRUE) - $invoke_service_start_time), __FILE__, __LINE__, __METHOD__, 10); return $retval; } function exec() { $this->server->exec(); } } //APIAuthentication->isLoggedIn() checks for active session or not as well. $session_id = getSessionID(); //Debug::Arr($_COOKIE,' API Cookies: ', __FILE__, __LINE__, __METHOD__, 10); //Debug::Arr($_POST,' API POST: ', __FILE__, __LINE__, __METHOD__, 10); if ($session_id != '' and !isset($_GET['session'])) { //When Flex calls PING() on a regular basis it will send Session=0, so always skip authentication checks for this. $authentication = new Authentication(); Debug::text('AMF Session ID: ' . $session_id . ' Source IP: ' . $_SERVER['REMOTE_ADDR'], __FILE__, __LINE__, __METHOD__, 10); if (isset($config_vars['other']['web_session_timeout']) and $config_vars['other']['web_session_timeout'] != '') { $authentication->setIdle((int) $config_vars['other']['web_session_timeout']); } if ($authentication->Check($session_id) === TRUE) { $current_user = $authentication->getObject(); if (is_object($current_user)) { $current_user->getUserPreferenceObject()->setDateTimePreferences(); $current_user_prefs = $current_user->getUserPreferenceObject(); Debug::text('Locale Cookie: ' . TTi18n::getLocaleCookie(), __FILE__, __LINE__, __METHOD__, 10);