1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2007 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | //----- インクルードテンプレートの出力をfetch |
---|
8 | |
---|
9 | /** |
---|
10 | * inc_navi.tpl の出力を返す |
---|
11 | * |
---|
12 | * $type が f または c の場合には、$target_id を指定する必要があります。 |
---|
13 | * |
---|
14 | * @param enum('h', 'f', 'c') $type : ナビゲーションのタイプ |
---|
15 | * @param int $target_id : 友達のメンバーID もしくは コミュニティID |
---|
16 | * @return html |
---|
17 | */ |
---|
18 | function fetch_inc_navi($type, $target_id = null) |
---|
19 | { |
---|
20 | // $type が h の場合のみ function cache |
---|
21 | if ($type == 'h') { |
---|
22 | static $is_recurred = false; //再帰処理中かどうかの判定フラグ |
---|
23 | |
---|
24 | if (!$is_recurred) { //function cacheのために再帰処理を行う |
---|
25 | $is_recurred = true; |
---|
26 | $funcargs = func_get_args(); |
---|
27 | return pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_LONG, __FUNCTION__, $funcargs); |
---|
28 | } |
---|
29 | |
---|
30 | $is_recurred = false; |
---|
31 | } |
---|
32 | |
---|
33 | $inc_smarty = new OpenPNE_Smarty($GLOBALS['SMARTY']); |
---|
34 | $inc_smarty->templates_dir = 'pc/templates'; |
---|
35 | $inc_smarty->assign('PHPSESSID', md5(session_id())); |
---|
36 | |
---|
37 | switch ($type) { |
---|
38 | case 'h': |
---|
39 | default: |
---|
40 | $type = 'h'; |
---|
41 | break; |
---|
42 | case 'f': |
---|
43 | $inc_smarty->assign('INC_NAVI_c_member_id_friend', $target_id); |
---|
44 | break; |
---|
45 | case 'c': |
---|
46 | $inc_smarty->assign('INC_NAVI_c_commu_id', $target_id); |
---|
47 | break; |
---|
48 | } |
---|
49 | $inc_smarty->assign('INC_NAVI_type', $type); |
---|
50 | $inc_smarty->assign('navi', util_get_c_navi($type)); |
---|
51 | |
---|
52 | $inc_smarty->assign('WORD_FRIEND', WORD_FRIEND); |
---|
53 | $inc_smarty->assign('WORD_MY_FRIEND', WORD_MY_FRIEND); |
---|
54 | $inc_smarty->assign('WORD_FRIEND_HALF', WORD_FRIEND_HALF); |
---|
55 | $inc_smarty->assign('WORD_MY_FRIEND_HALF', WORD_MY_FRIEND_HALF); |
---|
56 | |
---|
57 | return $inc_smarty->ext_fetch('inc_navi.tpl'); |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * inc_html_header.tpl |
---|
62 | */ |
---|
63 | function fetch_inc_html_header() |
---|
64 | { |
---|
65 | $inc_smarty = new OpenPNE_Smarty($GLOBALS['SMARTY']); |
---|
66 | $inc_smarty->templates_dir = 'pc/templates'; |
---|
67 | |
---|
68 | if (SNS_TITLE) { |
---|
69 | $inc_smarty->assign('title', SNS_TITLE); |
---|
70 | } else { |
---|
71 | $inc_smarty->assign('title', SNS_NAME); |
---|
72 | } |
---|
73 | |
---|
74 | $inc_smarty->assign('inc_html_head', p_common_c_siteadmin4target_pagename('inc_html_head')); |
---|
75 | $inc_smarty->assign('inc_custom_css', p_common_c_siteadmin4target_pagename('inc_custom_css')); |
---|
76 | |
---|
77 | $c_sns_config = db_select_c_sns_config(); |
---|
78 | $inc_smarty->assign('border_00', $c_sns_config['border_00']); |
---|
79 | $inc_smarty->assign('border_01', $c_sns_config['border_01']); |
---|
80 | $inc_smarty->assign('border_02', $c_sns_config['border_02']); |
---|
81 | $inc_smarty->assign('border_03', $c_sns_config['border_03']); |
---|
82 | $inc_smarty->assign('border_04', $c_sns_config['border_04']); |
---|
83 | $inc_smarty->assign('border_05', $c_sns_config['border_05']); |
---|
84 | $inc_smarty->assign('border_06', $c_sns_config['border_06']); |
---|
85 | $inc_smarty->assign('border_07', $c_sns_config['border_07']); |
---|
86 | $inc_smarty->assign('border_08', $c_sns_config['border_08']); |
---|
87 | $inc_smarty->assign('border_09', $c_sns_config['border_09']); |
---|
88 | $inc_smarty->assign('border_10', $c_sns_config['border_10']); |
---|
89 | |
---|
90 | $inc_smarty->assign('bg_00', $c_sns_config['bg_00']); |
---|
91 | $inc_smarty->assign('bg_01', $c_sns_config['bg_01']); |
---|
92 | $inc_smarty->assign('bg_02', $c_sns_config['bg_02']); |
---|
93 | $inc_smarty->assign('bg_03', $c_sns_config['bg_03']); |
---|
94 | $inc_smarty->assign('bg_04', $c_sns_config['bg_04']); |
---|
95 | $inc_smarty->assign('bg_05', $c_sns_config['bg_05']); |
---|
96 | $inc_smarty->assign('bg_06', $c_sns_config['bg_06']); |
---|
97 | $inc_smarty->assign('bg_07', $c_sns_config['bg_07']); |
---|
98 | $inc_smarty->assign('bg_08', $c_sns_config['bg_08']); |
---|
99 | $inc_smarty->assign('bg_09', $c_sns_config['bg_09']); |
---|
100 | $inc_smarty->assign('bg_10', $c_sns_config['bg_10']); |
---|
101 | $inc_smarty->assign('bg_11', $c_sns_config['bg_11']); |
---|
102 | $inc_smarty->assign('bg_12', $c_sns_config['bg_12']); |
---|
103 | $inc_smarty->assign('bg_13', $c_sns_config['bg_13']); |
---|
104 | |
---|
105 | return $inc_smarty->ext_fetch('inc_html_header.tpl'); |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | * inc_page_header.tpl |
---|
110 | */ |
---|
111 | function fetch_inc_page_header($type = null) |
---|
112 | { |
---|
113 | $inc_smarty = new OpenPNE_Smarty($GLOBALS['SMARTY']); |
---|
114 | $inc_smarty->templates_dir = 'pc/templates'; |
---|
115 | |
---|
116 | $v['PHPSESSID'] = md5(session_id()); |
---|
117 | $v['INC_PAGE_HEADER_type'] = $type; |
---|
118 | if ($type == 'public' || $type == 'regist') { |
---|
119 | $v['before_after'] = 'before'; |
---|
120 | $v['INC_PAGE_HEADER'] = db_banner_get_top_banner(false); |
---|
121 | } else { |
---|
122 | $v['before_after'] = 'after'; |
---|
123 | $v['INC_PAGE_HEADER'] = db_banner_get_top_banner(true); |
---|
124 | } |
---|
125 | $v['top_banner_html_before'] = p_common_c_siteadmin4target_pagename('top_banner_html_before'); |
---|
126 | $v['top_banner_html_after'] = p_common_c_siteadmin4target_pagename('top_banner_html_after'); |
---|
127 | $inc_smarty->assign('navi', util_get_c_navi('global')); |
---|
128 | |
---|
129 | $inc_smarty->assign($v); |
---|
130 | return $inc_smarty->ext_fetch('inc_page_header.tpl'); |
---|
131 | } |
---|
132 | |
---|
133 | /** |
---|
134 | * inc_page_footer.tpl |
---|
135 | */ |
---|
136 | function fetch_inc_page_footer($is_secure = false) |
---|
137 | { |
---|
138 | $inc_smarty = new OpenPNE_Smarty($GLOBALS['SMARTY']); |
---|
139 | $inc_smarty->templates_dir = 'pc/templates'; |
---|
140 | |
---|
141 | $inc_smarty->assign('PHPSESSID', md5(session_id())); |
---|
142 | if ($is_secure) { |
---|
143 | $inc_smarty->assign('inc_page_footer', |
---|
144 | p_common_c_siteadmin4target_pagename('inc_page_footer_after')); |
---|
145 | } else { |
---|
146 | $inc_smarty->assign('inc_page_footer', |
---|
147 | p_common_c_siteadmin4target_pagename('inc_page_footer_before')); |
---|
148 | } |
---|
149 | |
---|
150 | return $inc_smarty->ext_fetch('inc_page_footer.tpl'); |
---|
151 | } |
---|
152 | |
---|
153 | function fetch_from_db($tpl_name, &$smarty) |
---|
154 | { |
---|
155 | $content = ''; |
---|
156 | if ($smarty->template_exists($tpl_name)) { |
---|
157 | $security = $smarty->security; |
---|
158 | $smarty->security = true; |
---|
159 | $content = $smarty->fetch($tpl_name); |
---|
160 | $smarty->security = $security; |
---|
161 | } |
---|
162 | return $content; |
---|
163 | } |
---|
164 | |
---|
165 | function fetch_inc_entry_point(&$smarty, $target) |
---|
166 | { |
---|
167 | $list = get_inc_entry_point_list(); |
---|
168 | if (empty($list[$target])) { |
---|
169 | return false; |
---|
170 | } |
---|
171 | list($start, $end, $caption) = $list[$target]; |
---|
172 | |
---|
173 | $contents = array(); |
---|
174 | for ($i = (int)$start; $i <= (int)$end; $i++) { |
---|
175 | $tpl = sprintf('db:inc_entry_point_%s_%d', $target, $i); |
---|
176 | $contents[$i] = fetch_from_db($tpl, $smarty); |
---|
177 | } |
---|
178 | return $contents; |
---|
179 | } |
---|
180 | |
---|
181 | function get_inc_entry_point_list() |
---|
182 | { |
---|
183 | $list = array( |
---|
184 | 'h_home' => array(1, 12, '【PC版】 h_home'), |
---|
185 | 'f_home' => array(1, 9, '【PC版】 f_home (h_prof)'), |
---|
186 | 'c_home' => array(1, 7, '【PC版】 c_home'), |
---|
187 | 'h_reply_message' => array(1, 3, '【PC版】 h_reply_message'), |
---|
188 | 'h_diary_add' => array(1, 3, '【PC版】 h_diary_add'), |
---|
189 | 'h_diary_edit' => array(1, 3, '【PC版】 h_diary_edit'), |
---|
190 | 'ktai_o_login' => array(1, 2, '【携帯版】 o_login'), |
---|
191 | 'ktai_h_home' => array(1, 3, '【携帯版】 h_home'), |
---|
192 | 'ktai_f_home' => array(1, 3, '【携帯版】 f_home'), |
---|
193 | 'ktai_c_home' => array(1, 3, '【携帯版】 c_home'), |
---|
194 | ); |
---|
195 | return $list; |
---|
196 | } |
---|
197 | |
---|
198 | //------------ |
---|
199 | |
---|
200 | function get_int_assoc($from, $to) |
---|
201 | { |
---|
202 | $from = intval($from); |
---|
203 | $to = intval($to); |
---|
204 | if ($from > $to) return array(); |
---|
205 | |
---|
206 | for ($i = $from; $i <= $to; $i++) { |
---|
207 | $assoc[$i] = $i; |
---|
208 | } |
---|
209 | return $assoc; |
---|
210 | } |
---|
211 | |
---|
212 | /** 月リスト */ |
---|
213 | function p_regist_prof_c_profile_month_list4null() |
---|
214 | { |
---|
215 | return get_int_assoc(1, 12); |
---|
216 | } |
---|
217 | |
---|
218 | /** 日リスト */ |
---|
219 | function p_regist_prof_c_profile_day_list4null() |
---|
220 | { |
---|
221 | return get_int_assoc(1, 31); |
---|
222 | } |
---|
223 | |
---|
224 | //------------ |
---|
225 | |
---|
226 | function p_c_event_add_confirm_event4request($get_errors = false) |
---|
227 | { |
---|
228 | $rule = array( |
---|
229 | 'target_c_commu_id' => array( |
---|
230 | 'type' => 'int', |
---|
231 | 'default' => '', |
---|
232 | ), |
---|
233 | 'title' => array( |
---|
234 | 'type' => 'string', |
---|
235 | 'required' => '1', |
---|
236 | 'caption' => 'タイトル', |
---|
237 | ), |
---|
238 | 'open_date_year' => array( |
---|
239 | 'type' => 'int', |
---|
240 | 'default' => '', |
---|
241 | ), |
---|
242 | 'open_date_month' => array( |
---|
243 | 'type' => 'int', |
---|
244 | 'default' => '', |
---|
245 | ), |
---|
246 | 'open_date_day' => array( |
---|
247 | 'type' => 'int', |
---|
248 | 'default' => '', |
---|
249 | ), |
---|
250 | 'open_date_comment' => array( |
---|
251 | 'type' => 'string', |
---|
252 | 'default' => '', |
---|
253 | ), |
---|
254 | 'open_pref_id' => array( |
---|
255 | 'type' => 'int', |
---|
256 | 'default' => '', |
---|
257 | ), |
---|
258 | 'open_pref_comment' => array( |
---|
259 | 'type' => 'string', |
---|
260 | 'default' => '', |
---|
261 | ), |
---|
262 | 'detail' => array( |
---|
263 | 'type' => 'string', |
---|
264 | 'required' => '1', |
---|
265 | 'caption' => '詳細', |
---|
266 | ), |
---|
267 | 'invite_period_year' => array( |
---|
268 | 'type' => 'int', |
---|
269 | 'default' => '', |
---|
270 | ), |
---|
271 | 'invite_period_month' => array( |
---|
272 | 'type' => 'int', |
---|
273 | 'default' => '', |
---|
274 | ), |
---|
275 | 'invite_period_day' => array( |
---|
276 | 'type' => 'int', |
---|
277 | 'default' => '', |
---|
278 | ), |
---|
279 | 'image_filename1' => array( |
---|
280 | 'type' => 'string', |
---|
281 | 'default' => '', |
---|
282 | ), |
---|
283 | 'image_filename2' => array( |
---|
284 | 'type' => 'string', |
---|
285 | 'default' => '', |
---|
286 | ), |
---|
287 | 'image_filename3' => array( |
---|
288 | 'type' => 'string', |
---|
289 | 'default' => '', |
---|
290 | ), |
---|
291 | 'capacity' => array( |
---|
292 | 'type' => 'int', |
---|
293 | 'default' => '0', |
---|
294 | 'min' => '0', |
---|
295 | 'caption' => '募集人数', |
---|
296 | ), |
---|
297 | ); |
---|
298 | $validator = new OpenPNE_Validator($rule, $_REQUEST); |
---|
299 | |
---|
300 | $errors = array(); |
---|
301 | if (!$validator->validate()) { |
---|
302 | |
---|
303 | $errors = $validator->getErrors(); |
---|
304 | } |
---|
305 | $result = $validator->getParams(); |
---|
306 | $result['c_commu_id'] = $result['target_c_commu_id']; |
---|
307 | |
---|
308 | if ($get_errors) { |
---|
309 | return array($result, $errors); |
---|
310 | } else { |
---|
311 | return $result; |
---|
312 | } |
---|
313 | } |
---|
314 | |
---|
315 | function p_f_home_last_login4access_date($access_date) |
---|
316 | { |
---|
317 | if (!$access_date || $access_date == '0000-00-00 00:00:00') { |
---|
318 | return '未ログイン'; |
---|
319 | } |
---|
320 | |
---|
321 | $diff = time() - strtotime($access_date); |
---|
322 | |
---|
323 | $m_diff = ceil($diff / 60); //時間差:分 |
---|
324 | $h_diff = ceil($diff / (60*60)); //時間差:時 |
---|
325 | $d_diff = ceil($diff / (60*60*24)); //時間差:日 |
---|
326 | |
---|
327 | if ($m_diff <= 60) { // 1時間以内 |
---|
328 | if ($m_diff<= 3) { |
---|
329 | $last_login = '3分以内'; |
---|
330 | } elseif ($m_diff <= 5) { |
---|
331 | $last_login = '5分以内'; |
---|
332 | } elseif ($m_diff <= 10) { |
---|
333 | $last_login = '10分以内'; |
---|
334 | } elseif ($m_diff <= 15) { |
---|
335 | $last_login = '15分以内'; |
---|
336 | } elseif ($m_diff <= 30) { |
---|
337 | $last_login = '30分以内'; |
---|
338 | } elseif ($m_diff <= 45) { |
---|
339 | $last_login = '45分以内'; |
---|
340 | } else { |
---|
341 | $last_login = '60分以内'; |
---|
342 | } |
---|
343 | } elseif ($h_diff <= 24) { |
---|
344 | $last_login = $h_diff . '時間以内'; |
---|
345 | } elseif ($d_diff <= 3) { |
---|
346 | $last_login = $d_diff . '日以内'; |
---|
347 | } else { |
---|
348 | $last_login = '3日以上'; |
---|
349 | } |
---|
350 | |
---|
351 | return $last_login; |
---|
352 | } |
---|
353 | |
---|
354 | /** |
---|
355 | * ある日まであと何日かを計算する |
---|
356 | * |
---|
357 | * @param int $month |
---|
358 | * @param int $day |
---|
359 | * @return int 日数 |
---|
360 | */ |
---|
361 | function getCountdownDays($month, $day) |
---|
362 | { |
---|
363 | $year = date('Y'); |
---|
364 | |
---|
365 | // 今日の00:00:00 |
---|
366 | $today = mktime(0, 0, 0); |
---|
367 | |
---|
368 | $theday_thisyear = mktime(0, 0, 0, $month, $day, $year); |
---|
369 | $theday_nextyear = mktime(0, 0, 0, $month, $day, $year + 1); |
---|
370 | |
---|
371 | if ($theday_thisyear < $today) { |
---|
372 | $theday_next = $theday_nextyear; |
---|
373 | } else { |
---|
374 | $theday_next = $theday_thisyear; |
---|
375 | } |
---|
376 | |
---|
377 | // 24 * 60 * 60 = 86400 |
---|
378 | return ($theday_next - $today) / 86400; |
---|
379 | } |
---|
380 | |
---|
381 | /** |
---|
382 | * 生年月日から年齢を計算する |
---|
383 | */ |
---|
384 | function getAge($year, $month, $day) |
---|
385 | { |
---|
386 | $this_year = intval(date('Y')); |
---|
387 | $today = intval(date('nd')); |
---|
388 | |
---|
389 | $age = $this_year - $year; |
---|
390 | if ($today < $month * 100 + $day) $age--; |
---|
391 | |
---|
392 | return $age; |
---|
393 | } |
---|
394 | |
---|
395 | /** |
---|
396 | * 引用符を付ける |
---|
397 | */ |
---|
398 | function message_body2inyou($string) |
---|
399 | { |
---|
400 | if (!empty($string)) { |
---|
401 | //返信用に引用符をつける |
---|
402 | $string = '> '.$string; |
---|
403 | $string = str_replace("\r\n", "\n", $string); |
---|
404 | $string = str_replace("\r", "\n", $string); |
---|
405 | $string = str_replace("\n", "\n> ", $string); |
---|
406 | } |
---|
407 | return $string; |
---|
408 | } |
---|
409 | |
---|
410 | ?> |
---|