Created
April 29, 2020 10:27
-
-
Save prensmiskin/b37696f8f59cd1fb92d82162df6fe174 to your computer and use it in GitHub Desktop.
Sahnarts APP / Kullanıcıların yüklediği videoları sunucudan silmek için kullanılan web servis.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if($_SERVER['REQUEST_METHOD']=='POST'){ | |
$mailx = $_POST["mailx"]; | |
$servername = "delete"; | |
$username = "delete"; | |
$password = "delete"; | |
$dbname = "delete"; | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); | |
// set the PDO error mode to exception | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$v = $conn->prepare("select * from register where mail='$mailx' AND videoname=? "); | |
$v->execute(array('1')); | |
$x = $v->fetch(PDO::FETCH_ASSOC); | |
$d = $v->rowCount(); | |
if($d){ | |
$result["success"] = 44; | |
echo json_encode($result); | |
}else{ | |
$statement = $conn->prepare("SELECT videoname FROM register WHERE mail ='$mailx'"); | |
$statement->execute(); | |
$arrayd = $statement->fetchAll(PDO::FETCH_ASSOC); | |
foreach($arrayd as $rty){ | |
$ee = $rty["videoname"]; | |
} | |
$image_url = "imga/{$ee}"; | |
$dddg = realpath($image_url); | |
if (unlink($dddg)) { | |
$result["success"] = 8; | |
echo json_encode($result); | |
$sql = "UPDATE register SET videoname='1 ' WHERE mail='$mailx' "; | |
$stmt = $conn->prepare($sql); | |
// execute the query | |
$stmt->execute(); | |
if($stmt){ | |
$result["success"] = 15; | |
echo json_encode($result); | |
}else{ | |
$result["success"] = 25; | |
echo json_encode($result); | |
} | |
}else{ | |
$result["success"] = 9; | |
echo json_encode($result); | |
$dfsd = "1"; | |
$wdfswd = "1"; | |
} | |
//$result["imagename"] = $ee; | |
//echo json_encode($result); | |
//$dirs = scandir($dosya); | |
/* $sql = "INSERT INTO testred (code ) | |
VALUES ('$ee')" ; | |
// use exec() because no results are returned | |
$conn->exec($sql); | |
*/ | |
} | |
} | |
catch(PDOException $e) | |
{ | |
echo $sql . "<br>" . $e->getMessage(); | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment