'unknown', 'id'=>-1 ); } $user_browser = $_SERVER['HTTP_USER_AGENT']; $user_ip = $_SERVER['REMOTE_ADDR']; $BROWSER = ''; // insert_or_get_browser($user_browser); $ACTION = ok($action) . " / " . dumpit($USER) . " / " . $USER_GOO . " / " . $USER_EMAIL; //$persid = $USER->id; //if (! $persid) { $persid = -1; } $qupdate = "INSERT INTO gavi_logs SET action='{$ACTION}', " /*personnel_id='{$persid}',name='{$USER['user_id']}', */ . "browser=$BROWSER, ip='$user_ip'"; single_row_insert($qupdate,0,$c); return array("result"=>"success","action"=>"logged","query"=>$qupdate,"err"=>mysqli_error($c)); } if ( $server == 'intranet1.gavilan.edu' ) { // The SSO check should have happened on the actual page. If it gets // // stuck on an api call the app will break. if ( session_id() == '' ) { // session_status() == PHP_SESSION_ACTIVE // newer php uses this require 'mAuth.php'; $USER_TYPE = $attributes['http://wso2.org/claims/Roles'][0]; $USER_GOO = $attributes['http://wso2.org/claims/uid'][0]; $USER_EMAIL = $attributes['http://wso2.org/claims/emailaddress'][0]; session_start(); $_SESSION['USER_TYPE'] = $USER_TYPE; $_SESSION['USER_GOO'] = $USER_GOO; $_SESSION['USER_EMAIL'] = $USER_EMAIL; } else { // already logged in.... $USER_TYPE = $_SESSION['USER_TYPE']; $USER_GOO = $_SESSION['USER_GOO']; $USER_EMAIL = $_SESSION['USER_EMAIL']; } } else { // just testing on a different server... $USER_TYPE = 'FACULTY'; $USER_GOO = 'G00102586'; $USER_EMAIL = 'phowell@my.gavilan.edu'; session_start(); $_SESSION['USER_TYPE'] = $USER_TYPE; $_SESSION['USER_GOO'] = $USER_GOO; $_SESSION['USER_EMAIL'] = $USER_EMAIL; } // No email? Might be a problem. Look up by goo if (! $USER_EMAIL) { $goo = substr($USER_GOO, 3); $q0 = "SELECT email,name FROM conf_users WHERE goo='{$goo}'"; $temp_usr = single_row_select($q0,0); $USER_NAME = ''; // Is this a "MISSING USER?" Create an account for them. if (is_null($temp_usr)) { $LC_EMAIL = strtolower($USER_EMAIL); $result = single_row_insert("INSERT INTO conf_users (goo, email, name) VALUES ('{$goo}','{$LC_EMAIL}','{$USER_NAME}');"); //echo "INSERT INTO conf_users (goo, email, name) VALUES ('{$goo}','{$LC_EMAIL}','{$USER_NAME}');"; //print_r($result); //$logaction = log_it("Made a new conf_users row for {$USER_NAME} / {$LC_EMAIL} / {$USER_GOO}"); } $USER_NAME = $temp_usr['name']; $USER_EMAIL = strtolower($temp_usr['email']); } // // // // // Set up user global $goo = substr($USER_GOO, 3); $usr_qry = "SELECT id AS conf_id, goo AS conf_goo, email AS conf_email, name AS conf_name, active AS conf_active FROM conf_users WHERE goo='{$goo}'"; $USER = single_row_select($usr_qry, 0); // Check again for missing user entry. Create an account for them. if (is_null($USER)) { $LC_EMAIL = strtolower($USER_EMAIL); $goo = substr($USER_GOO, 3); $USER_NAME = ''; $result = single_row_insert("INSERT INTO conf_users (goo, email, name) VALUES ('{$goo}','{$LC_EMAIL}','{$USER_NAME}');"); //echo "INSERT INTO conf_users (goo, email, name) VALUES ('{$goo}','{$LC_EMAIL}','{$USER_NAME}');"; //print_r($result); //$logaction = log_it("Made a new conf_users row for {$USER_NAME} / {$LC_EMAIL} / {$USER_GOO}"); $usr_qry = "SELECT id AS conf_id, goo AS conf_goo, email AS conf_email, name AS conf_name, active AS conf_active FROM conf_users WHERE LOWER(email)='{$USER_EMAIL}'"; $USER = single_row_select($usr_qry, 0); }