Exemple #1
0
    // Make the API Call
    echo "<br> MAKING API CALL";
    curl_setopt($ch, CURLOPT_URL, $unifyServer . '/api/s/default/cmd/stamgr');
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'json=' . $data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_exec($ch);
    echo "<br> CURL COMMAND EXECUTED";
    // Logout of the connection
    echo "<br> CLOSING UNIFI CONNECTION";
    curl_setopt($ch, CURLOPT_URL, $unifyServer . "/logout");
    $content = curl_exec($ch);
    if (FALSE === $content) {
        echo "<br> <span style=\"color:red\"" . curl_error($ch) . curl_errno($ch) . "</span>";
    }
    curl_close($ch);
    echo "<br> CURL COMMAND EXECUTED";
    //sleep(10); // Small sleep to allow controller time to authorize
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    sendAuthorization($_SESSION['id'], 72 * 60);
}
?>
<!DOCTYPE html><html lang="en">
<head>

<meta charset="UTF-8">

</head>
<body>
</body>
</html>
Exemple #2
0
    $cookie_file = "/tmp/unifi_cookie";
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
    // Allow Self Signed Certs
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSLVERSION, 1);
    // Login to the UniFi controller
    curl_setopt($ch, CURLOPT_URL, $unifi['unifiServer'] . "/api/login");
    $data = json_encode(array("username" => $unifi['unifiUser'], "password" => $unifi['unifiPass']));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_exec($ch);
    // Send user to authorize and the time allowed
    $data = json_encode(array('cmd' => 'authorize-guest', 'mac' => $id, 'minutes' => $minutes));
    // Make the API Call
    curl_setopt($ch, CURLOPT_URL, $unifi['unifiServer'] . '/api/s/default/cmd/stamgr');
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'json=' . $data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_exec($ch);
    // Logout of the connection
    curl_setopt($ch, CURLOPT_URL, $unifi['unifiServer'] . "/logout");
    curl_exec($ch);
    curl_close($ch);
    sleep(6);
    // Small sleep to allow controller time to authorize
}
if ($_POST) {
    // If the form has been posted allow them through.
    sendAuthorization($_SESSION['id'], '480');
}
Exemple #3
0
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * The views and conclusions contained in the software and documentation are those
 * of the authors and should not be interpreted as representing official policies, 
 * either expressed or implied, of the FreeBSD Project.
*/
require_once './config.php';
if ($_POST) {
    // Check to see if the form has been posted to
    // Set and sanitze the posted variables
    $user = preg_replace("/[^a-zA-Z0-9.]/", "", $_POST['username']);
    $pass = $_POST['password'];
    if ($_POST['terms'] == 'yes') {
        // See if the user exists in SQL
        if (authorizeSQL($user, $pass)) {
            sendAuthorization($_SESSION['id'], '480', $unifi);
            echo "<script type='text/javascript'>\$(location).attr('href','" . $_SESSION['url'] . "');</script>";
            echo "Successfuly Connected";
        } else {
            echo "Couldn't authorize user please try again or use the contact form for additional assistance.";
        }
    } else {
        echo "You must accept the terms of service";
    }
}