$value) { if (is_array($value)) { continue; } $value = Ctrl_Db_Util::sqlQuote( $value ); $columns[] = $column; $values[] = $value; if ($update_str != '') { $update_str .= ', '; } $update_str .= $column . ' = ' . $value; } $columns = implode(", ", $columns); $values = implode(", ", $values); if (! $comment_id) { $sql = "INSERT INTO $comment_table ($columns) values ($values)"; Ctrl_Db_Controller::query($sql); } else { $sql = "UPDATE $comment_table SET $update_str WHERE id = " . Ctrl_Db_Util::sqlQuote( $comment_id ); Ctrl_Db_Controller::query($sql); } } //////////////////// BBS繧ウ繝。繝ウ繝域兜遞ソ譎・//////////////////// function pp_bbs_entry_comment(&$ctrl) { if (! Ctrl_Form_Manager::isDeleteMode()) { $thread_table = Ctrl_Db_Util::makeTableFullName('pp_bbs_thread'); $comment_table = Ctrl_Db_Util::makeTableFullName('pp_bbs_comment'); $thread_id = Ctrl_Db_Util::sqlQuote( $ctrl['target_form']['pp_bbs_comment__parent_id'] ); $comment_id = Ctrl_Db_Util::sqlQuote( $ctrl['target_form']['pp_bbs_comment__id'] ); if ( ! isset($ctrl['target_form']['pp_bbs_comment__comment_num']) ) { // 繝医Λ繝ウ繧カ繧ッ繧キ繝ァ繝ウ Ctrl_Db_Util::beginTransaction(); $sql = "SELECT MAX(comment_num) FROM $comment_table WHERE parent_id = $thread_id"; $comment_num = Ctrl_Db_Util::fetchOneValue($sql); $comment_num++; $sql = "UPDATE $comment_table SET comment_num = $comment_num WHERE id = $comment_id"; Ctrl_Db_Controller::query($sql); Ctrl_Db_Util::commit(); } if (empty($_POST['pp_bbs_comment__id'])) { // 繧「繝ゥ繝シ繝磯€∽ソ。 $sql = "SELECT * FROM $thread_table WHERE id = $thread_id"; $row = Ctrl_Db_Util::fetchOneRowAssoc($sql); if (!empty($row['email'])) { $ctrl['mail_setting']['use'] = true; $ctrl['mail_setting']['to'] = $row['email']; $ctrl['mail_setting']['message'] = <<< EOM {$row['name']}讒・縺・▽繧ゅ・繝・ヨ繧ケ繝・・繧キ繝ァ繝ウ繧偵#蛻ゥ逕ィ縺ゅj縺後→縺・#縺悶>縺セ縺吶€・ {$row['name']}讒倥′謗イ遉コ譚ソ縺ク譖ク縺崎セシ縺セ繧後∪縺励◆蜀・ョケ縺ク {$ctrl['target_form']['pp_bbs_comment__name']}讒倥′繧ウ繝。繝ウ繝医&繧後∪縺励◆縲・ {$ctrl['target_form']['pp_bbs_comment__name']}讒・繧ウ繝。繝ウ繝茨シ・{$ctrl['target_form']['pp_bbs_comment__comment']} 謗イ遉コ譚ソ縺ョURL https://petstation.jp/petpro/pp_bbs_comment.php?pp_bbs_thread__id={$thread_id} ------------------------ 繝壹ャ繝医せ繝・・繧キ繝ァ繝ウ https://www.petstation.jp/ ------------------------ EOM; } } $sql = "UPDATE $thread_table SET upd_date = now() WHERE id = $thread_id"; Ctrl_Db_Controller::query($sql); } } function pp_shop_manage_edit(&$ctrl) { pp_shop_premium_process($ctrl); pp_update_aipaw_stat_shop($ctrl); } //////////////////// 繧キ繝ァ繝・・逋サ骭イ諠・ア繧定・蜍輔〒縺顔衍繧峨○縺ォ霑ス蜉 //////////////////// function pp_add_shop_information(&$ctrl) { pp_add_update_information($ctrl, 1); pp_make_redraw_flag($ctrl); pp_update_aipaw_stat_shop($ctrl); pp_update_appeal($ctrl); } //////////////////// 繝壹ャ繝域峩譁ー諠・ア繧定・蜍輔〒縺顔衍繧峨○縺ォ霑ス蜉 //////////////////// function pp_add_pet_information(&$ctrl) { pp_add_update_information($ctrl, 2); pp_make_redraw_flag($ctrl); pp_process_latest_flag($ctrl); pp_update_aipaw_stat_pet($ctrl); pp_update_appeal($ctrl); $id = intval($ctrl['target_form']['shop_info__id']); if (in_array($id, array(4143, 4535, 3410, 4208, 4579, 4200, 4784, 4197, 4843, 4508, 4217, 4963, 3403, 4238, 4502, 3399, 5037, 4585, 4251, 4501, 4199, 4561, 4862, 4347, 5106, 4969, 4956, 5580, 5739, 5738, 5652, 5459, 5865, 5869, 5931, 5937, 5945, 6014))) { $param = array(); pp_remote_wp($ctrl, $param); } } //////////////////// 縺昴・莉悶・譖エ譁ー諠・ア繧定・蜍輔〒縺顔衍繧峨○縺ォ霑ス蜉 //////////////////// function pp_add_other_information(&$ctrl) { pp_add_update_information($ctrl, 3); pp_make_redraw_flag($ctrl); } //////////////////// 蜀肴緒逕サ謖・、コ繝輔ぃ繧、繝ォ //////////////////// function pp_make_redraw_flag(&$ctrl) { $path = DIR_ROOT . 'www/redrawFlag'; touch( $path ); } //////////////////// 譛€譁ー繝輔Λ繧ー縺ョ邂。逅・//////////////////// function pp_process_latest_flag(&$ctrl) { if (!empty($ctrl['target_form']['shop_info__id'])) { $id = $ctrl['target_form']['shop_info__id']; // 閾ェ蛻・・繧キ繝ァ繝・・縺ァlatest_stat縺君ULL縺・莉・荳翫・繧ゅ・繧・縺ォ縺吶k $sql = "UPDATE st_tb_animal SET latest_stat = 0, latest_stat_all = 0 WHERE parent_id = {$id} AND (latest_stat IS NULL OR latest_stat > 0)"; Ctrl_Db_Controller::query($sql); // 蜷・ィョ鬘槭€√ヨ繝・・2縺ョlatest_stat繧致ariety縺ォ縺吶k foreach($GLOBALS['animal_ids_array'] as $animal_ids) { $variety = 'variety IN ' . '(' . $animal_ids . ')'; $animalIds = pp_get_top2($id, $variety); foreach($animalIds as $animalId) { $sql = "UPDATE st_tb_animal SET latest_stat = variety WHERE id = {$animalId}"; Ctrl_Db_Controller::query($sql); } } // 迥ャ縺ョ遞ョ鬘槭↓縺ッ10000繧定カウ縺・ $variety = 'species = 1'; $animalIds = pp_get_top2($id, $variety); foreach($animalIds as $animalId) { $sql = "UPDATE st_tb_animal SET latest_stat = latest_stat + 10000 WHERE id = {$animalId}"; Ctrl_Db_Controller::query($sql); } // 迪ォ縺ョ遞ョ鬘槭↓縺ッ20000繧定カウ縺・ $variety = 'species = 2'; $animalIds = pp_get_top2($id, $variety); foreach($animalIds as $animalId) { $sql = "UPDATE st_tb_animal SET latest_stat = latest_stat + 20000 WHERE id = {$animalId}"; Ctrl_Db_Controller::query($sql); } // 縺昴l莉・螟悶・遞ョ鬘槭↓縺ッ3000繧定カウ縺・ $variety = 'species > 2'; $animalIds = pp_get_top2($id, $variety); foreach($animalIds as $animalId) { $sql = "UPDATE st_tb_animal SET latest_stat = latest_stat + 30000 WHERE id = {$animalId}"; Ctrl_Db_Controller::query($sql); } // fix 20160607194956 // 蜈ィ菴薙・繝医ャ繝励↓縺ッlatest_stat_all繝輔Λ繧ー繧偵▽縺代k $animalIds = pp_get_top2($id); foreach($animalIds as $animalId) { $sql = "UPDATE st_tb_animal SET latest_stat_all = 1 WHERE id = {$animalId}"; Ctrl_Db_Controller::query($sql); } } } function pp_update_aipaw_stat_pet(&$ctrl) { if (empty($ctrl['target_form']['animal__id'])) { return; } // id $id = $ctrl['target_form']['animal__id']; $id = strval(intval($id)); if (Ctrl_Form_Manager::isDeleteMode()) { shell_exec(DIR_ROOT . 'script/aipaw/hide_ps_curation_by_pet_id ' . $id); } $shop_is_open = SQL_SHOP_IS_OPEN; $animal_is_sale = "[[animal]].status != 3 AND [[animal]].status != 4 AND [[animal]].status != 5 AND status != 7 AND $shop_is_open AND [[animal]].upd_date > DATE_SUB(NOW(), INTERVAL 1 YEAR) "; $sql = "SELECT [[animal]].id FROM [[animal]] LEFT JOIN [[shop_info]] ON [[animal]].parent_id = [[shop_info]].id WHERE [[animal]].id = {$id} AND {$animal_is_sale} AND [[animal]].short_comment != '' AND [[shop_info]].premium_flag = 1"; $sql = Ctrl_Db_Util::interpretSql($sql); $stmt = Ctrl_Db_Controller::query($sql); if ($stmt === false) { shell_exec(DIR_ROOT . 'script/aipaw/hide_ps_curation_by_pet_id ' . $id); } } function pp_update_aipaw_stat_shop(&$ctrl) { if (empty($ctrl['target_form']['shop_info__id'])) { return; } // id $id = $ctrl['target_form']['shop_info__id']; $id = strval(intval($id)); if (Ctrl_Form_Manager::isDeleteMode()) { shell_exec(DIR_ROOT . 'script/aipaw/hide_ps_curation_by_shop_id ' . $id); } if (!empty($ctrl['target_form']['shop_info__open_stat'])) { if ($ctrl['target_form']['shop_info__open_stat'] != 1) { shell_exec(DIR_ROOT . 'script/aipaw/hide_ps_curation_by_shop_id ' . $id); } } if (!empty($ctrl['target_form']['shop_info__manage_stat'])) { if ($ctrl['target_form']['shop_info__manage_stat'] != 1) { shell_exec(DIR_ROOT . 'script/aipaw/hide_ps_curation_by_shop_id ' . $id); } } } function pp_get_top2($parent_id, $variety = '') { if ($variety != '') { $variety = 'AND ' . $variety; } $sql = "SELECT id FROM st_tb_animal WHERE status != 4 AND status != 5 AND status != 7 AND parent_id = {$parent_id} {$variety} ORDER BY id DESC LIMIT 0, 2"; $animalIds = Ctrl_Db_Util::fetchRowZeroByArray($sql); return $animalIds; } //////////////////// 繧キ繝ァ繝・・縺ョ譖エ譁ー髢「菫ゅ・諠・ア繧定・蜍輔〒縺顔衍繧峨○縺ォ霑ス蜉 //////////////////// function pp_add_update_information(&$ctrl, $update_type) { pp_shop_premium_process($ctrl); // update_type 1 = 繧キ繝ァ繝・・逋サ骭イ縲€2 = 繝壹ャ繝郁ソス蜉 3 = 譖エ譁ー if( $ctrl['locale'] == 'en' ) { function __NEW_SHOP_COMMENT__($shop) { return "{$shop} has newly joined"; } define( "__JOINED__", 'joined puppystation'); define( "__UPDATE_COUPON__", 'new coupon'); define( "__UPDATE_ANIMAL__", 'new pet'); } else { function __NEW_SHOP_COMMENT__($shop) { return "{$shop}讒倥′譁ー縺溘↓蜿ょ刈縺輔l縺セ縺励◆縲・; } define( "__JOINED__", '繝壹ャ繝医せ繝・・繧キ繝ァ繝ウ縺ォ蜿ょ刈縺励∪縺励◆縲・); define( "__UPDATE_COUPON__", '繧ッ繝シ繝昴Φ繧呈峩譁ー縺励∪縺励◆'); define( "__UPDATE_ANIMAL__", '繝壹ャ繝医r譖エ譁ー縺励∪縺励◆'); } // 蜑企勁縺ェ繧牙・逅・↑縺・ if ( Ctrl_Form_Manager::isDeleteMode() ) { return; } $info_table = Ctrl_Db_Util::makeTableFullName('update_information'); $news_table = Ctrl_Db_Util::makeTableFullName('shop_news'); $shop_id = $ctrl['target_form']['shop_info__id']; $shop_table = Ctrl_Db_Util::makeTableFullName('shop_info'); // 繧キ繝ァ繝・・繝・・繧ソ蜿門セ・ $shop_data = Ctrl_Db_Util::selectTableAssoc($shop_table, $shop_id); // 蜈ャ髢九ヵ繝ゥ繧ー繧貞愛螳壹@縺ヲ髱槫・髢九↑繧画カ亥悉縺励※邨ゆコ・ if ( isset($ctrl['target_form']['shop_info__open_stat']) and $ctrl['target_form']['shop_info__open_stat'] != 1) { // 豸亥悉 $sql = "DELETE FROM $info_table WHERE shop_id = " . Ctrl_Db_Util::sqlQuote( $shop_id ); Ctrl_Db_Controller::query($sql); return; } $info_title = ''; $news_title = ''; $link_url = ''; // 繧キ繝ァ繝・・逋サ骭イ譎・ if ($update_type == 1) { // shop_id縺後≠繧九°(蛻晏屓逋サ骭イ譎ゅ・縺ソ譛牙柑蛹・ $where = "shop_id = " . Ctrl_Db_Util::sqlQuote($shop_id); $count = Ctrl_Db_Util::countRows($info_table, $where); if ($count) { return; } // 繧ェ繝励す繝ァ繝ウ $info_title = __NEW_SHOP_COMMENT__( $ctrl['target_form']['shop_info__shop_name'] ); $news_title = __JOINED__; } // 譖エ譁ー譎・ elseif ($update_type == 2 or $update_type == 3) { // 繧ッ繝シ繝昴Φ縺ョ陦ィ遉コ險ュ螳壼愛螳・ if ( isset($ctrl['target_form']['shop_info__coupon_open_stat']) and $ctrl['target_form']['shop_info__coupon_open_stat'] == 1) { return; } // 荳€譌ヲ譖エ譁ー諠・ア繧呈カ亥悉 $sql = "DELETE FROM $info_table WHERE update_type = $update_type AND shop_id = " . Ctrl_Db_Util::sqlQuote( $shop_id ); Ctrl_Db_Controller::query($sql); // 蜈ャ髢九ヵ繝ゥ繧ー繧貞愛螳壹@縺ヲ髱槫・髢九↑繧峨%縺薙〒邨ゆコ・ /* if ($shop_data['open_stat'] != 1) { return; } */ // 繧ェ繝励す繝ァ繝ウ $info_title = $shop_data['shop_name']; if ( isset($ctrl['target_form']['shop_info__coupon_open_stat'])) { $news_title = __UPDATE_COUPON__; } if ( isset($ctrl['target_form']['animal__id'])) { if (( $ctrl['target_form']['animal__status'] == 4 ) or ( $ctrl['target_form']['animal__status'] == 7 )){ return; } $news_title = __UPDATE_ANIMAL__; $link_url = 'https://www.petstation.jp/animal_detail.php?animal__id=' . $ctrl['target_form']['animal__id']; } } $options = array(); // 繧ソ繧、繝繧ケ繧ソ繝ウ繝・ $options['ins_date'] = 'now()'; $options['upd_date'] = 'now()'; $options['title'] = $info_title; $options['disp_date'] = 'CURDATE()'; $options['parent_id'] = $shop_id ; $options['shop_id'] = $shop_id; $options['update_type'] = $update_type; $options['link_url'] = $link_url; // 迥ャ迪ォ繝輔Λ繧ー if ($shop_data['dog_flag']) { $options['dog_flag'] = '1'; } if ($shop_data['cat_flag']) { $options['cat_flag'] = '1'; } $options['search_word'] = $options['title']; // update_information $columns = array(); $values = array(); foreach ($options as $column => $value) { if (is_array($value)) { continue; } $value = Ctrl_Db_Util::sqlQuote( $value ); $columns[] = $column; $values[] = $value; } $columns = implode(", ", $columns); $values = implode(", ", $values); $sql = "INSERT INTO $info_table ($columns) values ($values)"; Ctrl_Db_Controller::query($sql); // 繧キ繝ァ繝・・縺ョ譖エ譁ー譎る俣繧呈峩譁ー (20150129013046) $sql = "UPDATE $shop_table SET upd_date = now() WHERE id = $shop_id"; Ctrl_Db_Controller::query($sql); // 蛻晏屓繝√ぉ繝・け if ($update_type == 1 and ($shop_data['ins_date'] != $shop_data['upd_date']) ) { return; } // 繝壹ャ繝育匳骭イ縺ェ繧我ク€譌ヲ蜑榊屓縺セ縺ァ繧呈カ医☆ if ($update_type == 2) { $sql = "DELETE FROM $news_table WHERE update_type = $update_type AND shop_id = " . Ctrl_Db_Util::sqlQuote( $shop_id ); Ctrl_Db_Controller::query($sql); } // shop_news縺ェ繧牙・逅・↑縺・ if ( isset($ctrl['target_form']['shop_news__id'])) { return; } $options['title'] = $news_title; $columns = array(); $values = array(); foreach ($options as $column => $value) { if (is_array($value)) { continue; } $value = Ctrl_Db_Util::sqlQuote( $value ); $columns[] = $column; $values[] = $value; } $columns = implode(", ", $columns); $values = implode(", ", $values); $sql = "INSERT INTO $news_table ($columns) values ($values)"; Ctrl_Db_Controller::query($sql); } //////////////////// 繧キ繝ァ繝・・縺ョ繝励Ξ繝溘い繝髢「騾」縺ョ蜃ヲ逅・//////////////////// function pp_shop_premium_process(&$ctrl) { // API逕ィ縺ョXML繧剃ス懊k pp_make_api_xml($ctrl); // 蜑企勁縺ェ繧牙・逅・↑縺・ if ( Ctrl_Form_Manager::isDeleteMode() ) { return; } $shop_id = $ctrl['target_form']['shop_info__id']; if ( isset($ctrl['target_form']['shop_info__premium_flag']) && $ctrl['target_form']['shop_info__premium_flag'] ) { return; } $select_table = Ctrl_Db_Util::makeTableFullName('shop_info'); // 繧キ繝ァ繝・・繝・・繧ソ蜿門セ・ $shop_data = Ctrl_Db_Util::selectTableAssoc($select_table, $shop_id); if ($shop_data['premium_flag'] === "1") { } else { if ($shop_data['page_color'] >= 6) { $sql = "UPDATE $select_table SET page_color = 1 WHERE id = $shop_id"; Ctrl_Db_Controller::query($sql); } if ($shop_data['frame_design'] >= 2) { $sql = "UPDATE $select_table SET frame_design = 1 WHERE id = $shop_id"; Ctrl_Db_Controller::query($sql); } /* * 蜆ェ蜈郁。ィ遉コ隗」髯、 */ $sql = "UPDATE st_tb_animal SET appeal_option_setting = 0, appeal_option_value = 0, appeal_reserve = 1, appeal_end_date = NULL, appeal_end_setting = 1, appeal_stop_flag = 0 WHERE parent_id = $shop_id"; Ctrl_Db_Controller::query($sql); $sql = "UPDATE st_tb_shop_info SET appeal_option_setting = 0, appeal_option_value = 0, appeal_reserve = 1, appeal_stop_flag = 0 WHERE id = $shop_id"; Ctrl_Db_Controller::query($sql); } } //////////////////// API逕ィ縺ョXML繧剃ス懊k //////////////////// function pp_make_api_xml(&$ctrl) { $keyArray = array('species', 'sex', 'pet_stat', 'price_range', 'species_out', 'area', 'prefecture'); $groupedKeyArray = array('variety' , 'hair_color'); pp_make_api_xml_function($ctrl, $keyArray, $groupedKeyArray, 'CommonList', 'common_list'); $keyArray = array('species', 'sex', 'pet_stat', 'prefecture'); $groupedKeyArray = array('variety' , 'hair_color'); pp_make_aipaw_api_function($ctrl, $keyArray, $groupedKeyArray, 'CommonList', 'common_list'); $keyArray = array('species', 'sex', 'pet_stat', 'price_range', 'species_out', 'area', 'prefecture', 'business_style'); $groupedKeyArray = array('variety' , 'hair_color'); pp_make_api_xml_function($ctrl, $keyArray, $groupedKeyArray, 'CommonList', 'common_list_mixi'); pp_make_redraw_flag($ctrl); } //////////////////// API逕ィ縺ョXML繧剃ス懊k髢「謨ー //////////////////// function pp_make_api_xml_function(&$ctrl, $keyArray, $groupedKeyArray, $tag_name, $file_name) { $content = << <{$tag_name}> EOM; foreach ($ctrl['group'] as $key => $group) { if (in_array($key, $groupedKeyArray)) { $content .= ' ' . "<{$key}>\n"; foreach ($group as $group_id => $items) { if (!empty($items)) { foreach ($items as $id => $word) { $content .= ' ' . '{$word}\n"; } } } $content .= ' ' . "\n"; } } foreach ($ctrl['options'] as $key => $items) { if (in_array($key, $keyArray)) { $content .= ' ' . "<{$key}>\n"; foreach ($items as $id => $word) { $content .= ' ' . '{$word}\n"; } $content .= ' ' . "\n"; } } $content .= << EOM; $current_filename = DIR_ROOT . 'www/petstation/public_html/api/' . $file_name . '.xml'; $temp_filename = DIR_ROOT . 'www/petstation/public_html/api/' . $file_name . '_temp.xml'; $date_filename = DIR_ROOT . 'www/petstation/public_html/api/' . $file_name . '_date.xml'; $fp = fopen($temp_filename, "ab+"); @flock($fp, LOCK_EX); ftruncate($fp, 0); fwrite($fp, $content); fclose($fp); if ( ! Ctrl_File_Util::compareFiles( $current_filename, $temp_filename ) ) { system("mv -f $temp_filename $current_filename"); $current_date = time(); $content = << <{$tag_name}> {$current_date} EOM; $fp = fopen($date_filename, "ab+"); @flock($fp, LOCK_EX); ftruncate($fp, 0); fwrite($fp, $content); fclose($fp); } } //////////////////// aipaw逕ィ縺ョjson繧剃ス懊k髢「謨ー //////////////////// function pp_make_aipaw_api_function(&$ctrl, $keyArray, $groupedKeyArray, $tag_name, $file_name) { $array = array(); $array[$tag_name] = array(); foreach ($ctrl['group'] as $key => $group) { if (in_array($key, $groupedKeyArray)) { $array[$tag_name][$key] = array(); foreach ($group as $group_id => $items) { if (!empty($items)) { foreach ($items as $id => $word) { $item = array(); $item['id'] = $id; $item['group_id'] = $group_id; $item['value'] = $word; $array[$tag_name][$key][] = $item; } } } } } foreach ($ctrl['options'] as $key => $items) { if (in_array($key, $keyArray)) { $array[$tag_name][$key] = array(); foreach ($items as $id => $word) { $item = array(); $item['id'] = $id; $item['group_id'] = 0; $item['value'] = $word; $array[$tag_name][$key][] = $item; } } } $dist_file_name = DIR_ROOT . 'www/petstation/public_html/aipaw_api/' . $file_name . '.data'; file_put_contents($dist_file_name, json_encode($array), LOCK_EX); } function pp_prepare_animal_data() { $registry = & SystemDataManager::$registry; if(isset($_GET['auction_animal__id'])) { $auctionId = intval($_GET['auction_animal__id']); $sql = "SELECT * FROM st_tb_auction_animal WHERE id = {$auctionId} AND bought_shop_id = {$registry['user_data']['id']}"; $data = Ctrl_Db_Util::fetchOneRowAssoc($sql); if (!empty($data)) { $registry['form']['animal__species'] = $data['species']; $registry['form']['animal__variety'] = $data['variety']; $registry['form']['animal__variety_other'] = $data['variety_other']; $registry['form']['animal__sex'] = $data['sex']; $registry['form']['animal__hair_color'] = $data['hair_color']; $registry['form']['animal__hair_color_other'] = $data['hair_color_other']; $birthDate = strtotime($data['birth_date']); $registry['form']['animal__birth_date'] = array(); $registry['form']['animal__birth_date']['Y'] = date('Y', $birthDate); $registry['form']['animal__birth_date']['m'] = date('m', $birthDate); $registry['form']['animal__birth_date']['d'] = date('d', $birthDate); $registry['form']['animal__pedigree'] = $data['pedigree']; $registry['form']['animal__vaccine'] = $data['vaccine']; $registry['form']['animal__birth_place'] = $data['birth_place']; $registry['form']['animal__image1'] = $data['image1']; $registry['form']['animal__image2'] = $data['image2']; $registry['form']['animal__image3'] = $data['image3']; $registry['form']['animal__image4'] = $data['image4']; $registry['form']['animal__image5'] = $data['image5']; $registry['form']['animal__image6'] = $data['image6']; $registry['form']['animal__mother_variety'] = $data['mother_variety']; $registry['form']['animal__father_variety'] = $data['father_variety']; $registry['form']['animal__mother_variety_other'] = $data['mother_variety_other']; $registry['form']['animal__father_variety_other'] = $data['father_variety_other']; } } } //////////////////// 繝壹ャ繝医・荳ヲ縺ウ鬆・r隱ソ謨エ //////////////////// function pp_check_animal_order(&$ctrl) { if ( isset($ctrl['add_on']['making_item']['animal__side']) ) { if ( isset($ctrl['target_form']['animal__id']) ) { $animalId = intval($ctrl['target_form']['animal__id']); $sql = "SELECT count(st_tb_shop_info.id) FROM st_tb_shop_info LEFT JOIN st_tb_animal ON st_tb_shop_info.id = st_tb_animal.parent_id " . "WHERE st_tb_animal.id = $animalId AND st_tb_shop_info.animal_order IS NOT NULL and st_tb_shop_info.animal_order >= 2"; $count = intval(Ctrl_Db_Util::fetchOneValue($sql)); if ($count) { $ctrl['items_order_by']['animal__side'] = array('FIELD([[animal]].status, 3, 6, 2, 1) DESC, [[animal]].id DESC'); } else { $ctrl['items_order_by']['animal__side'] = array('FIELD([[animal]].status, 3, 6, 2, 1) DESC'); } } } else if ( isset($ctrl['add_on']['making_item']['animal']) ) { if ( isset($ctrl['target_form']['shop_info__id']) ) { $shopId = intval($ctrl['target_form']['shop_info__id']); $sql = "SELECT count(id) FROM st_tb_shop_info WHERE id = $shopId AND animal_order IS NOT NULL and animal_order >= 2"; $count = intval(Ctrl_Db_Util::fetchOneValue($sql)); if ($count) { $ctrl['items_order_by']['animal'] = array('FIELD([[animal]].status, 3, 6, 2, 1) DESC, [[animal]].id DESC'); } else { $ctrl['items_order_by']['animal'] = array('FIELD([[animal]].status, 3, 6, 2, 1) DESC'); } } } } //////////////////// 繝・Φ繝励Ξ繝シ繝亥・繧頑崛縺医r隱ソ謨エ //////////////////// function pp_check_template_switch() { $ctrl = & SystemDataManager::$registry; if ( !empty($ctrl['target_form']['shop_info__id'])) { $shopId = intval($ctrl['target_form']['shop_info__id']); $sql = "SELECT st_tb_shop_info.page_color FROM st_tb_shop_info WHERE id = $shopId"; } else if ( !empty($ctrl['target_form']['animal__id'])) { $animalId = intval($ctrl['target_form']['animal__id']); $sql = "SELECT st_tb_shop_info.page_color FROM st_tb_shop_info LEFT JOIN st_tb_animal ON st_tb_shop_info.id = st_tb_animal.parent_id " . "WHERE st_tb_animal.id = $animalId"; } else if ( !empty($ctrl['target_form']['shop_diary__id'])) { $diaryId = intval($ctrl['target_form']['shop_diary__id']); $sql = "SELECT st_tb_shop_info.page_color FROM st_tb_shop_info LEFT JOIN st_tb_shop_diary ON st_tb_shop_info.id = st_tb_shop_diary.parent_id " . "WHERE st_tb_shop_diary.id = $diaryId"; } else { return; } $color = intval(Ctrl_Db_Util::fetchOneValue($sql)); if ($color >= 6) { $template = $ctrl['template']; if (! preg_match('/print/', $template)) { $template = preg_replace('/\.html/', '_temp01.html', $template); $ctrl['switch_template'] = $template; } } } //////////////////// 繧キ繝ァ繝・・縺瑚ヲ九▽縺九i縺ェ縺・エ蜷・//////////////////// function pp_shop_not_found() { $registry = & SystemDataManager::$registry; $id = intval($registry['form']['shop_info__id']); if ($id > 0) { $sql = "SELECT count(id) FROM st_tb_shop_info WHERE id = $id"; $value = Ctrl_Db_Util::fetchOneValue($sql); if ($value) { $registry['lost_template'] = 'hide_page.html'; } } } //////////////////// 繝壹ャ繝域峩譁ー逶エ蜑榊・逅・//////////////////// function pp_animal_pre_entry() { $registry = & SystemDataManager::$registry; if ($registry['newly_insert_flag']) { return; } if (!isset($registry['form']['animal__birth_date'])) { return; } $birthDate = ''; $id = isset($registry['form']['animal__id']) ? intval($registry['form']['animal__id']) : 0; if ($id > 0) { $sql = "SELECT birth_date FROM st_tb_animal WHERE id = $id"; $value = Ctrl_Db_Util::fetchOneValue($sql); if ($value) { $dateArray = explode(' ', $value); $birthDate = strtotime($dateArray[0]); } else { return; } } $newBirthDate = strtotime($registry['form']['animal__birth_date']['Y'] . '-' . $registry['form']['animal__birth_date']['m'] . '-' . $registry['form']['animal__birth_date']['d']); if ($newBirthDate != $birthDate) { $sql = "UPDATE st_sys_count SET num = 0 WHERE table_id = 2 AND entry_id = {$id}"; Ctrl_Db_Controller::query($sql); } } //////////////////// 閾ェ荳サ轤ケ讀懆ェソ謨エ //////////////////// function pp_self_check_entry(&$ctrl) { $shop_id = $ctrl['target_form']['shop_info__id']; $self_check_id = $ctrl['target_form']['self_check__id']; $no_count = 0; $shop_id = $ctrl['target_form']['shop_info__id']; for ($i = 1; $i <= 19; $i++) { $value = intval($ctrl['target_form']['self_check__point' . $i]); if ($value == 0) { $no_count++; } } $sql = "UPDATE st_tb_self_check SET no_check_num = {$no_count} WHERE id = {$self_check_id}"; Ctrl_Db_Controller::query($sql); } //////////////////// 螳壽悄蝣ア蜻頑嶌荳€隕ァ陦ィ遉コ //////////////////// function pp_view_annual_report_list() { } //////////////////// 萓。譬シ譁・ュ怜・霑ス蜉 //////////////////// function pp_add_price_str(&$ctrl, &$row_temp, $list_temp) { // 萓。譬シ縺ォ縺、縺・※ $price = $row_temp['animal__price']; $status = $list_temp['status']; $ask_flag = $list_temp['price_ask_flag']; $tax_flag = $list_temp['without_tax']; $price_str = $price . '蜀・; if ($status == 3) { $price_str = '螢イ邏・ク医∩'; } else if ($status == 2) { $price_str = '蝠・ォ・クュ'; } else if ($status == 6) { $price_str = '貅門y荳ュ'; } else if ($ask_flag) { $price_str = '縺雁撫縺・粋繧上○縺上□縺輔>'; } else if ($tax_flag == 1) { $price_str .= '(遞手セシ)'; } else if ($tax_flag == 2) { $price_str .= '(遞取栢)'; } $row_temp['animal__price_str'] = $price_str; // 遞ョ鬘槭↓縺、縺・※ $variety = $row_temp['animal__variety']; $variety_other = $row_temp['animal__variety_other']; $variety_str = $variety; if ($variety_other != '') { if ($variety != '') { $variety_str .= ' '; } $variety_str .= $variety_other; } $row_temp['animal__variety_str'] = $variety_str; // 豈阪・遞ョ鬘槭↓縺、縺・※ $variety = $row_temp['animal__mother_variety']; $variety_other = $row_temp['animal__mother_variety_other']; $variety_str = $variety; if ($variety_other != '') { if ($variety != '') { $variety_str .= ' '; } $variety_str .= $variety_other; } $row_temp['animal__mother_variety_str'] = $variety_str; // 辷カ縺ョ遞ョ鬘槭↓縺、縺・※ $variety = $row_temp['animal__father_variety']; $variety_other = $row_temp['animal__father_variety_other']; $variety_str = $variety; if ($variety_other != '') { if ($variety != '') { $variety_str .= ' '; } $variety_str .= $variety_other; } $row_temp['animal__father_variety_str'] = $variety_str; // 豈幄牡縺ォ縺、縺・※ $hair_color = $row_temp['animal__hair_color']; $hair_color_other = $row_temp['animal__hair_color_other']; $hair_color_str = $hair_color; if ($hair_color_other != '') { if ($hair_color != '') { $hair_color_str .= ' '; } $hair_color_str .= $hair_color_other; } $row_temp['animal__hair_color_str'] = $hair_color_str; } //////////////////// 繝壹ャ繝医♀蝠上>蜷医o縺帶凾 //////////////////// function pp_animal_mail(&$ctrl) { $registry = & SystemDataManager::$registry; if (isset($registry['detail']['animal']['animal__species_raw']) and $registry['detail']['animal']['animal__species_raw'] == '1') { $registry['mail_setting2']['message'] = preg_replace("/==for dog\r?\n(.+?)==/s", '$1', $registry['mail_setting2']['message']); } else { $registry['mail_setting2']['message'] = preg_replace("/==for dog\r?\n(.+?)==/s", '', $registry['mail_setting2']['message']); } } //////////////////// 蜍慕黄蜿匁桶讌ュ縺ョ隴ヲ蜻翫・繝シ繧ク繧定。ィ遉コ縺吶k //////////////////// function pp_show_register_attention() { $registry = & SystemDataManager::$registry; //var_dump($registry['user_data']); if ( ($registry['user_data']['shop_reg_name'] == '') or ($registry['user_data']['shop_reg_place'] == '') or ($registry['user_data']['shop_reg_num'] == '') or ($registry['user_data']['shop_reg_rep'] == '') ) { /* if (empty($_COOKIE['register_attention'])) { $registry['template'] = 'pp_register_attention.tmpl'; setcookie('register_attention', 'check', 0, '/'); } */ } } //////////////////// 繧ュ繝・繝ャ繝シ繧キ繝ァ繝ウ逕ィ繝槭う繝壹ャ繝医ョ繝シ繧ソ蜿門セ・//////////////////// function pp_make_curation_mypet_data() { $ctrl = & SystemDataManager::$registry; $articleData = null; $commentData = null; $authorData = null; $animalData = null; if (!empty($ctrl['detail']['curation_news']['curation_news__mp_article_id'])) { $articleId = intval($ctrl['detail']['curation_news']['curation_news__mp_article_id']); $path = DIR_ROOT . 'www/curation/data/article/' . strval($articleId); if (file_exists($path)) { $articleData = unserialize(file_get_contents($path)); } $path = DIR_ROOT . 'www/curation/data/comment/' . strval($articleId); if (file_exists($path)) { $commentData = unserialize(file_get_contents($path)); } } else { exit; } if (!empty($ctrl['detail']['curation_news']['curation_news__mp_owner_id'])) { $authorId = $ctrl['detail']['curation_news']['curation_news__mp_owner_id']; $path = DIR_ROOT . 'www/curation/data/author/' . strval($authorId); if (file_exists($path)) { $authorData = unserialize(file_get_contents($path)); } } else { exit; } if (!empty($ctrl['detail']['curation_news']['curation_news__mp_animal_id'])) { $animalId = $ctrl['detail']['curation_news']['curation_news__mp_animal_id']; $path = DIR_ROOT . 'www/curation/data/animal/' . strval($animalId); if (file_exists($path)) { $animalData = unserialize(file_get_contents($path)); } } else { exit; } $ctrl['smarty_vars']['article'] = $articleData; $ctrl['smarty_vars']['comment'] = $commentData; $ctrl['smarty_vars']['author'] = $authorData; $ctrl['smarty_vars']['animal'] = $animalData; } // 繝・せ繝医し繧、繝育畑縺ォ逕サ蜒上r謖√▲縺ヲ縺上k function pp_get_server_image($path) { if (! preg_match('/file\/[\/_a-z0-9.]+\.jpg$/', $path)) { return; } if ( preg_match('/(file\/.+\/)([^\/]+\.jpg)/', $path, $matches)) { $filePath = $matches[0]; $dir = $matches[1]; $dir = preg_replace('/\/$/', '', $dir); $dirArray = explode('/', $dir); $tempDir = DIR_ROOT . 'www/petstation/public_html/petpro/' . array_shift($dirArray); foreach($dirArray as $dirName) { $tempDir .= '/' . $dirName; if (! file_exists($tempDir)) { mkdir($tempDir); } } $url = 'https://petstation.jp/petpro/' . $filePath; $image = file_get_contents($url); if (! $image) { return; } file_put_contents(DIR_ROOT . 'www/petstation/public_html/petpro/' . $filePath, $image); //error_log( date('Y-m-d-H:i:s') . ' ' . print_r($filePath, true) . "\n", 3, DIR_ROOT . "script/log.txt"); } } function pp_prepare_for_list_form() { $ctrl = & SystemDataManager::$registry; $speciesId = isset($ctrl['form']["_search_animal__animal_search__species"]) ? intval($ctrl['form']["_search_animal__animal_search__species"]) : 0; $varietyId = isset($ctrl['form']["_search_animal__animal_search__variety"]) ? intval($ctrl['form']["_search_animal__animal_search__variety"]) : 0; if (!empty($varietyId) && empty($speciesId)) { $sql = "SELECT group_id FROM st_ls_variety WHERE id = {$varietyId}"; $speciesId = intval(Ctrl_Db_Util::fetchOneValue($sql)); $ctrl['form']["_search_animal__animal_search__species"] = $speciesId; } } function pp_make_variety_data(&$ctrl) { $speciesId = isset($ctrl['target_form']["animal__animal_search__species"]) ? intval($ctrl['target_form']["animal__animal_search__species"]) : 0; $varietyId = 0; if (isset($ctrl['target_form']["animal__animal_search__variety"])) { $varietyForm = $ctrl['target_form']["animal__animal_search__variety"]; if (is_array($varietyForm)) { if (!empty($varietyForm)) { $filteredArray = array_filter($varietyForm, function($value) { return !empty($value); }); $count = count($filteredArray); if ($count === 1) { $varietyId = array_keys($filteredArray)[0]; } } } else { $varietyId = $varietyForm; } } $regionId = 0; if (isset($ctrl['target_form']["shop_info__animal_search__shop_address2"])) { $regionForm = $_REQUEST['_search_shop_info__animal_search__shop_address2']; if (is_array($regionForm)) { if (!empty($regionForm)) { $filteredArray = array_filter($regionForm, function($value) { return !empty($value); }); $count = count($filteredArray); if ($count === 1) { $regionId = array_keys($filteredArray)[0]; } } } else { $regionId = $regionForm; } } $species = ''; $variety = ''; $region = ''; if (!empty($varietyId) && empty($speciesId)) { $sql = "SELECT group_id FROM st_ls_variety WHERE id = {$varietyId}"; $speciesId = intval(Ctrl_Db_Util::fetchOneValue($sql)); } if (!empty($speciesId) ) { if ($speciesId === 1 or $speciesId === 2) { if ($speciesId === 1) { $species = '蟄千堪'; } else if ($speciesId === 2) { $species = '蟄千賢'; } if (!empty($ctrl['options']['variety'][$varietyId])) { $variety = $ctrl['options']['variety'][$varietyId]; } } else { $species = $ctrl['options']['species'][$speciesId]; } } $ctrl['smarty_vars']['variety'] = $variety; $ctrl['smarty_vars']['species'] = $species; if (!empty($regionId)) { $region = preg_replace('/笏」/', '', $ctrl['options']['prefecture'][$regionId]); $region = preg_replace('/笏・', '', $region); $region .= '縺ョ'; } $ctrl['smarty_vars']['region'] = $region; pp_breed_area($ctrl, $speciesId, $varietyId); } function pp_make_shop_data(&$ctrl) { $region = ''; $regionId = isset($ctrl['target_form']["shop_info__shop_address2"]) && !is_array($ctrl['target_form']["shop_info__shop_address2"]) ? intval($ctrl['target_form']["shop_info__shop_address2"]) : 0; if (!empty($regionId) && !is_array($regionId)) { $region = preg_replace('/笏」/', '', $ctrl['options']['prefecture'][$regionId]); $region = preg_replace('/笏・', '', $region); $region .= '縺ョ'; } $ctrl['smarty_vars']['region'] = $region; } function pp_petpro_login(&$ctrl, $row) { if ($row['hq_flag'] === '1') { $ctrl['result_forward'] = 'central/'; } } function pp_check_login_status($result) { $ctrl = & SystemDataManager::$registry; $ctrl['smarty_vars']['env_type'] = ENV_TYPE; $plan = 1; $isShop = false; if (is_array($ctrl['user_data'])){ if (array_key_exists('plan_raw', $ctrl['user_data'])) { if (intval($ctrl['user_data']['plan_raw']) === 2) { $plan = 2; } } else { $isShop = true; if (isset($ctrl['user_data']['premium_flag']) && $ctrl['user_data']['premium_flag'] === '1') { $plan = 2; } } } $ctrl['smarty_vars']['my_page_enabled'] = USER_MY_PAGE_ENABLED; $ctrl['smarty_vars']['plan'] = $plan; $ctrl['smarty_vars']['is_shop'] = $isShop; $isLoginStr = !empty($ctrl['user_data']) ? '1' : '0'; $isShopStr = $isShop ? '1' : '0'; $ctrl['cache_id'] = $ctrl['cache_id'] . ENV_TYPE . $isLoginStr . $isShopStr . strval($plan); }