-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ali Mokhtari
committed
Sep 8, 2019
1 parent
bd5a0a0
commit 8d6ae52
Showing
57 changed files
with
1,380 additions
and
1,395 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
<?php | ||
$target_dir = "media/"; | ||
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); | ||
$uploadOk = 1; | ||
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); | ||
// Check if image file is a actual image or fake image | ||
if(isset($_POST["upload"])) { | ||
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); | ||
if($check !== false) { | ||
echo "File is an image - " . $check["mime"] . "."; | ||
$uploadOk = 1; | ||
} else { | ||
echo "File is not an image."; | ||
$uploadOk = 0; | ||
} | ||
} | ||
// Check if file already exists | ||
if (file_exists($target_file)) { | ||
echo "Sorry, file already exists."; | ||
$uploadOk = 0; | ||
} | ||
// Check file size | ||
if ($_FILES["fileToUpload"]["size"] > 5000000) { | ||
echo "Sorry, your file is too large."; | ||
$uploadOk = 0; | ||
} | ||
// Allow certain file formats | ||
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" | ||
&& $imageFileType != "gif" && $imageFileType != "svg" ) { | ||
echo "Sorry, only JPG, JPEG, SVG, PNG & GIF files are allowed."; | ||
$uploadOk = 0; | ||
} | ||
// Check if $uploadOk is set to 0 by an error | ||
if ($uploadOk == 0) { | ||
echo "Sorry, your file was not uploaded."; | ||
// if everything is ok, try to upload file | ||
} else { | ||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { | ||
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; | ||
} else { | ||
echo "Sorry, there was an error uploading your file."; | ||
} | ||
} | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
$newdir = $_POST["newfoldername"]; | ||
mkdir($newdir); | ||
echo "done"; | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
include('config/db_connect.php'); | ||
$title = $_POST['title']; | ||
$author = $_POST['author']; | ||
$content = $_POST['content']; | ||
|
||
if(isset($_POST['submit'])){ | ||
$sql = "INSERT INTO posts (title, author, content) VALUES ('$title', '$author', '$content')"; | ||
}else{ | ||
echo 'sorry operation failed'; | ||
} | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
/* this file compiles the wbsite html that is linked to the style sheet from a simple txt file*/ | ||
$site_index = fopen("website.php", "w+") or die("Unable to open file!");/* Do not change this really.... */ | ||
$web_cont = file_get_contents('web.php'); | ||
fwrite($site_index, $web_cont);/* Do not change this too.... */ | ||
fclose($site_index);/* Do not change this / thanks.... */ | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM php:7.2-apache | ||
COPY . /var/www/html |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
//آدرس فایلی که میخواهیم دانلود کنیم | ||
$fileUrl = 'https://lh104.irandns.com:2222/CMD_FILE_MANAGER/domains/code%2Dstudent.ir/public%5Fhtml/themes/nova/web%2Dcont%2Epy'; | ||
|
||
//آدرس و نام فایل تو محلی که قراره ذخیره بشه | ||
$saveTo = 'website/a.theme'; | ||
|
||
//باز کردن Hanlder فایل. | ||
$fp = fopen($saveTo, 'w+'); | ||
|
||
//اگر فایل باز نشد خطا نشان بده | ||
if($fp === false){ | ||
throw new Exception('Could not open: ' . $saveTo); | ||
} | ||
|
||
//باز کردن هندل curl | ||
$ch = curl_init($fileUrl); | ||
|
||
//پاس دادن هندل فایل خدمان به CURL | ||
curl_setopt($ch, CURLOPT_FILE, $fp); | ||
|
||
//تایم آوت بشه اگه فایل تا ۲۰ ثانیه دانلود نشه | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 20); | ||
|
||
//اجرای درخواست کورل موردنظر. | ||
curl_exec($ch); | ||
|
||
//اگه خطا رخ داد کنترل کن | ||
if(curl_errno($ch)){ | ||
throw new Exception(curl_error($ch)); | ||
} | ||
|
||
//وضعیت درخواست HHTP رو میگیریم | ||
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
|
||
//هندلر رو میبندیم | ||
curl_close($ch); | ||
|
||
if($statusCode == 200){ | ||
echo 'Downloaded!'; | ||
} else{ | ||
echo "Status Code: " . $statusCode; | ||
} | ||
|
||
echo "done"; | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
//conect to database | ||
$conn = mysqli_connect('localhost', 'ali82496', '1381 20034aA@'); | ||
|
||
//check connection | ||
if (!$conn){ | ||
echo 'connoction error' . mysqli_connect_error(); | ||
} | ||
// Create database | ||
$sql = "CREATE DATABASE IF NOT EXISTS ara"; | ||
if (mysqli_query($conn, $sql)) { | ||
echo "Database created successfully"; | ||
} else { | ||
echo "Error creating database: " . mysqli_error($conn); | ||
} | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
include('db_connect.php'); | ||
// sql to create table | ||
$sql_table = "CREATE TABLE IF NOT EXISTS posts ( | ||
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, | ||
title VARCHAR(30) NOT NULL, | ||
author VARCHAR(30) NOT NULL, | ||
content VARCHAR(30) NOT NULL, | ||
created_at TIMESTAMP | ||
)"; | ||
|
||
if (mysqli_query($conn, $sql_table)) { | ||
echo "Table posts created successfully"; | ||
} else { | ||
echo "Error creating table: " . mysqli_error($conn); | ||
} | ||
|
||
// sql to create table | ||
$sql_table_users = "CREATE TABLE IF NOT EXISTS ara_users ( | ||
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, | ||
user VARCHAR(30) NOT NULL, | ||
email VARCHAR(30) NOT NULL, | ||
password VARCHAR(250) NOT NULL, | ||
role VARCHAR(5) NOT NULL | ||
)"; | ||
|
||
if (mysqli_query($conn, $sql_table_users)) { | ||
echo "Table users created successfully"; | ||
} else { | ||
echo "Error creating table: " . mysqli_error($conn); | ||
} | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
session_start(); | ||
$db = mysqli_connect('localhost', 'ali82496', '1381 20034aA@', 'ara_users'); | ||
|
||
$db = mysqli_connect('localhost', 'ali82496', '1381 20034aA@', 'ara'); | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<h1>Dashboard</h1> | ||
<br> | ||
<div class="card p-3" style="width: 100%;"> | ||
<?php | ||
$web_dir = "website"; | ||
if(is_dir($web_dir)) | ||
{ | ||
echo ("<p><strong>Welcome to Ara....</strong></p>"); | ||
} | ||
else | ||
{ | ||
echo ("lets create your first website <br> Loading...."); | ||
include 'AraNewDirectory.php'; | ||
function newFolder(){ | ||
mkdir("website"); | ||
echo "done"; | ||
} | ||
newFolder(); | ||
mkdir("media"); | ||
} | ||
?> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h1>Files</h1> | ||
<br> | ||
<div class="card p-3" style="width: 100%;"> | ||
<p class="files-process">Files</p> | ||
<form action="AraNewDirectory.php" method="post"> | ||
<input type="text" name="newfoldername"><br> | ||
<input type="submit" class="new-folder" value="New Folder" name="newfolder"> | ||
</form> | ||
<hr> | ||
<?php | ||
$dir_files = "."; | ||
// Sort in ascending orderead-liner - this is default | ||
$a = scandir($dir_files); | ||
$a = array_diff($a, array('.', '..')); | ||
foreach($a as $a){ | ||
echo "<div class=".'card-reverse-1'.">".'<p class= "text">'.$a."</p>"."</div>"; | ||
} | ||
?> | ||
</div> |
Oops, something went wrong.