// LAST UPDATED 190521 BY EUGENEAHN@GMAIL.COM // DEFINE DATABASE INFORMATION define ('DB_USER', 'codeyourheartout'); define ('DB_PASSWORD', 'ScullyRocks2016!'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'codeyourheartout'); // DEFINE MYSQLI CONNECTION $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); ?> // 200126 updated listRecordsOLD() and added sort order as varaible based on format parameter provided by user // 200429 readability cleanups // ACTION HANDLERS if (isset($_GET['action'])) { if ($_GET['action']=="delete") { // take the inbound parameters and delete the item when appid = 0 and id // require a target key to indicate table $target= $_GET['target']; $target_attribute = $target . "_attribute"; $target_content = $target . "_content"; if ($_GET['app_id'] != null && $_GET['app_id'] != "*") { $thisAppID = $_GET['app_id']; $criteriaAppID = "and app_id = $thisAppID"; } else { $criteriaAppID = ""; } $thisID = $_GET['id']; $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); mysqli_query($mysqli,"DELETE FROM $target WHERE id = $thisID $criteriaAppID"); mysqli_query($mysqli,"DELETE FROM $target_attribute WHERE id = $thisID $criteriaAppID"); mysqli_query($mysqli,"DELETE FROM $target_content WHERE id = $thisID $criteriaAppID"); } } // FUNCTIONS function listWebsites($format) { // generate the $formOptionsWebsiteKey = listwebsites(options) $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = " SELECT id, name FROM website ORDER BY name ASC "; $rows=mysqli_query($mysqli,$query); $result=mysqli_num_rows($rows); // do the results here if ($result) { switch ($format) { case "summary": // start a table $report = "
| ID | Name | Actions |
| $row[0] | $row[1] |
| ID | Website Key | Story | Actions |
| $row[0] | $thisWebsiteKey | $thisSourceHeadline $thisSourceAuthor $thisSource | Edit | Delete |
| ID | Website | Title | Actions |
| ID | Website | Location | Actions |
| ID | Source | Author | Headline (with Link) | Actions |
| $row[0] $row[1] | $thisWebsiteID | $thisTitle | ||
| $row[0] $row[1] | $thisWebsiteID | $thisTitle | ||
| $row[0] | $thisSource | $thisSourceAuthor | $thisSourceHeadline | Edit | Delete |
| type | |||||||
| $row[0] | $thisType | $thisAStatus | $thisCAction$thisCName $thisCTitle $thisCSourceHeadline | $thisALocation $thisACategory $thisAVehicle | Manage |
| id | requested | status | request | fresca | blarney | actions |
| $row[0] | $thisAStatus | $thisCAction$thisCName $thisCTitle $thisCSourceHeadline | $thisALocation $thisACategory $thisAVehicle | Manage |
| Date | Author | Note | Action |
| $row[0] | $thisPersonName | $row[1] |
No Notes. Add a note:
"; } return $content; } function getRecordQuotes($table,$id) { $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = " SELECT create_date, content FROM $table WHERE id = '$id' AND type = 'Quote' ORDER BY create_date "; $rows=mysqli_query($mysqli,$query); $result=mysqli_num_rows($rows); // do the results here if ($result) { $content = "| Date | Quote | Action |
| $row[0] | $row[1] | Modify | Delete | Artifactize |
No Quotes. Add a quote:
"; } return $content; } function getRecordDetails($table,$id,$appID,$type,$field) { // if appID is not null, then use it in query, otherwise, no if ($appID != null && $appID != "*") { $queryAppID = "AND app_id = '$appID'"; } else { $queryAppID = null; } $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = " SELECT $field FROM $table WHERE id = '$id' AND type = '$type' $queryAppID "; $rows=mysqli_query($mysqli,$query); $result=mysqli_num_rows($rows); // do the results here if ($result) { while ($row = mysqli_fetch_array($rows,MYSQLI_NUM)) { $content = $row[0]; } } return $content; } function getRecordDetailsTypeName($table,$id,$appID,$type,$name,$field) { // ADDED 200312 // if appID is not null, then use it in query, otherwise, no if ($appID != null && $appID != "*") { $queryAppID = "AND app_id = '$appID'"; } else { $queryAppID = null; } $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = " SELECT $field FROM $table WHERE id = '$id' AND type = '$type' AND name = '$name' $queryAppID "; $rows=mysqli_query($mysqli,$query); $result=mysqli_num_rows($rows); // do the results here if ($result) { while ($row = mysqli_fetch_array($rows,MYSQLI_NUM)) { $content = $row[0]; } } return $content; } function getRecordDetailsTypeNameRelate($table,$id,$appID,$type,$name,$field,$relate_key,$relate_value) { // ADDED 200316 // if appID is not null, then use it in query, otherwise, no if ($appID != null && $appID != "*") { $queryAppID = "AND app_id = '$appID'"; } else { $queryAppID = null; } $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = " SELECT $field FROM $table WHERE id = '$id' AND type = '$type' AND name = '$name' AND relate_key = '$relate_key' AND relate_value = '$relate_value' $queryAppID "; $rows=mysqli_query($mysqli,$query); $result=mysqli_num_rows($rows); // do the results here if ($result) { while ($row = mysqli_fetch_array($rows,MYSQLI_NUM)) { $content = $row[0]; } } return $content; } function listArtifact($type) { // this function prepares a report of artifacts with type = URL Link, the same type of artifact being written. } function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } ?> /* EVERYTHING IN HERE IS PHP */ /* if (something){ then do this } else { then do this instead } */ $confirmationMessage = ""; if ($_POST['email'] != null) { // THERE IS POST CONTENT. PROCESS IT! // REGISTER RECIPIENT // Art 645 is an LACC class. So the Ask for now always goes to the instructor $email = "eugeneahn@gmail.com"; // get all the content, register it $person = $_POST['personName']; $personEmail = $_POST['personEmail']; $personGoal = $_POST['personGoal']; $alertRecipient = $email; $alertSubject = "[ Art64X.com ] - A course registration request from $person $personEmail"; $alertContent = "Submit a request for an account and login to the website.
"; $confirmationMessage = "Participate in an important survey!
"; } $newsFeed = displayNewsFeed("1",null,null,null,null,"5"); ?>Learn the art and craft of web design from the Department of Visual And Media Art at Los Angeles City College.
Course instructor: Eugene Ahn, MA. Email: AhnEW@laccd.edu