⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 讲的是网络编程
💻 PHP
📖 第 1 页 / 共 5 页
字号:
		}
	}
	$xoopsDB->query('ALTER TABLE '.$xoopsDB->prefix('xoopscomments').' CHANGE com_id com_id mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY');
	$b_next = array('updateSmilies', _INSTALL_L14);
	include 'install_tpl.php';
	break;

case 'updateSmilies':
	$content = '<p>'._INSTALL_L150.'</p>';
	$b_next = array('updateSmilies_go', _INSTALL_L140);
	include 'install_tpl.php';
	break;


case 'updateSmilies_go':
	unset($xoopsOption['nocommon']);
	include('../mainfile.php');
	$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix('smiles'));
	$content = '';
	$title = _INSTALL_L155;
	if (!defined('XOOPS_UPLOAD_PATH')) {
		define('XOOPS_UPLOAD_PATH', '../uploads');
	}
	while ($smiley = $xoopsDB->fetchArray($result)) {
		if (file_exists('../images/smilies/'.$smiley['smile_url']) && false != $fp = fopen('../images/smilies/'.$smiley['smile_url'], 'rb')) {
			$binary = fread($fp, filesize('../images/smilies/'.$smiley['smile_url']));
			fclose($fp);
			if (!preg_match("/\.([a-zA-Z0-9]+)$/", $smiley['smile_url'], $matched)) {
            	continue;
        	}
            $newsmiley = uniqid('smil').'.'.strtolower($matched[1]);
			if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newsmiley, 'wb')) {
				if (-1 != fwrite($fp, $binary)) {
					$xoopsDB->query("UPDATE ".$xoopsDB->prefix('smiles')." SET smile_url='".$newsmiley."' WHERE id=".$smiley['id']);
					$content .= _OKIMG.sprintf(_INSTALL_L154, $smiley['smile_url']).'<br />';
				} else {
					$content .= _NGIMG.sprintf(_INSTALL_L153, $smiley['smile_url']).'<br />';
				}
				fclose($fp);
			}
		} else {
			$content .= _OKIMG.sprintf(_INSTALL_L152, $smiley['smile_url']).'<br />';
		}
	}
	$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix('ranks'));
	while ($rank = $xoopsDB->fetchArray($result)) {
		if (file_exists('../images/ranks/'.$rank['rank_image']) && false != $fp = fopen('../images/ranks/'.$rank['rank_image'], 'rb')) {
			$binary = fread($fp, filesize('../images/ranks/'.$rank['rank_image']));
			fclose($fp);
			if (!preg_match("/\.([a-zA-Z0-9]+)$/", $rank['rank_image'], $matched)) {
            	continue;
        	}
            $newrank = uniqid('rank').'.'.strtolower($matched[1]);
			if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newrank, 'wb')) {
				if (-1 != fwrite($fp, $binary)) {
					$content .= _OKIMG.sprintf(_INSTALL_L154, $rank['rank_image']).'<br />';
					$xoopsDB->query("UPDATE ".$xoopsDB->prefix('ranks')." SET rank_image='".$newrank."' WHERE rank_id=".$rank['rank_id']);
				} else {
					$content .= _NGIMG.sprintf(_INSTALL_L153, $rank['rank_image']).'<br />';
				}
				fclose($fp);
			}
		} else {
			$content .= _OKIMG.sprintf(_INSTALL_L152, $rank['rank_image']).'<br />';
		}
	}
	$b_next = array('updateAvatars', _INSTALL_L14);
	include 'install_tpl.php';
	break;

case 'updateAvatars':
	$content = '<p>'._INSTALL_L151.'</p>';
	$b_next = array('updateAvatars_go', _INSTALL_L139);
	include 'install_tpl.php';
	break;

case 'updateAvatars_go':
	unset($xoopsOption['nocommon']);
	include('../mainfile.php');
	$content = '';
	$title = _INSTALL_L156;
	$avatars = getImageFileList(XOOPS_ROOT_PATH.'/images/avatar/users/');
	$xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='blank.gif'");
	$avt_handler =& xoops_gethandler('avatar');
	if (!defined('XOOPS_UPLOAD_PATH')) {
		define('XOOPS_UPLOAD_PATH', '../uploads');
	}
	foreach ($avatars as $avatar_file) {
		if (preg_match("/^([0-9]+)\.([a-zA-Z]+)$/", $avatar_file, $matched)) {
			$user_id = intval($matched[1]);
			if ($user_id > 0 && false != $fp = fopen('../images/avatar/users/'.$avatar_file, 'rb')) {
				$binary = fread($fp, filesize('../images/avatar/users/'.$avatar_file));
				fclose($fp);
            	$newavatar = uniqid('cavt').'.'.strtolower($matched[2]);
				if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newavatar, 'wb')) {
					if (-1 != fwrite($fp, $binary)) {
						$error = false;
						if (!$xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='".$newavatar."' WHERE uid=".$user_id)) {
							$error = true;
						} else {
							$avatar =& $avt_handler->create();
							$avatar->setVar('avatar_file', $newavatar);
							$avatar->setVar('avatar_name', 'custom');
							$avatar->setVar('avatar_mimetype', '');
							$avatar->setVar('avatar_display', 1);
							$avatar->setVar('avatar_type', 'C');
							if(!$avt_handler->insert($avatar)) {
								$error = true;
							} else {
								$avt_handler->addUser($avatar->getVar('avatar_id'), $user['uid']);
							}
						}
						if (false != $error) {
							$content .= _NGIMG.sprintf(_INSTALL_L153, $avatar_file).'<br />';
							@unlink(XOOPS_UPLOAD_PATH.'/'.$newavatar);
						} else {
							$content .= _OKIMG.sprintf(_INSTALL_L154, $avatar_file).'<br />';
						}
					} else {
						$content .= _NGIMG.sprintf(_INSTALL_L153, $avatar_file).'<br />';
						$xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='blank.gif' WHERE uid=".$user_id);
					}
					fclose($fp);
				}
			} else {
				$content .= _NGIMG.sprintf(_INSTALL_L152, $avatar_file).'<br />';
			}
		}
	}

	$b_next = array('finish', _INSTALL_L14);
	include 'install_tpl.php';
	break;


