\n" : ""; echo "\n"; } // writes the menu given querystring, database connection, option value and text indices and selected value function write_menu($qs, $db, $mn_name, $vl_x, $tx_x, $sel_vl, $atts=NULL, $first_item=NULL, $last_item=NULL) { require(get_template_directory()."/includes/connections/db.php"); $debugging = false && david_only(); mysqli_select_db($db, $database_db); echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; echo "\n"; } // writes the menu given querystring, database connection, option value and text indices and selected value function write_menu_new($qs, $db_con=NULL, $db_name=NULL, $mn_name, $vl_x, $tx_x, $sel_vl, $atts=NULL, $first_item=NULL, $last_item=NULL) { $debugging = false && david_only(); if (is_null($db_con) || is_null($db_name)) { require(get_template_directory()."/includes/connections/db.php"); $db_con = $db; $db_name = $database_db; } mysqli_select_db($db_con, $db_name); echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; echo "\n"; } // creates the menu given querystring, database connection, option value and text indices and selected value function create_menu($qs, $db, $mn_name, $vl_x, $tx_x, $sel_vl, $atts=NULL, $first_item=NULL, $last_item=NULL) { require(get_template_directory()."/includes/connections/db.php"); $debugging = false && david_only(); mysqli_select_db($db, $database_db); echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; $output = ""; $output .= "\n"; return $output; } function compare_vals($type, $val1, $val2) { switch($type) { case 'string': $result = (string)$val1 === (string)$val2; break; case 'integer': case 'int': $result = (int)$val1 === (int)$val2; break; case 'double': case 'float': case 'real': $result = (float)$val1 === (float)$val2; break; case 'boolean': case 'bool': $result = (bool)$val1 === (bool)$val2; break; default: $result = NULL; break; } return $result; } // writes the menu given array, option value and text indices and selected value (option provides key and index to add attribute to option tag) function write_menu_array($arr, $mn_name, $vl_x, $tx_x, $sel_vl, $atts=NULL, $first_item=NULL, $case=NULL, $option=NULL, $last_item=NULL) { $debugging = false && david_only(); if ($debugging) { echo "\n"; } if (is_numeric($sel_vl)) { echo ($debugging) ? "\n" : ""; if ((int)$sel_vl == (float)$sel_vl) { echo ($debugging) ? "\n" : ""; $sel_vl = (int)$sel_vl; $val_type = 'integer'; } else { echo ($debugging) ? "\n" : ""; $sel_vl = (float)$sel_vl; $val_type = 'real'; } } else { $val_type = 'string'; } // write out the opening select tag echo "\n"; } // writes the menu given querystring, database connection, option value and text indices and selected value function write_state_menu($qs, $db, $mn_name, $vl_x, $tx_x, $sel_vl, $atts=NULL, $first_item=NULL){ require(get_template_directory()."/includes/connections/db.php"); $debugging = false && david_only(); mysqli_select_db($db, $database_db); echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = mysqli_query($db, $qs)){ if ($num_rows = mysqli_num_rows($rs)){ echo "\n"; } } else { echo ($debugging) ? mysqli_errno($db) . ": " . mysqli_error($db) . "
\n" : ""; } } // writes a set of checkboxes given querystring, database connection, checkbox prefix, id index, label index and checked index function write_checkboxes($qs, $db, $cb_prefix, $id_x, $lb_x, $ck_x, $atts=NULL, $id=NULL) { require(get_template_directory()."/includes/connections/db.php"); $debugging = false && david_only(); mysqli_select_db($db, $database_db); echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = mysqli_query($db, $qs)){ if ($num_rows = mysqli_num_rows($rs)){ echo ($debugging) ? "\$num_rows: ".$num_rows."
\n" : ""; $num_fields = mysqli_num_fields($rs); for ($i=0; $i<$num_rows; $i++){ echo ($debugging) ? "\$num_fields: ".$num_fields."
\n" : ""; if ($row_rs = mysqli_fetch_row($rs)) { if ($debugging) { for ($j=0; $j<$num_fields; $j++){ echo $row_rs[$j]."
\n"; } } echo "\n"; // echo "
\n
\n
\n"; } else { echo ($debugging) ? mysqli_errno($db) . ": " . mysqli_error($db) . "
\n" : ""; } } mysqli_free_result($rs); } } else { echo ($debugging) ? mysqli_errno($db) . ": " . mysqli_error($db) . "
\n" : ""; } } function create_month_menu() { $mons = array(1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec"); $menu = "\n"; return $menu; } function create_year_menu() { $num_years = 21; $start_year = date("Y"); $menu = "\n"; return $menu; } function prop_belongs_to_user($prop_id, $user_id) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT id, user_id FROM properties WHERE id=".$prop_id." AND user_id=".$user_id; $arr = NULL; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; } } mysqli_free_result($rs); } echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; return (gettype($arr) == 'array'); } function user_owns_listing($prop_id, $user_id) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT id, user_id FROM FSBO_Property_Master WHERE id=".$prop_id." AND user_id=".$user_id; $arr = NULL; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; } } mysqli_free_result($rs); } echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; return (gettype($arr) == 'array'); } function fetch_city_id($county_id, $city) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT id FROM cities WHERE county_id=".$county_id." AND `name`='".$city."'"; $arr = NULL; $city_id = 0; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; $city_id = (gettype($arr) == 'array') ? $arr[0] : $arr; } } mysqli_free_result($rs); } return $city_id; } function fetch_city_from_id($city_id) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT `name` FROM cities WHERE id=".$city_id; $arr = NULL; $city = ""; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; $city = (gettype($arr) == 'array') ? $arr[0] : $arr; } } mysqli_free_result($rs); } return $city; } // returns the id of the user's property if account has one and only one property, retuns 0 otherwise function fetch_users_property_id($user_id) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT id FROM properties WHERE user_id=".$user_id; $arr = NULL; $prop_id = 0; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows == 1) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; $prop_id = (gettype($arr) == 'array') ? $arr[0] : $arr; } } mysqli_free_result($rs); } return $prop_id; } function fetch_users_property_ids($user_id) { $qs = "SELECT id FROM fsbonm_custom.FSBO_Property_Master WHERE user_id=".$user_id." ORDER BY id DESC"; $arr = fetch_multiple_record($qs); return $arr; } function redirect_with_prop_id($user_id, $dest) { $prop_id = fetch_users_property_id($user_id); if ($prop_id > 0) { header("Location: ".get_host().$dest."/?prop_id=".$prop_id); } else { header("Location: ".get_host()."select-property/"); } } // returns the id of the user's property if account has one and only one property, returns 0 otherwise function fetch_users_fsbo_property_id($user_id) { include(get_template_directory()."/includes/connections/db.php"); mysqli_select_db($db,$database_db); $debugging = false && david_only(); $qs = "SELECT id FROM fsbonm_custom.FSBO_Property_Master WHERE user_id=".$user_id; $arr = NULL; $prop_id = 0; echo ($debugging) ? "\$qs: ".$qs."
\n" : ""; if ($rs = @mysqli_query($db, $qs)) { if ($num_rows = @mysqli_num_rows($rs)){ if ($num_rows === 1) { $arr = @mysqli_fetch_row($rs); echo ($debugging) ? "gettype(\$arr): ".gettype($arr)."
\n" : ""; $prop_id = (gettype($arr) == 'array') ? $arr[0] : $arr; } } mysqli_free_result($rs); } return $prop_id; } function redirect_with_fsbo_prop_id($user_id, $dest) { $prop_id = fetch_users_fsbo_property_id($user_id); if ($prop_id > 0) { header("Location: ".get_host().$dest."/?prop_id=".$prop_id); } else { header("Location: ".get_host()."select-property/"); } } // function write_half_hourly_menu($mn_name, $sel_vl, $atts=NULL, $first_item=NULL, $last_item=NULL) { $debugging = false && david_only(); echo ($debugging) ? "\$sel_vl: ".$sel_vl."
\n" : ""; echo "\n"; } function write_meridian_menu($mn_name, $sel_vl, $atts=NULL, $first_item=NULL, $last_item=NULL) { $debugging = false && david_only(); echo "\n"; } // input like: 'key' => 'value', 'key2' => 'value2' function parse_array_input_string($input) { $debugging = false && david_only(); if (strlen($input)) { echo ($debugging) ? $input."
\n" : ""; $temp_arr = explode(',', $input); $num_els = count($temp_arr); $remove_chars = '\' '; $output_array = []; for ($i=0; $i<$num_els; $i++) { echo ($debugging) ? "\$temp_arr[$i]: ".$temp_arr[$i]."
\n" : ""; list($key, $val) = explode('=>', $temp_arr[$i]); $key = trim($key, $remove_chars); echo ($debugging) ? "\$key: ".$key."
\n" : ""; $val = trim($val, $remove_chars); echo ($debugging) ? "\$val: ".$val."
\n" : ""; if (array_key_exists($key, $output_array)) { $output_array[$key] .= " " . $val; } else $output_array[$key] = $val; } return $output_array; } else { return NULL; } } function fetch_keys_starting_with($key_part, $array) { $out_arr = []; if (strlen($key_part) && gettype($array) == 'array') { foreach ($array as $key => $val) { if (strpos($key, $key_part) === 0) { $out_arr[count($out_arr)] = $key; } } } return $out_arr; } function update_menu_option_vals($fld_id, $post, $rets, $database_rets, $cust, $debugging) { // mn_opt_type_768_0, mn_opt_val_768_0 $prefix = ($cust) ? "x_" : ""; echo ($debugging) ? "\$fld_id: ".$fld_id."
\n" : ""; $search_frag = $prefix.'mn_opt_val_' . $fld_id . "_"; echo ($debugging) ? "\$search_frag: ".$search_frag."
\n" : ""; $keys = fetch_keys_starting_with($prefix.'mn_opt_val_' . $fld_id . "_", $post); if ($debugging) { var_dump_pre($keys); } $form_id = ($post && array_key_exists('form_id', $post)) ? (int)$post['form_id'] : 0; $key_count = count($keys); for ($i=0; $i<$key_count; $i++) { $mn_opt_id = substr($keys[$i], strlen($prefix.'mn_opt_val_' . $fld_id . '_')); echo ($debugging) ? "\$mn_opt_id: ".$mn_opt_id."
\n" : ""; echo ($debugging) ? "\$fld_id: ".$fld_id."
\n" : ""; $fld_id = (int)$fld_id; $mn_opt_id = (int)$mn_opt_id; $mn_opt_type = (int)$post[$prefix.'mn_opt_type_' . $fld_id . '_' . $mn_opt_id]; // $mn_opt_default_val = mysqli_real_escape_string($rets, stripslashes($post['default_val_' . $fld_id])); $mn_opt_val = mysqli_real_escape_string($rets, stripslashes($post[$prefix.'mn_opt_val_' . $fld_id . '_' . $mn_opt_id])); if ($mn_opt_id) { // update or delete if ($mn_opt_type == -1) { // delete $qs = "DELETE rets_manager.RETS_Form_Field_Lookup_Options FROM rets_manager.RETS_Form_Field_Lookup_Options WHERE id=".$mn_opt_id; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } else { // update if (strlen($mn_opt_val)) { $qs = "UPDATE rets_manager.RETS_Form_Field_Lookup_Options SET `type`=".$mn_opt_type.", `val`='".$mn_opt_val."', `custom`=".(($cust) ? 1 : 0).", `form_id`=".$form_id." WHERE id=".$mn_opt_id; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } else { $qs = "DELETE rets_manager.RETS_Form_Field_Lookup_Options FROM rets_manager.RETS_Form_Field_Lookup_Options WHERE id=".$mn_opt_id; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } } } else { // insert if (strlen($mn_opt_val)) { $qs = "INSERT INTO rets_manager.RETS_Form_Field_Lookup_Options (`form_field_id`, `form_id`, `type`, `val`, `custom`) VALUES (".$fld_id.", ".$form_id.", ".$mn_opt_type.", '".$mn_opt_val."', ".(($cust) ? 1 : 0).")"; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } } } } function update_field_option_vals($fld_id, $post, $rets, $database_rets, $cust, $debugging) { $form_id = ($post && array_key_exists('form_id', $post)) ? (int)$post['form_id'] : 0; $prefix = ($cust) ? "x_" : ""; // fld_opt_type_768_0, fld_opt_val_768_0 echo ($debugging) ? "\$fld_id: ".$fld_id."
\n" : ""; $search_frag = $prefix.'fld_opt_val_' . $fld_id . "_"; echo ($debugging) ? "\$search_frag: ".$search_frag."
\n" : ""; $keys = fetch_keys_starting_with($prefix.'fld_opt_val_' . $fld_id . "_", $post); if ($debugging) { var_dump_pre($keys); } $key_count = count($keys); for ($i=0; $i<$key_count; $i++) { $fld_opt_id = substr($keys[$i], strlen($prefix.'fld_opt_val_' . $fld_id . '_')); echo ($debugging) ? "\$fld_opt_id: ".$fld_opt_id."
\n" : ""; echo ($debugging) ? "\$fld_id: ".$fld_id."
\n" : ""; $fld_id = (int)$fld_id; $fld_opt_id = (int)$fld_opt_id; $fld_opt_type = (int)$post[$prefix.'fld_opt_type_' . $fld_id . '_' . $fld_opt_id]; // $fld_opt_default_val = mysqli_real_escape_string($rets, stripslashes($post['default_val_' . $fld_id])); $fld_opt_val = mysqli_real_escape_string($rets, stripslashes($post[$prefix.'fld_opt_val_' . $fld_id . '_' . $fld_opt_id])); if ($fld_opt_id) { // update or delete if ($fld_opt_type == -1) { // delete $qs = "DELETE rets_manager.RETS_Form_Field_Options FROM rets_manager.RETS_Form_Field_Options WHERE id=".$fld_opt_id; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } else { if (strlen($fld_opt_val)) { // update $qs = "UPDATE rets_manager.RETS_Form_Field_Options SET `type`=" . $fld_opt_type . ", `val`='" . $fld_opt_val . "', `custom`=" . ( ( $cust ) ? 1 : 0 ) . ", `form_id`=".$form_id." WHERE id=" . $fld_opt_id; echo ( $debugging ) ? "qs: " . $qs . "
\n" : ""; $result = execute_query( $qs, $rets, $database_rets ); echo ( $debugging ) ? ( ( $result ) ? "good
\n" : "bad
\n" ) : ""; } else { $qs = "DELETE rets_manager.RETS_Form_Field_Options FROM rets_manager.RETS_Form_Field_Options WHERE id=".$fld_opt_id; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } } } else { // insert if (strlen($fld_opt_val)) { $qs = "INSERT INTO rets_manager.RETS_Form_Field_Options (`form_field_id`, `form_id`, `type`, `val`, `custom`) VALUES (".$fld_id.", ".$form_id.", ".$fld_opt_type.", '".$fld_opt_val."', ".(($cust) ? 1 : 0).")"; echo ($debugging) ? "qs: ".$qs."
\n" : ""; $result = execute_query($qs, $rets, $database_rets); echo ($debugging) ? (($result) ? "good
\n" : "bad
\n") : ""; } } } } function fetch_menu_options($rec) { $first_item = null; $last_item = null; $atts = null; $options = null; if ( array_key_exists( 'options', $rec ) ) { $num_options = count( $rec['options'] ); for ( $j = 0; $j < $num_options; $j ++ ) { $temp = $rec['options'][ $j ]['val']; if ( $rec['options'][ $j ]['type'] == 3 ) { $first_item = $temp; } elseif ( $rec['options'][ $j ]['type'] == 4 ) { $last_item = $temp; } elseif ( $rec['options'][ $j ]['type'] == 5 ) { $atts .= $temp; } elseif ( $rec['options'][ $j ]['type'] == 6 ) { $options .= $temp; } elseif ( $rec['options'][ $j ]['type'] == 7 ) { $options .= $temp; } } // each of the items is a string something like: ''=>'Select Post Direction', 'class'=>'my_class_name' /* // now we need to turn them into arrays $first_item = parse_array_input_string($first_item); $last_item = parse_array_input_string($last_item); $atts = parse_array_input_string($atts); $options = parse_array_input_string($options);*/ if (($rec['required'])) { $atts .= (strlen($atts)) ? "," : ""; $atts .= "'class'=>'required'"; } return array( parse_array_input_string( $first_item ), parse_array_input_string( $last_item ), parse_array_input_string( $atts ), parse_array_input_string( $options ) ); } else { return null; } } function fetch_field_options($rec) { $single = null; $key_val = null; $type = null; if ( array_key_exists( 'options', $rec ) ) { $num_options = count( $rec['options'] ); for ( $j = 0; $j < $num_options; $j ++ ) { $temp = $rec['options'][ $j ]['val']; if ( $rec['options'][ $j ]['type'] == 1 ) { $single = $temp; } elseif ( $rec['options'][ $j ]['type'] == 2 ) { $key_val = $temp; } elseif ( $rec['options'][ $j ]['type'] == 3 ) { $type = $temp; } } if (($rec['required'])) { $key_val .= (strlen($key_val)) ? "," : ""; $key_val .= "'class'=>'required'"; } return array( explode(" ", $single ), parse_array_input_string( $key_val ), $type ); } else { return null; } } function write_key_value_pairs($key_vals) { if ($key_vals) { foreach ($key_vals as $key => $val){ echo " ".$key."=\"".$val."\""; } } } function write_single_values($single_vals) { if ($single_vals) { foreach ($single_vals as $val){ echo " ".$val; } } } function get_prop_id($user_id, $classname) { require(get_template_directory()."/includes/connections/db.php"); $qs = "SELECT id FROM FSBO_Property_Master WHERE user_id=".$user_id; $qs .= (strlen($classname)) ? " AND classname='".mysqli_real_escape_string($db, $classname)."' " : ""; $qs .= " ORDER BY id ASC LIMIT 1"; $prop_id = fetch_single_record($qs); return ($prop_id) ? $prop_id[0] : 0; } function fetch_set_frag($rec, $post_val, $update) { require(get_template_directory()."/includes/connections/db.php"); $output = ($update) ? $rec['systemname']."=" : ""; switch(strtolower($rec['datatype'])) { case 'character': case 'date': case 'datetime': $output .= (strlen($post_val)) ? "'".mysqli_real_escape_string($db, stripslashes($post_val))."'" : 'NULL'; break; case 'int': case 'boolean': case 'decimal': $output .= (strlen($post_val)) ? mysqli_real_escape_string($db, stripslashes($post_val)) : 'NULL'; break; default: break; } return $output; } function write_lookupmulti($rec, $lkm_vals=NULL) { $prefix = (array_key_exists('custom', $rec) && $rec['custom'] === '1') ? "x_" : ""; list($first_item, $last_item, $atts, $options) = fetch_menu_options($rec); $atts['class'] = (!is_null($atts) && array_key_exists('class', $atts)) ? $atts['class'] . ' dd' : 'dd'; /* echo "\n";*/ if ($options) { if (array_key_exists('width', $options)) { echo "\n"; } } $num_opts = count( $rec['lookup_arr'] ); if ($num_opts <= 0) { echo " $val){ echo " ".$key."=\"".$val."\""; } unset($key); unset($val); } echo ">\n"; echo "".htmlentities( $rec['longname'] )."\n"; $lkm_cnt = 0; for ( $j = 0; $j < $num_opts; $j ++ ) { echo "\n"; } echo "\n"; } else { /* echo "\n";*/ echo "
$val){ echo " ".$key."=\"".$val."\""; } unset($key); unset($val); } echo ">\n".htmlentities( $rec['longname'] )."\n"; echo "
\n"; $lkm_cnt = 0; for ( $j = 0; $j < $num_opts; $j ++ ) { // echo "\n"; echo "\n"; } echo "
\n"; echo "
\n"; } } function fetch_field_type($datatype, $maxlength, $precision) { // require(get_template_directory()."/includes/connections/db.php"); $output = ""; switch(strtolower($datatype)) { case 'character': $output .= 'VARCHAR('.$maxlength.')'; break; case 'date': $output .= 'DATE'; break; case 'datetime': $output .= 'DATETIME'; break; case 'int': $output .= 'INT('.$maxlength.') UNSIGNED'; break; case 'boolean': $output .= 'TINYINT('.$maxlength.') UNSIGNED'; break; case 'decimal': $output .= 'DECIMAL('.$maxlength.', '.$precision.') UNSIGNED'; break; default: $output = $datatype; break; } return $output; } ?> Upload Your List - WorldSource Fasteners

Upload Your Files


Menu