예제 #1
0
function b_d3dside_category_edit($options)
{
    $mydirname = empty($options[0]) ? 'd3diary' : $options[0];
    require_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
    $d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_side_category");
    $func =& $d3dConf->func;
    $max_entry = empty($options[1]) ? 10 : intval($options[1]);
    $now_order = empty($options[2]) ? 'time' : trim($options[2]);
    $this_template = empty($options[3]) ? 'db:' . $mydirname . '_block_side_category.html' : trim($options[3]);
    $limit_self = empty($options[4]) ? 0 : (int) $options[4];
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    $orders = array('time' => _MB_D3DIARY_ORDERTIMED, 'posted' => _MB_D3DIARY_ORDERPOSTED);
    $order_options = '';
    foreach ($orders as $order_value => $order_name) {
        $selected = $order_value == $now_order ? "selected='selected'" : "";
        $order_options .= "<option value='{$order_value}' {$selected}>{$order_name}</option>\n";
    }
    $limitselfs = array(0 => _MB_D3DIARY_LIMITSELF_NO, 1 => _MB_D3DIARY_LIMITSELF_ALL, 2 => _MB_D3DIARY_LIMITSELF_OTHER, 3 => _MB_D3DIARY_LIMITSELF_PERSON);
    $limitself_options = '';
    foreach ($limitselfs as $limitself_value => $limitself_name) {
        $selected = $limitself_value == $limit_self ? "selected='selected'" : "";
        $limitself_options .= "<option value='{$limitself_value}' {$selected}>{$limitself_name}</option>\n";
    }
    $form = "\n\t\t<input type='hidden' name='options[0]' value='{$mydirname}' />\n\t\t<label for='o1'>" . sprintf(_MB_D3DIARY_DISPLAY, "</label><input type='text' size='4' name='options[1]' id='o1' value='{$max_entry}' style='text-align:right;' />") . "\n\t\t<br />\n\t\t<label for='orderrule'>" . _MB_D3DIARY_ORDERRULE . "</label>&nbsp;:\n\t\t<select name='options[2]' id='orderrule'>\n\t\t\t{$order_options}\n\t\t</select>\n\t\t<br />\n\t\t<label for='this_template'>" . _MB_D3DIARY_THISTEMPLATE . "</label>&nbsp;:\n\t\t<input type='text' size='60' name='options[3]' id='this_template' value='" . $func->htmlspecialchars($this_template) . "' />\n\t\t<br />\n\t\t<label for='limitself'>" . _MB_D3DIARY_LIMITSELF . "</label>&nbsp;:\n\t\t<select name='options[4]' id='limitself'>\n\t\t\t{$limitself_options}\n\t\t</select>\n\t\t<br />\n\t\n";
    return $form;
}
예제 #2
0
 function d3diary_new_base($mydirname, $limit = 0, $offset = 0)
 {
     if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
         die('Invalid mydirname');
     }
     $constpref = '_MB_' . strtoupper($mydirname);
     $_enc = _CHARSET;
     $URL_MOD = XOOPS_URL . "/modules/" . $mydirname;
     $mytrustdirpath = dirname(dirname(__FILE__));
     //include_once "$mytrustdirpath/include.php";
     require_once $mytrustdirpath . "/class/d3diaryConf.class.php";
     require_once $mytrustdirpath . "/class/photo.class.php";
     $d3dConf = D3diaryConf::getInstance($mydirname, 0, "whatsnew");
     $func =& $d3dConf->func;
     $myts =& $d3dConf->myts;
     $photo =& D3diaryPhoto::getInstance();
     $uid = $d3dConf->uid;
     //$req_uid = $d3dConf->req_uid; // overrided by d3dConf
     $req_uid = 0;
     // overrided by d3dConf
     $entry = $func->get_blist_tstamp($req_uid, $uid, $limit, false, $mytstamp);
     // dosort = false, byref $mytstamp
     // random photos
     $d3dConf->get_new_bids($got_bids);
     $photo->bids = $got_bids;
     $photo->readrand_mul($mydirname);
     foreach ($photo->photos as $i => $_photo) {
         $entry[$i]['photo'] = $_photo['pid'] . $_photo['ptype'];
     }
     unset($photo->photos);
     // comment counts, newest comments
     list($yd_comment, $yd_com_key) = $func->get_commentlist(0, $uid, 100, true, true);
     if (!empty($yd_comment)) {
         foreach ($yd_comment as $_com) {
             $i = (int) $_com['bid'];
             $entry[$i]['com_num'] = (int) $_com['com_num'];
         }
     }
     $ret = array();
     if (!empty($entry)) {
         array_multisort($mytstamp, SORT_DESC, $entry);
         $i = 0;
         foreach ($entry as $b => $e) {
             $entry_temp[$i] = $e;
             $ret[$i]['description'] = trim($func->substrTarea($e['diary'], $e['dohtml'], 500, true));
             $ret[$i]['link'] = $e['url'];
             $ret[$i]['cname'] = $myts->makeTboxData4Show($e['cname']);
             $ret[$i]['cat_link'] = $URL_MOD . "/index.php?page=category&amp;cid=" . $e['cid'];
             $ret[$i]['title'] = $e['title'];
             $ret[$i]['time'] = $e['tstamp'];
             $ret[$i]['uid'] = $e['uid'];
             $ret[$i]['hits'] = $e['view'];
             $ret[$i]['replies'] = !empty($e['com_num']) ? $e['com_num'] : 0;
             $ret[$i]['image'] = !empty($e['photo']) ? $URL_MOD . "/upimg/" . $e['photo'] : "";
             $ret[$i]['id'] = $e['bid'];
             $i++;
         }
     }
     return $ret;
 }
예제 #3
0
 function attachfile_check_download_permission_plugin($target_id)
 {
     //$mydirname , $module_dirname , $mytrustdirname , $targettrustdirname
     // emulate d3diary
     $mytrustdirname = $this->target_trustdirname;
     $mytrustdirpath = XOOPS_TRUST_PATH . '/modules/' . $mytrustdirname;
     $mydirname = $this->target_dirname;
     include_once $mytrustdirpath . '/class/diary.class.php';
     include_once $mytrustdirpath . '/class/category.class.php';
     include_once $mytrustdirpath . '/class/d3diaryConf.class.php';
     $diary = new D3diaryDiary();
     $cat = new D3diaryCategory();
     $diary->bid = $target_id;
     $diary->readdb($mydirname);
     if (empty($diary->uid)) {
         return false;
     }
     $d3dConf =& D3diaryConf::getInstance($mydirname, (int) $diary->uid, "attachfile");
     $d3dConf->mPerm->get_allowed_openarea();
     $uid = $d3dConf->uid;
     $cat->uid = $diary->uid;
     $cat->cid = $cid = $diary->cid;
     $cat->getchildren($mydirname);
     $_tmp_isfriend = $d3dConf->mPerm->check_is_friend($diary->uid);
     $_tmp_isfriend2 = $d3dConf->mPerm->check_is_friend2($diary->uid);
     $_tmp_op = intval($d3dConf->dcfg->openarea);
     list($_got_op, $_slctd_op, $_tmp_gperms, $_tmp_pperms) = $d3dConf->mPerm->override_openarea($_tmp_op, intval($diary->openarea), intval($cat->openarea), $diary->vgids, $diary->vpids, $cat->vgids, $cat->vpids);
     $yd_data['openarea'] = $_got_op;
     // var_dump($_tmp_gperms); var_dump($_tmp_pperms);
     $yd_data['can_disp'] = $d3dConf->mPerm->can_display($diary->uid, $_got_op, $diary->create_time, $_tmp_isfriend, $_tmp_isfriend2, $_tmp_gperms, $_tmp_pperms);
     return $yd_data['can_disp'];
 }
 public function __construct($d3forum_dirname, $target_dirname, $target_trustdirname = '')
 {
     parent::__construct($d3forum_dirname, $target_dirname, $target_trustdirname);
     $mydirname = $this->mydirname;
     require_once dirname(__FILE__) . '/d3diaryConf.class.php';
     $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, "d3comment");
     $this->mPerm =& $this->d3dConf->mPerm;
     $this->func =& $this->d3dConf->func;
     $this->mod_config =& $this->d3dConf->mod_config;
 }
예제 #5
0
 function d3diary_onuninstall_base($module, $mydirname)
 {
     // transations on module uninstall
     global $ret;
     // TODO :-D
     require dirname(__FILE__) . '/class/d3diaryConf.class.php';
     $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "onuninstall");
     $func =& $d3dConf->func;
     // for Cube 2.1
     if (defined('XOOPS_CUBE_LEGACY')) {
         $root =& XCube_Root::getSingleton();
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($mydirname) . '.Success', 'd3diary_message_append_onuninstall');
         $ret = array();
     } else {
         if (!is_array($ret)) {
             $ret = array();
         }
     }
     $db =& Database::getInstance();
     $mid = $module->getVar('mid');
     // TABLES (loading mysql.sql)
     $sql_file_path = dirname(__FILE__) . '/sql/mysql.sql';
     $prefix_mod = $db->prefix() . '_' . $mydirname;
     if (file_exists($sql_file_path)) {
         $ret[] = "SQL file found at <b>" . $func->htmlspecialchars($sql_file_path) . "</b>.<br  /> Deleting tables...<br />";
         $sql_lines = file($sql_file_path);
         foreach ($sql_lines as $sql_line) {
             if (preg_match('/^CREATE TABLE \\`?([a-zA-Z0-9_-]+)\\`? /i', $sql_line, $regs)) {
                 $sql = 'DROP TABLE ' . addslashes($prefix_mod . '_' . $regs[1]);
                 if (!$db->query($sql)) {
                     $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>' . $func->htmlspecialchars($prefix_mod . '_' . $regs[1]) . '<b>.</span><br />';
                 } else {
                     $ret[] = 'Table <b>' . $func->htmlspecialchars($prefix_mod . '_' . $regs[1]) . '</b> dropped.<br />';
                 }
             }
         }
     }
     // TEMPLATES (Not necessary because modulesadmin removes all templates)
     /* $tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
     	$templates =& $tplfile_handler->find( null , 'module' , $mid ) ;
     	$tcount = count( $templates ) ;
     	if( $tcount > 0 ) {
     		$ret[] = 'Deleting templates...' ;
     		for( $i = 0 ; $i < $tcount ; $i ++ ) {
     			if( ! $tplfile_handler->delete( $templates[$i] ) ) {
     				$ret[] = '<span style="color:#ff0000;">ERROR: Could not delete template '.$templates[$i]->getVar('tpl_file','s').' from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b></span><br />';
     			} else {
     				$ret[] = 'Template <b>'.$templates[$i]->getVar('tpl_file','s').'</b> deleted from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b><br />';
     			}
     		}
     	}
     	unset($templates); */
     return true;
 }