case "siteInit":
    include_once "../mainfile.php";

    $content = "<table align='center' width='70%'>\n";
    $content .= "<tr><td colspan='2' align='center'>"._INSTALL_L36."</td></tr>\n";
    $content .= "<tr><td align='right'><b>"._INSTALL_L37."</b></td><td><input type=\"text\" name=\"adminname\" /></td></tr>\n";
    $content .= "<tr><td align='right'><b>"._INSTALL_L38."</b></td><td><input type='text' name='adminmail' value='' maxlength='60' /></td></tr>\n";
    $content .= "<tr><td align='right'><b>"._INSTALL_L39."</b></td><td><input type='password' name='adminpass' /></td></tr>\n";
    $content .= "<tr><td align='right'><b>"._INSTALL_L74."</b></td><td><input type='password' name='adminpass2' /></td></tr>\n";
    $content .= "</table>\n";
    $b_next = array('insertData', _INSTALL_L116);

    include 'install_tpl.php';
    break;

case "insertData":
    $adminname = $myts->stripSlashesGPC($_POST['adminname']);
    $adminpass = $myts->stripSlashesGPC($_POST['adminpass']);
    $adminpass2 = $myts->stripSlashesGPC($_POST['adminpass2']);
    $adminmail = $myts->stripSlashesGPC($_POST['adminmail']);

    if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$adminmail)) {
        $content = "<p>"._INSTALL_L73."</p>\n";
        $b_back = array('', _INSTALL_L112 );
        include 'install_tpl.php';
        exit();
    }
    if ( !isset($adminname) || !isset($adminpass) || !isset($adminmail) || $adminmail == "" || $adminname =="" || $adminpass =="" || $adminpass != $adminpass2) {
        $content = "<p>"._INSTALL_L41."</p>\n";
        $b_back = array('', _INSTALL_L112 );
        include 'install_tpl.php';
        exit();
    }

    include_once "../mainfile.php";
    //include_once './include/createtables2.php';
    include_once './makedata.php';
    include_once './class/dbmanager.php';
    $dbm = new db_manager;
    include_once './class/cachemanager.php';
    $cm = new cache_manager;

    $language = check_language($language);
    if ( file_exists("./language/".$language."/install2.php") ) {
        include_once "./language/".$language."/install2.php";
    } elseif ( file_exists("./language/english/install2.php") ) {
        include_once "./language/english/install2.php";
        $language = 'english';
    } else {
        echo 'no language file (install2.php).';
        exit();
    }

    //$tables = array();
    $result = $dbm->queryFromFile('./sql/'.XOOPS_DB_TYPE.'.data.sql');
    $result = $dbm->queryFromFile('./language/'.$language.'/'.XOOPS_DB_TYPE.'.lang.data.sql');
    $group = make_groups($dbm);
    $result = make_data($dbm, $cm, $adminname, $adminpass, $adminmail, $language, $group);
    $content = $dbm->report();
    $content .= $cm->report();
    include_once "./class/mainfilemanager.php";
    $mm = new mainfile_manager("../mainfile.php");
    foreach($group as $key => $val){
        $mm->setRewrite($key, intval($val));
    }
    $result = $mm->doRewrite();
    $content .= $mm->report();

    $b_next = array('finish', _INSTALL_L117);
    $title = _INSTALL_L116;
    setcookie('xoops_session', '', time() - 3600);
    include 'install_tpl.php';

    break;

case 'finish':

    $title = _INSTALL_L32;
    $content = "<table width='60%' align='center'><tr><td align='left'>\n";
    include './language/'.$language.'/finish.php';
    $content .= "</td></tr></table>\n";
    include 'install_tpl.php';
    break;
}

/*
 * gets list of name of directories inside a directory
 */
function getDirList($dirname)
{
	require_once dirname(dirname(__FILE__))."/class/xoopslists.php";
	return XoopsLists::getDirListAsArray($dirname);
}

/*
 * gets list of name of files within a directory
 */
function getImageFileList($dirname)
{
	require_once dirname(dirname(__FILE__))."/class/xoopslists.php";
	return XoopsLists::getImgListAsArray($dirname);
}

function &xoops_module_gettemplate($dirname, $template, $block=false)
{
	if ($block) {
		$path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/blocks/'.$template;
	} else {
		$path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/'.$template;
	}
	if (!file_exists($path)) {
		return false;
	} else {
		$lines = file($path);
	}
	if (!$lines) {
		return false;
	}
	$ret = '';
	$count = count($lines);
	for ($i = 0; $i < $count; $i++) {
		$ret .= str_replace("

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -