我想为我的系统创建一个日志文件来注册/记录他们在系统内执行的每个操作.但我不知道该怎么做.
例如,我有这个执行登录功能的PHP代码.
public function hasAccess($username,$password){
$form = array();
$form['username'] = $username;
$form['password'] = $password;
$securityDAO = $this->getDAO('SecurityDAO');
$result = $securityDAO->hasAccess($form);
//var_dump($form);
//var_dump($result);
if($result[0]['success']=='1'){
$this->Session->add('user_id', $result[0]['id']);
//$this->Session->add('username', $result[0]['username']);
//$this->Session->add('roleid', $result[0]['roleid']);
return $this->status(0,true,'auth.success',$result);
}else{
return $this->status(0,false,'auth.failed',$result);
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想创建一个名为'今天的日期'的日志文件,然后当该函数用于登录时,它将写入该用户已登录,与其他功能相同.但我每天只想要一个文件.
有人能够引导并教我如何做我的代码吗?
对于上传,我想检查年文件夹和月子文件夹是否已经存在。如果没有,我想创建它们并将我的上传保存在那里。
<?php
$newname = $_POST['changename'];
$temp = explode(".", $_FILES["uploadfile"]["name"]);
$extension = end($temp);
if(!(
$_FILES['uploadfile']['type']=='image/jpeg' ||
$_FILES['uploadfile']['type']=='image/png' ||
$_FILES['uploadfile']['type']=='image/gif' ||
$_FILES['uploadfile']['type']=='image/bmp'
)) // if file does not equal these types, kill it
{
echo $_FILES['uploadfile']['type'] . " is not an acceptable format.";
die();
}
if ($_FILES["uploadfile"]["size"] > 20000000)
{
echo "File too big. Max 20mb";
die();
}
if ($_FILES["uploadfile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["uploadfile"]["error"] . "<br>";
}
else
{
$new_file_name = $newname.".".$extension;
$path = "uploads/".$new_file_name;
move_uploaded_file($_FILES["uploadfile"]["tmp_name"],$path);
echo …Run Code Online (Sandbox Code Playgroud)