예제 #6
0
function b_d3dside_comment_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 10 : intval( $options[1] ) ;
	$now_order = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_side_comment.html' : trim( $options[3] ) ;
	$limit_self = empty( $options[4] ) ? 0 : (int)$options[4] ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	
	$d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_side_comment");
	$func =& $d3dConf->func ;
	$mod_config =& $d3dConf->mod_config ;
	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	if( $limit_self == 1 ) {				// always show diarylist page
		$req_uid = 0 ;
	} elseif( $limit_self == 2 && $req_uid > 0 ) {		// not show for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid == 0 ) {		// not show except for personal page
		return ;
	}

		list( $yd_comment, $yd_com_key ) =  $func->get_commentlist ($req_uid,$uid,$max_entry,false);

		$lang = array();
		$constpref = "_MB_" . strtoupper( $mydirname ) ;
		$lang['more'] = constant($constpref.'_COMMENT_LIST');

		$block="";

		$block['yd_comment'] = $yd_comment;
		$block['yd_com_key'] = $yd_com_key;
		$block['yd_uid'] = $req_uid;
		$block['lang'] = $lang;
		$block['mydirname'] = $mydirname;
		$block['mod_config'] = $mod_config ;
	
	$d3dConf->debug_appendtime('b_side_comment');

		if( empty( $options['disable_renderer'] ) ) {
			require_once XOOPS_ROOT_PATH.'/class/template.php' ;
			$tpl = new XoopsTpl() ;
			$tpl->assign( 'block' , $block ) ;
			$ret['content'] = $tpl->fetch( $this_template ) ;
			return $ret ;
		} else {
			return $block ;
		}
}
예제 #7
0
function b_d3diary_bloggerlist_show( $options ){

	global $xoopsUser,$xoopsDB;
	
	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 10 : intval( $options[1] ) ;
	$params['order'] = $now_order = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_bloggerlist.html' : trim( $options[3] ) ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	$constpref = '_MB_' . strtoupper( $mydirname ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	$d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_bloggerlist");
	$func =& $d3dConf->func ;
	$mod_config =& $d3dConf->mod_config ;

	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	$params['ofst_key'] = "bgbofst" ;
	$_offset_ = $func->getpost_param($params['ofst_key']);
	$offset = isset($_offset_) ?(int)$_offset_ : 0;

	list( $blogger, $blogger2, $bloggernavi ) = $func->get_bloggerlist ( $req_uid, $uid, $max_entry, $offset, $params );

	$block="";

	$block['blogger'] = $blogger;
	$block['blogger2'] = $blogger2;
	$block['bloggernavi'] = $bloggernavi;
	$block['mydirname'] = $mydirname;
	$block['mod_config'] = $mod_config;
	$block['lang']['other'] = constant($constpref.'_OTHER');
	$block['lang']['more'] = constant($constpref.'_MORE');
	$block['lang']['newdiary'] = constant($constpref.'_NEWDIARY');
	$block['lang']['newphoto'] = constant($constpref.'_NEWPHOTO');
	
	$d3dConf->debug_appendtime('b_bloggerlist');

	if( empty( $options['disable_renderer'] ) ) {
		require_once XOOPS_ROOT_PATH.'/class/template.php' ;
		$tpl = new XoopsTpl() ;
		$tpl->assign( 'block' , $block ) ;
		$ret['content'] = $tpl->fetch( $this_template ) ;
		return $ret ;
	} else {
		return $block ;
	}

}
예제 #8
0
	function postFilter()
	{
		if( $this->isMobile() === true ) {

			include_once dirname(__FILE__).'/class/d3diaryConf.class.php';
			$d3dConf = & D3diaryConf::getInstance ( $this->mydirname, 0, "preload" ) ;
			$this->mod_config =& $d3dConf->mod_config ;

			// Overrides Module Configs
			$this->mod_config['block_diarynum'] = $this->mobile_diarynum;
			$this->mod_config['preview_charmax'] = $this->mobile_charmax;

		}
	}
예제 #9
0
function b_d3dside_friends_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 10 : intval( $options[1] ) ;
	$now_order = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_side_friends.html' : trim( $options[3] ) ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	
	$d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_side_fiends");
	$func =& $d3dConf->func ;
	$mPerm =& $d3dConf->mPerm ;

	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	//if( $req_uid > 0 || $uid > 0 ) {
	if( $req_uid > 0 ) {
		$block="";
		if ( $mPerm->d3d_conf['use_friend'] === true ) {
			list( $yd_friends, $yd_friendsnavi ) =  $func->get_friends ($mPerm->req_friends);

			$lang = array();
			$constpref = "_MB_" . strtoupper( $mydirname ) ;
			$lang['more'] = constant($constpref.'_DIARY_FRIENDSVIEW');

			$block['yd_friends'] = $yd_friends;
			$block['yd_friendsnavi'] = $yd_friendsnavi;
			$block['yd_uid'] = $req_uid;
			$block['lang'] = $lang;
			$block['mydirname'] = $mydirname;
		}
	
	$d3dConf->debug_appendtime('b_side_friends');

		if( empty( $options['disable_renderer'] ) ) {
			require_once XOOPS_ROOT_PATH.'/class/template.php' ;
			$tpl = new XoopsTpl() ;
			$tpl->assign( 'block' , $block ) ;
			$ret['content'] = $tpl->fetch( $this_template ) ;
			return $ret ;
		} else {
			return $block ;
		}
	}

}
예제 #10
0
 /**
  * Prepare driver before mount volume.
  * Connect to db, check required tables and fetch root path
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function init()
 {
     $this->mydirname = $mydirname = $this->options['mydirname'];
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     if (!file_exists($langmanpath)) {
         return false;
     }
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read('main.php', $mydirname, 'd3diary');
     $d3dTrustDir = XOOPS_TRUST_PATH . '/modules/d3diary';
     include_once $d3dTrustDir . '/class/d3diaryConf.class.php';
     $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, 'photolist');
     if (!is_object($this->d3dConf)) {
         return false;
     }
     mysql_set_charset('utf8');
     // make catgory tree
     $func =& $this->d3dConf->func;
     $uid = $this->d3dConf->uid;
     $cat = $func->get_categories($uid, $uid);
     $this->catTree = array();
     $this->catTree['root'] = array('subcats' => array());
     $pcid = 'root';
     //-1
     foreach ($cat as $_cat) {
         if (100 <= $_cat['blogtype']) {
             continue;
         }
         $this->catTree[$_cat['cid']] = array('name' => $_cat['cname'], 'pcid' => $_cat['subcat'] && $pcid ? $pcid : 'root');
         if ($_cat['subcat']) {
             if ($pcid !== 'root') {
                 if (!isset($this->catTree[$pcid]['subcats'])) {
                     $this->catTree[$pcid]['subcats'] = array();
                 }
                 $this->catTree[$pcid]['subcats'][] = $_cat['cid'];
             }
         } else {
             $pcid = $_cat['cid'];
             $this->catTree['root']['subcats'][] = $pcid;
         }
     }
     if (!isset($this->options['extAnother']) || strtolower($this->options['extAnother']) !== 'off') {
         $another_pcid = isset($this->catTree[0]) ? 0 : 'root';
         $this->catTree[-1] = array('name' => 'Another', 'pcid' => $another_pcid);
         $this->catTree[$another_pcid]['subcats'][] = -1;
     }
     return true;
 }
예제 #11
0
파일: preload.php 프로젝트: nao-pon/d3diary
 public function postFilter()
 {
     $mObj = $this->mRoot->mContext->mXoopsModule;
     if (is_a($mObj, 'XoopsModule') && $mObj->get('trust_dirname') === 'd3diary') {
         if ($this->isMobile() === true) {
             $root_setting_file = XOOPS_ROOT_PATH . '/modules/' . $this->mydirname . '/include/preload.inc.php';
             $trust_setting_file = dirname(__FILE__) . '/include/preload.inc.php';
             if (file_exists($root_setting_file)) {
                 include_once $root_setting_file;
             } elseif (file_exists($trust_setting_file)) {
                 include_once $trust_setting_file;
             }
             include_once dirname(__FILE__) . '/class/d3diaryConf.class.php';
             $d3dConf =& D3diaryConf::getInstance($this->mydirname, 0, "preload");
             $this->mod_config =& $d3dConf->mod_config;
             // Overrides Module Configs
             $this->mod_config['block_diarynum'] = $this->mobile_diarynum;
             $this->mod_config['preview_charmax'] = $this->mobile_charmax;
         }
         // for ckeditor4
         $this->mRoot->mDelegateManager->add('Ckeditor4.Utils.PreBuild_ckconfig', array($this, 'ckeditor4PreBuild'));
     }
 }
예제 #12
0
function b_d3dside_tagcroud_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 30 : intval( $options[1] ) ;
	$params['order'] = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_side_tagcroud.html' : trim( $options[3] ) ;
	$limit_self = empty( $options[4] ) ? 0 : (int)$options[4] ;
	$max_size = empty( $options[5] ) ? 160 : (int)$options[5] ;	// maximum font-size (%)
	$min_size = empty( $options[6] ) ?  80 : (int)$options[6] ;	// minimum font-size (%)

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	
	$d3dConf = & D3diaryConf::getInstance($mydirname, 0, "b_side_tagcroud");
	$func =& $d3dConf->func ;
	$mPerm =& $d3dConf->mPerm ;
	$mod_config =& $d3dConf->mod_config ;
	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	//var_dump($req_uid);
	
	
	if( $limit_self == 1 ) {				// always show diarylist page
		$req_uid = 0 ;
	} elseif( $limit_self == 2 && $req_uid > 0 ) {		// not show for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid == 0 ) {		// not show except for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid > 0 && $d3dConf->q_fr==1 ) {	// case of show friend page
		$req_uid = 0 ;
	}

	if ((int)$mod_config['use_tag'] >= 1) {
		// create base url
		//$page = $d3dConf->page ;
		//$q_mode = $d3dConf->q_mode ;
		$q_cid = $d3dConf->q_cid ;
		//$q_year = $d3dConf->q_year ;
		//$q_month = $d3dConf->q_month ;
		//$q_day = $d3dConf->q_day ;
		$q_fr = $d3dConf->q_fr ;
		
		$where = "";
		if($req_uid > 0 ){
			if ( $q_fr==1 ) {
				$where= "uid IN (". implode(',', $mPerm->req_friends).")";
			} else {
				$where= 'uid='. intval($req_uid);
			}
		}
		$base_url = $d3dConf->urluppr.$d3dConf->urlbase.$d3dConf->url4ex_tag. "&amp;";

		$params['ofst_key'] = "tofst" ;
		$tofst = $func->getpost_param($params['ofst_key']);

		switch ($params['order']) {
			case 'tag_name DESC' :
				$params['order'] = 'tag_name DESC'; break ;
			case 'quantity ASC' :
				$params['order'] = 'quantity ASC'; break ;
			case 'quantity DESC' :
				$params['order'] = 'quantity DESC'; break ;
			case 'reg_unixtime ASC' :
				$params['order'] = 'reg_unixtime ASC'; break ;
			case 'reg_unixtime DESC' :
				$params['order'] = 'reg_unixtime DESC'; break ;
			case 'tag_name ASC' :
			default :
				$params['order'] = 'tag_name ASC';
		}

		// getTagCloud ($where, $min_size, $max_size, $max_displays, $offset_page)
		list( $tagCloud, $tagnavi ) = $func->getTagCloud($where, $min_size, $max_size, $max_entry, $tofst, $params);

		$lang = array();
		//$lang['title'] = constant('_MD_CTITLE');

		$block="";

		$block['tagCloud'] = $tagCloud;
		$block['use_tag'] = $mod_config['use_tag'];
		$block['tagnavi'] = $tagnavi;
		$block['lang'] = $lang;
		$block['mydirname'] = $mydirname;
		$block['base_url'] = $base_url;
		$block['cid'] = $q_cid ;
		$block['tofst'] = $tofst ;
		$block['fr'] = $q_fr ;
	}

	$d3dConf->debug_appendtime('b_side_tagcroud');

		if( empty( $options['disable_renderer'] ) ) {
			require_once XOOPS_ROOT_PATH.'/class/template.php' ;
			$tpl = new XoopsTpl() ;
			$tpl->assign( 'block' , $block ) ;
			$ret['content'] = $tpl->fetch( $this_template ) ;
			return $ret ;
		} else {
			return $block ;
		}
}
예제 #13
0
function b_d3d_photolist_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 10 : (int)$options[1] ;
	$params['order'] = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$maxsize = empty( $options[3] ) ? 0 : (int)$options[3] ;
	if (!get_magic_quotes_gpc()) {
		$params['categories'] = empty( $options[4] ) ? array() : explode( ',', addslashes($options[4]) ) ;
		$params['tags'] = empty( $options[5] ) ? array() : explode( ',', addslashes($options[5]) ) ;
	} else {
		$params['categories'] = empty( $options[4] ) ? array() : explode( ',', $options[4] ) ;
		$params['tags'] = empty( $options[5] ) ? array() : explode( ',', $options[5] ) ;
	}
	$params['show_pinfo'] = empty( $options[6] ) ? false : true ;
	$params['max_info'] = empty( $options[7] ) ? 80 : intval( $options[7] ) ;
	$limit_self = empty( $options[8] ) ? 0 : (int)$options[8] ;
	$this_template = empty( $options[9] ) ? 'db:'.$mydirname.'_block_photolist.html' : trim( $options[9] ) ;
	$columns = empty( $options[10] ) ? 0 : (int)$options[10] ;
	$show_entrylink = empty( $options[11] ) ? false : true ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;
	$constpref = '_MB_' . strtoupper( $mydirname ) ;
	$_enc = _CHARSET;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	$d3dConf = & D3diaryConf::getInstance($mydirname, 0, "b_diarylist");
	$func =& $d3dConf->func ;
	$myts =& $d3dConf->myts;
	$mod_config =& $d3dConf->mod_config ;
	
	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	$params['ofst_key'] = "phbofst" ;
	$_offset_ = $func->getpost_param($params['ofst_key']);
	$offset = isset($_offset_) ?(int)$_offset_ : 0;


	if( $limit_self == 1 ) {				// always show all member's photos
		$req_uid = 0 ;
	} elseif( $limit_self == 2 && $req_uid > 0 ) {		// not show for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid == 0 ) {		// not show except for personal page
		return ;
	}

	if ($req_uid > 0) {
		$ret = $func->get_xoopsuname($req_uid) ;
		$yd_uname = $ret['uname'];
		$yd_name = $ret['name'];
	}

	$clear_num = array();
	if ( $columns > 0 ) {
		for($i=0; $i<$max_entry+5; $i++) {
			if ( ($i+1)%$columns == 0 ) {
				$clear_num[] = $i ;
			}
		}
	}

	$arr_req_uids = $req_uid > 0 ? array($req_uid) : array() ;
	$params['enc'] = _CHARSET ;
	$params['f_truncate']= true ;

	list( $entry, $photonavi ) = $func->get_photolist ( $arr_req_uids, $uid, $max_entry, $offset, $params );
	
/*	if (!empty($entry)) {
		$_enc =  _CHARSET ;
		$i=0;
		foreach ( $entry as $e ){
			if(empty($e)){break;}
			$entry[$i]['info'] = mb_substr(strip_tags($e['info']),0,$max_length,$_enc) ;
			$i++;
		}
	}
*/
		$lang = array();
		$block = array();
		
		switch ($params['order']) {
		case 'random' :
			$block['photonavi'] = "";
			$lang['order'] =  constant($constpref.'_B_ORDERRANDOM'); ;
			break;
		case 'time' :
		default :
			$block['photonavi'] = $photonavi;
			$lang['order'] =  constant($constpref.'_B_ORDERPOSTED'); ;
		}
			$lang['person'] = constant($constpref.'_PERSON');

		$lang['more'] = constant($constpref.'_MORE');
		
