예제 #1
0
 public function table_settings()
 {
     $table = z(t(v('table')));
     $tables = get_table_list(db());
     if (!in_array($table, $tables)) {
         return info_page('<a href="javascript:history.back(1);">table不存在,点击返回</a>');
     }
     $data['fields'] = get_fields_info($table);
     $data['actions'] = array('list' => 'List', 'insert' => 'Insert', 'update' => 'Update', 'remove' => 'Remove');
     $data['table'] = $table;
     $data['my_actions'] = get_data("SELECT * FROM `__meta_code` WHERE `table` = '" . s($table) . "' ORDER BY `id` DESC");
     //print_r( $fields );
     $data['title'] = $data['top_title'] = 'API设置';
     $data['js'][] = 'codemirror.js';
     $data['js'][] = 'util/runmode.js';
     $data['js'][] = 'mode/php/php.js';
     $data['js'][] = 'mode/htmlmixed/htmlmixed.js';
     $data['js'][] = 'mode/css/css.js';
     $data['js'][] = 'mode/javascript/javascript.js';
     $data['js'][] = 'mode/xml/xml.js';
     $data['js'][] = 'mode/clike/clike.js';
     $data['css'][] = 'codemirror.css';
     $data['css'][] = 'theme/night.css';
     render($data);
 }
예제 #2
0
 function _sitemap_xpress($mydirname)
 {
     global $sitemap_configs, $xoopsDB;
     if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')) {
         return '';
     }
     include XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php';
     if ($wp_db_version < 6124) {
         // UNDER WP2.3
         $block = sitemap_get_categoires_map($xoopsDB->prefix("wp_categories"), "cat_ID", "category_parent", "cat_name", "index.php?cat=", "cat_name");
         return $block;
     }
     $disp_sub = @$sitemap_configs["show_subcategoris"];
     $prefix = preg_replace('/wordpress/', 'wp', $mydirname);
     $prefix = $xoopsDB->prefix($prefix);
     require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/general_functions.php';
     $options_tables = get_table_list($prefix, 'options');
     $index = 0;
     $blogs = array();
     foreach ($options_tables as $options_table) {
         $blog_url = get_blog_option($options_table, 'siteurl');
         $blog_sub_url = preg_replace('/.*\\/' . $mydirname . '/', '', $blog_url);
         $blog_sub_url = preg_replace('/\\//', '', $blog_sub_url);
         if (!empty($blog_sub_url)) {
             $blog_sub_url = $blog_sub_url . '/';
         }
         $blog_name = get_blog_option($options_table, 'blogname');
         $db_prefix = get_multi_prefix($options_table, 'options');
         $data = array('blog_name' => $blog_name, 'blog_sub_url' => $blog_sub_url, 'term_taxonomy' => $db_prefix . 'term_taxonomy', 'terms' => $db_prefix . 'terms');
         $blogs[$index] = $data;
         $index++;
     }
     return xpress_get_categoires_map($blogs, $disp_sub);
 }
예제 #3
0
<?php 
// Copyright (C) GPLv2 2011 Nathan A. Mourey II <*****@*****.**>
include "config/functions.php";
$q = $_REQUEST['q'];
$update = $_REQUEST['update'];
?>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>MySQL Database Managment.</title>
	<link rel="stylesheet" type="text/css" href="css/db.css" />
</head>


<body>
	<div id="title"><h2>MySQL Database Schema Viewing Tool.</h2></div>
<?php 
if (isset($q)) {
    /* If user is in db.  List there databases. */
    $html = get_table_list($q);
    print $html;
} else {
    print "<div><span id=\"welcome\"><center><h3>Welcome.  Please click a database at the left to begin.</h3></center></span></div>";
}
?>
<p id="copyright">Copyright &copy; <a href="http://www.gnu.org/licenses/gpl-2.0.html" target="_top">GPLv2</a> 2011  
<a href="mailto:nmoureyii@ne.rr.com">Nathan A. Mourey II</a></p> 
</body>
</html>
예제 #4
0
function backup_tables($host, $user, $pass, $name, $tables = '*', $check_size = true)
{
    $link = mysql_connect($host, $user, $pass);
    mysql_select_db($name, $link);
    // get list of tables
    if ($tables == '*') {
        $tables = get_table_list();
    } else {
        $tables = is_array($tables) ? $tables : explode(',', $tables);
    }
    // loop through tables
    foreach ($tables as $table) {
        echo 'DROP TABLE IF EXISTS ' . $table . ';';
        $row = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
        echo "\n\n" . $row[1] . ";\n\n";
        $table_size = get_table_size(SDATA_DB_NAME, $table);
        if ($check_size and $table_size > MAX_TABLE_BACKUP_SIZE) {
            // else: the table is too large to be included in the main dump
            echo "-- table {$table} is too large ({$table_size} MB) so the rows have been excluded from this database dump\n\n\n\n";
        } else {
            $result = mysql_query('SELECT * FROM ' . $table);
            $num_fields = mysql_num_fields($result);
            while ($row = mysql_fetch_row($result)) {
                set_time_limit(90);
                echo 'INSERT INTO ' . $table . ' VALUES(';
                for ($j = 0; $j < $num_fields; $j++) {
                    $row[$j] = addslashes($row[$j]);
                    $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                    if (isset($row[$j])) {
                        echo '"' . $row[$j] . '"';
                    } else {
                        echo '""';
                    }
                    if ($j < $num_fields - 1) {
                        echo ',';
                    }
                }
                echo ");\n";
            }
            echo "\n\n\n";
        }
    }
}
예제 #5
0
function _xpress_data($mydirname,$limit=0, $offset=0) 
{
	// get $mydirnumber
	if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;

	global $xoopsDB;
	$wp_prefix = preg_replace('/wordpress/','wp',$mydirname);
	
	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
	$prefix = $xoopsDB->prefix($wp_prefix);
	$options_tables = get_table_list($prefix,'options');
	$table_count = count($options_tables);
	$sql = '';
	foreach( $options_tables as $options_table){
		$blog_url = get_blog_option($options_table , 'siteurl');
		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
		$blogname = get_blog_option($options_table , 'blogname');
		
		$table_prefix = get_multi_prefix($options_table,'options');
		$table_posts      = $table_prefix . "posts";

		$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 ";
		$sub_sql .= " FROM ".$table_posts;
		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";

		if ($table_count > 1){
			$sub_sql = '(' . $sub_sql . ')';
			if (!empty($sql)) $sql = $sql . ' UNION ';
			$sql = $sql . $sub_sql;
		} else {
			$sql =  $sub_sql;
		}
	}

	$result = $xoopsDB->queryF($sql,$limit,$offset);

	$i = 0;
	$ret = array();

	while($row1 = $xoopsDB->fetchArray($result))
	{
		$id = $row1['ID'];
		$blog_url = $row1['blog_url'];
		$blogname = $row1['blogname'];
		$ret[$i]['id'] = $id;
		$ret[$i]['link'] = $blog_url . "/index.php?p=".$id;
		$ret[$i]['title'] = $row1['post_title'];
		$ret[$i]['time']  = $row1['unix_post_date'];
		$i++;
	}

	return $ret;

}
예제 #6
0
function repair_user_meta_prefix()
{
    global $xoops_db;
    // repair usermeta db
    $db_xpress_usermeta = get_wp_prefix() . 'usermeta';
    $wp_prefix_only = get_wp_prefix_only();
    $user_meta_prefix = get_wp_prefix();
    $sql = "SELECT * FROM {$db_xpress_usermeta} WHERE meta_key LIKE '%_" . $wp_prefix_only . "%'";
    $user_metas = $xoops_db->get_results($sql);
    if (!empty($user_metas)) {
        foreach ($user_metas as $user_meta) {
            if (strpos($user_meta->meta_key, $user_meta_prefix) === false) {
                $new_meta_key = '';
                if (strpos($user_meta->meta_key, $wp_prefix_only . 'user_level')) {
                    $new_meta_key = $user_meta_prefix . 'user_level';
                }
                if (strpos($user_meta->meta_key, $wp_prefix_only . 'capabilities')) {
                    $new_meta_key = $user_meta_prefix . 'capabilities';
                }
                if (strpos($user_meta->meta_key, $wp_prefix_only . 'autosave_draft_ids')) {
                    $new_meta_key = $user_meta_prefix . 'autosave_draft_ids';
                }
                if (strpos($user_meta->meta_key, $wp_prefix_only . 'usersettings')) {
                    if (strpos($user_meta->meta_key, $wp_prefix_only . 'usersettingstime')) {
                        $new_meta_key = $user_meta_prefix . 'usersettingstime';
                    } else {
                        $new_meta_key = $user_meta_prefix . 'usersettings';
                    }
                }
                if (!empty($new_meta_key)) {
                    $repair_sql = "UPDATE {$db_xpress_usermeta} ";
                    $repair_sql .= 'SET ';
                    $repair_sql .= "meta_key = '{$new_meta_key}' ";
                    $repair_sql .= "WHERE (umeta_id = {$user_meta->umeta_id} )";
                    $xoops_db->query($repair_sql);
                }
            }
        }
    }
    // repair option db user_roles
    include_once ABSPATH . '/include/general_functions.php';
    $prefix = get_wp_prefix();
    $option_tables = get_table_list($prefix, 'options');
    if (!empty($option_tables)) {
        foreach ($option_tables as $option_table) {
            $mid_prefix = get_multi_mid_prefix($prefix, 'options', $option_table);
            $new_option_name = $prefix . $mid_prefix . 'user_roles';
            $sql = "SELECT option_id , option_name FROM {$option_table} WHERE option_name LIKE '%_user_roles'";
            $option = $xoops_db->get_row($sql);
            if ($option->option_name != $new_option_name) {
                $repair_sql = "UPDATE {$db_wp_option} ";
                $repair_sql .= 'SET ';
                $repair_sql .= "option_name = '{$new_option_name}' ";
                $repair_sql .= "WHERE (option_id = {$option->option_id} )";
                $xoops_db->query($repair_sql);
            }
        }
    }
}
예제 #7
0
 public function index()
 {
     //print_r( $_REQUEST );
     $table = z(t(v('_table')));
     $action = z(t(v('_interface')));
     if (strlen($table) < 1 || strlen($action) < 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'BAD ARGS');
     }
     // user define code
     if ($my_code = get_var("SELECT `code` FROM `__meta_code` WHERE `table` = '" . s($table) . "' AND `action` = '" . s($action) . "' LIMIT 1")) {
         return eval($my_code);
         exit;
     }
     // check table
     $tables = get_table_list(db());
     if (!in_array($table, $tables)) {
         return $this->send_error(LR_API_ARGS_ERROR, 'TABLE NOT EXISTS');
     }
     if ($table == c('token_table_name') && $action == 'get_token') {
         return $this->get_token();
     }
     $fields = get_fields($table);
     $kv = new SaeKV();
     $kv->init();
     $ainfo = unserialize($kv->get('msetting_' . $table . '_' . $action));
     $in_code = $kv->get('iosetting_input_' . $table . '_' . $action);
     $out_code = $kv->get('iosetting_output_' . $table . '_' . $action);
     // run user defined input fliter
     if (strlen($in_code) > 0) {
         eval($in_code);
     }
     if ($ainfo['on'] != 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'API NOT  AVAILABLE');
     }
     if ($ainfo['public'] != 1) {
         $this->check_token();
     }
     $requires = array();
     $inputs = array();
     $outs = array();
     $likes = array();
     $equal = array();
     foreach ($fields as $field) {
         $finfo = unserialize($kv->get('msetting_' . $table . '_' . $action . '_' . $field));
         if ($finfo['required'] == 1) {
             $requires[] = $field;
         }
         if ($finfo['input'] == 1) {
             $inputs[] = $field;
         }
         if ($finfo['output'] == 1) {
             $outputs[] = $field;
         }
         if ($finfo['like'] == 1) {
             $likes[] = $field;
         }
         if ($finfo['equal'] == 1) {
             $equals[] = $field;
         }
     }
     // check require
     if (count($requires) > 0) {
         foreach ($requires as $require) {
             if (strlen(v($require)) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, z(t($require)) . ' FIELD REQUIRED');
             }
         }
     }
     // build sql
     switch ($action) {
         case 'insert':
             if (count($inputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($outputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'OUTPUT MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 $dsql[] = "'" . s(v($input)) . "'";
             }
             $sql = "INSERT INTO `" . s($table) . "` ( " . rjoin(' , ', '`', $inputs) . " ) VALUES ( " . join(' , ', $dsql) . " )";
             //echo $sql;
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             $lid = last_id();
             if ($lid < 1) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             if (!($data = get_data("SELECT " . rjoin(' , ', '`', $outputs) . " FROM `" . s($table) . "` WHERE `id` = '" . intval($lid) . "'", db()))) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 $this->send_result($data);
             }
             break;
         case 'update':
             if (count($inputs) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($requires) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'REQUIRE MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 if (!in_array($input, $likes) && !in_array($input, $equals)) {
                     if (isset($_REQUEST[$input])) {
                         $dsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                     }
                 } else {
                     if (in_array($input, $likes)) {
                         $wsql[] = " `" . s($input) . "` LIKE '%" . s(v($input)) . "%' ";
                     } else {
                         $wsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                     }
                 }
             }
             if (!isset($dsql) || !isset($wsql)) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT AND LIKE/EQUALS MUST HAS 1 FIELD AT LEAST');
             }
             $sql = "UPDATE `" . s($table) . "` SET " . join(' , ', $dsql) . ' WHERE ' . join(' AND ', $wsql);
             //echo $sql ;
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             $lid = intval(v('id'));
             if ($lid < 1) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             if (!($data = get_data("SELECT " . rjoin(' , ', '`', $outputs) . " FROM `" . s($table) . "` WHERE `id` = '" . intval($lid) . "'"))) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 $this->send_result($data);
             }
             break;
         case 'remove':
             if (count($inputs) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($requires) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'REQUIRE MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 if (in_array($input, $likes)) {
                     $wsql[] = " `" . s($input) . "` LIKE '%" . s(v($input)) . "%' ";
                 } elseif (in_array($input, $equals)) {
                     $wsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                 }
             }
             if (!isset($wsql)) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT AND LIKE/EQUALS MUST HAS 1 FIELD AT LEAST');
             }
             if (count($outputs) > 0) {
                 $sql = "SELECT " . rjoin(',', '`', $outputs) . " FROM `" . s($table) . "` WHERE  " . join(' AND ', $wsql);
                 $data = get_line($sql);
                 if (mysql_errno() != 0) {
                     return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
                 }
             }
             $sql = "DELETE FROM `" . s($table) . "` WHERE " . join(' AND ', $wsql);
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (count($outputs) < 1) {
                     return $this->send_result(array('msg' => 'ok'));
                 } else {
                     if (strlen($out_code) > 0) {
                         eval($out_code);
                     }
                     return $this->send_result($data);
                 }
             }
             break;
         case 'list':
         default:
             $since_id = intval(v('since_id'));
             $max_id = intval(v('max_id'));
             $count = intval(v('count'));
             $order = strtolower(z(t(v('ord'))));
             $by = strtolower(z(t(v('by'))));
             if ($order == 'asc') {
                 $ord = ' ASC ';
             } else {
                 $ord = ' DESC ';
             }
             if (strlen($by) > 0) {
                 $osql = ' ORDER BY `' . s($by) . '` ' . $ord . ' ';
             } else {
                 $osql = '';
             }
             if ($count < 1) {
                 $count = 10;
             }
             if ($count > 100) {
                 $count = 100;
             }
             if (count($outputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'OUTPUT MUST HAS 1 FIELD AT LEAST');
             }
             $sql = "SELECT " . rjoin(',', '`', $outputs) . " FROM `" . s($table) . "` WHERE 1 ";
             if ($since_id > 0) {
                 $wsql = " AND `id` > '" . intval($since_id) . "' ";
             } elseif ($max_id > 0) {
                 $wsql = " AND `id` < '" . intval($max_id) . "' ";
             }
             if (count($inputs) > 0 && count($likes) + count($equals) > 0) {
                 // AND `xxx` == $xxx
                 if (count($likes) > 0) {
                     foreach ($likes as $like) {
                         if (z(t(v($like))) != '') {
                             $wwsql[] = " AND `" . s($like) . "` LIKE '%" . s(v($like)) . "%' ";
                         }
                     }
                 }
                 if (count($equals) > 0) {
                     foreach ($equals as $equal) {
                         if (z(t(v($equal))) != '') {
                             $wwsql[] = " AND `" . s($equal) . "` = '" . s(v($equal)) . "' ";
                         }
                     }
                 }
                 if (isset($wwsql)) {
                     $wsql = $wsql . join(' ', $wwsql);
                 }
             }
             $sql = $sql . $wsql . $osql . " LIMIT " . $count;
             //echo $sql;
             if ($idata = get_data($sql)) {
                 $first = reset($idata);
                 $max_id = $first['id'];
                 $min_id = $first['id'];
                 foreach ($idata as $item) {
                     if ($item['id'] > $max_id) {
                         $max_id = $item['id'];
                     }
                     if ($item['id'] < $min_id) {
                         $min_id = $item['id'];
                     }
                 }
                 $data = array('items' => $idata, 'max_id' => $max_id, 'min_id' => $min_id);
             } else {
                 $data = $idata;
             }
             if (mysql_errno() != 0) {
                 return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 return $this->send_result($data);
             }
     }
     //return $this->send_error( LR_API_ARGS_ERROR , 'FIELD NOT EXISTS' );
 }
