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