function Bod_Nueva() { $queryBodegaNueva = "INSERT INTO bodega (Ubicacion, Descripcion_Bod) VALUES ('$this->bodega_ubicacion', '$this->bodega_descripcion')"; db_connect(); $validador = mysql_query($queryBodegaNueva); $this->bodega_id = MYSQL_INSERT_ID(); db_close(); if ($validador) { $return = $this->bodega_id; } else { $return = false; } return $return; }
function Obra_Nueva() { $queryObraNueva = "INSERT INTO obra (SERVICIO_ID, DESCRIPCION_OBR, NOMBRE_OBR, FECHA_INI) VALUES($this->obra_id_servicio,'$this->obra_descripcion','$this->obra_nombre',CURRENT_TIMESTAMP);"; db_connect(); mysql_query($queryObraNueva); $validador = mysql_affected_rows(); $this->obra_id = MYSQL_INSERT_ID(); db_close(); if ($validador !== 0) { $return = $this->obra_id; } else { $return = false; } return $return; }
function VtaS_Nueva() { $queryServicio = "INSERT INTO servicio (Nombre, Descripcion) VALUES ('$this->VtaS_Nombre', '$this->VtaS_Descripcion')"; db_connect(); mysql_query($queryServicio); $validadorServicio = mysql_affected_rows(); $ultimoID = MYSQL_INSERT_ID(); if ($validadorServicio !== 0) { $validarServicio = true; } else { $validarServicio = false; } $queryVentaDeServicio = "INSERT INTO venta_de_servicio (Servicio_ID, Rut_Cli, Rut_Emp, Fecha) VALUES ('$ultimoID', '$this->VtaS_RutCliente', '$this->VtaS_RutEmpleado', CURRENT_TIMESTAMP)"; mysql_query($queryVentaDeServicio); $validadorVentaServicio = mysql_affected_rows(); db_close(); if ($validadorVentaServicio !== 0) { $validarVentaServicio = true; } else { $validarVentaServicio = false; } if ($validarServicio == true AND $validarVentaServicio == true) { return $ultimoID; } else { return false; } }
$address1 = addslashes($address1); $city = addslashes($city); $state = addslashes($state); $zip = addslashes($zip); $country = addslashes($country); $phone = addslashes($phone); $email = addslashes($email); $begin = addslashes($begin); $end = addslashes($end); $body = addslashes($body); $notes = addslashes($notes); } // Process variables if (!$name1) { $name1 = "Untitled"; } $begin = $begin ? date("Y-m-d H:i:s", strToTime($begin)) : NULL; $end = $end ? date("Y-m-d H:i:s", strToTime($end)) : NULL; // Add object to database $sql = "INSERT INTO objects (\n\t\t\tcreated, modified, \n\t\t\tname1, name2, \n\t\t\taddress1, city, state, zip, country, \n\t\t\tphone, email, \n\t\t\tbegin, end, \n\t\t\tbody, notes) \n\t\tVALUES ('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', \n\t\t\t'{$name1}', '{$name2}', \n\t\t\t'{$address1}', '{$city}', '{$state}', '{$zip}', '{$country}', \n\t\t\t'{$phone}', '{$email}', \n\t\t\t'{$begin}', '{$end}', \n\t\t\t'{$body}', '{$notes}'\n\t\t)"; $result = MYSQL_QUERY($sql); $insertId = MYSQL_INSERT_ID(); ///////////// // WIRES // ///////////// $sql = "INSERT INTO wires (\n\t\t\tcreated, modified, \n\t\t\tfromid, toid\n\t\t) \n\t\tVALUES('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', \n\t\t\t'{$object}', '{$insertId}'\n\t\t)"; $result = MYSQL_QUERY($sql); echo "Object added successfully.<br /><br />"; echo "<a href='" . $dbAdmin . "browse.php" . urlData() . "'>CONTINUE...</a>"; } require_once "GLOBAL/foot.php";
<?php include 'header.php'; include 'db_connect.php'; $COMMENTS = $_POST['comments']; $COMPANY = $_POST["companyname"]; $AUTHORITY = $_POST["authority"]; $statement = "INSERT INTO supervisor (authority, company_name) " . "VALUES ('{$AUTHORITY}', '{$COMPANY}')"; $query = MYSQL_QUERY($statement) or die("Sup Query failed with error: " . MYSQL_ERROR()); $ID = MYSQL_INSERT_ID(); $statement = "INSERT INTO supervisor_comments (id_num, comments, orgname)\r\n\tVALUES ('" . $ID . "', '" . $COMMENTS . "', '" . $COMPANY . "')"; $query = MYSQL_QUERY($statement) or die("Sup Comm Query failed with error: " . MYSQL_ERROR()); ?> Your comments will be reviewed by a system administrator and removed if deemed inappropriate.<br> If you would like to update your comments their ID# is <?php echo $ID; ?> <a href='my_page.php'>my page</a>" <?php include 'footer.php'; include 'db_close.php';
#variables $NAME = $_POST["name"]; $SOCIAL_VALUES = $_POST["social_values"]; $QUALITY_WORKPLACE = $_POST["quality_of_workplace"]; $PROFESSIONALISM_MANAGEMENT = $_POST["professionalism_management"]; $FAIRNESS_EVAL = $_POST["fairness_eval"]; $OPENNESS_WITH_STAFF = $_POST["openness_with_staff"]; $COOPERATION_AMONG_EMPLOYEES = $_POST["cooperation_employees"]; $ENCOURAGE_INNOVATION = $_POST["encourage_innovation"]; $REWARD_SYSTEM = $_POST["rewards"]; $ACCEPTANCE_IDEAS = $_POST["acceptance_ideas"]; $WAGES = $_POST["fair_wages"]; $RECOGNITION_ACHIEVEMENT = $_POST["recognition_achievement"]; $QUALITY_BENEFITS = $_POST["benefits"]; $SUPPORT_EMPLOYEES = $_POST["support"]; $LEVEL_STRESS = $_POST["stress"]; $LEVEL_COLLEGIALITY = $_POST["collegiality"]; $LEVEL_BUREACRACY = $_POST["bureaucracy_red_tape"]; $POSSIBILITY_ADVANCEMENT = $_POST["advancement"]; $SUPPORT_FAMILY = $_POST["family_support"]; #/variables #statements to insert into the database $statement = "INSERT INTO rating (orgname, social_values, quality_of_workplace, professionalism_management,\r\n\t\t\t\t\t\tfairness_eval, openness_with_staff, cooperation_employees,\r\n\t\t\t\t\t\tencourage_innovation, rewards, acceptance_ideas, fair_wages,\r\n\t\t\t\t\t\trecognition_achievement, benefits, support,\r\n\t\t\t\t\t\tstress, collegiality, bureaucracy_red_tape, advancement,\r\n\t\t\t\t\t\tfamily_support)" . "VALUES\r\n\t\t\t\t('{$NAME}', '{$SOCIAL_VALUES}', '{$QUALITY_WORKPLACE}', '{$PROFESSIONALISM_MANAGEMENT}',\r\n\t\t\t\t\t'{$FAIRNESS_EVAL}', '{$OPENNESS_WITH_STAFF}', '{$COOPERATION_AMONG_EMPLOYEES}',\r\n\t\t\t\t\t'{$ENCOURAGE_INNOVATION}', '{$REWARD_SYSTEM}', '{$ACCEPTANCE_IDEAS}', '{$WAGES}',\r\n\t\t\t\t\t'{$RECOGNITION_ACHIEVEMENT}', '{$QUALITY_BENEFITS}', '{$SUPPORT_EMPLOYEES}',\r\n\t\t\t\t\t'{$LEVEL_STRESS}', '{$LEVEL_COLLEGIALITY}', '{$LEVEL_BUREACRACY}', '{$POSSIBILITY_ADVANCEMENT}',\r\n\t\t\t\t\t'{$SUPPORT_FAMILY}')"; if (!($result = MYSQL_QUERY($statement))) { showerror(); #something went wrong in the insertion } echo "Rating accepted!<br>\r\n\tIf you would like to update your comments their id number is" . MYSQL_INSERT_ID(); echo "<br><a href='my_page.php'>return to home page</a>"; include "db_close.php"; include "footer.php";
if (empty($user_mypals)) { set_sess_mypals($touser_id); } else { set_sess_mypals($user_mypals . "," . $mreq_touser); } $title = $user_name . $m_langpackage->m_app_fri; $scrip_content = $user_name . $m_langpackage->m_app_friend; $is_success = api_proxy('scrip_send', $mp_langpackage->mp_system_sends, $title, $scrip_content, $mreq_touser, 0); if ($is_success) { api_proxy("message_set", $mreq_touser, "{num}" . $mp_langpackage->mp_a_notice, "modules.php?app=msg_notice", 0, 1, "remind"); action_return(2, $mp_langpackage->mp_treatment_success, -1); } else { action_return(2, $mp_langpackage->mp_treatment_failure, -1); } } //验证加入 if ($touser_pals_limit == 1) { $sql = "insert into {$t_mypals} (user_id,pals_id,pals_name,pals_sex,add_time,pals_ico)" . "value({$user_id},{$touser_id},'{$touser_name}','{$touser_sex}',NOW(),'{$touser_ico}')"; $dbo->exeUpdate($sql); $from_pals_id = MYSQL_INSERT_ID(); $sql = "insert into {$t_pals_request} (user_id,req_id,req_name,req_sex,add_time,from_id,req_ico)" . "value({$touser_id},{$user_id},'{$user_name}','{$user_sex}',NOW(),{$from_pals_id},'{$userico}')"; if ($dbo->exeUpdate($sql)) { api_proxy("message_set", $mreq_touser, $mp_langpackage->mp_remind, "modules.php?app=mypals_request", 0, 3, "remind"); //提醒机制 echo $mp_langpackage->mp_suc_reg; } else { $sql = "delete from {$t_mypals} where id={$from_pals_id}"; $dbo->exeUpdate($sql); echo $mp_langpackage->mp_req_false; } }
function displayOpenForum($pageName = 'discuss', $name1, $deck, $body, $id, $action, $submit, $idFull, $idBase, $reply, $userName) { global $childObject; global $posts; global $currentId; global $currentIdIndex; $currentId = $id; $posts = array(); // Parse $IdFull to get $idPath $idsFull = explode(",", $idFull); if (count($idsFull) > 1) { $idPath = $idsFull[0]; } else { $idPath = '0'; } // Find "Forum" object $sql = "SELECT objects.id AS objectsId FROM wires, objects "; $sql .= "WHERE wires.fromid = '{$idPath}' AND wires.toid = objects.id AND objects.name1 LIKE 'Discussion Forum' "; $sql .= "AND wires.active = 1 AND objects.active = 1 "; $sql .= "ORDER BY objects.created DESC LIMIT 1"; $res = MYSQL_QUERY($sql); $row = MYSQL_FETCH_ARRAY($res); $obj = $row["objectsId"]; // Post a message if ($action == "post") { // Clean up input if (!get_magic_quotes_gpc()) { $name1 = "_" . $name1; $name1 = addslashes($name1); $deck = addslashes($deck); $body = addslashes($body); } // Process variables if (!$name1) { $name1 = "[No Subject]"; } $name1 = textFilter($name1); $deck = textFilter($deck); $body = textFilter($body); echo "new!" . $body; // Add object to database $sql = "INSERT INTO objects (created, modified, name1, deck, body) "; $sql .= "VALUES ('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '{$name1}', '{$deck}', '{$body}')"; $res = MYSQL_QUERY($sql); $insertId = MYSQL_INSERT_ID(); //echo "INSERT ID".$insertId; // Add wire to database // Need to convert id to just get last part for messageId $explodedId = explode(",", $id); $messageId = $explodedId[count($explodedId) - 1]; // echo "messageId = " . $messageId; $sql = "INSERT INTO wires (created, modified, fromid, toid) "; // $sql .= "VALUES('". date("Y-m-d H:i:s") ."', '". date("Y-m-d H:i:s") ."', '$id', '$insertId')"; $sql .= "VALUES('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '{$messageId}', '{$insertId}')"; $res = MYSQL_QUERY($sql); $id = null; // THIS $id? } // Write a message if ($action == "write") { if (is_authed()) { $html2 = "You are posting a message to the Discussion Forum.<br />"; $html2 .= "<a href='" . $pageName . ".html?action=viewall'>View All Messages</a><br /><br />"; $html2 .= "<br />"; $html2 .= "<table cellpadding='0' cellspacing='0' border='0'>"; $html2 .= "<form enctype='multipart/form-data' action='" . $pageName . ".html?action=post' method='post' style='margin: 0; padding: 0;'>"; $html2 .= "<tr><td width='90'>Subject </td>"; $html2 .= "<td><textarea name='name1' cols='50' rows='1'>"; // Add Re: if replying. Will need to get the previous object that you are replying to... ** IN PROCESS ** if ($reply) { $html2 .= "\nRe: " . $reply; } $html2 .= "</textarea></td></tr>"; $html2 .= "<tr><td>From </td>"; $html2 .= "<td><textarea name='deck' cols='50' rows='1'>" . $userName . "</textarea></td></tr>"; $html2 .= "<tr><td style='vertical-align: top;'>Message </td>"; $html2 .= "<td><textarea name='body' cols='50' rows='40'></textarea></td></tr>"; $html2 .= "<tr><td><!-- --></td>"; $html2 .= "<td><br />"; $html2 .= "<input name='id' type='hidden' value='" . $id . "' />"; $html2 .= "<input name='action' type='hidden' value='post' />"; $html2 .= "<input name='submit' type='submit' value='Post Message' />"; $html2 .= "</form></td></tr>"; $html2 .= "</table>"; // These are all of the variables which are posted here in this form // These must be passed in from the page that uses this function // $name1, $deck, $body, $id, $action, $submit echo $html2; } else { echo "Please <a href='" . $pageName . ".html?user=login'>LOG IN</a> or <a href='" . $pageName . ".html?user=register'>REGISTER</a> to post messages in the Discussion Forum."; } } // View message selected if ($id != $obj) { // systemForumMapper($idFull, 2, TRUE); // systemForumMapper("3,386,390", 2, TRUE); // systemForumMapper("0,386,390", 2, TRUE); $idBasePad = "0," . $idBase; systemForumMapper($idBasePad, 10, TRUE); $postOlderIndex = $currentIdIndex < 2 ? 1 : $currentIdIndex - 1; $postNewerIndex = $currentIdIndex > count($posts) - 2 ? count($posts) - 1 : $currentIdIndex + 1; $postNewer = $posts[$postNewerIndex]; $postOlder = $posts[$postOlderIndex]; /* // Debug for $ids passing echo "id = " . $id . " / " . "idFull = " . $idFull . " / " . "idBase = " . $idBase . " / " . "idBasePad = " . $idBasePad . "<br />"; echo $postOlderIndex . " / " . $postNewerIndex . "<br />"; echo $postOlder . " / " . $postNewer . "<br />"; */ // Get selected "Forum" object $sql = "SELECT * FROM objects WHERE id = '{$id}' AND objects.active = 1 LIMIT 1"; $res = MYSQL_QUERY($sql); $row = MYSQL_FETCH_ARRAY($res); if (!$action) { $html .= "<a href='" . $pageName . ".html?id={$postOlder}'>Previous</a> / "; $html .= "\n<a href='" . $pageName . ".html?action=viewall'>View All Messages</a> / "; $html .= "<a href='" . $pageName . ".html?id={$postNewer}'>Next</a>"; $html .= "\n<br />"; if (count($ids) < 2) { $replySubject .= substr($row['name1'], 1); //$idComplete = $idFull . "," . $id; //echo "<br />" . $id . "<br />" . $idFull . "<br />" . $idComplete; $html .= "\n<a href='" . $pageName . ".html?action=write&id={$idFull}&reply={$replySubject}'>Reply to this message</a>"; } // $html .= "\n<a href='".$pageName.".html?action=write&id=$idBase'>Post a new message</a> / "; // $html .= "\n<a href='".$pageName."Print.html?id=".$idFull."'>Print</a>"; $html .= "<br /><br />"; // Write out the body of the selected message // Account for "_" which is at the beginning of each open record if (substr($row['name1'], 0, 1) == "_") { $nameDisplay = substr($row['name1'], 1); } $html .= "\n<table cellspacing='0' cellpadding='0'>"; //$html .= "\n<tr><td style='padding-right: 12px;'>Subject</td><td>".$row['name1']."</td></tr>"; $html .= "\n<tr><td style='padding-right: 12px;'>Subject</td><td>" . $nameDisplay . "</td></tr>"; $html .= "\n<tr><td style='padding-right: 12px;'>Date</td><td>" . date('j F Y H:i:s', strtotime($row['created'])) . "</td></tr>"; $html .= "\n<tr><td style='padding-right: 12px;'>From</td><td>" . $row['deck'] . "</td></tr>"; $html .= "\n</table><br />"; $html .= "\n" . nl2br($row['body']) . "<br /><br />"; } if (!$action) { $html .= "<a href='" . $pageName . ".html?id={$postOlder}'>Previous</a> / "; $html .= "\n<a href='" . $pageName . ".html?action=viewall'>View All Messages</a> / "; $html .= "<a href='" . $pageName . ".html?id={$postNewer}'>Next</a>"; $html .= "\n<br />"; if (count($ids) < 2) { $replySubject .= substr($row['name1'], 1); $html .= "\n<a href='" . $pageName . ".html?action=write&id={$idFull}&reply={$replySubject}'>Reply to this message</a>"; } // $html .= "\n<a href='".$pageName.".html?action=write&id=$idBase'>Post a new message</a> / "; // $html .= "\n<a href='".$pageName."Print.html?id=".$idFull."'>Print</a>"; } echo $html; } if ($action == 'post') { $html3 = "You are posting to the Discussion Forum.<br />"; $html3 .= "<a href='" . $pageName . ".html?action=viewall'>View All Messages</a><br /><br />"; $html3 .= "Your message has been posted as of " . date('j F Y H:i:s') . "<br />"; $html3 .= "Please <a href='" . $pageName . ".html'>click here to continue</a>..."; echo $html3; } // Show all messages if ($id == $obj && !$action || $id == $obj && $action == 'viewall') { echo "You are viewing all posts in the Discussion Forum.<br /><br />"; systemForumMapper($id, 10); echo "<br /><a href='" . $pageName . ".html?action=write&id={$idFull}'>Post a new response to the essay</a><br/><br/>"; } }
function displayOrderedReadingGleaner($id = '0', $note = null, $pageName = 'main', $write = FALSE, $quiet = null, $wordFind = null, $wordFindNumber = '1', $contextLimit = '10') { /////////////// 1. QUERY /////////////// // Harvest OPEN-RECORDS-GENERATOR // Avoids hidden records with % wildcard $sql = "SELECT id AS objectsId, name1, body FROM objects "; $sql .= "WHERE name1 NOT LIKE '.%' "; $sql .= "AND name1 NOT LIKE '2007%' "; $sql .= "AND name1 NOT LIKE '(%' "; $sql .= "AND objects.active = 1 "; $sql .= "ORDER BY id ASC"; $result = MYSQL_QUERY($sql); // These will be used for text manipulation // But first we have to load them up $textMass = null; $textMassLines = null; $textMassLinesSorted = null; $textMassLinesSortedCounted = null; // Build raw TextMass while ($myrow = MYSQL_FETCH_ARRAY($result)) { $textMass .= $myrow["name1"] . " " . $myrow["body"]; } /////////////// 2. PROCESS /////////////// // Print raw textMass if (!$quiet) { echo "\n\t\t<div class = 'rightSubContainer'>"; echo "\n\t\t\t<div class = 'Mono'>"; echo "\n\t\t\t<!-- textMass -->"; echo "\n\n\t\t\t\t<ul>"; echo "\n\t\t\t\t\t<li class = 'Body collapseListOpen'>" . $textMass . "</li>"; echo "\n\t\t\t\t</ul>"; echo "\n\t\t\t</div>"; echo "\n\t\t</div>"; } // Clean up $textMass // Strip out anything that is not (^) either a-z or A-Z $pattern = '/[^a-zA-Z]/'; $replacement = ' '; $textMassParsed = preg_replace($pattern, $replacement, $textMass); // Split textMassParsed by any number of commas or space characters // And put result into an array // Then sort through $textMassArray manually when finding the selected word $textMassArray = preg_split("/[\\s,]+/", $textMassParsed); // Print unsorted $textMassArray if (!$quiet) { echo "\n\t\t<div class = 'rightSubContainer'>"; echo "\n\t\t\t<div class = 'Mono'>"; echo "\n\t\t\t<!-- textMassArray -->"; foreach ($textMassArray as $value) { if (!$quiet) { echo $value . " "; } } echo "\n\t\t\t</div>"; echo "\n\t\t</div>"; } // Print sorted $textMassArray natcasesort($textMassArray); if (!$quiet) { echo "\n\t\t<div class = 'rightSubContainer'>"; echo "\n\t\t\t<div class = 'Mono'>"; echo "\n\t\t\t<!-- textMassArray -->"; foreach ($textMassArray as $value) { if (!$quiet) { echo $value . " "; } } echo "\n\t\t\t</div>"; echo "\n\t\t</div>"; } // Count how many times each word appears // Do this by cycling through the sorted array // Every time the word changes, record Count and Word // In a 2d array which would be more elegant! $previousValue = null; $i = 0; $counter = 1; foreach ($textMassArray as $value) { $value = strtolower($value); if ($value != $previousValue) { // Temporary hack for removing words!! would be best to use REGEX above if ($previousValue == "the" | $previousValue == "a" | $previousValue == "an" | $previousValue == "of" | $previousValue == "for" | $previousValue == "and" | $previousValue == "i" | $previousValue == "in" | $previousValue == "it" | $previousValue == "to" | $previousValue == "was" | $previousValue == "is" | $previousValue == "href" | $previousValue == "url" | $previousValue == "edu" | $previousValue == "target" | $previousValue == "http" | $previousValue == "www" | $previousValue == "what" | $previousValue == "at" | $previousValue == "that" | $previousValue == "href" | $previousValue == "s" | $previousValue == "on" | $previousValue == "be" | $previousValue == "br" | $previousValue == "this" | $previousValue == "html" | $previousValue == "as" | $previousValue == "has" | $previousValue == "he" | $previousValue == "by" | $previousValue == "com") { // Discard word, do nothing and reset $counter $counter = 1; } else { // Add this word to the List $word[$i] = $previousValue; $count[$i] = $counter; $wordCount[$i] = "(" . $count[$i] . ") " . $word[$i]; $counter = 1; } } else { // Increase $counter and go to next word $counter++; } $previousValue = $value; $i++; } // Sort combined array and reverse order to make $wordCount // $wordCount is an array of all words and their frequencies developed above natcasesort($wordCount); $wordCount = array_reverse($wordCount); $i = 0; foreach ($wordCount as $value) { if (!$quiet) { echo $value . "<br />"; } if ($i < 4) { $tipofthetongue[$i] = $value; } $i++; } /////////////// 3. CLEAN UP /////////////// // Clean up final words list // Prepare master Arrays $tipofthetongueParsed and $tipofthetongueParsedCounts // Output final words and send $wordFind in URL to return context foreach ($tipofthetongue as $value) { // Strip out anything that is not (^) either a-z or A-Z // in order to get correct search term $pattern = '/[^a-zA-Z]/'; $replacement = ''; $tipofthetongueParsedStub = preg_replace($pattern, $replacement, $value); $tipofthetongueParsed[] = $tipofthetongueParsedStub; // Strip out anything that is not (^) 0-9 in order to get the counts of each $pattern = '/[^0-9]/'; $replacement = ''; $tipofthetongueParsedCounts[] = preg_replace($pattern, $replacement, $value); } /////////////// 4. WRITE /////////////// // Uses Flag $write to control output to database if ($write == TRUE) { // 1. Write object with date to house the words // Get .Tip of the Tongue .Outputs object $sql = "SELECT id AS objectsId FROM objects "; $sql .= "WHERE name1 LIKE '.Outputs' "; $sql .= "AND objects.active = 1 "; $sql .= "LIMIT 1"; $result = MYSQL_QUERY($sql); $myrow = MYSQL_FETCH_ARRAY($result); $thisObjectId = $myrow['objectsId']; // Add object to database $sql = "INSERT INTO objects (created, modified, name1) "; $sql .= "VALUES ('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')"; $res = MYSQL_QUERY($sql); $insertId = MYSQL_INSERT_ID(); // Add wire to database $sql = "INSERT INTO wires (created, modified, fromid, toid) "; $sql .= "VALUES('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '{$thisObjectId}', '{$insertId}')"; $res = MYSQL_QUERY($sql); $insertIdStub = $insertId; // 2. Write Tip of the Tongue words foreach ($tipofthetongue as $value) { // Add object to database $sql = "INSERT INTO objects (created, modified, name1) "; $sql .= "VALUES ('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '{$value}')"; $res = MYSQL_QUERY($sql); $insertId = MYSQL_INSERT_ID(); // Add wire to database $sql = "INSERT INTO wires (created, modified, fromid, toid) "; $sql .= "VALUES('" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "', '{$insertIdStub}', '{$insertId}')"; $res = MYSQL_QUERY($sql); } // 3. Redundantly Update the .Notes under .Tip of the Tongue object // Find this .Tip of the Tongue object $sql = "SELECT id AS objectsId FROM objects "; $sql .= "WHERE name1 LIKE '.Tip of the Tongue' "; $sql .= "AND objects.active = 1 "; $sql .= "LIMIT 1"; $result = MYSQL_QUERY($sql); $myrow = MYSQL_FETCH_ARRAY($result); $thisTipoftheTongueId = $myrow['objectsId']; // Find this .Notes object $sql = "SELECT *, objects.id AS objectsId FROM wires, objects "; $sql .= "WHERE wires.fromid = {$thisTipoftheTongueId} AND wires.toid = objects.id "; $sql .= "AND objects.name1 LIKE '.Notes' "; $sql .= "AND wires.active=1 AND objects.active=1 "; $sql .= "LIMIT 1"; $result = MYSQL_QUERY($sql); $myrow = MYSQL_FETCH_ARRAY($result); $foundObjectId = $myrow['objectsId']; // Find connected objects $sql = "SELECT *, objects.id AS objectsId FROM wires, objects "; $sql .= "WHERE wires.fromid = {$foundObjectId} AND wires.toid = objects.id "; $sql .= "AND wires.active=1 AND objects.active=1 "; $sql .= "ORDER BY rank ASC"; $result = MYSQL_QUERY($sql); while ($myrow = MYSQL_FETCH_ARRAY($result)) { $foundObjectIdArray[] = $myrow['objectsId']; } // Update objects // Output all numbers corresponding to wordFindNumbers to make $writeWordFindNumberURLStub // This will be used to write in the .Notes body for each word for ($i = 0; $i < count($tipofthetongueParsedCounts); $i++) { for ($ii = 1; $ii <= $tipofthetongueParsedCounts[$i]; $ii++) { // to deal with Notes since it is written one time, do it manually to keep the note open using $foundObjectIdArray[] $noteStub = $foundObjectIdArray[$i]; $writeWordFindNumberURLStubStub .= "<a href = 'tipofthetongue.html?wordFind=" . $tipofthetongueParsed[$i] . "&wordFindNumber=" . $ii . "&write=false¬e=" . $noteStub . "'>" . $ii . "</a> "; } $writeWordFindNumberURLStub[] = $writeWordFindNumberURLStubStub; $writeWordFindNumberURLStubStub = ''; } $counter = 0; foreach ($foundObjectIdArray as $value) { $thisWord = $tipofthetongue[$counter]; $thisURL = $writeWordFindNumberURLStub[$counter]; $thisURLescaped = addslashes($thisURL); //echo $thisURL; //echo $thisURLescaped; $sql = "UPDATE objects "; $sql .= "SET name1 = '{$thisWord}', body = '{$thisURLescaped}' "; $sql .= "WHERE id = {$value}"; $result = MYSQL_QUERY($sql); $counter++; } } /////////////// 5. FIND /////////////// // Find and print Words in Context // Sorting manually through $textMassArray (sorted) looking at adjacent words // Using array_keys to retrieve which positions return a match and collecting indices // Uses $contextLimit to determine how many words either side // First -- populate an Array of indices using array_keys in order to refer to it later by number if ($wordFind) { foreach (array_keys($textMassArray, $wordFind) as $value) { $wordFindIndex[] = $value; } echo "\n\t<!-- LEFT -->"; echo "\n\t<div id='left' class='leftContainer'>"; echo "\n\t\t<div class = 'Body'>"; echo "{$wordFindNumber}.<br /><br />"; echo "... "; for ($i = $contextLimit; $i > 0; $i--) { $stub = strtolower($textMassArray[$wordFindIndex[$wordFindNumber] - $i]); echo $stub . " "; } $stub = strtoupper($textMassArray[$wordFindIndex[$wordFindNumber]]); echo $stub . " "; for ($i = 1; $i < $contextLimit; $i++) { $stub = strtolower($textMassArray[$wordFindIndex[$wordFindNumber] + $i]); echo $stub . " "; } echo " ..."; $contextLimitNext = $contextLimit + 100; echo "<br /><br /><a href='" . $pageName . ".html?wordFind={$wordFind}&wordFindNumber={$wordFindNumber}&write=FALSE¬e={$note}&contextLimit={$contextLimitNext}'>Read more . . .</a>\t"; echo "\n\t\t</div>"; echo "\n\t</div>"; } }