Initial commit
[2ch-be.git] / dev-test / artist / ajax / ajax.php
blobf950cb8d61280185a115c1ed6c95050c94adf826
1 <?php
2 include("../encrypt_artist.php");
3 header('Content-Type: application/json');
4 if(!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) )
6 header("Location: ../artist.php");
7 }
8 if(!empty($_SESSION['artistid'])){
9 if(!empty($_POST['category'])){
10 $category = trim($_POST['category']);
11 $id = rand(1000000,9999999);
12 $writeData = "<id>{$id}</id><aid>".$_SESSION['artistid']."</aid><classname>{$category}</classname>\n";
14 $filename = ADBD_PATH."class.log";
15 $check = file(ADBD_PATH."class.log");
16 $thou = TRUE;
17 foreach ($check as $key => $value) {
18 if($category==within_str($value, "<classname>", "</classname>")) {
19 $thou = FALSE;
20 break;
23 if($thou){
24 if (!file_exists($filename)) {
25 if(!file_put_contents($filename,$writeData)) {
26 $writeSuccess = false;
28 $writeSuccess = true;
29 } else {
30 $handle = fopen($filename, "a");
31 if(!fwrite($handle, $writeData)) {
32 $writeSuccess = false;
33 }else{
34 $writeSuccess = true;
36 fclose($handle);
38 if($writeSuccess){
39 echo json_encode(array("a" => "success", "b" => $id));
40 }else{
41 echo json_encode(array("a" => "FALSE"));
43 }else{
44 echo json_encode(array("a" => "FALSE"));
47 }else{
48 echo json_encode(array("a" => "FALSE"));
50 }else{
51 echo json_encode(array("a" => "FALSE"));