Exemplo n.º 1
0
 function isActive()
 {
     $activeStatus = VpnBo::sendCommand("/etc/init.d/openvpn status");
     // TODO
     $activeStatus = strpos($activeStatus, "not running") === false;
     return $activeStatus;
 }
Exemplo n.º 2
0
 function isActive()
 {
     $activeStatus = VpnBo::sendCommand("ps | grep openvpn");
     $activeStatus = strpos($activeStatus, "/usr/sbin/openvpn") !== false;
     return $activeStatus;
 }
Exemplo n.º 3
0
<?php

/*
	Copyright 2014-2015 Cédric Levieux, Jérémy Collot, ArmagNet

	This file is part of Parpaing.

    Parpaing is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Parpaing is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Parpaing.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
$path = "../../";
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'config/config.php';
require_once 'engine/bo/VpnBo.' . $config["parpaing"]["dialect"] . '.php';
$vpnBo = VpnBo::newInstance($config);
// Giving no configuration
$vpnBo->activate();
$activeStatus = $vpnBo->isActive();
echo json_encode(array("ok" => "ok", "isActive" => $activeStatus));
Exemplo n.º 4
0
    (at your option) any later version.

    VPN is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with VPN.  If not, see <http://www.gnu.org/licenses/>.
*/
// security
if (!isset($arguments)) {
    echo json_encode(array("error" => "not_a_service"));
    exit;
}
error_log("getSerial");
require_once "engine/bo/AccountBo.php";
require_once "engine/bo/VpnBo.php";
$connection = openConnection();
$accountBo = AccountBo::newInstance($connection);
$vpnBo = VpnBo::newInstance($connection);
$account = json_decode(urldecode($arguments["account"]), true);
$login = $account["login"];
$password = $account["password"];
$account = $accountBo->login($login, $password);
if (!$account) {
    echo json_encode(array("ko" => "ko", "message" => "badCredentials"));
    exit;
}
$serial = $vpnBo->getSerial();
echo json_encode(array("ok" => "ok", "serial" => $serial));
Exemplo n.º 5
0
 function execute($orderLine)
 {
     $code = $orderLine["oli_product_code"];
     switch ($code) {
         case "vpn_membership":
         case "vpn_year":
         case "pave_vpn_year":
             $validity = 12;
         case "vpn_6months":
             if (!isset($validity)) {
                 $validity = 6;
             }
             $vpnId = $orderLine["oli_additional_information"]["vpnId"];
             $vpnBo = VpnBo::newInstance($this->pdo);
             $vpns = $vpnBo->getVpns(array("vpn_hash" => $vpnId));
             //				echo "VpnId : $vpnId \n";
             //				print_r($vpns);
             if (count($vpns)) {
                 $vpn = $vpns[0];
                 if (!$vpn["vpn_end_date"]) {
                     $vpn["vpn_end_date"] = date("Y-m-d");
                     $vpnBo->save($vpn);
                 }
                 $vpnBo->addValidity($vpn, $validity);
                 shell_exec("api/activateCn.sh \"" . $vpn["vpn_cn"] . "\"");
             }
             break;
     }
 }