Ejemplo n.º 1
0
function get_cachedata_threadprofile() {
	global $_G;
	if(!helper_dbtool::isexisttable('forum_threadprofile')) {
		return;
	}
	$threadprofiles = C::t('forum_threadprofile')->fetch_all();
	$threadprofile_group = C::t('forum_threadprofile_group')->fetch_all();
	$data = array();
	foreach($threadprofiles as $id => $threadprofile) {
		if($threadprofile['global']) {
			$data['template'][0] = dunserialize($threadprofile['template']);
		}
	}
	foreach($threadprofile_group as $group) {
		if($threadprofiles[$group['tpid']]) {
			$id = $threadprofiles[$group['tpid']]['global'] ? 0 : $group['tpid'];
			if(!isset($data['template'][$id])) {
				$data['template'][$id] = dunserialize($threadprofiles[$group['tpid']]['template']);
			}
			if($id) {
				$data['groupid'][$group['gid']] = $id;
			}
		}
	}
	foreach($data['template'] as $id => $template) {
		foreach($template as $type => $row) {
			$data['template'][$id][$type] = preg_replace('/\{([\w:]+)(=([^}]+?))?\}(([^}]+?)\{\*\}([^}]+?)\{\/\\1\})?/es', "get_cachedata_threadprofile_nodeparse(\$id, \$type, '\\1', '\\5', '\\6', '\\3')", $template[$type]);
		}
	}
	$data['code'] = $_G['cachedata_threadprofile_code'];
	return $data;
}
        showtableheader();
        showtitle('usergroups_copy');
        showsetting(cplang('usergroups_copy_source') . ':', '', '', $sourceusergroup['grouptitle']);
        showsetting('usergroups_merge_target', '', '', $usergroupselect);
        showsetting('usergroups_merge_delete_source', 'delete_source', 0, 'radio');
        showsubmit('copysubmit');
        showtablefooter();
        showformfooter();
    } else {
        $target = intval($_GET['target']);
        $targetusergroup = $_G['cache']['usergroups'][$target];
        if (empty($targetusergroup) || $targetusergroup['type'] == 'system' || $targetusergroup['type'] == 'special' && $targetusergroup['radminid']) {
            cpmsg('usergroups_copy_target_invalid', '', 'error');
        }
        C::t('common_member')->update_groupid_by_groupid($source, $target);
        if (helper_dbtool::isexisttable('common_member_archive')) {
            C::t('common_member_archive')->update_groupid_by_groupid($source, $target);
        }
        if ($_GET['delete_source']) {
            C::t('common_usergroup')->delete($source, $sourceusergroup['type']);
            C::t('common_usergroup_field')->delete($source);
            C::t('forum_onlinelist')->delete_by_groupid($source);
        }
        updatecache('usergroups');
        cpmsg('usergroups_merge_succeed', 'action=usergroups', 'succeed');
    }
}
function array_flip_keys($arr)
{
    $arr2 = array();
    $arrkeys = @array_keys($arr);
 public function merge_table()
 {
     $limit = 2000;
     $tmptable = $this->_table . '_tmp___';
     $archivetable = $this->_table . '_archive';
     $key = $this->_pk ? $this->_pk : 'split_id';
     if (!helper_dbtool::isexisttable($archivetable)) {
         return 2;
     }
     $this->create_relatedtable($tmptable);
     $targettable = helper_dbtool::showtablecloumn($this->_table);
     $fieldstr = '`' . implode('`, `', array_keys($targettable)) . '`';
     DB::query("INSERT INTO %t ({$fieldstr}) SELECT {$fieldstr} FROM %t " . DB::limit($limit), array($tmptable, $archivetable));
     if (DB::result_first('SELECT COUNT(*) FROM %t', array($tmptable))) {
         $keylist = DB::fetch_all('SELECT ' . $key . ' FROM %t', array($tmptable), $key);
         $keylist = dimplode(array_keys($keylist));
         if (DB::query("INSERT INTO %t ({$fieldstr}) SELECT {$fieldstr} FROM %t WHERE {$key} in ({$keylist})", array($this->_table, $archivetable), false, true)) {
             DB::query("DELETE FROM %t WHERE {$key} in ({$keylist})", array($archivetable), false, true);
         }
         DB::query('DROP TABLE %t', array($tmptable));
         return 1;
     } else {
         DB::query('DROP TABLE %t', array($tmptable));
         DB::query('DROP TABLE %t', array($archivetable));
         $this->optimize();
         return 2;
     }
 }
Ejemplo n.º 4
0
function get_cachedata_threadprofile()
{
    global $_G;
    if (!helper_dbtool::isexisttable('forum_threadprofile')) {
        return;
    }
    $threadprofiles = C::t('forum_threadprofile')->fetch_all();
    $threadprofile_group = C::t('forum_threadprofile_group')->fetch_all();
    $data = array();
    foreach ($threadprofiles as $id => $threadprofile) {
        if ($threadprofile['global']) {
            $data['template'][0] = dunserialize($threadprofile['template']);
        }
    }
    foreach ($threadprofile_group as $group) {
        if ($threadprofiles[$group['tpid']]) {
            $id = $threadprofiles[$group['tpid']]['global'] ? 0 : $group['tpid'];
            if (!isset($data['template'][$id])) {
                $data['template'][$id] = dunserialize($threadprofiles[$group['tpid']]['template']);
            }
            if ($id) {
                $data['groupid'][$group['gid']] = $id;
            }
        }
    }
    foreach ($data['template'] as $id => $template) {
        foreach ($template as $type => $row) {
            //Coxxs
            $data['template'][$id][$type] = preg_replace_callback('/\\{([\\w:]+)(=([^}]+?))?\\}(([^}]+?)\\{\\*\\}([^}]+?)\\{\\/\\1\\})?/s', function ($matches) use($type, $id) {
                return get_cachedata_threadprofile_nodeparse($id, $type, isset($matches[1]) ? $matches[1] : '', isset($matches[5]) ? $matches[5] : '', isset($matches[6]) ? $matches[6] : '', isset($matches[3]) ? $matches[3] : '');
            }, $template[$type]);
            //Coxxs
        }
    }
    $data['code'] = $_G['cachedata_threadprofile_code'];
    return $data;
}