예제 #8
0
파일: index.php 프로젝트: nouphet/rata
function xpress_state($is_report = false)
{
    global $xoopsModule;
    include dirname(__FILE__) . '/../wp-includes/version.php';
    include_once dirname(__FILE__) . '/../include/general_functions.php';
    $xoopsDB =& Database::getInstance();
    $xp_prefix = $GLOBALS['xoopsModule']->getInfo('dirname');
    $xp_prefix = preg_replace('/wordpress/', 'wp', $xp_prefix);
    $prefix = $xoopsDB->prefix($xp_prefix . '_');
    $posts_tables = get_table_list($prefix, 'posts');
    $blogname = array();
    $count_article = array();
    $count_author = array();
    $count_category = array();
    $array_index = 0;
    foreach ($posts_tables as $posts_table) {
        $sql = "SELECT COUNT(DISTINCT post_author) AS count_author, COUNT(*) AS count_article FROM " . $posts_table . " WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')";
        $result = $xoopsDB->query($sql);
        if ($myrow = $xoopsDB->fetchArray($result)) {
            $count_article[$array_index] = $myrow["count_article"];
            $count_author[$array_index] = $myrow["count_author"];
        } else {
            $count_article[$array_index] = 0;
            $count_author[$array_index] = 0;
        }
        $mid_prefix = get_multi_mid_prefix($prefix, 'posts', $posts_table);
        $sql = "SELECT option_value AS blogname FROM " . $prefix . $mid_prefix . "options" . " WHERE option_name = 'blogname'";
        $result = $xoopsDB->query($sql);
        if ($myrow = $xoopsDB->fetchArray($result)) {
            $blogname[$array_index] = $myrow["blogname"];
        } else {
            $blogname[$array_index] = 'none name';
        }
        if ($wp_db_version < 6124) {
            $sql = "SELECT COUNT(*) AS count_category FROM " . $prefix . $mid_prefix . "categories";
        } else {
            $sql = "SELECT COUNT(*) AS count_category FROM " . $prefix . $mid_prefix . "term_taxonomy" . " WHERE taxonomy = 'category'";
        }
        $result = $xoopsDB->query($sql);
        if ($myrow = $xoopsDB->fetchArray($result)) {
            $count_category[$array_index] = $myrow["count_category"];
        } else {
            $count_category[$array_index] = 0;
        }
        $array_index++;
    }
    for ($i = 0; $i < $array_index; $i++) {
        if ($is_report) {
            echo "******** " . $blogname[$i] . _AM_XP2_STATS . "********" . "<br />\n";
            echo _AM_XP2_CATEGORIES . ":  " . @$count_category[$i] . "<br />\n";
            echo _AM_XP2_ARTICLES . ":  " . $count_article[$i] . "<br />\n";
            echo _AM_XP2_AUTHORS . ":  " . $count_author[$i] . "<br />\n";
        } else {
            echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . $blogname[$i] . _AM_XP2_STATS . "</legend>";
            echo "<div style='padding: 8px;'>";
            echo "<label>" . _AM_XP2_CATEGORIES . ":</label><text>" . @$count_category[$i];
            echo "</text><br />";
            echo "<label>" . _AM_XP2_ARTICLES . ":</label><text>" . $count_article[$i];
            echo "</text><br />";
            echo "<label>" . _AM_XP2_AUTHORS . ":</label><text>" . $count_author[$i];
            echo "</text>";
            echo "</div>";
            echo '</legend>';
            echo "</fieldset>";
        }
    }
}
예제 #9
0
파일: search.php 프로젝트: nouphet/rata
 function xpress_global_search_base($mydirname, $queryarray, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB, $myts;
     require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/general_functions.php';
     $myts =& MyTextSanitizer::getInstance();
     $xp_prefix = preg_replace('/wordpress/', 'wp', $mydirname);
     if ($userid) {
         $wp_uid = xoops_uid_to_wp_uid(intval($userid), $mydirname);
     }
     $prefix = XOOPS_DB_PREFIX . '_' . $xp_prefix;
     $posts_tables = get_table_list($prefix, 'posts');
     $i = 0;
     $ret = array();
     foreach ($posts_tables as $views_table) {
         $mid_prefix = get_multi_mid_prefix($prefix, 'posts', $views_table);
         $option_table = $prefix . $mid_prefix . 'options';
         $time_difference = get_blog_option($option_table, 'gmt_offset');
         $blog_url = get_blog_option($option_table, 'siteurl');
         $pattern = '/.*' . $mydirname . '/';
         $mid_url = preg_replace($pattern, '', $blog_url);
         $mid_url = preg_replace('/\\//', '', $mid_url);
         if (!empty($mid_url)) {
             $mid_url = $mid_url . '/';
         }
         $blog_name = get_blog_option($option_table, 'blogname');
         if (empty($mid_url)) {
             $blog_name = '';
         } else {
             $blog_name = $blog_name . ':: ';
         }
         $now = date('Y-m-d H:i:s', time() + $time_difference * 3600);
         $where = "(post_status = 'publish') AND (post_date <= '" . $now . "') AND (post_type <> 'revision') AND (post_type <> 'nav_menu_item') ";
         if (is_array($queryarray) && ($count = count($queryarray))) {
             $str_query = array();
             for ($j = 0; $j < $count; $j++) {
                 $str_query[] = "(post_title LIKE '%" . $queryarray[$j] . "%' OR post_content LIKE '%" . $queryarray[$j] . "%')";
             }
             $where .= " AND " . implode(" {$andor} ", $str_query);
         }
         if ($userid) {
             if ($wp_uid) {
                 $where .= " AND (post_author=" . $wp_uid . ")";
             } else {
                 $where .= " AND 0 ";
             }
         }
         $request = "SELECT * FROM " . $views_table . " WHERE " . $where;
         $request .= " ORDER BY post_date DESC";
         $result = $xoopsDB->query($request, $limit, $offset);
         while ($myrow = $xoopsDB->fetchArray($result)) {
             if ($myrow['post_type'] !== 'revision' && $myrow['post_type'] !== 'nav_menu_item') {
                 switch ($myrow['post_type']) {
                     case 'page':
                         $ret[$i]['link'] = $mid_url . '?page_id=' . $myrow['ID'];
                         break;
                     case 'post':
                     case '':
                         $ret[$i]['link'] = $mid_url . '?p=' . $myrow['ID'];
                         break;
                     default:
                         $ret[$i]['link'] = $mid_url . '?' . $myrow['post_type'] . '=' . $myrow['post_name'];
                 }
             }
             $ret[$i]['title'] = $blog_name . $myts->htmlSpecialChars($myrow['post_title']);
             $date_str = $myrow['post_date'];
             $yyyy = substr($date_str, 0, 4);
             $mm = substr($date_str, 5, 2);
             $dd = substr($date_str, 8, 2);
             $hh = substr($date_str, 11, 2);
             $nn = substr($date_str, 14, 2);
             $ss = substr($date_str, 17, 2);
             $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
             $ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'], $mydirname);
             $context = '';
             $text = $myrow['post_content'];
             // get context for module "search"
             $showcontext = empty($_GET['showcontext']) ? 0 : 1;
             if (function_exists('search_make_context') && $showcontext) {
                 if (function_exists('easiestml')) {
                     $text = easiestml($text);
                 }
                 $full_context = strip_tags($text);
                 $context = search_make_context($full_context, $queryarray);
             }
             $ret[$i]['context'] = $context;
             $i++;
         }
     }
     return $ret;
 }
