<?php /*----- function: hum_conn_no_login: void -> connection purpose: expects nothing, has the side-effect of trying to connect to Humboldt's Oracle student database based on where the PHP file resides, and, if successful, returns the resulting connection object, but, if NOT successful, ENDS the document and exits the current PHP document...! (yes, it can do that...!) uses: 328footer-plus-end.html last modified: 2025-04-07 -----*/ function hum_conn_no_login() { // oci_connect, to get a connection object from Oracle, // NEEDS several parameters // (probably seb-server-dependent) - from URL-to-directory // mapping information on the server end, get part of the // needed campus owner's username $os_username = substr($_SERVER["CONTEXT_PREFIX"], 2); // but, for Humboldt's PHP-to-Oracle setup, the Oracle account // you can log into using OCI is your username followed // by _php $ora_php_username = "{$os_username}_php"; // but, to ask to use blah_php's password to log in as blah, // we need to express it in the form blah_php[blah] $conn_username = "{$ora_php_username}[{$os_username}]"; // grab the password from this user's .oraauth $ora_php_password = trim(file_get_contents("/home/{$os_username}/.oraauth")); // now: oci_connect expects: // a username, // a password, // a connection string (can be null in this particular approach, // so PHP can build it from environment variables), // the desired character encoding (we'll use "AL32UTF8"), // the desired session mode (we'll use the default, the PHP constant // OCI_DEFAULT) $connectn = oci_connect(username: $conn_username, password: $ora_php_password, connection_string: null, encoding: "AL32UTF8", session_mode: OCI_DEFAULT); // ADDED AFTER CLASS -- if oci_connect fails to make a connection, // the value returned will be "falsey" -- so you can use an if // statement to end gracefully in that case if (! $connectn) { ?> <p> Could not log into Oracle, sorry! </p> <?php require_once("328footer-plus-end.html"); // in this case, want to exit this PHP document NOW -- // this is reasonable when you have hit an error situation // so bad that there is NO point in going any further exit; } return $connectn; } ?>