//		$block['entry'] = $entry_temp;
		$block['entry'] = $entry;
		$block['yd_uid'] = $req_uid;
		$block['yd_uname'] = !empty($yd_uname) ? htmlSpecialChars($yd_uname, ENT_QUOTES) : "" ;
		$block['yd_name'] = !empty($yd_name) ? htmlSpecialChars($yd_name, ENT_QUOTES) : "" ;
		$block['lang'] = $lang;
		$block['categories'] = implode(',', $params['categories']);
		$block['tags'] = implode(',', $params['tags']);
		$block['mydirname'] = $mydirname;
		$block['mod_config'] = $mod_config;
		//$block['max_length'] = $max_length;
		$block['maxsize'] = $maxsize;
		$block['show_pinfo'] = $params['show_pinfo'];
		$block['show_entrylink'] = $show_entrylink;
		$block['columns'] = $columns;
		$block['clear_num'] = $clear_num;

	$d3dConf->debug_appendtime('b_photolist');

	if( empty( $options['disable_renderer'] ) ) {
		require_once XOOPS_ROOT_PATH.'/class/template.php' ;
		$tpl = new XoopsTpl() ;
		$tpl->assign( 'block' , $block ) ;
		$ret['content'] = $tpl->fetch( $this_template ) ;
		return $ret ;
	} else {
		return $block ;
	}
}
예제 #14
0
파일: onupdate.php 프로젝트: naao/d3diary
 function d3diary_onupdate_base($module, $mydirname)
 {
     // transations on module update
     global $msgs;
     // TODO :-D
     require dirname(__FILE__) . '/class/d3diaryConf.class.php';
     $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "onupdate");
     $func =& $d3dConf->func;
     // for Cube 2.1
     if (defined('XOOPS_CUBE_LEGACY')) {
         $root =& XCube_Root::getSingleton();
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'd3diary_message_append_onupdate');
         $msgs = array();
     } else {
         if (!is_array($msgs)) {
             $msgs = array();
         }
     }
     $db =& Database::getInstance();
     $mid = $module->getVar('mid');
     // TABLES (write here ALTER TABLE etc. if necessary)
     // configs (Though I know it is not a recommended way...)
     $check_sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'";
     if (($result = $db->query($check_sql)) && ($myrow = $db->fetchArray($result)) && @$myrow['Type'] == 'varchar(30)') {
         $db->queryF("ALTER TABLE " . $db->prefix("config") . " MODIFY `conf_title` varchar(255) NOT NULL default '', MODIFY `conf_desc` varchar(255) NOT NULL default ''");
     }
     // 0.01 -> 0.01
     $check_sql = "SELECT blogtype FROM " . $db->prefix($mydirname . "_category");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD blogtype tinyint(3) NOT NULL default '0' AFTER corder");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD blogurl text AFTER blogtype");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD rss text AFTER blogurl");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD openarea tinyint(3) NOT NULL AFTER rss");
     }
     // 0.01 -> 0.01
     $check_sql = "SELECT openarea FROM " . $db->prefix($mydirname . "_diary");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " ADD openarea tinyint(3) unsigned NOT NULL AFTER create_time");
     }
     // 0.01 -> 0.01
     $check_sql = "SELECT cid FROM " . $db->prefix($mydirname . "_newentry");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_newentry") . " ADD cid int(10) unsigned NOT NULL default '0' AFTER uid");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_newentry") . " DROP PRIMARY KEY");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_newentry") . " ADD PRIMARY KEY (uid,cid)");
     }
     // 0.01 -> 0.01
     $check_sql = "SELECT tag_id FROM " . $db->prefix($mydirname . "_tag");
     if (!$db->query($check_sql)) {
         $db->queryF("CREATE TABLE " . $db->prefix($mydirname . "_tag") . " ( tag_id int(11) unsigned NOT NULL auto_increment, tag_name varchar(64) NOT NULL default '',\tbid int(11) unsigned NOT NULL default '0', uid mediumint(8) unsigned NOT NULL default '0',\ttag_group int(11) unsigned NOT NULL default '0', reg_unixtime int(11) unsigned NOT NULL default '0', PRIMARY KEY  (tag_id), KEY (tag_name), KEY (bid), KEY (uid) ) ENGINE=MyISAM");
     }
     // 0.01 -> 0.01
     // deleted dayly cout up
     $db->queryF("DELETE FROM " . $db->prefix($mydirname . "_cnt") . " WHERE ymd<>'1111-11-11'");
     // 0.05 -> 0.06
     // add dohtml
     $check_sql = "SELECT dohtml FROM " . $db->prefix($mydirname . "_diary");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " ADD dohtml tinyint(1) unsigned NOT NULL AFTER openarea");
     }
     $check_sql = "SELECT dohtml FROM " . $db->prefix($mydirname . "_category");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD dohtml tinyint(1) unsigned NOT NULL AFTER openarea");
     }
     // 0.11a2 -> 0.11a3
     // add subcategory
     $check_sql = "SELECT subcat FROM " . $db->prefix($mydirname . "_category");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD subcat tinyint(1) unsigned NOT NULL default '0' AFTER corder");
     }
     // 0.11a3 -> 0.12
     // add group and personal permissions
     $check_sql = "SELECT vgids FROM " . $db->prefix($mydirname . "_category");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD vgids varchar(255) default NULL AFTER dohtml");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " ADD vpids varchar(255) default NULL AFTER vgids");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " ADD vgids varchar(255) default NULL AFTER dohtml");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " ADD vpids varchar(255) default NULL AFTER vgids");
     }
     // add page view
     $check_sql = "SELECT view FROM " . $db->prefix($mydirname . "_diary");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " ADD view int(10) unsigned NOT NULL default '0' AFTER vpids");
     }
     // 0.12b2 -> 0.12b3
     // add photo info
     $check_sql = "SELECT info FROM " . $db->prefix($mydirname . "_photo");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_photo") . " ADD info text AFTER tstamp");
     }
     // 0.13c -> 0.14
     // cppy tag registered unixtime from each diary's create_time
     $sql = "SELECT t.tag_id, d.create_time FROM " . $db->prefix($mydirname . "_tag") . " t \n\t\t\t\tINNER JOIN " . $db->prefix($mydirname . "_diary") . " d USING(bid) \n\t\t\t\tWHERE t.bid=d.bid AND t.reg_unixtime='0'";
     if ($result = $db->query($sql)) {
         while ($dbdat = $db->fetchArray($result)) {
             $ctime = preg_split("/[-: ]/", $dbdat['create_time']);
             $tstamp = mktime($ctime[3], $ctime[4], $ctime[5], $ctime[1], $ctime[2], $ctime[0]);
             $sql = "UPDATE " . $db->prefix($mydirname . "_tag") . " SET \n\t\t\t\t\treg_unixtime='" . $tstamp . "' WHERE tag_id='" . $dbdat['tag_id'] . "'";
             $irs = $db->query($sql);
         }
     }
     // 0.15 -> 0.16
     // add mail post
     $check_sql = "SELECT mailpost FROM " . $db->prefix($mydirname . "_config");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD `mailpost` tinyint(1) unsigned NOT NULL default '0' AFTER openarea");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD `address` varchar(255) NOT NULL default '' AFTER mailpost");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD `keep` tinyint(1) NOT NULL default '0' AFTER address");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD `uptime` int(10) unsigned NOT NULL default '0' AFTER keep");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD `updated` int(10) unsigned NOT NULL default '0' AFTER uptime");
     }
     // 0.18
     // modify photo `tstamp` column data type from timestamp to datetime
     $result = $db->query("SELECT `tstamp` FROM " . $db->prefix($mydirname . "_photo"));
     static $link = null;
     if (is_null($link)) {
         //$db = XoopsDatabaseFactory::getDatabaseConnection();
         $link = is_object($db->conn) && get_class($db->conn) === 'mysqli' ? $db->conn : false;
     }
     if ($link) {
         $field_info = mysqli_fetch_field_direct($result, 0);
         $field_type = $field_info->type;
     } else {
         $field_type = mysql_field_type($result, 0);
     }
     if ($field_type == "timestamp") {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_photo") . " modify `tstamp` datetime NOT NULL");
         // for NULL tstamp, copy from diary's create_time
         $sql = "UPDATE " . $db->prefix($mydirname . "_photo") . " p \n\t\t\t\tINNER JOIN " . $db->prefix($mydirname . "_diary") . " d USING(bid) \n\t\t\t\tSET p.tstamp=d.create_time WHERE (p.tstamp IS NULL) OR (p.tstamp = '0000-00-00 00:00:00')";
         $result = $db->queryF($sql);
     }
     // 0.28 -> 0.29
     // add indexes for tables
     $check_sql = "SHOW INDEX FROM " . $db->prefix($mydirname . "_category") . " WHERE Key_name='idx_uid'";
     $result = $db->query($check_sql);
     $dbdat = $db->fetchArray($result);
     if (!$dbdat) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " \n\t\t\tADD KEY idx_uid (`uid`,`cid`,`blogtype`,`openarea`)");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_config") . " \n\t\t\tADD KEY idx_uid (`uid`,`blogtype`,`openarea`)");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_diary") . " \n\t\t\tADD KEY idx_uid (`uid`,`cid`,`openarea`,`create_time`)");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_newentry") . " \n\t\t\tADD KEY idx_uid (`uid`,`cid`,`blogtype`,`create_time`)");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_photo") . " \n\t\t\tADD KEY idx_uid (`uid`)");
     }
     $check_sql = "SHOW INDEX FROM " . $db->prefix($mydirname . "_cnt_ip") . " WHERE Column_name='acctime'";
     $result = $db->query($check_sql);
     $dbdat = $db->fetchArray($result);
     if (!$dbdat) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_cnt_ip") . " \n\t\t\tADD KEY `acctime` (`acctime`)");
     }
     // 0.44 -> 0.45
     // add show whole detail on the index page
     $check_sql = "SELECT showoption FROM " . $db->prefix($mydirname . "_category");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_category") . " \n\t\t\tADD `showoption` tinyint(1) unsigned NOT NULL default '0' AFTER openarea");
     }
     // TEMPLATES (all templates have been already removed by modulesadmin)
     $tplfile_handler =& xoops_gethandler('tplfile');
     $tpl_path = dirname(__FILE__) . '/templates';
     if ($handler = @opendir($tpl_path . '/')) {
         while (($file = readdir($handler)) !== false) {
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             $file_path = $tpl_path . '/' . $file;
             if (is_file($file_path)) {
                 $mtime = intval(@filemtime($file_path));
                 $tplfile =& $tplfile_handler->create();
                 $tplfile->setVar('tpl_source', file_get_contents($file_path), true);
                 $tplfile->setVar('tpl_refid', $mid);
                 $tplfile->setVar('tpl_tplset', 'default');
                 $tplfile->setVar('tpl_file', $mydirname . '_' . $file);
                 $tplfile->setVar('tpl_desc', '', true);
                 $tplfile->setVar('tpl_module', $mydirname);
                 $tplfile->setVar('tpl_lastmodified', $mtime);
                 $tplfile->setVar('tpl_lastimported', 0);
                 $tplfile->setVar('tpl_type', 'module');
                 if (!$tplfile_handler->insert($tplfile)) {
                     $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span>';
                 } else {
                     $tplid = $tplfile->getVar('tpl_id');
                     $msgs[] = 'Template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)';
                     // generate compiled file
                     include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
                     include_once XOOPS_ROOT_PATH . '/class/template.php';
                     if (!xoops_template_touch($tplid)) {
                         $msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b>.</span>';
                     } else {
                         $msgs[] = 'Template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> compiled.</span>';
                     }
                 }
             }
         }
         closedir($handler);
     }
     include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
     include_once XOOPS_ROOT_PATH . '/class/template.php';
     xoops_template_clear_module_cache($mid);
     return true;
 }
