PHP 无限分类
<?php
//作者:梁文平 http://www.tyasp.net
session_start();
if($_SESSION["username"]!="admin")
{
echo("<mce:script type="text/javascript"><!--
alert("操作超时!请重新登陆...");window.location.href="../index.php";
// --></mce:script>");
//header("refresh:0;url=../");
exit();
}
include("../../include/include.php");
$simple=new simple_gb;
$simple->linkdb($host,$user,$password,$db);
if($_GET["action"]=="submit")
{
$result=mysql_query("select max(ClassId)+1 as aa from newsclass");
$row=mysql_fetch_array($result);
$sql="insert into newsclass (ClassId,ClassDesc,ParentId) values("". $row["aa"] ."","". $_POST["txtClassDesc"] ."","". $_POST["dropParentId"] ."")";
mysql_query($sql);
echo("提交成功!");
exit();
}
/*
$sql="insert into news (newstitle,content,savedate) values("a","b","". date("Y-m-d H:i:s") ."")";
mysql_query($sql,$simple->con);
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8" />
<title></title>
</head>
<body>
<link href="../Admin_Style.css" mce_href="Admin_Style.css" rel="stylesheet" type="text/css" />
<form id="form1" name="form1" method="post" action="?action=submit">
<table width="427" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="58">类别名:</td>
<td width="353"><label>
<input name="txtClassDesc" type="text" id="txtClassDesc" />
</label></td>
</tr>
<tr>
<td>父 类:</td>
<td><label>
<select name="dropParentId" id="dropParentId">
<option value="0">根目录</option>
<?php
$result=@mysql_query("sel
相关文档:
一个非常简单的PHP生成缩略图的代码程序,参数及代码都算得上精简,有兴趣的朋友可以试下它的功能,有不太完善的地方还请指正。 非原创,来自网络
<?$FILENAME="image_name";
// 生成图片的宽度
$RESIZEWIDTH=400;
// 生成图片的高度
$RESIZEHEIGHT=400;
function ResizeImage($im,$maxwidth,$maxheight,$name){ ......
in_array(value,array,type) //检查一个值是否在数组中,type可选,设置为true检查类型是否相同,分大小写
例:
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
......
PHP的safe_mode选项的目的是为了解决本章所述的某些问题。
但是,在PHP层面上去解决这类问题从架构上来看是不正确的,正如PHP手册所述(http://php.net/features.safe-mode)。
当安全模式生效时,PHP会对正在执行的脚本所读取(或所操作)文件的属主进行检查,以保证与该脚本的属主是相同的。
虽然这样确实可以防范本章中 ......
在新安装好的mysql ,apahce,php 的时候,如果在代码中使用了sessions_start() 的时候会出现类似以下的错误:
Warning: session_start() [function.session-start]: Cannot send session cooki 等的错误。
请安装如下的思路去修正:
1.在php.ini 中配置 session.savepath='/tmp'
2.开启session.auto_start=1
3.把更改 ......
一般的文件安全下载方法可以使用下面的代码:
1. <?php?
2.
3. $durl = 'file/phpcms2008_o2abf32efj883c91a.iso';
4. $filename = 'phpcms2008_o2abf32efj883c91a.iso';
5. $file = @fopen($durl, 'r');
6. header("Content-Type: application/octet-stream");
......