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

📄 index.php

📁 讲的是网络编程
💻 PHP
📖 第 1 页 / 共 5 页
字号:
				if ($blocks != false) {
					$count = count($blocks);
					include_once(XOOPS_ROOT_PATH.'/class/xoopsblock.php');
					for ( $i = 1; $i <= $count; $i++ ) {
						if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') {
							$editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : '';
							$showfuncs[] = $blocks[$i]['show_func'];
							$funcfiles[] = $blocks[$i]['file'];
							$template = '';
							if ((isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '')) {
								$content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true);
								$template = $blocks[$i]['template'];
							}
							if (!$content) {
								$content = '';
							}
							$options = '';
							if (isset($blocks[$i]['options']) && $blocks[$i]['options'] != '') {
								$options = $blocks[$i]['options'];
							}
							$sql = "SELECT bid, name FROM ".$xoopsDB->prefix('newblocks')." WHERE mid=".$mid." AND func_num=".$i;
							$fresult = $xoopsDB->query($sql);
							$fcount = 0;
							while ($fblock = $xoopsDB->fetchArray($fresult)) {
								$fcount++;
								$sql = "UPDATE ".$xoopsDB->prefix("newblocks")." SET name='".addslashes($blocks[$i]['name'])."', title='".addslashes($blocks[$i]['name'])."', dirname='".addslashes($dirname)."',  func_file='".addslashes($blocks[$i]['file'])."', show_func='".addslashes($blocks[$i]['show_func'])."', template='".addslashes($template)."', edit_func='".addslashes($editfunc)."', options='".addslashes($options)."', content='', template='".$template."', last_modified=".time()." WHERE bid=".$fblock['bid'];
								$result = $xoopsDB->query($sql);
								if (!$result) {
									$msgs[] = '&nbsp;&nbsp;ERROR: Could not update '.$fblock['name'];
								} else {
									$msgs[] = '&nbsp;&nbsp;Block <b>'.$fblock['name'].'</b> updated. Block ID: <b>'.$fblock['bid'].'</b>';
									if ($template != '') {
										$tplfile =& $tplfile_handler->create();
										$tplfile->setVar('tpl_refid', $fblock['bid']);
										$tplfile->setVar('tpl_source', $content, true);
										$tplfile->setVar('tpl_tplset', 'default');
										$tplfile->setVar('tpl_file', $blocks[$i]['template']);
										$tplfile->setVar('tpl_module', $dirname);
										$tplfile->setVar('tpl_type', 'block');
										$tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
										$tplfile->setVar('tpl_lastimported', 0);
										$tplfile->setVar('tpl_lastmodified', time());
										if (!$tplfile_handler->insert($tplfile)) {
											$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert template <b>'.$blocks[$i]['template'].'</b> to the database.</span>';
										} else {
											$msgs[] = '&nbsp;&nbsp;Template <b>'.$blocks[$i]['template'].'</b> inserted to the database.';
											//if ($xoopsConfig['default_theme'] == 'default') {
											//	if (!xoops_template_touch($tplfile[0]->getVar('tpl_id'))) {
											//		$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not recompile template <b>'.$blocks[$i]['template'].'</b>.</span>';
											//	} else {
											//		$msgs[] = '&nbsp;&nbsp;Template <b>'.$blocks[$i]['template'].'</b> recompiled.';
											//	}
											//}
										}
									}
								}
							}
							if ($fcount == 0) {
								$newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks').'_bid_seq');
								$block_name = addslashes($blocks[$i]['name']);
								$sql = "INSERT INTO ".$xoopsDB->prefix("newblocks")." (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (".$newbid.", ".$mid.", ".$i.",'".addslashes($options)."','".$block_name."', '".$block_name."', '', 0, 0, 0, 'M', 1, '".addslashes($dirname)."', '".addslashes($blocks[$i]['file'])."', '".addslashes($blocks[$i]['show_func'])."', '".addslashes($editfunc)."', '".$template."', ".time().")";
								$result = $xoopsDB->query($sql);
								if (!$result) {
									$msgs[] = '&nbsp;&nbsp;ERROR: Could not create '.$blocks[$i]['name'];
								} else {
									if (empty($newbid)) {
										$newbid = $xoopsDB->getInsertId();
									}
									if ($template != '') {
										$tplfile =& $tplfile_handler->create();
										$tplfile->setVar('tpl_module', $dirname);
										$tplfile->setVar('tpl_refid', $newbid);
										$tplfile->setVar('tpl_source', $content, true);
										$tplfile->setVar('tpl_tplset', 'default');
										$tplfile->setVar('tpl_file', $blocks[$i]['template'], true);
										$tplfile->setVar('tpl_type', 'block');
										$tplfile->setVar('tpl_lastimported', 0);
										$tplfile->setVar('tpl_lastmodified', time());
										$tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
										if (!$tplfile_handler->insert($tplfile)) {
											$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert template <b>'.$blocks[$i]['template'].'</b> to the database.</span>';
										} else {
											$msgs[] = '&nbsp;&nbsp;Template <b>'.$blocks[$i]['template'].'</b> inserted to the database.';
										}
									}
									$msgs[] = '&nbsp;&nbsp;Block <b>'.$blocks[$i]['name'].'</b> created. Block ID: <b>'.$newbid.'</b>';
								}
							}
						}
					}
				}
				$block_arr = XoopsBlock::getByModule($mid);
				foreach ($block_arr as $block) {
					if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
						$sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
						if(!$xoopsDB->query($sql)) {
							$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not delete block <b>'.$block->getVar('name').'</b>. Block ID: <b>'.$block->getVar('bid').'</b></span>';
						} else {
							$msgs[] = '&nbsp;&nbsp;Block <b>'.$block->getVar('name').' deleted. Block ID: <b>'.$block->getVar('bid').'</b>';
						}
					}
				}

				$configs = $modules[$mid]->getInfo('config');
				if ($configs != false) {
					if ($modules[$mid]->getVar('hascomments') != 0) {
						include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
						array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
						array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
					}
				} else {
					if ($modules[$mid]->getVar('hascomments') != 0) {
						$configs = array();
						include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
						$configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
						array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
					}
				}
				// RMV-NOTIFY
				if ($modules[$mid]->getVar('hasnotification') != 0) {
					if (empty($configs)) {
						$configs = array();
					}
					include_once(XOOPS_ROOT_PATH.'/include/notification_constants.php');
					$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options);
				}

				if ($configs != false) {
					$msgs[] = 'Adding module config data...';
					$config_handler =& xoops_gethandler('config');
					$order = 0;
					foreach ($configs as $config) {
						$confobj =& $config_handler->createConfig();
						$confobj->setVar('conf_modid', $newmid);
						$confobj->setVar('conf_catid', 0);
						$confobj->setVar('conf_name', $config['name']);
						$confobj->setVar('conf_title', $config['title'], true);
						$confobj->setVar('conf_desc', $config['description'], true);
						$confobj->setVar('conf_formtype', $config['formtype']);
						$confobj->setVar('conf_valuetype', $config['valuetype']);
						$confobj->setVar('conf_value', $config['default'], true);
						$confobj->setVar('conf_order', $order);
						$confop_msgs = '';
						if (isset($config['options']) && is_array($config['options'])) {
							foreach ($config['options'] as $key => $value) {
								$confop =& $config_handler->createConfigOption();
								$confop->setVar('confop_name', $key, true);
								$confop->setVar('confop_value', $value, true);
								$confobj->setConfOptions($confop);
								$confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;Config option added. Name: <b>'.$key.'</b> Value: <b>'.$value.'</b>';
								unset($confop);
							}
						}
						$order++;
						if ($config_handler->insertConfig($confobj) != false) {
							$msgs[] = '&nbsp;&nbsp;Config <b>'.$config['name'].'</b> added to the database.'.$confop_msgs;
						} else {
							$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert config <b>'.$config['name'].'</b> to the database.</span>';
						}
						unset($confobj);
					}
					unset($configs);
				}
				foreach ($msgs as $msg) {
					echo '<code>'.$msg.'</code><br />';
				}
			}
			// data for table 'block_module_link'
			include_once './class/dbmanager.php';
    		$dbm = new db_manager;
    		$sql = 'SELECT bid, side FROM '.$dbm->prefix('newblocks');
    		$result = $dbm->query($sql);

    		while ($myrow = $dbm->fetchArray($result)) {
        		if ($myrow['side'] == 0) {
            		$dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", 0)");
        		} else {
            		$dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", -1)");
        		}
    		}
		}
		echo '<br />';
		flush();
		sleep(1);
	}
