| 1 | <?php | 
|---|
| 2 | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ; | 
|---|
| 3 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; | 
|---|
| 4 |  | 
|---|
| 5 | eval( ' | 
|---|
| 6 |  | 
|---|
| 7 | function '.$mydirname.'_new($limit=0, $offset=0){ | 
|---|
| 8 | return _xpress_new("'.$mydirname.'" ,$limit, $offset ) ; | 
|---|
| 9 | } | 
|---|
| 10 |  | 
|---|
| 11 | function '.$mydirname.'_num(){ | 
|---|
| 12 | return _xpress_num("'.$mydirname.'") ; | 
|---|
| 13 | } | 
|---|
| 14 |  | 
|---|
| 15 | function '.$mydirname.'_data($limit=0, $offset=0){ | 
|---|
| 16 | return _xpress_data("'.$mydirname.'" ,$limit, $offset ) ; | 
|---|
| 17 | } | 
|---|
| 18 | ' ) ; | 
|---|
| 19 |  | 
|---|
| 20 | if (!function_exists('_xpress_new')) { | 
|---|
| 21 | //================================================================ | 
|---|
| 22 | // What's New Module | 
|---|
| 23 | // get aritciles from module | 
|---|
| 24 | // xpress 0.20 <http://www.toemon.com> | 
|---|
| 25 | // 2007-07-17 toemon | 
|---|
| 26 | //================================================================ | 
|---|
| 27 |  | 
|---|
| 28 | // --- function start --- | 
|---|
| 29 | function _xpress_new($mydirname, $limit=0, $offset=0) | 
|---|
| 30 | { | 
|---|
| 31 | global $xoopsDB; | 
|---|
| 32 |  | 
|---|
| 33 | if ($mydirname == 'wordpress'){ | 
|---|
| 34 | $wp_prefix = 'wp'; | 
|---|
| 35 | } else { | 
|---|
| 36 | $wp_prefix = $mydirname; | 
|---|
| 37 | } | 
|---|
| 38 | require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); | 
|---|
| 39 | include(XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/wp-includes/version.php'); | 
|---|
| 40 |  | 
|---|
| 41 | $modules_table = $xoopsDB->prefix('modules'); | 
|---|
| 42 | $modSQL ="SELECT mid FROM " . $modules_table . " WHERE dirname LIKE '" . $mydirname . "'"; | 
|---|
| 43 | $modRes = $xoopsDB->query($modSQL, 0, 0); | 
|---|
| 44 | $modRow = $xoopsDB->fetchArray($modRes); | 
|---|
| 45 | $module_id = $modRow['mid']; | 
|---|
| 46 |  | 
|---|
| 47 | $table_config = $xoopsDB->prefix('config'); | 
|---|
| 48 | $confSQL ="SELECT conf_value FROM " . $table_config . " WHERE (conf_modid = " . $module_id . ") AND (conf_name LIKE 'whatsnew_use_mod_date')"; | 
|---|
| 49 | $confRes = $xoopsDB->query($confSQL, 0, 0); | 
|---|
| 50 | $confRow = $xoopsDB->fetchArray($confRes); | 
|---|
| 51 | $use_modified_date = $confRow['conf_value']; | 
|---|
| 52 |  | 
|---|
| 53 | $url_mod = XOOPS_URL."/modules/".$mydirname; | 
|---|
| 54 |  | 
|---|
| 55 | require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); | 
|---|
| 56 | $prefix = $xoopsDB->prefix($wp_prefix); | 
|---|
| 57 | $options_tables = get_table_list($prefix,'options'); | 
|---|
| 58 | $table_count = count($options_tables); | 
|---|
| 59 | $sql1 = ''; | 
|---|
| 60 | foreach( $options_tables as $options_table){ | 
|---|
| 61 | $blog_url = get_blog_option($options_table , 'siteurl'); | 
|---|
| 62 | $blog_url = preg_replace('/\/$/', '' ,$blog_url); | 
|---|
| 63 | $blogname = get_blog_option($options_table , 'blogname'); | 
|---|
| 64 |  | 
|---|
| 65 | $table_prefix = get_multi_prefix($options_table,'options'); | 
|---|
| 66 |  | 
|---|
| 67 | $table_posts      = $table_prefix . "posts"; | 
|---|
| 68 |  | 
|---|
| 69 | $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; | 
|---|
| 70 | $sub_sql .= " FROM ".$table_posts; | 
|---|
| 71 | $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; | 
|---|
| 72 |  | 
|---|
| 73 | if ($table_count > 1){ | 
|---|
| 74 | $sub_sql = '(' . $sub_sql . ')'; | 
|---|
| 75 | if (!empty($sql1)) $sql1 = $sql1 . ' UNION '; | 
|---|
| 76 | $sql1 = $sql1 . $sub_sql; | 
|---|
| 77 | } else { | 
|---|
| 78 | $sql1 =  $sub_sql; | 
|---|
| 79 | } | 
|---|
| 80 | } | 
|---|
| 81 | $sql1 .= " ORDER BY post_date DESC LIMIT $offset,$limit"; | 
|---|
| 82 |  | 
|---|
| 83 | $res1 = $xoopsDB->queryF($sql1); | 
|---|
| 84 |  | 
|---|
| 85 | $i = 0; | 
|---|
| 86 | $ret = array(); | 
|---|
| 87 |  | 
|---|
| 88 | while($row1 = $xoopsDB->fetchArray($res1)) | 
|---|
| 89 | { | 
|---|
| 90 | $id = $row1['ID']; | 
|---|
| 91 | $blog_url = $row1['blog_url']; | 
|---|
| 92 | $blogname = $row1['blogname']; | 
|---|
| 93 | $table_views   =$modules_table = $xoopsDB->prefix($wp_prefix) . "_views"; | 
|---|
| 94 | $table_term_relationships = $row1['table_prefix'] . "term_relationships"; | 
|---|
| 95 | $table_term_taxonomy = $row1['table_prefix'] . "term_taxonomy"; | 
|---|
| 96 | $table_terms = $row1['table_prefix'] . "terms"; | 
|---|
| 97 | $table_categories = $row1['table_prefix'] . "categories"; | 
|---|
| 98 | $table_post2cat   = $row1['table_prefix'] . "post2cat"; | 
|---|
| 99 |  | 
|---|
| 100 | if ($table_count <= 1){ | 
|---|
| 101 | if ($wp_db_version < 6124){ | 
|---|
| 102 | $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id; | 
|---|
| 103 | } else { | 
|---|
| 104 | $sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; | 
|---|
| 105 | $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id "; | 
|---|
| 106 | $sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')"; | 
|---|
| 107 | } | 
|---|
| 108 | $row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) ); | 
|---|
| 109 | $ret[$i]['cat_link'] = $blog_url."/index.php?cat=".$row2['cat_ID']; | 
|---|
| 110 | $ret[$i]['cat_name'] = $row2['cat_name']; | 
|---|
| 111 | } else { | 
|---|
| 112 | $ret[$i]['cat_link'] = $blog_url; | 
|---|
| 113 | $ret[$i]['cat_name'] = $blogname; | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 | if ($row1['post_type'] == 'page'){ | 
|---|
| 117 | $ret[$i]['link']     = $blog_url."/?page_id=".$id; | 
|---|
| 118 | } else { | 
|---|
| 119 | $ret[$i]['link']     = $blog_url."/index.php?p=".$id; | 
|---|
| 120 | } | 
|---|
| 121 |  | 
|---|
| 122 | $ret[$i]['title']    = $row1['post_title']; | 
|---|
| 123 |  | 
|---|
| 124 | $ret[$i]['uid'] = wp_uid_to_xoops_uid($row1['post_author'],$mydirname); | 
|---|
| 125 | $ret[$i]['replies'] = $row1['comment_count']; | 
|---|
| 126 |  | 
|---|
| 127 |  | 
|---|
| 128 | if(empty($use_modified_date)) { | 
|---|
| 129 | $time = $row1['unix_post_date']; | 
|---|
| 130 | } else { | 
|---|
| 131 |  | 
|---|
| 132 | if ($row1['unix_post_modified'] > $row1['unix_post_date']){ | 
|---|
| 133 | $time = $row1['unix_post_modified']; | 
|---|
| 134 | } else { | 
|---|
| 135 | $time = $row1['unix_post_date']; | 
|---|
| 136 | } | 
|---|
| 137 | } | 
|---|
| 138 |  | 
|---|
| 139 | $ret[$i]['time']     = $time; | 
|---|
| 140 | $ret[$i]['modified'] = $time; | 
|---|
| 141 | $ret[$i]['issued']   = $row1['unix_post_date']; | 
|---|
| 142 | $content=$row1['post_content']; | 
|---|
| 143 | $content = strip_tags($content); | 
|---|
| 144 |  | 
|---|
| 145 | $ret[$i]['description'] = $content; | 
|---|
| 146 |  | 
|---|
| 147 | $sql3 = "SELECT post_views FROM  " .  $table_views . " WHERE post_id = " . $id; | 
|---|
| 148 | $row3 = $xoopsDB->fetchArray( $xoopsDB->query($sql3) ); | 
|---|
| 149 | $ret[$i]['hits']     = $row3['post_views']; | 
|---|
| 150 |  | 
|---|
| 151 |  | 
|---|
| 152 |  | 
|---|
| 153 | $i++; | 
|---|
| 154 | } | 
|---|
| 155 |  | 
|---|
| 156 | return $ret; | 
|---|
| 157 | } | 
|---|
| 158 |  | 
|---|
| 159 | function _xpress_num($mydirname) | 
|---|
| 160 | { | 
|---|
| 161 | // get $mydirnumber | 
|---|
| 162 | if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ; | 
|---|
| 163 |  | 
|---|
| 164 | global $xoopsDB; | 
|---|
| 165 |  | 
|---|
| 166 | if ($mydirname == 'wordpress'){ | 
|---|
| 167 | $wp_prefix = 'wp'; | 
|---|
| 168 | } else { | 
|---|
| 169 | $wp_prefix = $mydirname; | 
|---|
| 170 | } | 
|---|
| 171 | require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); | 
|---|
| 172 | $prefix = $xoopsDB->prefix($wp_prefix); | 
|---|
| 173 | $options_tables = get_table_list($prefix,'options'); | 
|---|
| 174 | $table_count = count($options_tables); | 
|---|
| 175 | $sql = ''; | 
|---|
| 176 | foreach( $options_tables as $options_table){ | 
|---|
| 177 | $blog_url = get_blog_option($options_table , 'siteurl'); | 
|---|
| 178 | $blog_url = preg_replace('/\/$/', '' ,$blog_url); | 
|---|
| 179 | $blogname = get_blog_option($options_table , 'blogname'); | 
|---|
| 180 |  | 
|---|
| 181 | $table_prefix = get_multi_prefix($options_table,'options'); | 
|---|
| 182 | $table_posts      = $table_prefix . "posts"; | 
|---|
| 183 |  | 
|---|
| 184 | $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; | 
|---|
| 185 | $sub_sql .= " FROM ".$table_posts; | 
|---|
| 186 | $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; | 
|---|
| 187 |  | 
|---|
| 188 | if ($table_count > 1){ | 
|---|
| 189 | $sub_sql = '(' . $sub_sql . ')'; | 
|---|
| 190 | if (!empty($sql)) $sql = $sql . ' UNION '; | 
|---|
| 191 | $sql = $sql . $sub_sql; | 
|---|
| 192 | } else { | 
|---|
| 193 | $sql =  $sub_sql; | 
|---|
| 194 | } | 
|---|
| 195 | } | 
|---|
| 196 |  | 
|---|
| 197 | $array = $xoopsDB->fetchRow( $xoopsDB->queryF($sql) ); | 
|---|
| 198 | $num = $array[0]; | 
|---|
| 199 | if (empty($num)) $num = 0; | 
|---|
| 200 |  | 
|---|
| 201 | return $num; | 
|---|
| 202 | } | 
|---|
| 203 |  | 
|---|
| 204 | function _xpress_data($mydirname,$limit=0, $offset=0) | 
|---|
| 205 | { | 
|---|
| 206 | // get $mydirnumber | 
|---|
| 207 | if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ; | 
|---|
| 208 |  | 
|---|
| 209 | global $xoopsDB; | 
|---|
| 210 |  | 
|---|
| 211 | if ($mydirname == 'wordpress'){ | 
|---|
| 212 | $wp_prefix = 'wp'; | 
|---|
| 213 | } else { | 
|---|
| 214 | $wp_prefix = $mydirname; | 
|---|
| 215 | } | 
|---|
| 216 |  | 
|---|
| 217 | require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); | 
|---|
| 218 | $prefix = $xoopsDB->prefix($wp_prefix); | 
|---|
| 219 | $options_tables = get_table_list($prefix,'options'); | 
|---|
| 220 | $table_count = count($options_tables); | 
|---|
| 221 | $sql = ''; | 
|---|
| 222 | foreach( $options_tables as $options_table){ | 
|---|
| 223 | $blog_url = get_blog_option($options_table , 'siteurl'); | 
|---|
| 224 | $blog_url = preg_replace('/\/$/', '' ,$blog_url); | 
|---|
| 225 | $blogname = get_blog_option($options_table , 'blogname'); | 
|---|
| 226 |  | 
|---|
| 227 | $table_prefix = get_multi_prefix($options_table,'options'); | 
|---|
| 228 | $table_posts      = $table_prefix . "posts"; | 
|---|
| 229 |  | 
|---|
| 230 | $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; | 
|---|
| 231 | $sub_sql .= " FROM ".$table_posts; | 
|---|
| 232 | $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; | 
|---|
| 233 |  | 
|---|
| 234 | if ($table_count > 1){ | 
|---|
| 235 | $sub_sql = '(' . $sub_sql . ')'; | 
|---|
| 236 | if (!empty($sql)) $sql = $sql . ' UNION '; | 
|---|
| 237 | $sql = $sql . $sub_sql; | 
|---|
| 238 | } else { | 
|---|
| 239 | $sql =  $sub_sql; | 
|---|
| 240 | } | 
|---|
| 241 | } | 
|---|
| 242 |  | 
|---|
| 243 | $result = $xoopsDB->queryF($sql,$limit,$offset); | 
|---|
| 244 |  | 
|---|
| 245 | $i = 0; | 
|---|
| 246 | $ret = array(); | 
|---|
| 247 |  | 
|---|
| 248 | while($row1 = $xoopsDB->fetchArray($result)) | 
|---|
| 249 | { | 
|---|
| 250 | $id = $row1['ID']; | 
|---|
| 251 | $blog_url = $row1['blog_url']; | 
|---|
| 252 | $blogname = $row1['blogname']; | 
|---|
| 253 | $ret[$i]['id'] = $id; | 
|---|
| 254 | $ret[$i]['link'] = $blog_url . "/index.php?p=".$id; | 
|---|
| 255 | $ret[$i]['title'] = $row1['post_title']; | 
|---|
| 256 | $ret[$i]['time']  = $row1['unix_post_date']; | 
|---|
| 257 | $i++; | 
|---|
| 258 | } | 
|---|
| 259 |  | 
|---|
| 260 | return $ret; | 
|---|
| 261 |  | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | if( ! function_exists( 'get_blog_option' ) ) { | 
|---|
| 265 | function get_blog_option($option_table,$option_name){ | 
|---|
| 266 | $xoopsDB =& Database::getInstance(); | 
|---|
| 267 |  | 
|---|
| 268 | $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; | 
|---|
| 269 |  | 
|---|
| 270 | $result =  $xoopsDB->query($sql, 0, 0); | 
|---|
| 271 | if ($xoopsDB->getRowsNum($result)  > 0){ | 
|---|
| 272 | $row = $xoopsDB->fetchArray($result); | 
|---|
| 273 | return $row['option_value']; | 
|---|
| 274 | } | 
|---|
| 275 | return 0; | 
|---|
| 276 | } | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 |  | 
|---|
| 280 | // --- function end --- | 
|---|
| 281 |  | 
|---|
| 282 | } | 
|---|
| 283 |  | 
|---|
| 284 | ?> | 
|---|