OSDN Git Service

0c89daeb3e42f6cd287e58c8a80383d545a0c2a6
[fswiki/fswiki.git] / docs / API / Util.pm.html
1 <html>
2 <head>
3 <title>Module Reference</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
5 <link rel="stylesheet" type="text/css" href="../default.css">
6 </head>
7 <body>
8 <h1>Util</h1>
9 <p>
10    FSWikiÁ´ÂΤǻÈÍѤµ¤ì¤ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô·²¤òÄ󶡤¹¤ë¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
11 </p>
12 <h2>override_die</h2>
13 <p>
14    die¤Èexit¤Î¥ª¡¼¥Ð¥é¥¤¥ÉÁàºî¤ò¹Ô¤¤¤Þ¤¹¡£
15 </p>
16 <h2>url_encode </h2>
17         *CORE::GLOBAL::die = \&Util::_die;
18         *CORE::GLOBAL::exit = \&Util::_exit;
19 <p>
20    °ú¿ô¤ÇÅϤµ¤ì¤¿Ê¸»úÎó¤òURL¥¨¥ó¥³¡¼¥É¤·¤ÆÊÖ¤·¤Þ¤¹¡£
21 </p>
22 <pre>
23  $str = Util::url_encode($str)
24 </pre>
25 <h2>url_decode</h2>
26 <p>
27    °ú¿ô¤ÇÅϤµ¤ì¤¿Ê¸»úÎó¤òURL¥Ç¥³¡¼¥É¤·¤ÆÊÖ¤·¤Þ¤¹¡£
28 </p>
29 <pre>
30  $str = Util::url_decode($str);
31 </pre>
32 <h2>cookie_path </h2>
33 <p>
34    Cookie¤Îpath¤Ë»ØÄꤹ¤ëʸ»úÎó¤ò¼èÆÀ¤·¤Þ¤¹¡£
35 </p>
36 <pre>
37  $path = Util::cookie_path($wiki);
38 </pre>
39 <h2>make_filename </h2>
40 <p>
41    ¥Ç¥£¥ì¥¯¥È¥ê¡¢¥Õ¥¡¥¤¥ë̾¡¢³ÈÄ¥»Ò¤ò·ë¹ç¤·¤Æ¥Õ¥¡¥¤¥ë̾¤òÀ¸À®¤·¤Þ¤¹¡£
42 </p>
43 <pre>
44  my $filename = Util::make_filename(¥Ç¥£¥ì¥¯¥È¥ê̾,¥Õ¥¡¥¤¥ë̾,³ÈÄ¥»Ò);
45 </pre>
46 <h2>escapeHTML </h2>
47 <p>
48    °ú¿ô¤ÇÅϤµ¤ì¤¿Ê¸»úÎó¤ÎHTML¥¿¥°¤ò¥¨¥¹¥±¡¼¥×¤·¤ÆÊÖ¤·¤Þ¤¹¡£
49 </p>
50 <pre>
51  $str = Util::escapeHTML($str);
52 </pre>
53 <h2>format_date </h2>
54         $retstr =~ s/&amp;([a-zA-Z0-9]{2,8});/&$1;/go;
55 <p>
56    ÆüÉÕ¤ò&quot;yyyyǯmm·îddÆü hh»þmiʬssÉÃ&quot;·Á¼°¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤Þ¤¹¡£
57 </p>
58 <pre>
59  my $date = Util::format_date(time());
60 </pre>
61 <h2>trim </h2>
62 <p>
63    Ê¸»úÎó¤Îξü¤Î¶õÇò¤òÀÚ¤êÍî¤È¤·¤Þ¤¹¡£
64 </p>
65 <pre>
66  $text = Util::trim($text);
67 </pre>
68 <h2>delete_tag </h2>
69 <p>
70    ¥¿¥°¤òºï½ü¤·¤Æʸ»úÎó¤Î¤ß¤ò¼èÆÀ¤·¤Þ¤¹¡£
71 <p>
72 <pre>
73  my $html = "<B>ʸ»úÎó</B>";
74  # &lt;B&gt;¤È&lt;/B&gt;¤òºï½ü¤·¡¢&quot;ʸ»úÎó&quot;¤Î¤ß¼èÆÀ
75  my $text = Util::delete_tag($html);
76 </pre>
77 <h2>check_numeric </h2>
78 <p>
79    ¿ôÃͤ«¤É¤¦¤«¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£¿ôÃͤξì¹ç¤Ï¿¿¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ïµ¶¤òÊÖ¤·¤Þ¤¹¡£
80 </p>
81 <pre>
82  if(Util::check_numeric($param)){
83    # À°¿ô¤Î¾ì¹ç¤Î½èÍý
84  } else {
85    # À°¿ô¤Ç¤Ê¤¤¾ì¹ç¤Î½èÍý
86  }
87 </pre>
88 <h2>send_mail </h2>
89 <p>
90    ´ÉÍý¼Ô¤Ë¥á¡¼¥ë¤òÁ÷¿®¤·¤Þ¤¹¡£
91    setup.dat¤ÎÀßÄêÆâÍƤ˱þ¤¸¤Æsendmail¥³¥Þ¥ó¥É¤â¤·¤¯¤ÏSMTPÄÌ¿®¤Ë¤è¤Ã¤Æ¥á¡¼¥ë¤¬Á÷¿®¤µ¤ì¤Þ¤¹¡£
92    ¤É¤Á¤é¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤ÏÁ÷¿®¤ò¹Ô¤ï¤º¡¢¥¨¥é¡¼¤Ë¤â¤Ê¤ê¤Þ¤»¤ó¡£
93    SMTP¤ÇÁ÷¿®¤¹¤ë¾ì¹ç¡¢¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤¿»þÅÀ¤ÇNet::SMTP¤¬use¤µ¤ì¤Þ¤¹¡£
94 </p>
95 <pre>
96  Util::send_mail($wiki,·ï̾,ËÜʸ);
97 </pre>
98 <h2>handyphone </h2>
99 <p>
100    ¥¯¥é¥¤¥¢¥ó¥È¤¬·ÈÂÓÅÅÏ䫤ɤ¦¤«¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£
101    ·ÈÂÓÅÅÏäξì¹ç¤Ï¿¿¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ïµ¶¤òÊÖ¤·¤Þ¤¹¡£
102 </p>
103 <pre>
104  if(Util::handyphone()){
105    # ·ÈÂÓÅÅÏäξì¹ç¤Î½èÍý
106  } else {
107    # ·ÈÂÓÅÅÏäǤʤ¤¾ì¹ç¤Î½èÍý
108  }
109 </pre>
110 <h2>load_config_hash </h2>
111 <p>
112    ÀßÄê¥Õ¥¡¥¤¥ë¤ò³ÊǼ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¡Ê¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï./config¡Ë¤«¤é»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¡¢
113    ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤È¤·¤Æ¼èÆÀ¤·¤Þ¤¹¡£Âè°ì°ú¿ô¤Ë¤Ï$wiki¤òÅϤ·¡¢ÂèÆó°ú¿ô¤Ç¥Õ¥¡¥¤¥ë̾¤ò»ØÄꤷ¤Þ¤¹¡£
114 </p>
115 <pre>
116  my $hashref = Util::load_config_hash($wiki, &quot;hoge.dat&quot;);
117 </pre>
118 <h2>load_config_text </h2>
119 <p>
120    ÀßÄê¥Õ¥¡¥¤¥ë¤ò³ÊǼ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¡Ê¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï./config¡Ë¤«¤é»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¡¢
121    ¥Õ¥¡¥¤¥ëÆâÍƤòʸ»úÎó¤È¤·¤Æ¼èÆÀ¤·¤Þ¤¹¡£Âè°ì°ú¿ô¤Ë¤Ï$wiki¤òÅϤ·¡¢ÂèÆó°ú¿ô¤Ç¥Õ¥¡¥¤¥ë̾¤ò»ØÄꤷ¤Þ¤¹¡£
122 </p>
123 <pre>
124  my $content = Util::load_config_text($wiki, &quot;hoge.dat&quot;);
125 </pre>
126 <h2>save_config_hash </h2>
127 <p>
128    °ú¿ô¤ÇÅϤ·¤¿¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤òÀßÄê¥Õ¥¡¥¤¥ë¤ò³ÊǼ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¡Ê¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï./config¡Ë¤Ë
129   »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë̾¤ÇÊݸ¤·¤Þ¤¹¡£Âè°ì°ú¿ô¤Ë¤Ï$wiki¤òÅϤ·¡¢ÂèÆó°ú¿ô¤Ç¥Õ¥¡¥¤¥ë̾¤ò»ØÄꤷ¤Þ¤¹¡£
130 </p>
131 <pre>
132  Util::save_config_hash($wiki, ¥Õ¥¡¥¤¥ë̾, ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹);
133 </pre>
134 <h2>save_config_text </h2>
135 <p>
136    °ú¿ô¤ÇÅϤ·¤¿¥Æ¥­¥¹¥È¤òÀßÄê¥Õ¥¡¥¤¥ë¤ò³ÊǼ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¡Ê¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï./config¡Ë¤Ë
137   »ØÄꤷ¤¿¥Õ¥¡¥¤¥ë̾¤ÇÊݸ¤·¤Þ¤¹¡£Âè°ì°ú¿ô¤Ë¤Ï$wiki¤òÅϤ·¡¢ÂèÆó°ú¿ô¤Ç¥Õ¥¡¥¤¥ë̾¤ò»ØÄꤷ¤Þ¤¹¡£
138 </p>
139 <pre>
140  Util::save_config_hash($wiki, ¥Õ¥¡¥¤¥ë̾, ¥Æ¥­¥¹¥È);
141 </pre>
142 <h2>sync_update_config </h2>
143 <p>
144    ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤È½ñ¤­¹þ¤ß¤òƱ°ì¤Î¥í¥Ã¥¯Æâ¤Ç¹Ô¤¦¤¿¤á¤Î´Ø¿ô¡£
145    Æɤ߹þ¤ó¤ÀÆâÍƤòÊÑ´¹¤·¤Æ½ñ¤­¹þ¤ß¤ò¹Ô¤¦¤è¤¦¤Ê¾ì¹ç¤Ë»ÈÍѤ·¤Þ¤¹¡£
146 </p>
147 <pre>
148  sub convert {
149    my $hash = shift;
150    ...
151    return $hash;
152  }
153  
154  Util::sync_update_config($wiki, ¥Õ¥¡¥¤¥ë̾, \&convert);
155 </pre>
156 <h2>file_lock </h2>
157 <p>
158    °ú¿ô¤ÇÅϤ·¤¿¥Õ¥¡¥¤¥ë¤ò¥í¥Ã¥¯¤·¤Þ¤¹¡£
159    ¥Õ¥¡¥¤¥ëÁàºî½ªÎ»¸å¤Ïɬ¤ºÆ±¤¸¥Õ¥¡¥¤¥ë̾¤ÇUtil::file_unlock¤ò¸Æ¤Ó½Ð¤·¤Æ²¼¤µ¤¤¡£
160    ¥í¥Ã¥¯¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ïdie¤·¤Þ¤¹¡£
161 </p>
162 <pre>
163  Util::file_lock(¥Õ¥¡¥¤¥ë̾, ¥ê¥È¥é¥¤²ó¿ô¡Ê¢â¥¿¥¤¥à¥¢¥¦¥È»þ´Ö¡¢¾Êά²Ä¡Ë);
164 </pre>
165  ¥í¥Ã¥¯¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤òµ­Ï¿¤·¡¢½ªÎ»»þ¤Ë̤²ò½ü¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ëÊݸ±¤ò¤Ä¤±¤¿Êý¤¬Îɤ¤¤«¤âÃΤì¤Ê¤¤¡£
166 <h2>file_unlock </h2>
167         debug("file_lock($$): $lock");
168 <p>
169    °ú¿ô¤ÇÅϤ·¤¿¥Õ¥¡¥¤¥ë¤Î¥í¥Ã¥¯¤ò²ò½ü¤·¤Þ¤¹¡£
170 </p>
171 <pre>
172  Util::file_unlock(¥Õ¥¡¥¤¥ë̾);
173 </pre>
174 <h2>inline_error </h2>
175         debug("file_unlock($$): $lock");
176 <p>
177    ¥¤¥ó¥é¥¤¥ó¥×¥é¥°¥¤¥ó¤«¤é¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹¾ì¹ç¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£
178 </p>
179 <pre>
180   return Util::inline_error('¥×¥í¥¸¥§¥¯¥È̾¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó¡£');
181 </pre>
182 <h2>paragraph_error </h2>
183 <p>
184    ¥Ñ¥é¥°¥é¥Õ¥×¥é¥°¥¤¥ó¤«¤é¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹¾ì¹ç¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£
185 </p>
186 <pre>
187  return Util::paragraph_error('¥×¥í¥¸¥§¥¯¥È̾¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó¡£');
188 </pre>
189 <h2>get_response </h2>
190 <p>
191    »ØÄê¤ÎURL¤ËGET¥ê¥¯¥¨¥¹¥È¤òȯ¹Ô¤·¡¢¥ì¥¹¥Ý¥ó¥¹¤Î¥Ü¥Ç¥£Éô¤òÊֵѤ·¤Þ¤¹¡£
192    ¤³¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤¿»þÅÀ¤ÇLWP::UserAgent¤¬use¤µ¤ì¤Þ¤¹¡£
193 </p>
194 <pre>
195  my $response = Util::get_response($wiki,URL);
196 </pre>
197 <h2>get_module_file </h2>
198 <p>
199    ¥â¥¸¥å¡¼¥ë̾¤«¤é¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ¤·¤Þ¤¹¡£
200    Î㤨¤Ðplugin::core::Install¤òÅϤ¹¤Èplugin/core/Install.pm¤¬ÊֵѤµ¤ì¤Þ¤¹¡£
201 </p>
202 <pre>
203  $file = Util::get_module_file(¥â¥¸¥å¡¼¥ë̾);
204 </pre>
205 <h2>debug </h2>
206 <p>
207    ¥Ç¥Ð¥Ã¥°¥í¥°¡Êdebug.log¡Ë¤ò¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Ë½ÐÎϤ·¤Þ¤¹¡£
208    Wiki::DEBUG=1¤Î¾ì¹ç¤Î¤ß½ÐÎϤò¹Ô¤¤¤Þ¤¹¡£
209 </p>
210 <h2>md5 </h2>
211 <p>
212    Digest::Perl::MD5¤òÍѤ¤¤¿¥Ñ¥¹¥ï¡¼¥É¤Î°Å¹æ²½¤ò¹Ô¤¤¤Þ¤¹¡£
213    Âè°ì°ú¿ô¤Ë¥Ñ¥¹¥ï¡¼¥É¡¢ÂèÆó°ú¿ô¤Ë¥¢¥«¥¦¥ó¥È¤òÅϤ·¤Þ¤¹¡£
214    ¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤¿»þÅÀ¤ÇDigest::Perl::MD5¤¬use¤µ¤ì¤Þ¤¹¡£
215 </p>
216 <pre>
217  my $md5pass = Util::md5($pass,$account);
218 </pre>
219 <h2>make_content_disposition </h2>
220 <p>
221    HTTP¥Ø¥Ã¥À¤ÎContent-Disposition¹Ô¤òÀ¸À®¤·¤Þ¤¹¡£
222    ÅºÉÕ¥Õ¥¡¥¤¥ë¤äPDF¤Ê¤É¤Ë»ÈÍѤ·¤Þ¤¹¡£
223 </p>
224 <h2>restore_die</h2>
225 <p>
226    die¤Èexit¤Î¥ª¡¼¥Ð¥é¥¤¥ÉÁàºî¤ò²ò½ü¤·¤Þ¤¹¡£
227 </p>
228 <div class="footer">
229 Generated by makedoc.pl
230 </div>
231 </body>
232 </html>