?>
	</div></td>
    <td width='5%'>&nbsp;</td>
  </tr>
  <tr>
    <td width='5%'>&nbsp;</td>
    <td width='35%' align='left'>&nbsp;</td>
    <td width='20%' align='center'>&nbsp;</td>
    <td width='35%' align='right'><span style='font-size:85%;'><?php echo _INSTALL_L14;?> >></span> <input type='hidden' name='op' value='updateComments' /><input type='submit' name='submit' value='<?php echo _INSTALL_L47;?>' /></td>
    <td width='5%'>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
</table>

<table width="778" cellspacing="0" cellpadding="0" align="center" background="img/bg_table.gif">
  <tr>
    <td width="150"><img src="img/hbar_left.gif" width="100%" height="23" alt="" /></td>
    <td width="478" background="img/hbar_middle.gif">&nbsp;</td>
    <td width="150"><img src="img/hbar_installer_right.gif" width="100%" height="23" alt="" /></td>
  </tr>
</table>
</form>
</body>
</html>
<?php
	break;

case 'updateComments':
	$content = "<p>"._INSTALL_L149."</p>\n";
	$b_next = array('updateComments_go', _INSTALL_L138);
	include 'install_tpl.php';
	break;

case 'updateComments_go':
	unset($xoopsOption['nocommon']);
	include '../mainfile.php';
	include '../class/xoopscomments.php';
	include '../include/comment_constants.php';
	$module_handler =& xoops_gethandler('module');
	$old_commentd_mods = array('news' => 'comments', 'xoopspoll' => 'xoopspollcomments');
	$title = _INSTALL_L147;
	$content = '';
	foreach ($old_commentd_mods as $module => $com_table) {
		$moduleobj =& $module_handler->getByDirname($module);
		if (is_object($moduleobj)) {
			$content .= '<h5>'.$moduleobj->getVar('name').'</h5>';
			$comment_handler =& xoops_gethandler('comment');
			$criteria = new CriteriaCompo();
			$criteria->setOrder('DESC');
			$criteria->setSort('com_id');
			$criteria->setLimit(1);
			$last_comment =& $comment_handler->getObjects($criteria);
			$offset = (is_array($last_comment) && count($last_comment) > 0) ? $last_comment[0]->getVar('com_id') : 0;
			$xc = new XoopsComments($xoopsDB->prefix($com_table));
			$top_comments =& $xc->getAllComments(array('pid=0'));

			foreach ($top_comments as $tc) {
				$sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('xoopscomments'), $tc->getVar('comment_id') + $offset, 0, $moduleobj->getVar('mid'), '', addslashes($tc->getVar('subject', 'n')), addslashes($tc->getVar('comment', 'n')), $tc->getVar('date'), $tc->getVar('date'), $tc->getVar('user_id'), $tc->getVar('ip'), 0, $tc->getVar('item_id'), $tc->getVar('comment_id') + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1);

				if (!$xoopsDB->query($sql)) {
					$content .= _NGIMG.sprintf(_INSTALL_L146, $tc->getVar('comment_id') + $offset).'<br />';
				} else {
					$content .= _OKIMG.sprintf(_INSTALL_L145, $tc->getVar('comment_id') + $offset).'<br />';
					$child_comments = $tc->getCommentTree();
					foreach ($child_comments as $cc) {
						$sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('xoopscomments'), $cc->getVar('comment_id') + $offset, $cc->getVar('pid') + $offset, $moduleobj->getVar('mid'), '', addslashes($cc->getVar('subject', 'n')), addslashes($cc->getVar('comment', 'n')), $cc->getVar('date'), $cc->getVar('date'), $cc->getVar('user_id'), $cc->getVar('ip'), 0, $cc->getVar('item_id'), $tc->getVar('comment_id') + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1);
						if (!$xoopsDB->query($sql)) {
							$content .= _NGIMG.sprintf(_INSTALL_L146, $cc->getVar('comment_id') + $offset).'<br />';
						} else {
							$content .= _OKIMG.sprintf(_INSTALL_L145, $cc->getVar('comment_id') + $offset).'<br />';
						}
					}
				}
			}

⌨️ 快捷键说明

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