예제 #10
0
 public function lp3()
 {
     // 首先获取所有表
     if ($tables = get_table_list(db())) {
         $data['tables'] = $tables;
     }
     $data['actions'] = $actions = array('list', 'insert', 'remove', 'update');
     $kv = new SaeKV();
     $kv->init();
     foreach ($tables as $table) {
         foreach ($actions as $action) {
             $data['in_code'][$table][$action] = $kv->get('iosetting_input_' . $table . '_' . $action);
             $data['out_code'][$table][$action] = $kv->get('iosetting_output_' . $table . '_' . $action);
             $data['ainfo'][$table][$action] = unserialize($kv->get('msetting_' . $table . '_' . $action));
             $data['in_code'][$table][$action] = $kv->get('iosetting_input_' . $table . '_' . $action);
             $data['out_code'][$table][$action] = $kv->get('iosetting_output_' . $table . '_' . $action);
             $fields = get_fields($table);
             foreach ($fields as $field) {
                 $finfo = unserialize($kv->get('msetting_' . $table . '_' . $action . '_' . $field));
                 if ($finfo['required'] == 1) {
                     $data['requires'][$table][$action][] = $field;
                 }
                 if ($finfo['input'] == 1) {
                     $data['inputs'][$table][$action][] = $field;
                 }
                 if ($finfo['output'] == 1) {
                     $data['outputs'][$table][$action][] = $field;
                 }
                 if ($finfo['like'] == 1) {
                     $data['likes'][$table][$action][] = $field;
                 }
                 if ($finfo['equal'] == 1) {
                     $data['equals'][$table][$action][] = $field;
                 }
             }
         }
         // 取得自定义接口
         $data['my_actions'] = get_data("SELECT * FROM `__meta_code` WHERE `table` = '" . s($table) . "' ORDER BY `id` DESC");
     }
     ob_start();
     @extract($data);
     require AROOT . 'meta/api.sample.php';
     $code = ob_get_contents();
     ob_end_clean();
     $code = "<?php \r\n" . $code . '?>';
     include AROOT . 'function/phpbeautifier/PhpBeautifier.inc';
     $beautify = new PhpBeautifier();
     $beautify->tokenSpace = true;
     //put space between tokens
     $beautify->blockLine = true;
     //put empty lines between blocks of code (if, while etc)
     $beautify->optimize = false;
     //optimize strings (for now), if a double quoted string does not contain variables of special carachters transform it to a single quoted string to save parsing time
     if (v('read') == 1) {
         highlight_string($beautify->process($code));
     } else {
         echo $beautify->process($code);
     }
     //echo $code;
     /*
     $smarty->assign( 'data' ,  $data  );
     echo $smarty->fetch( AROOT . 'meta/api.sample.php' );
     */
     //echo 'lp3';
 }