/osj-osj2dpostssrch.php
PHP | 367 lines | 272 code | 45 blank | 50 comment | 45 complexity | 913654d39415ebe4feb3e6f0f750a82e MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
- <?php
- define("EW_PAGE_ID", "search", TRUE); // Page ID
- define("EW_TABLE_NAME", 'osj-posts', TRUE);
- ?>
- <?php
- session_start(); // Initialize session data
- ob_start(); // Turn on output buffering
- ?>
- <?php include "osj-ewcfg50.php" ?>
- <?php include "osj-ewmysql50.php" ?>
- <?php include "osj-phpfn50.php" ?>
- <?php include "osj-osj2dpostsinfo.php" ?>
- <?php include "osj-userfn50.php" ?>
- <?php include "osj-osj2dusersinfo.php" ?>
- <?php
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
- header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache"); // HTTP/1.0
- ?>
- <?php
-
- // Open connection to the database
- $conn = ew_Connect();
- ?>
- <?php
- $Security = new cAdvancedSecurity();
- ?>
- <?php
- if (!$Security->IsLoggedIn()) $Security->AutoLogin();
- $Security->LoadCurrentUserLevel('osj-posts');
- ?>
- <?php
-
- // Common page loading event (in userfn*.php)
- Page_Loading();
- ?>
- <?php
-
- // Page load event, used in current page
- Page_Load();
- ?>
- <?php
- $osj2Dposts->Export = @$_GET["export"]; // Get export parameter
- $sExport = $osj2Dposts->Export; // Get export parameter, used in header
- $sExportFile = $osj2Dposts->TableVar; // Get export file, used in header
- ?>
- <?php
-
- // Get action
- $osj2Dposts->CurrentAction = @$_POST["a_search"];
- switch ($osj2Dposts->CurrentAction) {
- case "S": // Get Search Criteria
-
- // Build search string for advanced search, remove blank field
- $sSrchStr = BuildAdvancedSearch();
- if ($sSrchStr <> "") {
- Page_Terminate("osj-osj2dpostslist.php?" . $sSrchStr); // Go to list page
- }
- break;
- default: // Restore search settings
- LoadAdvancedSearch();
- }
-
- // Render row for search
- $osj2Dposts->RowType = EW_ROWTYPE_SEARCH;
- RenderRow();
- ?>
- <?php include "osj-header.php" ?>
- <script type="text/javascript">
- <!--
- var EW_PAGE_ID = "search"; // Page id
- var EW_SHOW_HIGHLIGHT = "Show highlight";
- var EW_HIDE_HIGHLIGHT = "Hide highlight";
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- function ew_ValidateForm(fobj) {
- if (fobj.a_confirm && fobj.a_confirm.value == "F")
- return true;
- var i, elm, aelm, infix;
- var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
- for (i=0; i<rowcnt; i++) {
- infix = (fobj.key_count) ? String(i+1) : "";
- elm = fobj.elements["x" + infix + "_post_edit_date"];
- if (elm && !ew_CheckUSDate(elm.value)) {
- if (!ew_OnError(elm, "Incorrect date, format = mm/dd/yyyy - Post Edit Date"))
- return false;
- }
- }
- return true;
- }
-
- //-->
- </script>
- <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
- <script type="text/javascript">
- <!--
- _width_multiplier = 16;
- _height_multiplier = 60;
- var ew_DHTMLEditors = [];
-
- function ew_UpdateTextArea() {
- if (typeof ew_DHTMLEditors != 'undefined' &&
- typeof FCKeditorAPI != 'undefined') {
- var inst;
- for (inst in FCKeditorAPI.__Instances)
- FCKeditorAPI.__Instances[inst].UpdateLinkedField();
- }
- }
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- // js for Popup Calendar
- //-->
-
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your client script here, no need to add script tags.
- // To include another .js script, use:
- // ew_ClientScriptInclude("my_javascript.js");
- //-->
-
- </script>
- <p><span class="phpmaker">Search TABLE: Posts<br><br><a href="osj-osj2dpostslist.php">Back to List</a></span></p>
- <form name="fosj2Dpostssearch" id="fosj2Dpostssearch" action="osj-osj2dpostssrch.php" method="post">
- <p>
- <input type="hidden" name="a_search" id="a_search" value="S">
- <table class="ewTable">
- <tr class="ewTableRow">
- <td class="ewTableHeader">Employer ID</td>
- <td<?php echo $osj2Dposts->user_id->CellAttributes() ?>><span class="ewSearchOpr">=<input type="hidden" name="z_user_id" id="z_user_id" value="="></span></td>
- <td<?php echo $osj2Dposts->user_id->CellAttributes() ?>><span class="phpmaker">
- <input type="text" name="x_user_id" id="x_user_id" size="30" value="<?php echo $osj2Dposts->user_id->EditValue ?>"<?php echo $osj2Dposts->user_id->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Creation Date</td>
- <td<?php echo $osj2Dposts->post_creation_date->CellAttributes() ?>><span class="ewSearchOpr"><select name="z_post_creation_date" id="z_post_creation_date"><option value="="<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator=="=")?" selected":"" ?>>=</option><option value="<>"<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator=="<>")?" selected":"" ?>><></option><option value="<"<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator=="<")?" selected":"" ?>><</option><option value="<="<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator=="<=")?" selected":"" ?>><=</option><option value=">"<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator==">")?" selected":"" ?>>></option><option value=">="<?php echo ($osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator==">=")?" selected":"" ?>>>=</option></select></span></td>
- <td<?php echo $osj2Dposts->post_creation_date->CellAttributes() ?>><span class="phpmaker">
- <input type="text" name="x_post_creation_date" id="x_post_creation_date" value="<?php echo $osj2Dposts->post_creation_date->EditValue ?>"<?php echo $osj2Dposts->post_creation_date->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableRow">
- <td class="ewTableHeader">Title</td>
- <td<?php echo $osj2Dposts->post_title->CellAttributes() ?>><span class="ewSearchOpr"><select name="z_post_title" id="z_post_title"><option value="="<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="=")?" selected":"" ?>>=</option><option value="<>"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="<>")?" selected":"" ?>><></option><option value="<"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="<")?" selected":"" ?>><</option><option value="<="<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="<=")?" selected":"" ?>><=</option><option value=">"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator==">")?" selected":"" ?>>></option><option value=">="<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator==">=")?" selected":"" ?>>>=</option><option value="LIKE"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="LIKE")?" selected":"" ?>>contains</option><option value="NOT LIKE"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="NOT LIKE")?" selected":"" ?>>not contains</option><option value="STARTS WITH"<?php echo ($osj2Dposts->post_title->AdvancedSearch->SearchOperator=="STARTS WITH")?" selected":"" ?>>starts with</option></select></span></td>
- <td<?php echo $osj2Dposts->post_title->CellAttributes() ?>><span class="phpmaker">
- <div><input type="text" name="x_post_title" id="x_post_title" size="30" value="<?php echo $osj2Dposts->post_title->EditValue ?>" onblur="ew_AstHideDiv('as_x_post_title');" onkeydown="ew_AstOnKeyDown('x_post_title', 'as_x_post_title', event);" onkeypress="return ew_AstOnKeyPress(event);" onkeyup="ew_AstOnKeyUp('x_post_title', 'as_x_post_title', event);" autocomplete="off"></div>
- <div class='ewAstList' style='visibility:hidden' id='as_x_post_title'></div>
- <input type="hidden" name="sv_x_post_title" id="sv_x_post_title" value="">
- <?php
- $sSqlWrk = "SELECT DISTINCT `post_title`, `post_description` FROM `osj-posts` WHERE (`post_title` LIKE '@FILTER_VALUE%')";
- $sSqlWrk .= " ORDER BY `post_creation_date` ";
- $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
- ?>
- <input type="hidden" name="s_x_post_title" id="s_x_post_title" value="<?php echo $sSqlWrk ?>">
- <input type="hidden" name="lt_x_post_title" id="lt_x_post_title" value="1">
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Description</td>
- <td<?php echo $osj2Dposts->post_description->CellAttributes() ?>><span class="ewSearchOpr"><select name="z_post_description" id="z_post_description"><option value="="<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="=")?" selected":"" ?>>=</option><option value="<>"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="<>")?" selected":"" ?>><></option><option value="<"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="<")?" selected":"" ?>><</option><option value="<="<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="<=")?" selected":"" ?>><=</option><option value=">"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator==">")?" selected":"" ?>>></option><option value=">="<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator==">=")?" selected":"" ?>>>=</option><option value="LIKE"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="LIKE")?" selected":"" ?>>contains</option><option value="NOT LIKE"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="NOT LIKE")?" selected":"" ?>>not contains</option><option value="STARTS WITH"<?php echo ($osj2Dposts->post_description->AdvancedSearch->SearchOperator=="STARTS WITH")?" selected":"" ?>>starts with</option></select></span></td>
- <td<?php echo $osj2Dposts->post_description->CellAttributes() ?>><span class="phpmaker">
- <textarea name="x_post_description" id="x_post_description" cols="35" rows="4"<?php echo $osj2Dposts->post_description->EditAttributes() ?>><?php echo $osj2Dposts->post_description->EditValue ?></textarea>
- </span></td>
- </tr>
- <tr class="ewTableRow">
- <td class="ewTableHeader">Post Edit Date</td>
- <td<?php echo $osj2Dposts->post_edit_date->CellAttributes() ?>><span class="ewSearchOpr"><select name="z_post_edit_date" id="z_post_edit_date"><option value="="<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator=="=")?" selected":"" ?>>=</option><option value="<>"<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator=="<>")?" selected":"" ?>><></option><option value="<"<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator=="<")?" selected":"" ?>><</option><option value="<="<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator=="<=")?" selected":"" ?>><=</option><option value=">"<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator==">")?" selected":"" ?>>></option><option value=">="<?php echo ($osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator==">=")?" selected":"" ?>>>=</option></select></span></td>
- <td<?php echo $osj2Dposts->post_edit_date->CellAttributes() ?>><span class="phpmaker">
- <input type="text" name="x_post_edit_date" id="x_post_edit_date" value="<?php echo $osj2Dposts->post_edit_date->EditValue ?>"<?php echo $osj2Dposts->post_edit_date->EditAttributes() ?>>
- </span></td>
- </tr>
- </table>
- <p>
- <input type="button" name="Action" id="Action" value=" Search " onClick="ew_SubmitForm(this.form);">
- <input type="button" name="Reset" id="Reset" value=" Reset " onclick="ew_ClearForm(this.form);">
- </form>
- <script type="text/javascript">
- <!--
- ew_CreateEditor(); // Create DHTML editor(s)
-
- //-->
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php include "osj-footer.php" ?>
- <?php
-
- // If control is passed here, simply terminate the page without redirect
- Page_Terminate();
-
- // -----------------------------------------------------------------
- // Subroutine Page_Terminate
- // - called when exit page
- // - clean up connection and objects
- // - if url specified, redirect to url, otherwise end response
- function Page_Terminate($url = "") {
- global $conn;
-
- // Page unload event, used in current page
- Page_Unload();
-
- // Global page unloaded event (in userfn*.php)
- Page_Unloaded();
-
- // Close Connection
- $conn->Close();
-
- // Go to url if specified
- if ($url <> "") {
- ob_end_clean();
- header("Location: $url");
- }
- exit();
- }
- ?>
- <?php
-
- // Build advanced search
- function BuildAdvancedSearch() {
- global $osj2Dposts;
- $sSrchUrl = "";
-
- // Field user_id
- BuildSearchUrl($sSrchUrl, $osj2Dposts->user_id, @$_POST["x_user_id"], @$_POST["z_user_id"], @$_POST["v_user_id"], @$_POST["y_user_id"], @$_POST["w_user_id"]);
-
- // Field post_creation_date
- BuildSearchUrl($sSrchUrl, $osj2Dposts->post_creation_date, ew_UnFormatDateTime(@$_POST["x_post_creation_date"],6), @$_POST["z_post_creation_date"], @$_POST["v_post_creation_date"], ew_UnFormatDateTime(@$_POST["y_post_creation_date"],6), @$_POST["w_post_creation_date"]);
-
- // Field post_title
- BuildSearchUrl($sSrchUrl, $osj2Dposts->post_title, @$_POST["x_post_title"], @$_POST["z_post_title"], @$_POST["v_post_title"], @$_POST["y_post_title"], @$_POST["w_post_title"]);
-
- // Field post_description
- BuildSearchUrl($sSrchUrl, $osj2Dposts->post_description, @$_POST["x_post_description"], @$_POST["z_post_description"], @$_POST["v_post_description"], @$_POST["y_post_description"], @$_POST["w_post_description"]);
-
- // Field post_edit_date
- BuildSearchUrl($sSrchUrl, $osj2Dposts->post_edit_date, ew_UnFormatDateTime(@$_POST["x_post_edit_date"],6), @$_POST["z_post_edit_date"], @$_POST["v_post_edit_date"], ew_UnFormatDateTime(@$_POST["y_post_edit_date"],6), @$_POST["w_post_edit_date"]);
- return $sSrchUrl;
- }
-
- // Function to build search URL
- function BuildSearchUrl(&$Url, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
- $sWrk = "";
- $FldParm = substr($Fld->FldVar, 2);
- $FldVal = ew_StripSlashes($FldVal);
- if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
- $FldVal2 = ew_StripSlashes($FldVal2);
- if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
- $FldOpr = strtoupper(trim($FldOpr));
- if ($FldOpr == "BETWEEN") {
- $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2));
- if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
- $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
- "&y_" . $FldParm . "=" . urlencode($FldVal2) .
- "&z_" . $FldParm . "=" . urlencode($FldOpr);
- }
- } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
- $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
- "&z_" . $FldParm . "=" . urlencode($FldOpr);
- } else {
- $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType = EW_DATATYPE_NUMBER && is_numeric($FldVal));
- if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
- $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
- "&z_" . $FldParm . "=" . urlencode($FldOpr);
- }
- $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType = EW_DATATYPE_NUMBER && is_numeric($FldVal2));
- if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
- if ($sWrk <> "") $sWrk .= "&v_" . $FldParm . "=" . urlencode($FldCond) . "&";
- $sWrk .= "&y_" . $FldParm . "=" . urlencode($FldVal2) .
- "&w_" . $FldParm . "=" . urlencode($FldOpr2);
- }
- }
- if ($sWrk <> "") {
- if ($Url <> "") $Url .= "&";
- $Url .= $sWrk;
- }
- }
- ?>
- <?php
-
- // Render row values based on field settings
- function RenderRow() {
- global $conn, $Security, $osj2Dposts;
-
- // Call Row Rendering event
- $osj2Dposts->Row_Rendering();
-
- // Common render codes for all row types
- if ($osj2Dposts->RowType == EW_ROWTYPE_VIEW) { // View row
- } elseif ($osj2Dposts->RowType == EW_ROWTYPE_ADD) { // Add row
- } elseif ($osj2Dposts->RowType == EW_ROWTYPE_EDIT) { // Edit row
- } elseif ($osj2Dposts->RowType == EW_ROWTYPE_SEARCH) { // Search row
-
- // user_id
- $osj2Dposts->user_id->EditCustomAttributes = "";
- $osj2Dposts->user_id->EditValue = ew_HtmlEncode($osj2Dposts->user_id->AdvancedSearch->SearchValue);
-
- // post_creation_date
- $osj2Dposts->post_creation_date->EditCustomAttributes = "";
- $osj2Dposts->post_creation_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($osj2Dposts->post_creation_date->AdvancedSearch->SearchValue, 6));
-
- // post_title
- $osj2Dposts->post_title->EditCustomAttributes = "";
- $osj2Dposts->post_title->EditValue = ew_HtmlEncode($osj2Dposts->post_title->AdvancedSearch->SearchValue);
-
- // post_description
- $osj2Dposts->post_description->EditCustomAttributes = "";
- $osj2Dposts->post_description->EditValue = ew_HtmlEncode($osj2Dposts->post_description->AdvancedSearch->SearchValue);
-
- // post_edit_date
- $osj2Dposts->post_edit_date->EditCustomAttributes = "";
- $osj2Dposts->post_edit_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($osj2Dposts->post_edit_date->AdvancedSearch->SearchValue, 6));
- }
-
- // Call Row Rendered event
- $osj2Dposts->Row_Rendered();
- }
- ?>
- <?php
-
- // Load advanced search
- function LoadAdvancedSearch() {
- global $osj2Dposts;
- $osj2Dposts->user_id->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_user_id");
- $osj2Dposts->post_creation_date->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_creation_date");
- $osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_creation_date");
- $osj2Dposts->post_title->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_title");
- $osj2Dposts->post_title->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_title");
- $osj2Dposts->post_description->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_description");
- $osj2Dposts->post_description->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_description");
- $osj2Dposts->post_edit_date->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_edit_date");
- $osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_edit_date");
- }
- ?>
- <?php
-
- // Page Load event
- function Page_Load() {
-
- //echo "Page Load";
- }
-
- // Page Unload event
- function Page_Unload() {
-
- //echo "Page Unload";
- }
- ?>