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