2-3
/index.php
022 | $xoopsOption [ 'template_main' ] = set_bootstrap( 'phone_book_index_b3.html' ); |
023 | include_once XOOPS_ROOT_PATH . "/header.php" ; |
028 | function show_one_phone_book( $sn = '' ) |
030 | global $xoopsDB , $xoopsTpl , $isAdmin ; |
038 | $myts = MyTextSanitizer::getInstance(); |
040 | $sql = "select * from `" . $xoopsDB ->prefix( "phone_book" ) . "` |
041 | where `sn` = '{$sn}' "; |
042 | $result = $xoopsDB ->query( $sql ) |
043 | or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
044 | $all = $xoopsDB ->fetchArray( $result ); |
047 | foreach ( $all as $k => $v ) { |
052 | $phone_book_cate_arr = get_phone_book_cate( $cate_sn ); |
055 | $name = $myts ->htmlSpecialChars( $name ); |
056 | $birthday = $myts ->htmlSpecialChars( $birthday ); |
057 | $phone = $myts ->htmlSpecialChars( $phone ); |
058 | $email = $myts ->htmlSpecialChars( $email ); |
059 | $zip = $myts ->htmlSpecialChars( $zip ); |
060 | $county = $myts ->htmlSpecialChars( $county ); |
061 | $city = $myts ->htmlSpecialChars( $city ); |
062 | $addr = $myts ->htmlSpecialChars( $addr ); |
063 | $note = $myts ->displayTarea( $note , 0, 1, 0, 1, 1); |
065 | $xoopsTpl ->assign( 'sn' , $sn ); |
066 | $xoopsTpl ->assign( 'cate_sn' , $cate_sn ); |
067 | $xoopsTpl ->assign( 'cate_sn_title' , $phone_book_cate_arr [ 'cate_title' ]); |
068 | $xoopsTpl ->assign( 'name' , $name ); |
069 | $xoopsTpl ->assign( 'birthday' , $birthday ); |
070 | $xoopsTpl ->assign( 'phone' , $phone ); |
071 | $xoopsTpl ->assign( 'email' , $email ); |
072 | $xoopsTpl ->assign( 'zip' , $zip ); |
073 | $xoopsTpl ->assign( 'county' , $county ); |
074 | $xoopsTpl ->assign( 'city' , $city ); |
075 | $xoopsTpl ->assign( 'addr' , $addr ); |
076 | $xoopsTpl ->assign( 'note' , $note ); |
077 | $xoopsTpl ->assign( 'action' , $_SERVER [ 'PHP_SELF' ]); |
078 | $xoopsTpl ->assign( 'now_op' , 'show_one_phone_book' ); |
081 | $sql = "select cate_sn, cate_title from `" . $xoopsDB ->prefix( "phone_book_cate" ) . "` where `cate_enable` = '1' order by cate_sort" ; |
082 | $result = $xoopsDB ->query( $sql ) or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
083 | while (list( $csn , $cate_title ) = $xoopsDB ->fetchRow( $result )){ |
084 | $arr [ $csn ]= $cate_title ; |
086 | $arr [ 'selected' ]= $cate_sn ; |
087 | $json =json_encode( $arr ); |
088 | $json = str_replace ( '"' ,"'", $json ); |
091 | include_once XOOPS_ROOT_PATH. "/modules/tadtools/jeditable.php" ; |
092 | $file = "save_phone_book.php" ; |
093 | $jeditable = new jeditable(); |
095 | $jeditable ->setTextCol( "#name" , $file , '240px' , '36px' , "{'sn':$sn }" , "點擊編輯" ); |
096 | $jeditable ->setTextAreaCol( "#note" , $file , '500px' , '150px' , "{'sn':$sn, 'op':'textarea'}" , "點擊編輯" ); |
097 | $jeditable ->setSelectCol( "#cate_sn" , $file , $json , "{'sn' : $sn}" , "點擊編輯" ); |
099 | $jeditable_set = $jeditable ->render(); |
100 | $xoopsTpl ->assign( "jeditable_set" , $jeditable_set ); |
105 | function get_phone_book_cate( $cate_sn = '' ) |
109 | if ( empty ( $cate_sn )) { |
113 | $sql = "select * from `" . $xoopsDB ->prefix( "phone_book_cate" ) . "` |
114 | where `cate_sn` = '{$cate_sn}' "; |
115 | $result = $xoopsDB ->query( $sql ) |
116 | or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
117 | $data = $xoopsDB ->fetchArray( $result ); |
122 | function list_phone_book( $def_cate_sn = "" , $def_city = "" ) |
124 | global $xoopsDB , $xoopsTpl , $isAdmin ; |
128 | $and_name = $and_cate_sn = $and_city = "" ; |
129 | if (isset( $_GET [ 'keyword' ])){ |
130 | $and_name = "and name='{$_GET['keyword']}'" ; |
132 | $and_cate_sn = empty ( $def_cate_sn ) ? "" : "and `cate_sn` = '{$def_cate_sn}'" ; |
133 | $and_city = empty ( $def_city ) ? "" : "and `city` = '{$def_city}'" ; |
137 | $phone_book_cate_arr = get_phone_book_cate_arr(); |
139 | $myts = MyTextSanitizer::getInstance(); |
141 | $sql = "select * from `" . $xoopsDB ->prefix( "phone_book" ) . "` where 1 $and_cate_sn $and_city $and_name" ; |
144 | $PageBar = getPageBar( $sql , 20, 10, null, null, $bootstrap ); |
145 | $bar = $PageBar [ 'bar' ]; |
146 | $sql = $PageBar [ 'sql' ]; |
147 | $total = $PageBar [ 'total' ]; |
149 | $result = $xoopsDB ->query( $sql ) |
150 | or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
154 | while ( $all = $xoopsDB ->fetchArray( $result )) { |
156 | foreach ( $all as $k => $v ) { |
161 | $name = $myts ->htmlSpecialChars( $name ); |
162 | $birthday = $myts ->htmlSpecialChars( $birthday ); |
163 | $phone = $myts ->htmlSpecialChars( $phone ); |
164 | $email = $myts ->htmlSpecialChars( $email ); |
165 | $zip = $myts ->htmlSpecialChars( $zip ); |
166 | $county = $myts ->htmlSpecialChars( $county ); |
167 | $city = $myts ->htmlSpecialChars( $city ); |
168 | $addr = $myts ->htmlSpecialChars( $addr ); |
169 | $note = $myts ->displayTarea( $note , 0, 1, 0, 1, 1); |
171 | $all_content [ $i ][ 'sn' ] = $sn ; |
172 | $all_content [ $i ][ 'cate_sn' ] = $cate_sn ; |
173 | $all_content [ $i ][ 'cate_title' ] = $phone_book_cate_arr [ $cate_sn ][ 'cate_title' ]; |
174 | $all_content [ $i ][ 'name' ] = $name ; |
175 | $all_content [ $i ][ 'birthday' ] = $birthday ; |
176 | $all_content [ $i ][ 'phone' ] = $phone ; |
177 | $all_content [ $i ][ 'email' ] = $email ; |
178 | $all_content [ $i ][ 'zip' ] = $zip ; |
179 | $all_content [ $i ][ 'county' ] = $county ; |
180 | $all_content [ $i ][ 'city' ] = $city ; |
181 | $all_content [ $i ][ 'addr' ] = $addr ; |
182 | $all_content [ $i ][ 'note' ] = $note ; |
186 | $xoopsTpl ->assign( 'bar' , $bar ); |
187 | $xoopsTpl ->assign( 'action' , $_SERVER [ 'PHP_SELF' ]); |
188 | $xoopsTpl ->assign( 'isAdmin' , $isAdmin ); |
189 | $xoopsTpl ->assign( 'all_content' , $all_content ); |
190 | $xoopsTpl ->assign( 'now_op' , 'list_phone_book' ); |
191 | $xoopsTpl ->assign( 'cate_sn' , $cate_sn ); |
192 | $xoopsTpl ->assign( 'cate_arr' , get_phone_book_cate_arr()); |
195 | $county_arr =get_county_arr(); |
198 | $xoopsTpl ->assign( 'county_arr' , $county_arr ); |
202 | function get_county_arr(){ |
205 | $sql = "select county from `" . $xoopsDB ->prefix( "phone_book" ) . "` group by county order by zip" ; |
206 | $result = $xoopsDB ->query( $sql ) or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
207 | while (list( $county ) = $xoopsDB ->fetchRow( $result )) { |
208 | $county_arr [] = $county ; |
214 | function get_phone_book_cate_arr() |
218 | $sql = "select * from `" . $xoopsDB ->prefix( "phone_book_cate" ) . "` |
219 | where `cate_enable` = '1' "; |
220 | $result = $xoopsDB ->query( $sql ) |
221 | or redirect_header( $_SERVER [ 'PHP_SELF' ], 3, mysql_error()); |
222 | while ( $data = $xoopsDB ->fetchArray( $result )) { |
223 | $cate_sn = $data [ 'cate_sn' ]; |
224 | $all [ $cate_sn ] = $data ; |
229 | include_once $GLOBALS [ 'xoops' ]->path( '/modules/system/include/functions.php' ); |
230 | $op = system_CleanVars( $_REQUEST , 'op' , '' , 'string' ); |
231 | $city = system_CleanVars( $_REQUEST , 'city' , '' , 'string' ); |
232 | $sn = system_CleanVars( $_REQUEST , 'sn' , '' , 'int' ); |
233 | $cate_sn = system_CleanVars( $_REQUEST , 'cate_sn' , '' , 'int' ); |
240 | list_phone_book( $cate_sn , $city ); |
242 | show_one_phone_book( $sn ); |
250 | $xoopsTpl ->assign( "toolbar" , toolbar_bootstrap( $interface_menu )); |
251 | $xoopsTpl ->assign( "isAdmin" , $isAdmin ); |
252 | include_once XOOPS_ROOT_PATH . '/footer.php' ; |