PageRenderTime 62ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-osj2dpostssrch.php

http://osjobber.googlecode.com/
PHP | 367 lines | 272 code | 45 blank | 50 comment | 45 complexity | 913654d39415ebe4feb3e6f0f750a82e MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "search", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-posts', TRUE);
  4. ?>
  5. <?php
  6. session_start(); // Initialize session data
  7. ob_start(); // Turn on output buffering
  8. ?>
  9. <?php include "osj-ewcfg50.php" ?>
  10. <?php include "osj-ewmysql50.php" ?>
  11. <?php include "osj-phpfn50.php" ?>
  12. <?php include "osj-osj2dpostsinfo.php" ?>
  13. <?php include "osj-userfn50.php" ?>
  14. <?php include "osj-osj2dusersinfo.php" ?>
  15. <?php
  16. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  17. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  18. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  19. header("Cache-Control: post-check=0, pre-check=0", false);
  20. header("Pragma: no-cache"); // HTTP/1.0
  21. ?>
  22. <?php
  23. // Open connection to the database
  24. $conn = ew_Connect();
  25. ?>
  26. <?php
  27. $Security = new cAdvancedSecurity();
  28. ?>
  29. <?php
  30. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  31. $Security->LoadCurrentUserLevel('osj-posts');
  32. ?>
  33. <?php
  34. // Common page loading event (in userfn*.php)
  35. Page_Loading();
  36. ?>
  37. <?php
  38. // Page load event, used in current page
  39. Page_Load();
  40. ?>
  41. <?php
  42. $osj2Dposts->Export = @$_GET["export"]; // Get export parameter
  43. $sExport = $osj2Dposts->Export; // Get export parameter, used in header
  44. $sExportFile = $osj2Dposts->TableVar; // Get export file, used in header
  45. ?>
  46. <?php
  47. // Get action
  48. $osj2Dposts->CurrentAction = @$_POST["a_search"];
  49. switch ($osj2Dposts->CurrentAction) {
  50. case "S": // Get Search Criteria
  51. // Build search string for advanced search, remove blank field
  52. $sSrchStr = BuildAdvancedSearch();
  53. if ($sSrchStr <> "") {
  54. Page_Terminate("osj-osj2dpostslist.php?" . $sSrchStr); // Go to list page
  55. }
  56. break;
  57. default: // Restore search settings
  58. LoadAdvancedSearch();
  59. }
  60. // Render row for search
  61. $osj2Dposts->RowType = EW_ROWTYPE_SEARCH;
  62. RenderRow();
  63. ?>
  64. <?php include "osj-header.php" ?>
  65. <script type="text/javascript">
  66. <!--
  67. var EW_PAGE_ID = "search"; // Page id
  68. var EW_SHOW_HIGHLIGHT = "Show highlight";
  69. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  70. //-->
  71. </script>
  72. <script type="text/javascript">
  73. <!--
  74. function ew_ValidateForm(fobj) {
  75. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  76. return true;
  77. var i, elm, aelm, infix;
  78. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  79. for (i=0; i<rowcnt; i++) {
  80. infix = (fobj.key_count) ? String(i+1) : "";
  81. elm = fobj.elements["x" + infix + "_post_edit_date"];
  82. if (elm && !ew_CheckUSDate(elm.value)) {
  83. if (!ew_OnError(elm, "Incorrect date, format = mm/dd/yyyy - Post Edit Date"))
  84. return false;
  85. }
  86. }
  87. return true;
  88. }
  89. //-->
  90. </script>
  91. <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  92. <script type="text/javascript">
  93. <!--
  94. _width_multiplier = 16;
  95. _height_multiplier = 60;
  96. var ew_DHTMLEditors = [];
  97. function ew_UpdateTextArea() {
  98. if (typeof ew_DHTMLEditors != 'undefined' &&
  99. typeof FCKeditorAPI != 'undefined') {
  100. var inst;
  101. for (inst in FCKeditorAPI.__Instances)
  102. FCKeditorAPI.__Instances[inst].UpdateLinkedField();
  103. }
  104. }
  105. //-->
  106. </script>
  107. <script type="text/javascript">
  108. <!--
  109. // js for Popup Calendar
  110. //-->
  111. </script>
  112. <script language="JavaScript" type="text/javascript">
  113. <!--
  114. // Write your client script here, no need to add script tags.
  115. // To include another .js script, use:
  116. // ew_ClientScriptInclude("my_javascript.js");
  117. //-->
  118. </script>
  119. <p><span class="phpmaker">Search TABLE: Posts<br><br><a href="osj-osj2dpostslist.php">Back to List</a></span></p>
  120. <form name="fosj2Dpostssearch" id="fosj2Dpostssearch" action="osj-osj2dpostssrch.php" method="post">
  121. <p>
  122. <input type="hidden" name="a_search" id="a_search" value="S">
  123. <table class="ewTable">
  124. <tr class="ewTableRow">
  125. <td class="ewTableHeader">Employer ID</td>
  126. <td<?php echo $osj2Dposts->user_id->CellAttributes() ?>><span class="ewSearchOpr">=<input type="hidden" name="z_user_id" id="z_user_id" value="="></span></td>
  127. <td<?php echo $osj2Dposts->user_id->CellAttributes() ?>><span class="phpmaker">
  128. <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() ?>>
  129. </span></td>
  130. </tr>
  131. <tr class="ewTableAltRow">
  132. <td class="ewTableHeader">Creation Date</td>
  133. <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>
  134. <td<?php echo $osj2Dposts->post_creation_date->CellAttributes() ?>><span class="phpmaker">
  135. <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() ?>>
  136. </span></td>
  137. </tr>
  138. <tr class="ewTableRow">
  139. <td class="ewTableHeader">Title</td>
  140. <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>
  141. <td<?php echo $osj2Dposts->post_title->CellAttributes() ?>><span class="phpmaker">
  142. <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>
  143. <div class='ewAstList' style='visibility:hidden' id='as_x_post_title'></div>
  144. <input type="hidden" name="sv_x_post_title" id="sv_x_post_title" value="">
  145. <?php
  146. $sSqlWrk = "SELECT DISTINCT `post_title`, `post_description` FROM `osj-posts` WHERE (`post_title` LIKE '@FILTER_VALUE%')";
  147. $sSqlWrk .= " ORDER BY `post_creation_date` ";
  148. $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
  149. ?>
  150. <input type="hidden" name="s_x_post_title" id="s_x_post_title" value="<?php echo $sSqlWrk ?>">
  151. <input type="hidden" name="lt_x_post_title" id="lt_x_post_title" value="1">
  152. </span></td>
  153. </tr>
  154. <tr class="ewTableAltRow">
  155. <td class="ewTableHeader">Description</td>
  156. <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>
  157. <td<?php echo $osj2Dposts->post_description->CellAttributes() ?>><span class="phpmaker">
  158. <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>
  159. </span></td>
  160. </tr>
  161. <tr class="ewTableRow">
  162. <td class="ewTableHeader">Post Edit Date</td>
  163. <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>
  164. <td<?php echo $osj2Dposts->post_edit_date->CellAttributes() ?>><span class="phpmaker">
  165. <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() ?>>
  166. </span></td>
  167. </tr>
  168. </table>
  169. <p>
  170. <input type="button" name="Action" id="Action" value=" Search " onClick="ew_SubmitForm(this.form);">
  171. <input type="button" name="Reset" id="Reset" value=" Reset " onclick="ew_ClearForm(this.form);">
  172. </form>
  173. <script type="text/javascript">
  174. <!--
  175. ew_CreateEditor(); // Create DHTML editor(s)
  176. //-->
  177. </script>
  178. <script language="JavaScript" type="text/javascript">
  179. <!--
  180. // Write your table-specific startup script here
  181. // document.write("page loaded");
  182. //-->
  183. </script>
  184. <?php include "osj-footer.php" ?>
  185. <?php
  186. // If control is passed here, simply terminate the page without redirect
  187. Page_Terminate();
  188. // -----------------------------------------------------------------
  189. // Subroutine Page_Terminate
  190. // - called when exit page
  191. // - clean up connection and objects
  192. // - if url specified, redirect to url, otherwise end response
  193. function Page_Terminate($url = "") {
  194. global $conn;
  195. // Page unload event, used in current page
  196. Page_Unload();
  197. // Global page unloaded event (in userfn*.php)
  198. Page_Unloaded();
  199. // Close Connection
  200. $conn->Close();
  201. // Go to url if specified
  202. if ($url <> "") {
  203. ob_end_clean();
  204. header("Location: $url");
  205. }
  206. exit();
  207. }
  208. ?>
  209. <?php
  210. // Build advanced search
  211. function BuildAdvancedSearch() {
  212. global $osj2Dposts;
  213. $sSrchUrl = "";
  214. // Field user_id
  215. 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"]);
  216. // Field post_creation_date
  217. 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"]);
  218. // Field post_title
  219. 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"]);
  220. // Field post_description
  221. 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"]);
  222. // Field post_edit_date
  223. 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"]);
  224. return $sSrchUrl;
  225. }
  226. // Function to build search URL
  227. function BuildSearchUrl(&$Url, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
  228. $sWrk = "";
  229. $FldParm = substr($Fld->FldVar, 2);
  230. $FldVal = ew_StripSlashes($FldVal);
  231. if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
  232. $FldVal2 = ew_StripSlashes($FldVal2);
  233. if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
  234. $FldOpr = strtoupper(trim($FldOpr));
  235. if ($FldOpr == "BETWEEN") {
  236. $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  237. ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2));
  238. if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
  239. $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
  240. "&y_" . $FldParm . "=" . urlencode($FldVal2) .
  241. "&z_" . $FldParm . "=" . urlencode($FldOpr);
  242. }
  243. } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
  244. $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
  245. "&z_" . $FldParm . "=" . urlencode($FldOpr);
  246. } else {
  247. $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  248. ($Fld->FldDataType = EW_DATATYPE_NUMBER && is_numeric($FldVal));
  249. if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
  250. $sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
  251. "&z_" . $FldParm . "=" . urlencode($FldOpr);
  252. }
  253. $IsValidValue = ($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  254. ($Fld->FldDataType = EW_DATATYPE_NUMBER && is_numeric($FldVal2));
  255. if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
  256. if ($sWrk <> "") $sWrk .= "&v_" . $FldParm . "=" . urlencode($FldCond) . "&";
  257. $sWrk .= "&y_" . $FldParm . "=" . urlencode($FldVal2) .
  258. "&w_" . $FldParm . "=" . urlencode($FldOpr2);
  259. }
  260. }
  261. if ($sWrk <> "") {
  262. if ($Url <> "") $Url .= "&";
  263. $Url .= $sWrk;
  264. }
  265. }
  266. ?>
  267. <?php
  268. // Render row values based on field settings
  269. function RenderRow() {
  270. global $conn, $Security, $osj2Dposts;
  271. // Call Row Rendering event
  272. $osj2Dposts->Row_Rendering();
  273. // Common render codes for all row types
  274. if ($osj2Dposts->RowType == EW_ROWTYPE_VIEW) { // View row
  275. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_ADD) { // Add row
  276. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_EDIT) { // Edit row
  277. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_SEARCH) { // Search row
  278. // user_id
  279. $osj2Dposts->user_id->EditCustomAttributes = "";
  280. $osj2Dposts->user_id->EditValue = ew_HtmlEncode($osj2Dposts->user_id->AdvancedSearch->SearchValue);
  281. // post_creation_date
  282. $osj2Dposts->post_creation_date->EditCustomAttributes = "";
  283. $osj2Dposts->post_creation_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($osj2Dposts->post_creation_date->AdvancedSearch->SearchValue, 6));
  284. // post_title
  285. $osj2Dposts->post_title->EditCustomAttributes = "";
  286. $osj2Dposts->post_title->EditValue = ew_HtmlEncode($osj2Dposts->post_title->AdvancedSearch->SearchValue);
  287. // post_description
  288. $osj2Dposts->post_description->EditCustomAttributes = "";
  289. $osj2Dposts->post_description->EditValue = ew_HtmlEncode($osj2Dposts->post_description->AdvancedSearch->SearchValue);
  290. // post_edit_date
  291. $osj2Dposts->post_edit_date->EditCustomAttributes = "";
  292. $osj2Dposts->post_edit_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($osj2Dposts->post_edit_date->AdvancedSearch->SearchValue, 6));
  293. }
  294. // Call Row Rendered event
  295. $osj2Dposts->Row_Rendered();
  296. }
  297. ?>
  298. <?php
  299. // Load advanced search
  300. function LoadAdvancedSearch() {
  301. global $osj2Dposts;
  302. $osj2Dposts->user_id->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_user_id");
  303. $osj2Dposts->post_creation_date->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_creation_date");
  304. $osj2Dposts->post_creation_date->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_creation_date");
  305. $osj2Dposts->post_title->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_title");
  306. $osj2Dposts->post_title->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_title");
  307. $osj2Dposts->post_description->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_description");
  308. $osj2Dposts->post_description->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_description");
  309. $osj2Dposts->post_edit_date->AdvancedSearch->SearchValue = $osj2Dposts->getAdvancedSearch("x_post_edit_date");
  310. $osj2Dposts->post_edit_date->AdvancedSearch->SearchOperator = $osj2Dposts->getAdvancedSearch("z_post_edit_date");
  311. }
  312. ?>
  313. <?php
  314. // Page Load event
  315. function Page_Load() {
  316. //echo "Page Load";
  317. }
  318. // Page Unload event
  319. function Page_Unload() {
  320. //echo "Page Unload";
  321. }
  322. ?>