/** * Проверка данных из формы. */ function tu_validation(&$tservice, $is_exist_feedbacks = 0) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_categories.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/validation.php'; $errors = array(); $validator = new validation(); $tservices_categories = new tservices_categories(); //--- //$tservice->title = trim(htmlspecialchars(InPost('title'),ENT_QUOTES,'cp1251')); //$tservice->title = antispam(__paramInit('string', NULL, 'name', NULL, 60, TRUE)); $tservice->title = sentence_case(__paramInit('html', null, 'title', null, 100, true)); $title = trim(stripslashes(InPost('title'))); if (!$validator->required($title)) { $errors['title'] = validation::VALIDATION_MSG_REQUIRED; } elseif (!$validator->symbols_interval($title, 4, 100)) { $errors['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 100); } //--- $tservice->price = intval(trim(InPost('price'))); if (!$validator->is_natural_no_zero($tservice->price)) { $errors['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE; } elseif (!$validator->greater_than_equal_to($tservice->price, 300)) { $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_GREATER_THAN_EQUAL_TO, '300 р.'); } elseif (!$validator->less_than_equal_to($tservice->price, 999999)) { $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_LESS_THAN_EQUAL_TO, '999 999 р.'); } //--- $days_db_id = intval(trim(InPost('days_db_id'))); if (!$validator->is_natural_no_zero($days_db_id) || !in_array($days_db_id, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 21, 30, 45, 60, 90))) { $errors['days'] = validation::VALIDATION_MSG_FROM_LIST; $days_db_id = 1; } $tservice->days = $days_db_id; //--- //Если есть отзывы то не даем изменить категорию if (!(InPost('action') == 'save' && $is_exist_feedbacks > 0)) { $category_id = intval(trim(InPost('category_db_id'))); $parent_category_id = $tservices_categories->getCategoryParentId($category_id); if ($parent_category_id === false) { $errors['category'] = validation::VALIDATION_MSG_CATEGORY_FROM_LIST; } else { $tservice->category_id = $category_id; //$this->property()->parent_category_id = $parent_category_id; } } //--- $str_tags = trim(preg_replace('/\\s+/s', ' ', strip_tags(InPost('tags')))); $tags = strlen($str_tags) > 0 ? array_unique(array_map('trim', explode(',', $str_tags))) : array(); $tags = array_filter($tags, function ($el) { $len = strlen(stripslashes($el)); return $len < 80 && $len > 2; }); $tags_cnt = count(array_unique(array_map('strtolower', $tags))); $tags = array_map(function ($value) { return htmlspecialchars($value, ENT_QUOTES, 'cp1251'); }, $tags); $tservice->tags = $tags; if (!$validator->required($str_tags)) { $errors['tags'] = validation::VALIDATION_MSG_REQUIRED; } elseif ($tags_cnt > 10) { $errors['tags'] = sprintf(validation::VALIDATION_MSG_MAX_TAGS, 10); } //--- $videos = __paramInit('array', null, 'videos', array()); $videos = is_array($videos) ? array_values($videos) : array(); if (count($videos)) { $tservice->videos = null; foreach ($videos as $key => $video) { if ($validator->required($video)) { $_video_data = array('url' => $video, 'video' => false, 'image' => false); //$_video = $validator->video_validate($video); $_video = $validator->video_validate($video); $is_error = true; if ($_video) { $_video_data['url'] = $_video; if ($_video_meta = $validator->video_validate_with_thumbs($_video, 0)) { $_video_data = array_merge($_video_data, $_video_meta); $is_error = false; } } if ($is_error) { $errors['videos'][$key] = validation::VALIDATION_MSG_BAD_LINK; } $tservice->videos[$key] = $_video_data; } } } //--- //$tservice->description = trim(htmlspecialchars(InPost('description'),ENT_QUOTES, "cp1251")); //$description = trim(InPost('description')); $tservice->description = trim(__paramInit('html', null, 'description', null, 5000, true)); $description = trim(stripslashes(InPost('description'))); if (!$validator->required($description)) { $errors['description'] = validation::VALIDATION_MSG_REQUIRED; } elseif (!$validator->symbols_interval($description, 4, 5000)) { $errors['description'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000); } //--- //$tservice->requirement = trim(htmlspecialchars(InPost('requirement'),ENT_QUOTES, "cp1251")); //$requirement = trim(InPost('requirement')); $tservice->requirement = trim(__paramInit('html', null, 'requirement', null, 5000, true)); $requirement = trim(stripslashes(InPost('requirement'))); if (!$validator->required($requirement)) { $errors['requirement'] = validation::VALIDATION_MSG_REQUIRED; } elseif (!$validator->symbols_interval($requirement, 4, 5000)) { $errors['requirement'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000); } //--- $extra = __paramInit('array', null, 'extra', array()); $extra = is_array($extra) ? array_values($extra) : array(); $total_extra_price = 0; if (count($extra)) { $key = 0; $tservice->extra = null; foreach ($extra as $el) { if (isset($el['title'], $el['price'], $el['days_db_id'])) { $el['title'] = stripslashes($el['title']); $title = trim(htmlspecialchars($el['title'], ENT_QUOTES, 'cp1251')); $title_native = trim($el['title']); $price = trim($el['price']); if (!$validator->required($title_native) && !$validator->required($price)) { continue; } $is_title = $validator->min_length($title_native, 4) && $validator->max_length($title_native, 255); $is_price = $validator->is_integer_no_zero($price) && $validator->numeric_interval($price, -999999, 999999); if (!$is_price) { $errors['extra'][$key]['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE; } if (!$is_title) { $errors['extra'][$key]['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 255); } $days = trim($el['days_db_id']); $is_days = $validator->is_natural($days) && $validator->less_than_equal_to($days, 5); if (!$is_days) { $errors['extra'][$key]['days'] = sprintf(validation::VALIDATION_MSG_INTERVAL, '0', '5 дней'); $days = 1; } $price = intval($price); $days = intval($days); $tservice->extra[$key] = array('title' => $title, 'price' => $price, 'days' => $days); ++$key; if ($price < 0) { $total_extra_price += $price; } } } } //--- $tservice->is_express = 'f'; $tservice->express_price = 0; $tservice->express_days = 1; if (InPost('express_activate') == 1 && $tservice->days > 1) { $express = InPost('express'); $price = trim($express['price']); if (!$validator->is_natural_no_zero($price) || !$validator->less_than_equal_to($price, 999999)) { $errors['express']['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE; } $days_db_id = intval(trim($express['days_db_id'])); if (!$validator->is_natural_no_zero($days_db_id) || !in_array($days_db_id, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 21, 30, 45, 60, 90))) { $errors['express']['days'] = validation::VALIDATION_MSG_FROM_LIST; $days_db_id = 1; } $tservice->is_express = 't'; $tservice->express_price = intval($price); $tservice->express_days = $days_db_id; } //--- //Проверка общей суммы с учетом скидок, опций (срочность не учитываю так как она выбирается по желанию) if (!isset($errors['price']) && !$validator->greater_than_equal_to($tservice->price + $total_extra_price, 300)) { $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_MIN_TOTAL, '300 р.'); } //--- //TODO: Есть проблема с контроллом выпадающего списка // он не отрабатывает новое значение укзанное по умолчанию if (!in_array(intval(InPost('distance')), array(1, 2))) { $errors['distance'] = validation::VALIDATION_MSG_FROM_RADIO; } elseif (intval(InPost('distance')) == 2) { $city_db_id = intval(InPost('city_db_id')); $city = new city(); if ($city_db_id <= 0 || !$city->getCityName($city_db_id)) { $errors['distance'] = validation::VALIDATION_MSG_CITY_FROM_LIST; } else { $tservice->city = intval(InPost('city_db_id')); $tservice->is_meet = 't'; } } else { $tservice->is_meet = 'f'; } //--- $tservice->agree = InPost('agree') == 1 ? 't' : 'f'; if ($tservice->agree === 'f') { $errors['agree'] = validation::VALIDATION_MSG_ONE_REQUIRED; } //--- if (in_array(InPost('active'), array(0, 1))) { $tservice->active = intval(InPost('active')) == 1 ? 't' : 'f'; if ($tservice->is_angry) { $tservice->active = 't'; } } //--- //Вырезаем слеши если ошибка if (count($errors) > 0) { $attrs = array('title', 'description', 'requirement', 'tags'); foreach ($attrs as $attr) { if (is_array($tservice->{$attr})) { foreach ($tservice->{$attr} as &$value) { $value = stripslashes($value); } } else { $tservice->{$attr} = stripslashes($tservice->{$attr}); } } } return $errors; }
function piece_casestudy($array_portfolio) { $id = $_GET['id']; $portfolio = $array_portfolio[$id]; /*————————————————————————————————————————————————————————————————————*/ if (isset($portfolio['casestudy'])) { $output = $output . '<form class="casestudy" style="margin:0 0 5px 0;" action="piece.php" method="get">'; $output = $output . '<input type="hidden" name="id" value="' . $id . '">'; $output = $output . '<input type="submit" value="Back to Presentation">'; $output = $output . '</form>'; } $count = 0; $output = $output . '<div class="blockinfo">'; $output = $output . '<div class="groupcontent">'; /*$output = $output . '<form class="casestudy" action="piece.php" method="get">'; $output = $output . '<input type="hidden" name="id" value="'.$id.'">'; $output = $output . '<input type="submit" value="Back to Presentation">'; $output = $output . '</form>'; */ $output = $output . '<h1 class="title" style="margin-top:10px;">Casestudy</h1>'; $output = $output . '<p class="sub"><strong>Project</strong>: ' . titlecase($portfolio['title']) . '</p>'; $output = $output . '<ul style="padding:20px; background:#f3f3f3; margin:0px 0px 30px 0px;">'; foreach ($portfolio['credit'] as $credit => $title) { $output = $output . '<p class="subcase" style="list-style-type:none;">' . titlecase($credit) . ', <i>' . titlecase($title) . '</i></li>'; } $output = $output . '</ul>'; /* if(vidlink is set){then $output = $output . '<div class="videoclip"></div>'; // this will be for mobile & tablet to show on vimeo but not next code. disable this in desktop $output = $output . '<div class="videoclip"></div>'; // this will be shown for desktop to view here but not on mobile & tablet. disable this in scss } */ $count = 0; foreach ($portfolio['casestudy'] as $key => $casestudy) { $count = $count + 1; if ($count == 1) { $output = $output . '<p class="caseintro"><b>' . ucfirst($casestudy) . '.</b></p>'; } } $output = $output . '<ol style="padding:10px 0 10px 20px;">'; $count = 0; foreach ($portfolio['casestudy'] as $key => $casestudy) { $count = $count + 1; if ($count > 1) { $output = $output . '<li class="brief"><b class="bold">' . titlecase($key) . ':</b> ' . sentence_case($casestudy) . '.</li>'; } } $output = $output . '</ol>'; /*——————————————————————————————*/ /* $output = $output . '<ul style="padding:0;">'; $output = $output . '<h2>Deliverable(s):</h2>'; $count = 0; foreach($portfolio['deliverables'] as $deliverables){ $count = $count +1; $output = $output . '<li style="list-style-type:none;" class="deliverables">'.$count.'. '.ucwords($deliverables).'</li>'; } $output = $output . '</ul>'; $output = $output . '<ul class="supportingimages" style="padding:0; background:#999;">'; $count = 0; foreach($portfolio['images'] as $image => $description){ $output = $output . '<div>'; $output = $output . '<a target="none" class="'.$count.'" href="'.$image.'">'; $output = $output . '<li style="list-style-type:none; background:url('.$image.')center; background-size:cover; width:100px; height:100px;"></li>'; $output = $output . '</a>'; $output = $output . '<p>'.sentence_case($description).'</p>'; $output = $output . '</div>'; } $output = $output . '</ul>'; /* /*——————————————————————————————*/ /*if(isset($portfolio['casestudy'])){ $output = $output . '<form class="casestudy" action="piece.php" method="get">'; $output = $output . '<input type="hidden" name="id" value="'.$id.'">'; $output = $output . '<input type="submit" value="Back to Presentation">'; $output = $output . '</form>'; } */ /*——————————————————————————————*/ $output = $output . '</div>'; $output = $output . '</div>'; // closing container return $output; }
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php"; //require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/config.php"); //require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/profiler.php"); //require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/account.php"); //require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/mem_storage.php"); //require_once($_SERVER['DOCUMENT_ROOT'] . '/tu/models/TServiceOrderModel.php'); //require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_smail.php'); //------------------------------------------------------------------------------ $results = array(); //$profiler = new profiler(); //------------------------------------------------------------------------------ //$profiler->start('fill_frl_mem'); //------------------------------------------------------------------------------ //$results['locale'] = setlocale(LC_ALL, NULL); $string = 'неужели? эта хуйн¤ Ќ≈–јЅќ“ј≈“ на бете из-за кодировки? сука? ЅЋя“№!'; $string = sentence_case($string); //$results['test'] = $string; //$string = iconv('utf-8','cp1251',$string); $string = iconv('cp1251', 'utf-8', $string); $results['test'] = $string; /* $results['test1'] = iconv('cp1251','utf8',sentence_case($string)); $results['test2'] = iconv('cp1251','utf-8',sentence_case($string)); $results['test3'] = print_r( preg_split('/([.?!]+)/', $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE) ,true); $results['test4'] = iconv('cp1251','utf8', ucfirst(mb_strtolower(trim($string))) ); $results['test5'] = iconv('cp1251','utf-8', ucfirst(mb_strtolower(trim($string))) ); */ //------------------------------------------------------------------------------ //$profiler->stop('fill_frl_mem'); //------------------------------------------------------------------------------
function influence($array_lab) { $id = $_GET['id']; $influence = $array_lab[$id]; $ownername = $influence['ownername']; $category = $influence['category']; $linktopage = $influence['linktopage']; $count = 0; if ($category == 'ad') { $str_category = 'art direction'; } if ($category == 'cd') { $str_category = 'creative direction'; } if ($category == 'td') { $str_category = 'typography direction'; } if ($category == 'ci') { $str_category = 'color influence'; } /*———————————————————————————————————*/ if ($linktopage !== '') { $output = $output . '<div class="tip">'; $output = $output . '<a style="text-decoration:none;" href="http://' . $linktopage . '" target="none"><p>Visit Page of ' . titlecase($ownername) . '</p></a>'; $output = $output . '</div>'; // end DIV .tip } /*———————————————————————————————————*/ $output = $output . '<div class="blockinfo">'; foreach ($influence['image'] as $image => $tag) { $count = $count + 1; if ($count == 1) { $output = $output . '<a href="bingo.php?id=' . $image . '">'; $output = $output . '<div class="imagery" style="background:url(' . $image . ')center; background-size:cover; width:100%; height:400px;">'; $output = $output . '<p class="label">' . ucwords($ownername) . '</p>'; $output = $output . '</div>'; $output = $output . '</a>'; } } if (isset($influence['description'])) { $output = $output . '<div class="groupcontent">'; $output = $output . '<p class="content">' . sentence_case($influence['description']) . '</p>'; $output = $output . '</div>'; } $output = $output . '</div>'; // end DIV .blockinfo /*———————————————————————————————————*/ $output = $output . '<ul class="grid">'; $count = 0; foreach ($influence['image'] as $image => $tag) { $count = $count + 1; if ($count > 1) { $output = $output . '<a style="background:url(' . $image . ')center; background-size:cover;" href="bingo.php?id=' . $image . '">'; $output = $output . '<li></li>'; $output = $output . '</a>'; } } $output = $output . '</ul>'; return $output; }
echo '<title>Strings</title>'; include 'sidebar.php'; echo '<section> <article> <h1>Playing With Strings</h1>'; displayForm(); //If form is filled if (isset($_POST['email'])) { //Concatenate words $var = $_POST['fname'] . " " . $_POST['lname'] . " " . $_POST['address'] . " " . $_POST['city'] . " " . $_POST['state'] . " " . $_POST['zip'] . " " . $_POST['email']; echo $var . "<br>"; echo str_word_count($var) . " words<br>"; echo strtoupper($var) . "<br>"; echo strtolower($var) . "<br>"; echo ucfirst($var) . "<br>"; echo sentence_case($var) . "<br>"; } echo ' </article> </section>'; include 'footer.php'; /** * Display the form to the user */ function displayForm() { echo '<form action="strings.php" method="post"> <table> <tr> <td>First Name: </td><td><input type="Text" name="fname"></td> </tr> <tr>
function about($array_about) { $output = $output . '<div class="containerinfo">'; /*———————————————————————————————————*/ $output = $output . '<div class="blockinfo">'; $count = 0; $output = $output . '<div class="groupcontent">'; $count = 0; foreach ($array_about['selfphoto'] as $image) { $count = $count + 1; if ($count == 1) { $output = $output . '<a class="photocircle" style="background-image:url(' . $image . '); height:100px; width:100px;"></a>'; } } $output = $output . '<p class="boldintro">' . $array_about['description_intro'] . '</p>'; $output = $output . '<p class="content">' . $array_about['description_body'] . '</p>'; $output = $output . '</div>'; $output = $output . '</div>'; /* EXPERIENCE ———————————————————————————————————*/ $output = $output . '<div id="experience">'; $resumecount = 0; foreach ($array_about['resume'] as $resume => $resume_group) { $resumecount = $resumecount + 1; $output = $output . '<div class="resume_group resume' . $resumecount . '">'; $output = $output . '<h2>' . strtoupper($resume . ' experience') . '</h2>'; // $resume -> $data_work -> company -> data $output = $output . '<div style="margin-bottom:20px;">'; foreach ($resume_group as $company => $data_company) { if ($data_company['switch'] == 'on') { $output = $output . '<div class="resume_target">'; $output = $output . '<h3>' . titlecase($company) . ' (' . ucwords($data_company['location']) . ')</h3>'; $output = $output . '<p>' . ucfirst($data_company['experience']) . '</p>'; if ($resume == 'school') { $output = $output . '<p> <strong>Focus:</strong> ' . ucwords($data_company['focus']) . '</p>'; } else { $output = $output . '<p> <strong>Position:</strong> ' . ucwords($data_company['focus']) . '</p>'; } if ($resume == 'school') { $output = $output . '<p> <strong>Interests:</strong>'; } else { $output = $output . '<p> <strong>Responsibilities:</strong>'; } $total = 0; $count = 0; /*—————————————————————————*/ // foreach($data_company['details'] as $details => $list_details){ // //this is meant to precount the total items in array before numbering them // $total = $total +1; // } // foreach($data_company['details'] as $details => $list_details){ // $count = $count +1; // $output = $output .' '. titlecase($list_details); // if($count == $total){ // $output = $output . '.'; // }else{ // $output = $output . ', '; // } // } /*—————————————————————————*/ $output = $output . '<ul>'; foreach ($data_company['details'] as $details => $list_details) { $output = $output . '<li>' . sentence_case($list_details) . '</li>'; } $output = $output . '</ul>'; $output = $output . '</div>'; } } $output = $output . '</div>'; $output = $output . '</div>'; } $output = $output . '</div>'; $output = $output . '<div class="containerinfo" style="margin-top:5px;">'; $output = $output . '<div class="blockinfo">'; $output = $output . '<div class="groupcontent">'; $output = $output . '<p class="content">' . $array_about['description_extra'] . '</p>'; $output = $output . '</div>'; $output = $output . '</div>'; $output = $output . '</div>'; // $output = $output . '<ul class="windows">'; // $output = $output . '<div>'; // $count = 0; // foreach($array_about['photography'] as $image => $flickr){ // $count = $count +1; // if($count < 3){ // $output = $output . '<a href="'.$flickr.'">'; // $output = $output . '<li style="background:url('.$image.')center; background-size:cover;"></li>'; // $output = $output . '</a>'; // } // } // $output = $output . '</div>'; // $output = $output . "<p>I update my Flickr account whenever I get a chance. I enjoy taking photos for fun as a way to capture travel experiences, and ... yeah, for my screen saver — HA!</p>"; // $output = $output . '</ul>'; /*———————————————————————————————————*/ $output = $output . '</div>'; // end DIV containerinfo return $output; }
public function postTranslate() { $group = Input::get('group'); $key = Input::get('key'); $lang = Input::get('lang'); $key = str_replace('.', '/', $group) . '.' . $key; if (Lang::has($key, 'en')) { $word = Lang::get($key, [], 'en'); if ($translated = Cache::get($word . ':' . $lang)) { // Cached } else { $translated = TranslateClient::translate('en', $lang, $word); Cache::put($word . ':' . $lang, $translated, 30); } } else { $translated = null; } $translated = sentence_case($translated); $translated = str_replace([' .', '\''], ['.', '’'], $translated); if (stripos($lang, 'fr') === 0) { $translated = preg_replace('/\\s+\\?/', ' ?', $translated); } return ['word' => $translated]; }
/** * Updates RealtyPress tables with IDX data. Scans image directory and * updates listing table with image date. * * @global <type> $local_temp_dir * @global <type> $local_images_dir * @global <type> $wpdb */ function update_database() { global $local_temp_dir; global $local_images_dir; global $wpdb; global $db_table; // array of lines from data file $file = $local_temp_dir . "listings-residential.txt"; if (!file_exists($file)) { wp_die('<div class="updated fade"><p>The file: ' . $file . ' doesn\'t exist.</p></div>'); } $lines = file($file, FILE_IGNORE_NEW_LINES); $listing_count = 0; foreach ($lines as $line) { // explode columns into $fields array $fields = explode("\t", $line); // make data safe $fields[1] = $wpdb->escape(ucwords(strtolower($fields[1]))); $fields[2] = $wpdb->escape(ucwords(strtolower($fields[2]))); $fields[3] = $wpdb->escape(ucwords(strtolower($fields[3]))); $fields[4] = $wpdb->escape($fields[4]); $fields[5] = $wpdb->escape($fields[5]); $fields[6] = $wpdb->escape($fields[6]); $fields[7] = $wpdb->escape(ucwords(strtolower($fields[7]))); $fields[8] = $wpdb->escape(ucwords(strtolower($fields[8]))); $fields[9] = $wpdb->escape(ucwords(strtolower($fields[9]))); $fields[10] = $wpdb->escape($fields[10]); $fields[11] = $wpdb->escape($fields[11]); $fields[12] = $wpdb->escape($fields[12]); $fields[13] = $wpdb->escape($fields[13]); $fields[14] = $wpdb->escape($fields[14]); $fields[15] = $wpdb->escape($fields[15]); $fields[16] = $wpdb->escape($fields[16]); $fields[17] = $wpdb->escape($fields[17]); $fields[19] = $wpdb->escape(ucwords(strtolower($fields[19]))); $fields[22] = $wpdb->escape(ucwords(strtolower($fields[22]))); $fields[24] = $wpdb->escape($fields[24]); $fields[26] = $wpdb->escape(ucwords(strtolower($fields[26]))); $fields[27] = $wpdb->escape(ucwords(strtolower($fields[27]))); $fields[49] = $wpdb->escape($fields[49]); $fields[54] = $wpdb->escape(ucwords(strtolower($fields[54]))); $fields[59] = $wpdb->escape($fields[59]); $fields[101] = $wpdb->escape($fields[101]); $fields[108] = $wpdb->escape(sentence_case($fields[108])); $fields[123] = $wpdb->escape($fields[123]); $fields[125] = $wpdb->escape($fields[125]); $fields[126] = $wpdb->escape($fields[126]); $price_change = $fields[101] - $fields[4]; // format date $fields[47] = date("Y-m-d", strtotime($fields[47])); // does listing already exist? $wpdb->show_errors(); $found = $wpdb->get_results("SELECT listing_id FROM " . $db_table . " WHERE listing_id='{$fields['0']}'"); // if found, listing exists. UPDATE it. $arr_size = count($found); if ($arr_size != 0) { $rows_affected = $wpdb->query("UPDATE " . $db_table . " SET class='{$fields['1']}',\ntype='{$fields['2']}',\narea='{$fields['3']}',\nprice='{$fields['4']}',\nstreet_num='{$fields['5']}',\nstreet_dir='{$fields['6']}',\nstreet_name='{$fields['7']}',\nstreet_line2='{$fields['8']}',\ncity='{$fields['9']}',\nstate='{$fields['10']}',\nzipcode='{$fields['11']}',\nstatus='{$fields['12']}',\nsale_or_rent='{$fields['13']}',\nbeds='{$fields['14']}',\nbaths_full='{$fields['15']}',\nbaths_partial='{$fields['16']}',\ngarage_cap='{$fields['17']}',\nstories='{$fields['19']}',\nwater_src='{$fields['22']}',\nacres='{$fields['24']}',\nlot_dimensions='{$fields['26']}',\nlot_description='{$fields['27']}',\nlist_date='{$fields['47']}',\nyear_built='{$fields['49']}',\nsubdivision='{$fields['54']}',\ntotal_rooms='{$fields['59']}',\norig_price='{$fields['101']}',\npublic_remarks='{$fields['108']}',\nagent_id='{$fields['123']}',\noffice_id='{$fields['125']}',\nsqft='{$fields['126']}',\nprice_change='{$price_change}'\nWHERE listing_id='{$fields['0']}'"); if ($rows_affected === 0) { //echo "Listing #$fields[0] doesn't need updating.<br />"; //echo '<div class="updated fade"><p>Plugin settings saved.</p></div>'; } elseif ($rows_affected === FALSE) { echo '<div class="error fade"><p>There has been an error querying the database.</p></div>'; } else { $listing_count++; } unset($found); } else { $affected = $wpdb->query("\nINSERT INTO " . $db_table . " (listing_id,\nclass,\ntype,\narea,\nprice,\nstreet_num,\nstreet_dir,\nstreet_name,\nstreet_line2,\ncity,\nstate,\nzipcode,\nstatus,\nsale_or_rent,\nbeds,\nbaths_full,\nbaths_partial,\ngarage_cap,\nstories,\nwater_src,\nacres,\nlot_dimensions,\nlot_description,\nlist_date,\nyear_built,\nsubdivision,\ntotal_rooms,\norig_price,\npublic_remarks,\nagent_id,\noffice_id,\nsqft,\nprice_change)\nVALUES (\n'{$fields['0']}',\n'{$fields['1']}',\n'{$fields['2']}',\n'{$fields['3']}',\n'{$fields['4']}',\n'{$fields['5']}',\n'{$fields['6']}',\n'{$fields['7']}',\n'{$fields['8']}',\n'{$fields['9']}',\n'{$fields['10']}',\n'{$fields['11']}',\n'{$fields['12']}',\n'{$fields['13']}',\n'{$fields['14']}',\n'{$fields['15']}',\n'{$fields['16']}',\n'{$fields['17']}',\n'{$fields['19']}',\n'{$fields['22']}',\n'{$fields['24']}',\n'{$fields['26']}',\n'{$fields['27']}',\n'{$fields['47']}',\n'{$fields['49']}',\n'{$fields['54']}',\n'{$fields['59']}',\n'{$fields['101']}',\n'{$fields['108']}',\n'{$fields['123']}',\n'{$fields['125']}',\n'{$fields['126']}',\n'{$price_change}')\n "); } // end else flush(); $wpdb->flush(); } // end foreach echo '<div class="updated fade"><p>The listings database was updated successfully. Count: ' . $listing_count . '</p></div>'; }