gpt4 book ai didi

PHP回调包含

转载 作者:太空宇宙 更新时间:2023-11-03 12:11:03 24 4
gpt4 key购买 nike

我用 PHP 创建了一个类:

<?php

class _new_model extends model {

/**
* NEW contruct
*/
public function __construct() {
parent::__construct();
}

function newuser(){
$password = trim($_POST['psw']);
$password2= trim($_POST['psw1']);
if($password === $password2){
$hashpsw = hash('sha512', $password);
$salt = $this->createSalt();
$psw = hash('sha512', $salt . $hashpsw);
$query = $this->db->prepare('INSERT INTO users (username, password, salt) VALUES (?,?,?)');
$query->bindValue(1, $_POST['user'], PDO::PARAM_STR);
$query->bindValue(2, $psw, PDO::PARAM_STR);
$query->bindValue(3, $salt, PDO::PARAM_STR);
try{
if($query->execute()){
echo 'ჩაიწერა!';
}else{
echo 'მოხდა შეცდომა!';
}
}catch(PDOException $e){
die($e->getMessage());
}
}else{
echo 'პაროლები ერთმანეთს არ ემთხვევა!';
}
}

/**
* @return string
*/
function createSalt(){
$text = md5(uniqid(rand(), TRUE));
$salt = substr($text, 0, 32);
return $salt;
}
function newlanguage(){
$lang = trim($_POST('language'));
$checklang = $this->checklang($lang);
if($checklang == true){
echo 'ეს ენა უკვე არსებობს';
}else{
if(is_uploaded_file($_FILES['flag']['tmp_name'])){
$maxsize=100000;
$size=$_FILES['flag']['size'];
$imgdetails = getimagesize($_FILES['flag']['tmp_name']);
$mime_type = $imgdetails['mime'];
// checking for valid image type
if(($mime_type=='image/jpeg')||($mime_type=='image/gif')||($mime_type=='image/bmp')||($mime_type=='image/png')){
// checking for size again
if($size<$maxsize){
$filename=$_FILES['flag']['name'];
$imgData =addslashes (file_get_contents($_FILES['flag']['tmp_name']));
$query = $this->db->prepare('INSERT INTO lang (name,mokled,flag,flagname,flagtype,flagsize) VALUES (?,?,?,?,?,?)');
$query->bindValue(1, $lang, PDO::PARAM_STR);
$query->bindValue(2, trim($_POST('shortlang')), PDO::PARAM_STR);
$query->bindValue(3, $imgData, PDO::PARAM_LOB);
$query->bindValue(4, $filename, PDO::PARAM_STR);
$query->bindValue(5, $mime_type, PDO::PARAM_STR);
$query->bindValue(6, addslashes($imgdetails[3]), PDO::PARAM_STR);
try{
if($query->execute()){
echo 'yes';
}else{
echo 'no query-ის გაშვებისას';
}
}catch (PDOException $e){
die($e->getMessage());
}
}else{
echo "<span class='error'>Image to be uploaded is too large..Error uploading the image!!</span>";
}
}else{
echo "<span class='error'>Not a valid image file! Please upload jpeg or gif image.</span>";
}
}else{
switch($_FILES['flag']['error']){
case 0: //no error; possible file attack!
echo "<span class='error'>There was a problem with your upload.</span>";
break;
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
echo "<span class='error'>The file you are trying to upload is too big.</span>";
break;
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
echo "<span class='error'>The file you are trying to upload is too big.</span>";
break;
case 3: //uploaded file was only partially uploaded
echo "<span class='error'>The file you are trying upload was only partially uploaded.</span>";
break;
case 4: //no file was uploaded
echo "<span class='error'>You must select an image for upload.</span>";
break;
default: //a default error, just in case!
echo "<span class='error'>There was a problem with your upload.</span>";
break;
}
}
}
}

/**
* @param $name
* @return bool
*/
function checklang($name){
$query = $this->db->prepare('SELECT id FROM lang WHERE name = ?');
$query->bindValue(1, $name, PDO::PARAM_STR);
try{
$query->execute();
if($query->rowCount() > 0){
return true;
}else{
return false;
}
}catch (PDOException $e){
die($e->getMessage());
}
}}

并且有这个 HTML 表单:

<form enctype="multipart/form-data" action="<?php echo Domain; ?>_new/newlanguage/" name="newlanguage" method="post" id="newlanguage" >
<input type="text" name="language" id="language" placeholder="New Language">
<input type="text" name="shortlang" id="shortlang" placeholder="short name"><br>
<input type="file" name="flag" id="flag" placeholder="Flag"><br>
<input type="submit" name="submit" value="submit"></form>

提交表单时,我收到此错误:

array callback has to contain indices 0 and 1 in _new_model.php on line 49 and on this line is written return $salt;

这是名为 create salt 的函数。我不明白当我调用 newlanguage 函数时,为什么它会扫描其他函数?

请帮忙

最佳答案

$_POST('language') 应该是 $_POST['language']

关于PHP回调包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24194930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com