No Description

irwanmohi 7deb1eaef0 Perbarui 'index.php' 2 years ago
CloudFlare 72307cb71f initial commit 7 years ago
ErrorPages 72307cb71f initial commit 7 years ago
assets 4be84237cb :zap: updates 7 years ago
LICENSE.md ff19d7eaf6 Create LICENSE.md 7 years ago
README.md eec487b809 updates :zap: 6 years ago
htaccess.txt d4566704d4 fixing stuff 7 years ago
index.php 7deb1eaef0 Perbarui 'index.php' 2 years ago

README.md

cloudflare-dns-creator

A simple PHP script to create DNS records using the Cloudflare PHP API.

Installation

You will need:

  • Cloudflare
  • Web server (PHP)
  • Domain name
git clone https://github.com/reckr/cloudflare-dns-creator.git

Alternatively, download as a ZIP-archive and extract the files to your web server. When everything is on place, running a correctly configured web server, you can begin with modifying the files.

OPTIONAL: Rename the file "htaccess.txt" to ".htaccess" to get the recommended settings for an Apache HTTP server.

include "$_SERVER[DOCUMENT_ROOT]/CloudFlare/Api.php";
include "$_SERVER[DOCUMENT_ROOT]/CloudFlare/Zone/Dns.php";

$result = "";

$key = "Your Cloudflare Zone ID goes here"; 
// Above Cloudflare Zone ID, find it in Domain Overview --> Domain Summary --> Zone ID
$id = new \Cloudflare\Api("Your Cloudflare Email", "Your Cloudflare Global API Key");
// Above Cloudflare Email + Cloudflare Global API Key (https://www.cloudflare.com/a/profile) --> Global API Key
$dns = new \Cloudflare\Zone\Dns($id);

if(!empty($_POST["name"]) and !empty($_POST["value"]) and !empty($_POST["record"])) {
    $response = $dns->create($key, $_POST["record"], $_POST["name"] . ".yourdomain.name", $_POST["value"], 1);
    // Make sure to enter your domain name above (.yourdomain.name), or else the script won't work
    if ($response->success) {
        $result = '<div class="toast toast-success" style="margin: 0 auto; width:714px;text-align: center;"><b>Success!</b> Your hostname <b>' . $_POST['name'] . '.yourdomain.name</b> is now online!</div>';
    } else {
        $result = '<div class="toast toast-error" style="margin: 0 auto; width:714px;text-align: center;"><b>Sorry!</b> Your hostname <b>' . $_POST['name'] . '.yourdomain.name</b> could not be created!</div>';
    }
    
}

In the "index.php" file (code snippet above), make sure to edit the the $key = "Your Cloudflare Zone ID goes here"; and $id = new \Cloudflare\Api("Your Cloudflare Email", "Your Cloudflare Global API Key"). There are comments below each one of these lines, if you need help with finding your Cloudflare keys. Also make sure to replace all entries of yourdomain.name with your actual domain name.

Made using …

License

MIT License — see the LICENSE.md for more details.