예제 #15
0
}
include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
if (defined('XOOPS_CUBE_LEGACY')) {
    include_once XOOPS_ROOT_PATH . '/modules/legacy/include/xoops2_system_constants.inc.php';
} else {
    include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
}
if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule']) {
    $gperm_handler =& xoops_gethandler('groupperm');
    $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
    $xoopsTpl->assign('xoops_iscommentadmin', $gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_COMMENT, $groups));
    include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/comment.php';
    $comment_config = $xoopsModule->getInfo('comments');
    $com_itemid = trim($comment_config['itemName']) != '' && isset($_GET[$comment_config['itemName']]) ? intval($_GET[$comment_config['itemName']]) : 0;
    require_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
    $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "xoopscomment");
    $func =& $d3dConf->func;
    if ($com_itemid > 0) {
        $com_mode = isset($_GET['com_mode']) ? $func->htmlspecialchars(trim($_GET['com_mode'])) : '';
        if ($com_mode == '') {
            if (is_object($xoopsUser)) {
                $com_mode = $xoopsUser->getVar('umode');
            } else {
                $com_mode = $xoopsConfig['com_mode'];
            }
        }
        $xoopsTpl->assign('comment_mode', $com_mode);
        if (!isset($_GET['com_order'])) {
            if (is_object($xoopsUser)) {
                $com_order = $xoopsUser->getVar('uorder');
            } else {
예제 #16
0
function b_d3dside_mlist_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 12 : intval( $options[1] ) ;
	$now_order = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_side_mlist.html' : trim( $options[3] ) ;
	$limit_self = empty( $options[4] ) ? 0 : (int)$options[4] ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	
	$d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_side_mlist");
	$func =& $d3dConf->func ;
	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	if( $limit_self == 1 ) {				// always show diarylist page
		$req_uid = 0 ;
	} elseif( $limit_self == 2 && $req_uid > 0 ) {		// not show for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid == 0 ) {		// not show except for personal page
		return ;
	}

	// create base url
	//$page = $d3dConf->page ;
	//$q_mode = $d3dConf->q_mode ;
	//$q_cid = $d3dConf->q_cid ;
	//$q_tag = $d3dConf->q_tag ;
	$q_fr = $d3dConf->q_fr ;

	if( $req_uid > 0 ) {
		$base_url = $d3dConf->urluppr.$d3dConf->urlbase.$d3dConf->url4ex_date."&amp;";
	} elseif( strcmp( $d3dConf->page, "photolist" ) == 0 ) {
		$base_url = $d3dConf->urluppr."page=photolist".$d3dConf->url4ex_date."&amp;";
	} else {
		$base_url = $d3dConf->urluppr.$d3dConf->urlbase_dlst.$d3dConf->url4ex_date."&amp;";
	}

	list( $yd_monlist, $yd_monthnavi ) =  $func->get_monlist ($req_uid, $uid, $max_entry );

		$lang = array();
		$constpref = "_MB_" . strtoupper( $mydirname ) ;
		$lang['year'] = constant($constpref.'_YEAR');
		$lang['month'] = constant($constpref.'_MONTH');

		$block="";

		$block['yd_monlist'] = $yd_monlist;
		$block['yd_monthnavi'] = $yd_monthnavi;
		$block['yd_uid'] = $req_uid;
		$block['lang'] = $lang;
		$block['mydirname'] = $mydirname;
		$block['base_url'] = $base_url;

	$d3dConf->debug_appendtime('b_side_mlist');

		if( empty( $options['disable_renderer'] ) ) {
			require_once XOOPS_ROOT_PATH.'/class/template.php' ;
			$tpl = new XoopsTpl() ;
			$tpl->assign( 'block' , $block ) ;
			$ret['content'] = $tpl->fetch( $this_template ) ;
			return $ret ;
		} else {
			return $block ;
		}
}
예제 #17
0
	global $xoopsUser ;
	if (is_object( @$xoopsUser )){
		$uid = intval($xoopsUser->getVar('uid'));
	} else {
		$uid = 0 ;
	}

	if($uid<=0) {
		redirect_header(XOOPS_URL.'/user.php',2,_MD_IVUID_ERR);
		exit();
	}

	$req_uid = $uid;

$d3dConf = & D3diaryConf::getInstance($mydirname, $req_uid, "usr_config");
$func =& $d3dConf->func ;
$dcfg =& $d3dConf->dcfg;
$myts =& $d3dConf->myts;
$mPerm =& $d3dConf->mPerm ;
$gPerm =& $d3dConf->gPerm ;
$mod_config =& $d3dConf->mod_config ;

//--------------------------------------------------------------------
// GET Initial Valuses
//--------------------------------------------------------------------

$uname = $d3dConf->uname;
$name = $d3dConf->name;
// get permission unames for each groupPermission
//$_tempGperm = $gPerm->getUidsByName( array('allow_edit') );
예제 #18
0
파일: search.php 프로젝트: naao/d3diary
 function d3diary_global_search_base($mydirname, $queryarray, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB, $xoopsUser;
     require dirname(__FILE__) . '/class/d3diaryConf.class.php';
     $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "search");
     $func =& $d3dConf->func;
     $mod_config =& $d3dConf->mod_config;
     // for sanitizing contents
     $myts =& $d3dConf->myts;
     $ret = array();
     #	if ( $userid != 0 ) {
     #		return $ret;
     #	}
     $uid = $d3dConf->uid;
     $editperm = 0;
     if ($d3dConf->mPerm->isadmin) {
         $editperm = 1;
     }
     $sql = "SELECT *\n\t\t\tFROM " . $xoopsDB->prefix($mydirname . '_config');
     $result = $xoopsDB->query($sql);
     $openarea = array();
     $is_friend = array();
     $is_friend2 = array();
     $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0;
     if ($showcontext == 1) {
         $q_diary = "d.diary,";
     } else {
         $q_diary = "";
     }
     if ($d3dConf->mPerm->isadmin) {
         $whr_openarea = " 1 ";
     } else {
         $_params4op['use_gp'] = $d3dConf->gPerm->use_gp;
         $_params4op['use_pp'] = $d3dConf->gPerm->use_pp;
         $whr_openarea = $d3dConf->mPerm->get_open_query("search", $_params4op);
     }
     $sql = "SELECT d.bid, d.uid, d.title, " . $q_diary . " d.create_time, d.openarea AS openarea_entry, \n\t\t\td.vgids AS vgids, d.vpids AS vpids, cfg.openarea AS openarea, \n\t\t\tc.openarea AS openarea_cat, c.vgids AS vgids_cat, c.vpids AS vpids_cat \n\t\tFROM " . $xoopsDB->prefix($mydirname . '_diary') . " d LEFT JOIN " . $xoopsDB->prefix($mydirname . '_config') . " cfg ON d.uid=cfg.uid LEFT JOIN " . $xoopsDB->prefix($mydirname . '_category') . " c ON (d.cid=c.cid AND (d.uid=c.uid OR c.uid='0')) WHERE " . $whr_openarea;
     if ($userid != 0) {
         $sql .= " AND d.uid=" . $userid . " ";
     }
     // because count() returns 1 even if a supplied variable
     // is not an array, we must check if $querryarray is really an array
     static $link = null;
     if (is_null($link)) {
         $link = is_object($xoopsDB->conn) && get_class($xoopsDB->conn) === 'mysqli' ? $xoopsDB->conn : false;
     }
     $count = count($queryarray);
     if ($count > 0 && is_array($queryarray)) {
         $queryarray[0] = $link ? mysqli_real_escape_string($link, $queryarray[0]) : mysql_real_escape_string($queryarray[0]);
         $sql .= " AND ((d.title LIKE '%{$queryarray['0']}%' OR d.diary LIKE '%{$queryarray['0']}%') ";
         for ($i = 1; $i < $count; $i++) {
             $queryarray[$i] = $link ? mysqli_real_escape_string($link, $queryarray[$i]) : mysql_real_escape_string($queryarray[$i]);
             $sql .= " {$andor} ";
             $sql .= " (d.title LIKE '%{$queryarray[$i]}%' OR d.diary LIKE '%{$queryarray[$i]}%') ";
         }
         $sql .= ") ";
     }
     //var_dump($sql);
     $sql .= " ORDER BY d.create_time DESC";
     $result = $xoopsDB->query($sql, $limit, $offset);
     $i = 0;
     while ($dbdat = $xoopsDB->fetchArray($result)) {
         $dbdat['uid'] = intval($dbdat['uid']);
         $ret[$i]['image'] = "images/pencil.gif";
         $ret[$i]['link'] = "index.php?page=detail&amp;bid=" . $dbdat['bid'];
         $ret[$i]['title'] = $func->htmlspecialchars($dbdat['title']);
         $tmparray = preg_split("/[-: ]/", $dbdat['create_time']);
         $ret[$i]['time'] = mktime($tmparray[3], $tmparray[4], $tmparray[5], $tmparray[1], $tmparray[2], $tmparray[0]);
         $ret[$i]['uid'] = $dbdat['uid'];
         if (!empty($dbdat['diary'])) {
             //start main
             $context = $dbdat['diary'];
             //			$context = strip_tags($myts->displayTarea(strip_tags($context)));
             //			$context = strip_tags($context);
             $context = $func->substrTarea($context, (int) $dbdat['dohtml'], $mod_config['preview_charmax'], true, "");
             $ret[$i]['context'] = d3diary_search_make_context3($context, $queryarray);
             //end main
         }
         $i++;
     }
     return $ret;
 }
예제 #19
0
function b_d3dside_category_show( $options ){

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_entry = empty( $options[1] ) ? 10 : intval( $options[1] ) ;
	$now_order = empty( $options[2] ) ? 'time' : trim( $options[2] ) ;
	$this_template = empty( $options[3] ) ? 'db:'.$mydirname.'_block_side_category.html' : trim( $options[3] ) ;
	$limit_self = empty( $options[4] ) ? 0 : (int)$options[4] ;

	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	$d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_side_category");
	$func =& $d3dConf->func ;

	$uid = $d3dConf->uid;
	$req_uid = $d3dConf->req_uid; // overrided by d3dConf
	
	if( $limit_self == 1 ) {				// always show diarylist page
		$req_uid = 0 ;
	} elseif( $limit_self == 2 && $req_uid > 0 ) {		// not show for personal page
		return ;
	} elseif( $limit_self == 3 && $req_uid == 0 ) {		// not show except for personal page
		return ;
	}

	// create base url
	//$page = $d3dConf->page ;
	//$q_tag = $d3dConf->q_tag ;
	//$q_year = $d3dConf->q_year ;
	//$q_month = $d3dConf->q_month ;
	//$q_day = $d3dConf->q_day ;
	$q_fr = $d3dConf->q_fr ;

		if( $req_uid > 0 ) {
			$base_url = $d3dConf->urluppr.$d3dConf->urlbase.$d3dConf->url4ex_cat."&amp;";
		} elseif( strcmp( $d3dConf->page, "photolist" ) == 0 ) {
			$base_url = $d3dConf->urluppr."page=photolist".$d3dConf->url4ex_cat."&amp;";
		} else {
			$base_url = $d3dConf->urluppr.$d3dConf->urlbase_dlst.$d3dConf->url4ex_cat."&amp;";
		}

		$catopt = $func->get_categories($req_uid,$uid,true);
		$tag_name = rawurlencode(rawurldecode($d3dConf->getpost_param('tag_name'))) ;
		//$tag_name = $d3dConf->getpost_param('tag_name') ;

		$lang = array();
		$constpref = '_MB_' . strtoupper( $mydirname ) ;
		$lang['edit'] = constant($constpref.'_CATEGORY_EDIT');

		$block="";

		$block['catopt'] = $catopt;
		$block['yd_uid'] = $req_uid;
		$block['lang'] = $lang;
		$block['mydirname'] = $mydirname;
		$block['base_url'] = $base_url;
		$block['tag_name'] = $tag_name ;
		$block['fr'] = $q_fr ;
	
	$d3dConf->debug_appendtime('b_side_category');

		if( empty( $options['disable_renderer'] ) ) {
			require_once XOOPS_ROOT_PATH.'/class/template.php' ;
			$tpl = new XoopsTpl() ;
			$tpl->assign( 'block' , $block ) ;
			$ret['content'] = $tpl->fetch( $this_template ) ;
			return $ret ;
		} else {
			return $block ;
		}
}
예제 #20
0
 /**
  * Prepare driver before mount volume.
  * Connect to db, check required tables and fetch root path
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function init()
 {
     $this->mydirname = $mydirname = $this->options['mydirname'];
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     if (!file_exists($langmanpath)) {
         return false;
     }
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read('main.php', $mydirname, 'd3diary');
     $d3dTrustDir = XOOPS_TRUST_PATH . '/modules/d3diary';
     include_once $d3dTrustDir . '/class/d3diaryConf.class.php';
     $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, 'photolist');
     if (!is_object($this->d3dConf)) {
         return false;
     }
     xoops_elFinder::dbSetCharset('utf8');
     // make catgory tree
     $func =& $this->d3dConf->func;
     $uid = $this->d3dConf->uid;
     $cat = $func->get_categories($uid, $uid);
     $this->catTree = array();
     $this->catTree['root'] = array('subcats' => array());
     $pcid = 'root';
     foreach ($cat as $_cat) {
         if (100 <= $_cat['blogtype'] || $_cat['subcat'] && !$_cat['num']) {
             continue;
         }
         $this->catTree[$_cat['cid']] = array('subcats' => array(), 'num' => $_cat['num'], 'name' => $_cat['cname'], 'pcid' => $_cat['subcat'] && $pcid ? $pcid : 'root');
         if ($_cat['subcat']) {
             if ($pcid !== 'root') {
                 $this->catTree[$pcid]['subcats'][$_cat['cid']] = $_cat['cname'];
             }
         } else {
             if ($pcid !== 'root' && !$this->catTree[$pcid]['subcats'] && !$this->catTree[$pcid]['num']) {
                 // no entry
                 unset($this->catTree[$this->catTree[$pcid]['pcid']]['subcats'][$pcid], $this->catTree[$pcid]);
             }
             $pcid = $_cat['cid'];
             $this->catTree['root']['subcats'][$pcid] = $_cat['cname'];
         }
     }
     if (!isset($this->options['extAnother']) || strtolower($this->options['extAnother']) !== 'off') {
         if (!isset($this->catTree[0])) {
             $this->catTree[0] = array('subcats' => array(), 'name' => _MD_NOCNAME, 'pcid' => 'root');
             $this->catTree['root']['subcats'][0] = $this->strToUTF8(_MD_NOCNAME);
         }
         $this->catTree[0]['name'] = $this->strToUTF8($this->catTree[0]['name']);
         $this->catTree[-1] = array('subcats' => array(), 'name' => 'Another', 'pcid' => 0);
         $this->catTree[0]['subcats'][-1] = 'Another';
     }
     if (is_null($this->options['syncChkAsTs'])) {
         $this->options['syncChkAsTs'] = true;
     }
     return true;
 }
예제 #21
0
include_once dirname( dirname(__FILE__) ).'/class/category.class.php';
include_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
include_once dirname( dirname(__FILE__) ).'/class/photo.class.php';

$diaryObj =& D3diaryDiary::getInstance();
$category =& D3diaryCategory::getInstance();
$photoObj =& D3diaryPhoto::getInstance();

//--------------------------------------------------------------------
// GET Initial Valuses
//--------------------------------------------------------------------

$myname = "photolist.php";
$yd_list=array(); $yd_com_key=""; $yd_monthnavi="";

$d3dConf =& D3diaryConf::getInstance($mydirname, 0, "photolist");
$func =& $d3dConf->func ;
$myts =& $d3dConf->myts;
$mPerm =& $d3dConf->mPerm ;
$gPerm =& $d3dConf->gPerm ;
$mod_config =& $d3dConf->mod_config ;

// query values
$uid = $d3dConf->uid;
$req_uid = $d3dConf->req_uid;
$b_tag_noquote = $d3dConf->q_tag_noquote;
$b_tag = $d3dConf->q_tag;
$yd_param = array() ;
$yd_param['cid'] = $req_cid = $d3dConf->q_cid;
$yd_param['mode'] = $d3dConf->q_mode;
$yd_param['friend'] = strcmp($yd_param['mode'], "friends")==0 ? 1 : $d3dConf->q_fr ;
예제 #22
0
<?php

//--------------------------------------------------------------------
// Config
//--------------------------------------------------------------------
include_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
$d3dConf =& D3diaryConf::getInstance($mydirname);
$func =& $d3dConf->func;
$mPerm =& $d3dConf->mPerm;
$gPerm =& $d3dConf->gPerm;
$uid = $d3dConf->uid;
if ($uid <= 0) {
    redirect_header(XOOPS_URL . '/user.php', 2, _MD_IVUID_ERR);
    exit;
}
$d3dConf->set_mod_config(0, "editcat_diaries");
// needs $dcfg
$uname = $d3dConf->uname;
$_tempGperm = $gPerm->getUidsByName(array('allow_edit'));
// check edit permission by group
if (!empty($_tempGperm['allow_edit'])) {
    if (!isset($_tempGperm['allow_edit'][$uid])) {
        redirect_header(XOOPS_URL . '/user.php', 2, _MD_NOPERM_EDIT);
        exit;
    }
} else {
    redirect_header(XOOPS_URL . '/user.php', 2, _MD_NOPERM_EDIT);
    exit;
}
unset($_tempGperm);
$req_uid = intval($func->getpost_param('req_uid'));
예제 #23
0
파일: mailpost.php 프로젝트: naao/d3diary
<?php

include_once dirname(dirname(__FILE__)) . '/class/diary.class.php';
include_once dirname(dirname(__FILE__)) . '/class/photo.class.php';
include_once dirname(dirname(__FILE__)) . '/class/tag.class.php';
include_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
$myname = "mailpost.php";
$diary =& D3diaryDiary::getInstance();
$photo =& D3diaryPhoto::getInstance();
$tag =& D3diaryTag::getInstance();
$d3dConf =& D3diaryConf::getInstance($mydirname, 0, "mailpost");
$func =& $d3dConf->func;
$uid = $d3dConf->uid;
// overrides $d3dConf->req_uid
$d3dConf->req_uid = $req_uid = isset($_GET['req_uid']) ? (int) $_GET['req_uid'] : $uid;
$mPerm =& $d3dConf->mPerm;
$mPerm->ini_set();
$gPerm =& $d3dConf->gPerm;
$mod_config =& $d3dConf->mod_config;
if ($mPerm->isadmin && 0 < $req_uid) {
    $query_req_uid = "&amp;req_uid=" . $req_uid;
    $rtn = $func->get_xoopsuname($req_uid);
    $uname = $rtn['uname'];
    $name = !empty($rtn['name']) ? $rtn['name'] : "";
    $rtn = $func->get_xoopsuname($uid);
    $myuname = $rtn['uname'];
    $myname = !empty($rtn['name']) ? $rtn['name'] : "";
} elseif (!$mPerm->isadmin && 0 < $req_uid && $req_uid != $uid) {
    redirect_header(XOOPS_URL . '/user.php', 2, _MD_NOPERM_EDIT);
    exit;
} else {
예제 #24
0
파일: imgresize.php 프로젝트: naao/d3diary
<?php

// image size conversion
$mytrustdirpath = dirname(dirname(__FILE__));
require_once $mytrustdirpath . "/class/d3diaryConf.class.php";
$d3dConf = D3diaryConf::getInstance($mydirname, 0, "imgresize");
$cachedir = $d3dConf->params['cachedir'];
// check input
if (empty($_GET['fname']) or preg_match("/\\.\\.\\//", $_GET['fname'])) {
    print_emptyimg();
    exit;
}
# http ~ remove domain
$fname = str_replace(XOOPS_URL . "/", "", $_GET['fname']);
$dirlist = str_replace("/", "_", $fname);
if (!empty($_GET['maxsize']) and intval($_GET['maxsize']) > 0 and !empty($fname)) {
    $maxsize = intval($_GET['maxsize']);
    $fname = XOOPS_ROOT_PATH . "/" . $fname;
    $cachename = $cachedir . "maxsize_" . $maxsize . "_" . $dirlist;
} else {
    print_emptyimg();
    exit;
}
// desplay cache
if (is_file($cachename)) {
    print_img($cachename);
    exit;
}
list($width, $height, $type, $attr) = getimagesize($fname);
// display small image as original size
if ($maxsize > $width and $maxsize > $height) {
예제 #25
0
function b_d3dside_tagcroud_edit($options)
{
    $mydirname = empty($options[0]) ? 'd3diary' : $options[0];
    require_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
    $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "b_side_tagcroud");
    $func =& $d3dConf->func;
    $max_entry = empty($options[1]) ? 30 : intval($options[1]);
    $now_order = empty($options[2]) ? 'time' : trim($options[2]);
    $this_template = empty($options[3]) ? 'db:' . $mydirname . '_block_side_tagcroud.html' : trim($options[3]);
    $limit_self = empty($options[4]) ? 0 : (int) $options[4];
    $max_size = empty($options[5]) ? 160 : (int) $options[5];
    // maximum font-size (%)
    $min_size = empty($options[6]) ? 80 : (int) $options[6];
    // minimum font-size (%)
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    $orders = array('tag_name ASC' => _MB_D3DIARY_TAGORDER_NAMEASC, 'tag_name DESC' => _MB_D3DIARY_TAGORDER_NAMEDESC, 'quantity ASC' => _MB_D3DIARY_TAGORDER_COUNTASC, 'quantity DESC' => _MB_D3DIARY_TAGORDER_COUNTDESC, 'reg_unixtime ASC' => _MB_D3DIARY_TAGORDER_TIMEASC, 'reg_unixtime DESC' => _MB_D3DIARY_TAGORDER_TIMEDESC);
    $order_options = '';
    foreach ($orders as $order_value => $order_name) {
        $selected = $order_value == $now_order ? "selected='selected'" : "";
        $order_options .= "<option value='{$order_value}' {$selected}>{$order_name}</option>\n";
    }
    $limitselfs = array(0 => _MB_D3DIARY_LIMITSELF_NO, 1 => _MB_D3DIARY_LIMITSELF_ALL, 2 => _MB_D3DIARY_LIMITSELF_OTHER, 3 => _MB_D3DIARY_LIMITSELF_PERSON);
    $limitself_options = '';
    foreach ($limitselfs as $limitself_value => $limitself_name) {
        $selected = $limitself_value == $limit_self ? "selected='selected'" : "";
        $limitself_options .= "<option value='{$limitself_value}' {$selected}>{$limitself_name}</option>\n";
    }
    $form = "\n\t\t<input type='hidden' name='options[0]' value='{$mydirname}' />\n\t\t<label for='o1'>" . sprintf(_MB_D3DIARY_DISPLAY, "</label><input type='text' size='4' name='options[1]' id='o1' value='{$max_entry}' style='text-align:right;' />") . "\n\t\t<br />\n\t\t<label for='orderrule'>" . _MB_D3DIARY_ORDERRULE . "</label>&nbsp;:\n\t\t<select name='options[2]' id='orderrule'>\n\t\t\t{$order_options}\n\t\t</select>\n\t\t<br />\n\t\t<label for='this_template'>" . _MB_D3DIARY_THISTEMPLATE . "</label>&nbsp;:\n\t\t<input type='text' size='60' name='options[3]' id='this_template' value='" . $func->htmlspecialchars($this_template) . "' />\n\t\t<br />\n\t\t<label for='limitself'>" . _MB_D3DIARY_LIMITSELF . "</label>&nbsp;:\n\t\t<select name='options[4]' id='limitself'>\n\t\t\t{$limitself_options}\n\t\t</select>\n\t\t<br />\n\t\t<label for='o5'>" . sprintf(_MB_D3DIARY_TAGSIZE_MAX, "</label><input type='text' size='4' name='options[5]' id='o5' value='{$max_size}' style='text-align:right;' />") . "\n\t\t<br />\n\t\t<label for='o6'>" . sprintf(_MB_D3DIARY_TAGSIZE_MIN, "</label><input type='text' size='4' name='options[6]' id='o6' value='{$min_size}' style='text-align:right;' />") . "\n\t\t<br />\n\t\n";
    return $form;
}
예제 #26
0
function b_d3diary_d3comlist_topics_edit($options)
{
    $mydirname = empty($options[0]) ? 'd3diary' : $options[0];
    require_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
    $d3dConf = D3diaryConf::getInstance($mydirname, 0, "b_d3comlist_topics");
    $func =& $d3dConf->func;
    $max_topics = empty($options[1]) ? 10 : intval($options[1]);
    $show_fullsize = empty($options[2]) ? false : true;
    $now_order = empty($options[3]) ? 'time' : trim($options[3]);
    $request_uid = empty($options[4]) ? 0 : intval($options[4]);
    $is_markup = empty($options[5]) ? false : true;
    $use_detail = empty($options[6]) ? false : true;
    $this_template = empty($options[7]) ? 'db:' . $mydirname . '_block_d3comlist_topics.html' : trim($options[7]);
    $use_aggre = empty($options[8]) ? false : true;
    $categories = empty($options[9]) ? array() : explode(',', $options[9]);
    $forums = empty($options[10]) ? array() : explode(',', $options[10]);
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    if ($show_fullsize) {
        $fullyes_checked = "checked='checked'";
        $fullno_checked = "";
    } else {
        $fullno_checked = "checked='checked'";
        $fullyes_checked = "";
    }
    $orders = array('time' => _MB_D3DIARY_ORDERTIMED, 'votes' => _MB_D3DIARY_ORDERVOTESD, 'points' => _MB_D3DIARY_ORDERPOINTSD, 'average' => _MB_D3DIARY_ORDERAVERAGED);
    $order_options = '';
    foreach ($orders as $order_value => $order_name) {
        $selected = $order_value == $now_order ? "selected='selected'" : "";
        $order_options .= "<option value='{$order_value}' {$selected}>{$order_name}</option>\n";
    }
    if ($is_markup) {
        $markupyes_checked = "checked='checked'";
        $markupno_checked = "";
    } else {
        $markupno_checked = "checked='checked'";
        $markupyes_checked = "";
    }
    if ($use_aggre) {
        $use_aggreyes_checked = "checked='checked'";
        $use_aggreno_checked = "";
    } else {
        $use_aggreno_checked = "checked='checked'";
        $use_aggreyes_checked = "";
    }
    if ($use_detail) {
        $use_detailyes_checked = "checked='checked'";
        $use_detailno_checked = "";
    } else {
        $use_detailno_checked = "checked='checked'";
        $use_detailyes_checked = "";
    }
    $categories = array_map('intval', $categories);
    $forums = array_map('intval', $forums);
    $form = "\n\t\t<input type='hidden' name='options[0]' value='{$mydirname}' />\n\t\t<label for='o1'>" . sprintf(_MB_D3DIARY_DISPLAY, "</label><input type='text' size='4' name='options[1]' id='o1' value='{$max_topics}' style='text-align:right;' />") . "\n\t\t<br />\n\t\t<label for='o2'>" . _MB_D3DIARY_DISPLAYF . "</label>&nbsp;:\n\t\t<input type='radio' name='options[2]' id='o21' value='1' {$fullyes_checked} /><label for='o21'>" . _YES . "</label>\n\t\t<input type='radio' name='options[2]' id='o20' value='0' {$fullno_checked} /><label for='o20'>" . _NO . "</label>\n\t\t<br />\n\t\t<label for='orderrule'>" . _MB_D3DIARY_ORDERRULE . "</label>&nbsp;:\n\t\t<select name='options[3]' id='orderrule'>\n\t\t\t{$order_options}\n\t\t</select>\n\t\t<br />\n\t\t<label for='request_uid'>" . _MB_D3DIARY_REQ_UID . "</label>&nbsp;:\n\t\t<input type='text' size='20' name='options[4]' id='request_uid' value='{$request_uid}' style='text-align:right;' />\n\t\t<br />\n\t\t<label for='ismarkup'>" . _MB_D3DIARY_MARKISUP . "</label>&nbsp;:\n\t\t<input type='radio' name='options[5]' id='markupyes' value='1' {$markupyes_checked} /><label for='markupyes'>" . _YES . "</label>\n\t\t<input type='radio' name='options[5]' id='markupno' value='0' {$markupno_checked} /><label for='markupno'>" . _NO . "</label>\n\t\t<br />\n\t\t<label for='o6'>" . _MB_D3DIARY_ASSIGNDETAIL . "</label>&nbsp;:\n\t\t<input type='radio' name='options[6]' id='o61' value='1' {$use_detailyes_checked} /><label for='o61'>" . _YES . "</label>\n\t\t<input type='radio' name='options[6]' id='o60' value='0' {$use_detailno_checked} /><label for='o60'>" . _NO . "</label>\n\t\t<br />\n\t\t<label for='this_template'>" . _MB_D3DIARY_THISTEMPLATE . "</label>&nbsp;:\n\t\t<input type='text' size='60' name='options[7]' id='this_template' value='" . $func->htmlspecialchars($this_template) . "' />\n\t\t<br />\n\t\t<hr />\n\t\t\n\t\t<label for='o8'>" . _MB_D3DIARY_USEAGGRE . "</label>&nbsp;:\n\t\t<input type='radio' name='options[8]' id='o81' value='1' {$use_aggreyes_checked} /><label for='o81'>" . _YES . "</label>\n\t\t<input type='radio' name='options[8]' id='o80' value='0' {$use_aggreno_checked} /><label for='o80'>" . _NO . "</label>\n\t\t<br />\n\t\t<label for='categories'>" . _MB_D3DIARY_CATLIMIT . "</label>&nbsp;:\n\t\t<input type='text' size='20' name='options[9]' id='categories' value='" . implode(',', $categories) . "' />" . _MB_D3DIARY_CATLIMITDSC . "\n\t\t<br />\n\t\t<label for='forums'>" . _MB_D3DIARY_FORUMLIMIT . "</label>&nbsp;:\n\t\t<input type='text' size='20' name='options[10]' id='forums' value='" . implode(',', $forums) . "' />" . _MB_D3DIARY_FORUMLIMITDSC . "\n\t\t<br />\n\t\n";
    return $form;
}
예제 #27
0
// Config
//--------------------------------------------------------------------
include_once dirname(dirname(__FILE__)) . '/class/category.class.php';
include_once dirname(dirname(__FILE__)) . '/class/d3diaryConf.class.php';
$category =& D3diaryCategory::getInstance();
global $xoopsUser;
if (is_object(@$xoopsUser)) {
    $uid = (int) $xoopsUser->getVar('uid');
} else {
    $uid = 0;
}
if ($uid <= 0) {
    redirect_header(XOOPS_URL . '/user.php', 2, _MD_IVUID_ERR);
    exit;
}
$d3dConf =& D3diaryConf::getInstance($mydirname, 0, "editcategory");
$func =& $d3dConf->func;
$myts =& $d3dConf->myts;
$mPerm =& $d3dConf->mPerm;
$gPerm =& $d3dConf->gPerm;
$mod_config =& $d3dConf->mod_config;
//--------------------------------------------------------------------
// GET Initial Values
//--------------------------------------------------------------------
$myname = "editcategory.php";
if ($uid <= 0) {
    redirect_header(XOOPS_URL . '/user.php', 2, _MD_IVUID_ERR);
    exit;
}
$d3dConf->req_uid = $req_uid = 0 < (int) $func->getpost_param('req_uid') ? (int) $func->getpost_param('req_uid') : $uid;
$mPerm->ini_set();
예제 #28
0
파일: d3diary.php 프로젝트: naao/d3diary
	$tzoffset_s2u : the offset from server to user
	$now : the result of time()
	$plugin = array('dirname'=>'dirname','name'=>'name','dotgif'=>'*.gif','options'=>'options')
	
	$plugin_returns[ DATE ][]
*/
$mydirname = $plugin['dirname'];
// set range (added 86400 second margin "begin" & "end")
$range_start_s = mktime(0, 0, 0, $this->month, 0, $this->year);
$range_end_s = mktime(0, 0, 0, $this->month + 1, 1, $this->year);
// options
//$options = explode( '|' , $plugin['options'] ) ;
$mytrustdirpath = XOOPS_TRUST_PATH . '/modules/d3diary';
require_once $mytrustdirpath . "/class/d3diaryConf.class.php";
require_once $mytrustdirpath . "/class/photo.class.php";
$d3dConf = D3diaryConf::getInstance($mydirname, 0, "whatsnew");
$myts =& $d3dConf->myts;
$uid = $d3dConf->uid;
//$req_uid = $d3dConf->req_uid; // overrided by d3dConf
$req_uid = 0;
// overrided by d3dConf
$params['range_start'] = date("Y-m-d H:i:s", $range_start_s);
$params['range_end'] = date("Y-m-d H:i:s", $range_end_s);
$entry = $d3dConf->func->get_blist($req_uid, $uid, 500, true, $params);
// dosort = true
$URL_MOD = XOOPS_URL . "/modules/" . $mydirname;
if (!empty($entry)) {
    $i = 0;
    foreach ($entry as $b => $e) {
        $user_time = $e['tstamp'] + $tzoffset_s2u;
        if (date('n', $user_time) != $this->month) {
예제 #29
0
function b_d3diary_d3comlist_topics_show( $options ){

	global $xoopsUser, $xoopsDB;

	$mydirname = empty( $options[0] ) ? 'd3diary' : $options[0] ;
	$max_topics = empty( $options[1] ) ? 10 : intval( $options[1] ) ;
	$show_fullsize = empty( $options[2] ) ? false : true ;
	$now_order = empty( $options[3] ) ? 'time' : trim( $options[3] ) ;
	$req_uid = empty( $options[4] ) ? 0 : intval( $options[4] ) ;
	$is_markup = empty( $options[5] ) ? false : true ;
	$use_detail = empty( $options[6] ) ? false : true ;
	$this_template = empty( $options[7] ) ? 'db:'.$mydirname.'_block_d3comlist_topics.html' : trim( $options[7] ) ;

	$use_aggre = empty( $options[8] ) ? false : true ;
	$categories = empty( $options[9] ) ? array() : explode(',',$options[9]) ;
	$forums = empty( $options[10] ) ? array() : explode(',',$options[10]) ;

	require_once dirname( dirname(__FILE__) ).'/class/d3diaryConf.class.php';
	$d3dConf = & D3diaryConf::getInstance($mydirname, 0, "b_d3comlist_topics");
	$func =& $d3dConf->func ;
	$myts =& $d3dConf->myts;
	$mPerm =& $d3dConf->mPerm ;
	$gPerm =& $d3dConf->gPerm ;
	$mod_config =& $d3dConf->mod_config ;

	$uid = $d3dConf->uid;

	$com_dirname = $mod_config['comment_dirname'];
	$com_forum_id = intval($mod_config['comment_forum_id']);
	$com_anchor_type = intval($mod_config['comment_anchor_type']);
	
	// if comment integration is not set, exit immediately
	if(empty($com_dirname) || $com_forum_id<=0) {
		echo "This block needs d3forum comment integration setting!";
		return array() ;
	}

	// d3forum_configs
	$module_handler =& xoops_gethandler( 'module' ) ;
	$module =& $module_handler->getByDirname( $com_dirname ) ;
	$mid_com = $module->getVar('mid');
	$config_handler =& xoops_gethandler('config');
	$configs = $config_handler->getConfigsByCat(0, $mid_com);
	
	$editperm=0;
	$owner=0;
	if($uid>0 && $req_uid==$uid){$editperm=1;}
	if($mPerm->isadmin){$editperm=1;}

	// forums can be read by current viewer (check by forum_access)
	$temparr_forums_can_read = $func->get_d3comforums_can_read( $com_dirname, $uid );
	if(!empty($temparr_forums_can_read)) {
		// remove comment_forum_id from allowed forums array
		$arrcom_forum_id[] = $com_forum_id;
		$gotarr_forums_can_read = array_diff($temparr_forums_can_read, $arrcom_forum_id);
	}

	// get all forums
	$sql = "SELECT forum_id, forum_external_link_format FROM ".$xoopsDB->prefix($com_dirname."_forums") ;
	$frs = $xoopsDB->query( $sql ) ;
	$d3com = array() ;
	while( $forum_row = $xoopsDB->fetchArray( $frs ) ) {
		// d3comment object
		$temp_forum_id = intval($forum_row['forum_id']);
		// exclude d3diary's comment forum
		if( ($temp_forum_id != $com_forum_id) && ! empty( $forum_row['forum_external_link_format'] ) ) {
			$d3com[$temp_forum_id] =& $func->get_d3com_object( $com_dirname , $forum_row['forum_external_link_format'] ) ;
		} else {
			$d3com[$temp_forum_id] = false ;
		}
	}

	if ( !in_array( $com_forum_id, $temparr_forums_can_read ) ) {
		$whr_extid = '0';
	}

	// order
	$whr_order = '1' ;
	switch( $now_order ) {
		case 'views':
			$odr = 't.topic_views DESC';
			break;
		case 'replies':
			$odr = 't.topic_posts_count DESC';
			break;
		case 'votes':
			$odr = 't.topic_votes_count DESC';
			break;
		case 'points':
			$odr = 't.topic_votes_sum DESC';
			break;
		case 'average':
			$odr = 't.topic_votes_sum/t.topic_votes_count DESC, topic_votes_count DESC';
			$whr_order = 't.topic_votes_count>0' ;
			break;
		case 'time':
		default:
			$odr = 't.topic_last_post_time DESC';
			break;
	}

	// finally, query d3comments
	$whr_extid = 'f.forum_id='.$com_forum_id ;

	// use solved or not
	if( empty( $configs['use_solved'] ) ) {
		$sel_solved = '1 AS topic_solved' ;
	} else {
		$sel_solved = 't.topic_solved' ;
	}

	if( $use_aggre ) {
		// categories
		$categories = array_map( 'intval' , $categories ) ;
		$categories4assign = implode(',',$categories) ;
		// forums
		$forums = array_map( 'intval' , $forums ) ;
		$forums4assign = implode(',',$forums) ;
		if( empty( $categories ) &&  empty( $forums )){
			$arrforums_to_read = $gotarr_forums_can_read;
			$whr_cats_or_forums = 'f.forum_id IN ('.implode(',',$arrforums_to_read).')' ;
			
		} else {
		    if(empty( $categories ) && !empty( $forums )) {
			$arrforums_to_read = array_intersect($gotarr_forums_can_read, $forums);
			$whr_cats_or_forums = 'f.forum_id IN ('.implode(',',$arrforums_to_read).')' ;
			
		    } elseif( !empty( $categories ) && empty( $forums )) {
			$whr_categories = 'f.cat_id IN ('.implode(',',$categories).')' ;
			$whr_cats_or_forums = $whr_categories. ' AND f.forum_id IN ('.implode(',',$gotarr_forums_can_read).')' ;
			
		    } else {	// !empty( $categories ) && !empty( $forums )
			$whr_categories = 'f.cat_id IN ('.implode(',',$categories).')' ;
			$whr_forums = 'f.forum_id IN ('.implode(',',$gotarr_forums_can_read).')' ;
			$arrforums_to_read = array_intersect($gotarr_forums_can_read, $forums);
			$whr_cats_or_forums = $whr_categories. ' AND '.$whr_forums .' OR f.forum_id IN ('.implode(',',$arrforums_to_read).')' ;
		    }
		}
	} else {
		$whr_cats_or_forums = '0' ;
		$categories4assign = "" ;
		$forums4assign = "" ;
	}

	// diary permission
	if($mPerm->isadmin){
		$whr_openarea = " 1 ";
	} else {
		$_params4op['use_gp'] = $gPerm->use_gp;
		$_params4op['use_pp'] = $gPerm->use_pp;
		$whr_openarea = $mPerm->get_open_query( "b_d3com_topics", $_params4op );
	}

	if( $uid > 0 && $is_markup ) {
		$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_uid, t.topic_last_post_id, t.topic_last_post_time, 
			t.topic_views, t.topic_votes_count, t.topic_votes_sum, t.topic_posts_count, t.topic_external_link_id, 
			$sel_solved, t.forum_id, 
			p.post_id, p.subject, p.post_text, p.guest_name, p.html, p.smiley, p.xcode, p.br, p.unique_path,
			 f.forum_title, u2t.u2t_marked, u.uname, u.name 
			FROM ".$xoopsDB->prefix($com_dirname."_topics")." t 
			LEFT JOIN ".$xoopsDB->prefix($com_dirname."_forums")." f ON f.forum_id=t.forum_id 
			LEFT JOIN ".$xoopsDB->prefix($com_dirname."_posts")." p ON t.topic_last_post_id=p.post_id 
			LEFT JOIN ".$xoopsDB->prefix($mydirname."_diary")." d ON t.topic_external_link_id=d.bid 
			LEFT JOIN ".$xoopsDB->prefix($mydirname.'_category')." c ON ((d.uid=c.uid  OR c.uid='0') AND d.cid=c.cid)  
			LEFT JOIN ".$xoopsDB->prefix($mydirname.'_config')." cfg ON d.uid=cfg.uid 
			LEFT JOIN ".$xoopsDB->prefix($com_dirname."_users2topics")." u2t ON u2t.topic_id=t.topic_id AND u2t.uid=$uid 
			LEFT JOIN ".$xoopsDB->prefix('users')." u ON u.uid=t.topic_last_uid 
			WHERE ! t.topic_invisible AND (($whr_extid AND $whr_openarea) OR ($whr_cats_or_forums)) 
			AND ($whr_order) ORDER BY u2t.u2t_marked<=>1 DESC , $odr";
	} else {
		$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_uid, t.topic_last_post_id, t.topic_last_post_time, 
			t.topic_views, t.topic_votes_count, t.topic_votes_sum, t.topic_posts_count, t.topic_external_link_id, 
			$sel_solved, t.forum_id, 
			p.post_id, p.subject, p.post_text, p.guest_name, p.html, p.smiley, p.xcode, p.br, p.unique_path, 
			f.forum_title, 0 AS u2t_marked, u.uname, u.name 
			FROM ".$xoopsDB->prefix($com_dirname."_topics")." t 
			LEFT JOIN ".$xoopsDB->prefix($com_dirname."_forums")." f ON f.forum_id=t.forum_id 
			LEFT JOIN ".$xoopsDB->prefix($com_dirname."_posts")." p ON t.topic_last_post_id=p.post_id 
			LEFT JOIN ".$xoopsDB->prefix($mydirname."_diary")." d ON t.topic_external_link_id=d.bid 
			LEFT JOIN ".$xoopsDB->prefix($mydirname.'_category')." c ON ((d.uid=c.uid  OR c.uid='0') AND d.cid=c.cid)  
			LEFT JOIN ".$xoopsDB->prefix($mydirname.'_config')." cfg ON d.uid=cfg.uid 
			LEFT JOIN ".$xoopsDB->prefix('users')." u ON u.uid=t.topic_last_uid 
			WHERE ! t.topic_invisible AND (($whr_extid AND $whr_openarea) OR ($whr_cats_or_forums)) 
			AND ($whr_order) ORDER BY $odr";
	}

	if( $result = $xoopsDB->query( $sql , $max_topics , 0 )) {

		$constpref = '_MB_' . strtoupper( $mydirname ) ;
		if($com_anchor_type==1) {
			$unique_key = "#post_id";
		} else {
			$unique_key = "#post_path";
		}

		$block = array( 
			'mydirname' => $mydirname ,
			'mod_url' => XOOPS_URL.'/modules/'.$com_dirname ,
			'mod_imageurl' => XOOPS_URL.'/modules/'.$com_dirname.'/'.$configs['images_dir'] ,
			'categories' => $categories4assign ,
			'forums' => $forums4assign ,
			'full_view' => $show_fullsize ,
			'unique_key' => $unique_key ,
			'use_aggre' => $use_aggre ,
			'com_forum_id' => $com_forum_id ,
			'mod_config' => $mod_config ,
			'lang_forum' => constant($constpref.'_FORUM') ,
			'lang_topic' => constant($constpref.'_TOPIC') ,
			'lang_replies' => constant($constpref.'_REPLIES') ,
			'lang_views' => constant($constpref.'_VIEWS') ,
			'lang_votescount' => constant($constpref.'_VOTESCOUNT') ,
			'lang_votessum' => constant($constpref.'_VOTESSUM') ,
			'lang_lastpost' => constant($constpref.'_LASTPOST') ,
			'lang_linktosearch' => constant($constpref.'_LINKTOSEARCH') ,
			'lang_linktolistcategories' => constant($constpref.'_LINKTOLISTCATEGORIES') ,
			'lang_linktolistforums' => constant($constpref.'_LINKTOLISTFORUMS') ,
			'lang_linktolisttopics' => constant($constpref.'_LINKTOLISTTOPICS') ,
		) ;

	   while( $topic_row = $xoopsDB->fetchArray( $result ) ) {
		// d3comment overridings
		$can_display = true;	//default
		if( is_object( $d3com[intval($topic_row['forum_id'])]) ) {
			$d3com_obj = $d3com[intval($topic_row['forum_id'])];
			$external_link_id = intval($topic_row['topic_external_link_id']);
			if( ( $external_link_id = $d3com_obj->validate_id( $external_link_id ) ) === false ) {
				$can_display = false;
			}
		}
			
		if ($can_display == true) {	// naao
			if($com_anchor_type==1) {
				$unique_path = $topic_row['post_id'];
			} else {
				$unique_path = ltrim($topic_row['unique_path'], ".");
			}
			if($use_detail) {
				$temp_post_text = strip_tags( $myts->displayTarea(strip_tags($topic_row['post_text']), $topic_row['html'], $topic_row['smiley'], $topic_row['xcode'], 1, $topic_row['br'] ) );
			} else {
				$temp_post_text = "";
			}
		    $topic4assign = array(
			'id' => intval( $topic_row['topic_id'] ) ,
			'unique_path' => $unique_path ,
			'title' => $myts->makeTboxData4Show( $topic_row['topic_title'] ) ,
			'forum_id' => intval( $topic_row['forum_id'] ) ,
			'forum_title' => $myts->makeTboxData4Show( $topic_row['forum_title'] ) ,
			'replies' => $topic_row['topic_posts_count'] - 1 ,
			'views' => intval( $topic_row['topic_views'] ) ,
			'votes_count' => $topic_row['topic_votes_count'] ,
			'votes_sum' => intval( $topic_row['topic_votes_sum'] ) ,
			'last_post_id' => intval( $topic_row['topic_last_post_id'] ) ,
			'last_post_time' => intval( $topic_row['topic_last_post_time'] ) ,
			'last_post_time_formatted' => formatTimestamp($topic_row['topic_last_post_time'] , 'm' ) ,
			'last_uid' => intval( $topic_row['topic_last_uid'] ) ,
		//	'last_uname' => XoopsUser::getUnameFromId( $topic_row['topic_last_uid']) ,
			'last_uname' => !empty($topic_row['uname']) ? htmlspecialchars( $topic_row['uname'], ENT_QUOTES ) : "" ,
			'last_name' => !empty($topic_row['name']) ? htmlspecialchars( $topic_row['name'], ENT_QUOTES ) : "" ,
			'solved' => intval( $topic_row['topic_solved'] ) ,
			'u2t_marked' => intval( $topic_row['u2t_marked'] ) ,
			'link_id' => intval( $topic_row['topic_external_link_id'] ) ,
			'post_text' => $temp_post_text ,
			'guest_name' => !empty($topic_row['guest_name']) ? htmlspecialchars( $topic_row['guest_name'], ENT_QUOTES ) : 
					$GLOBALS['xoopsConfig']['anonymous'] ,
			'can_display' => intval( $can_display ) ,
		    ) ;
		    $block['topics'][] = $topic4assign ;
		    $reg_time[] = intval( $topic_row['topic_last_post_time'] );
		}	// end if( $can_display
	   }	// end while
	}	// end if( $result

	//var_dump($mPerm->mydirname);

	$d3dConf->debug_appendtime('b_d3com_topics');

	if( empty( $options['disable_renderer'] ) ) {
		require_once XOOPS_ROOT_PATH.'/class/template.php' ;
		$tpl = new XoopsTpl() ;
		$tpl->assign( 'block' , $block ) ;
		$ret['content'] = $tpl->fetch( $this_template ) ;
		return $ret ;
	} else {
		return $block ;
	}

}
예제 #30
0
파일: oninstall.php 프로젝트: naao/d3diary
 function d3diary_oninstall_base($module, $mydirname)
 {
     // transations on module install
     global $ret;
     // TODO :-D
     require dirname(__FILE__) . '/class/d3diaryConf.class.php';
     $d3dConf =& D3diaryConf::getInstance($mydirname, 0, "oninstall");
     $func =& $d3dConf->func;
     // for Cube 2.1
     if (defined('XOOPS_CUBE_LEGACY')) {
         $root =& XCube_Root::getSingleton();
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'd3diary_message_append_oninstall');
         $ret = array();
     } else {
         if (!is_array($ret)) {
             $ret = array();
         }
     }
     $db =& Database::getInstance();
     $mid = $module->getVar('mid');
     // TABLES (loading mysql.sql)
     $sql_file_path = dirname(__FILE__) . '/sql/mysql.sql';
     $prefix_mod = $db->prefix() . '_' . $mydirname;
     if (file_exists($sql_file_path)) {
         $ret[] = "SQL file found at <b>" . $func->htmlspecialchars($sql_file_path) . "</b>.<br /> Creating tables...";
         if (file_exists(XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php')) {
             include_once XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php';
             $sqlutil = new OldSqlUtility();
         } else {
             include_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php';
             $sqlutil = new SqlUtility();
         }
         $sql_query = trim(file_get_contents($sql_file_path));
         $sqlutil->splitMySqlFile($pieces, $sql_query);
         $created_tables = array();
         if (is_array($pieces)) {
             foreach ($pieces as $piece) {
                 $prefixed_query = $sqlutil->prefixQuery($piece, $prefix_mod);
                 if (!$prefixed_query) {
                     $ret[] = "Invalid SQL <b>" . $func->htmlspecialchars($piece) . "</b><br />";
                     return false;
                 }
                 if (!$db->query($prefixed_query[0])) {
                     $ret[] = '<b>' . $func->htmlspecialchars($db->error()) . '</b><br />';
                     //var_dump( $db->error() ) ;
                     return false;
                 } else {
                     if (!in_array($prefixed_query[4], $created_tables)) {
                         $ret[] = 'Table <b>' . $func->htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b> created.<br />';
                         $created_tables[] = $prefixed_query[4];
                     } else {
                         $ret[] = 'Data inserted to table <b>' . $func->htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b>.</br />';
                     }
                 }
             }
         }
     }
     // TEMPLATES
     $tplfile_handler =& xoops_gethandler('tplfile');
     $tpl_path = dirname(__FILE__) . '/templates';
     if ($handler = @opendir($tpl_path . '/')) {
         while (($file = readdir($handler)) !== false) {
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             $file_path = $tpl_path . '/' . $file;
             if (is_file($file_path)) {
                 $mtime = intval(@filemtime($file_path));
                 $tplfile =& $tplfile_handler->create();
                 $tplfile->setVar('tpl_source', file_get_contents($file_path), true);
                 $tplfile->setVar('tpl_refid', $mid);
                 $tplfile->setVar('tpl_tplset', 'default');
                 $tplfile->setVar('tpl_file', $mydirname . '_' . $file);
                 $tplfile->setVar('tpl_desc', '', true);
                 $tplfile->setVar('tpl_module', $mydirname);
                 $tplfile->setVar('tpl_lastmodified', $mtime);
                 $tplfile->setVar('tpl_lastimported', 0);
                 $tplfile->setVar('tpl_type', 'module');
                 if (!$tplfile_handler->insert($tplfile)) {
                     $ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span><br />';
                 } else {
                     $tplid = $tplfile->getVar('tpl_id');
                     $ret[] = 'Template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br />';
                     // generate compiled file
                     include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
                     include_once XOOPS_ROOT_PATH . '/class/template.php';
                     if (!xoops_template_touch($tplid)) {
                         $ret[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b>.</span><br />';
                     } else {
                         $ret[] = 'Template <b>' . $func->htmlspecialchars($mydirname . '_' . $file) . '</b> compiled.</span><br />';
                     }
                 }
             }
         }
         closedir($handler);
     }
     include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
     include_once XOOPS_ROOT_PATH . '/class/template.php';
     xoops_template_clear_module_cache($mid);
     return true;
 }