-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.php
29 lines (29 loc) · 963 Bytes
/
post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
@session_start();
if (isset($_SESSION['dirname']) && $_SESSION['dirname'] == dirname($_SERVER['SCRIPT_NAME'])){
$login = true;
}else{
$login = false;
}
if(isset($_POST['tweet'])){
$now = date("Y-m-d H:i:s");
$tweets = simplexml_load_file($xmlfile);
$newid = $tweets->count() + 1;
$entry = $tweets->addChild("entry");
$entry -> addAttribute("id",$newid);
$entry -> addAttribute("share", $_POST['share']);
$entry -> addAttribute("person", $_POST['person']);
$entry -> addChild("date", $now);
$entry -> addChild("text", $_POST['tweet']);
if(isset($_POST['retweet'])){
$entry -> addChild("retweet",$_POST['retweet']);
}
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
$tmpfile = $_FILES['image']['tmp_name'];
$imgfile = "./img/upload/".$newid."_".$_FILES['image']['name'];
move_uploaded_file($tmpfile, $imgfile);
$entry -> addChild("img", $imgfile);
}
file_put_contents($xmlfile, $tweets->asXML());
}
?>