Example #1
0
 function __construct()
 {
     if (!islogged()) {
         redirect('login');
     }
     $this->usermodel = new usermodel();
     $this->mailerdecorator = new mailerdecorator();
 }
Example #2
0
 function __construct()
 {
     if (!islogged()) {
         redirect('login');
     }
     if (!isadmin()) {
         redirect('/');
     }
     $this->adminmodel = new adminmodel();
     $this->mailerdecorator = new mailerdecorator();
 }
Example #3
0
function getperm()
{
    if (!islogged()) {
        echo "&notlogged";
    } else {
        if (isadmin()) {
            echo "&admin";
        } else {
            echo "&logged";
        }
    }
}
Example #4
0
function can_get_listrule($user)
{
    global $session;
    if (isadmin()) {
        return TRUE;
    }
    if ($user === "guest") {
        return TRUE;
    }
    if ($user === "common") {
        return TRUE;
    }
    if (!islogged()) {
        return FALSE;
    }
    if ($session["user"] === $user) {
        return TRUE;
    }
    return FALSE;
}
Example #5
0
<?php

if (islogged()) {
    echo '<div id="left-container">
	<ul class="left-menu">';
    if (isadmin()) {
        $links = array('/' . get_site_lang() => lang('title.accounts'), '/' . get_site_lang() . '/application/add' => lang('title.add.account'), '/' . get_site_lang() . '/application/import' => lang('title.import.accounts'));
    }
    $links['/' . get_site_lang() . '/application/profile'] = lang('title.profile');
    $links['/' . get_site_lang() . '/login/logout'] = lang('login.logout');
    foreach ($links as $link => $title) {
        echo '<li><a href="' . $link . '">' . $title . '</a></li>';
    }
    echo '</ul>
	</div>';
}
Example #6
0
function show_menu()
{
    global $betatest;
    if (isset($_GET['iframe'])) {
        return;
    }
    global $webdir;
    global $session;
    $menu = <<<EOF

<div class=menu-box>
<div class=menu>
EOF;
    /* // Beta testing */
    /*   if(islogged()) { */
    $menu .= <<<EOF
<a class="menulink" href="{$webdir}/">
 Home</a> -
<a class="menulink" href="{$webdir}/explore/">
  Explore</a> -
<a class="menulink" href="{$webdir}/tools.php">
Tools</a> - 
<a class="menulink" href="{$webdir}/help/">
Help</a>
EOF;
    if (isadmin()) {
        $menu .= <<<EOF
 -
<a class="menulink" href="{$webdir}/admin/">Admin </a>
EOF;
    }
    /*	// Beta testing */
    /*     } else { */
    /* 	$menu .= <<<EOF */
    /* NucleoidDB is in beta test */
    /* EOF; */
    /*       } */
    $menu .= <<<EOF
</div>
<div id="login-panel">
EOF;
    if (islogged()) {
        $menu .= <<<EOF
\t    <p>
\t    Logged as <span id="menuusername">{$session['user']}</span></p><p>
\t    <a href="{$webdir}/admin/user.php?action=logout">Logout</a> -
\t    <a href="{$webdir}/admin/change-passwd.php">Change password</a>
\t    </p>
EOF;
    } else {
        $menu .= <<<EOF
  <form action="javascript:void(0)" name="loginform"
\tmethod="post" onsubmit='login(event)'>
      <label>User: </label>
\t<input class="loginField" name="username"
\t       type="text" maxlength="80" value="" />
      <label>Pass: </label>
\t<input class="loginField" name="password"
\t       type="password" maxlength="12" value="" />
      <input class="loginField" 
\t     type="submit" name="submit" value="Sign In" />
      <p id="usererror">You are not logged in</p>
  </form> 
EOF;
    }
    $menu .= "</div>";
    $menu .= "</div><br />";
    echo $menu;
}
function cyrus_cluster_receive()
{
    $array = unserialize(base64_decode($_POST["cyrus-cluster"]));
    $users = new usersMenus();
    $sock = new sockets();
    $fqdn = $users->fqdn;
    if ($fqdn == null) {
        $fqdn = $users->hostname;
    }
    $_GET["admin"] = $array["admin"];
    $_GET["pass"] = $array["pass"];
    if (!islogged(1, 1)) {
        writelogs("Bad username and password", __FUNCTION__, __FILE__, __LINE__);
        $return["RESULT"] = "{$fqdn}: {$array["admin"]}: {username}/{password} {failed}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    writelogs("Username and password OK", __FUNCTION__, __FILE__, __LINE__);
    $users = new usersMenus();
    if (!$users->cyrus_sync_installed) {
        $return["RESULT"] = "{$fqdn}: {sync_tools_not_compiled}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    if ($sock->GET_INFO("CyrusEnableImapMurderedFrontEnd") == 1) {
        $return["RESULT"] = "{$fqdn}: {already_a_murder_frontend}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    if (!function_exists("curl_init")) {
        $return["RESULT"] = "{$fqdn}:{error_php_curl}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    writelogs("Success pass tests...", __FUNCTION__, __FILE__, __LINE__);
    if ($array["cmd"] == "tests") {
        $return["RESULT"] = "{$fqdn}: {success}";
        $return["REPLY"] = true;
        echo base64_encode(serialize($return));
        return;
    }
    if ($array["cmd"] == "connect") {
        writelogs("Try to be a replica {$array["master_ip"]}:{$array["master_artica_port"]}", __FUNCTION__, __FILE__, __LINE__);
        $cyrus_cluster = new cyrus_cluster();
        if (!$cyrus_cluster->test_remote_server($array["master_ip"], $array["master_artica_port"], $array["ldap_admin"], $array["ldap_password"])) {
            writelogs("Unable to call master server {$array["master_ip"]}:{$cyrus_cluster->error_text}", __FUNCTION__, __FILE__, __LINE__);
            $return["RESULT"] = $cyrus_cluster->error_text;
            $return["REPLY"] = false;
            echo base64_encode(serialize($return));
            return;
        }
        writelogs("Call master server {$array["master_ip"]}: success", __FUNCTION__, __FILE__, __LINE__);
        $ini = new Bs_IniHandler();
        $ini->set("REPLICA", "servername", $array["master_ip"]);
        $ini->set("REPLICA", "username", $array["ldap_admin"]);
        $ini->set("REPLICA", "password", $array["ldap_password"]);
        $ini->set("REPLICA", "artica_port", $array["master_artica_port"]);
        $ini->set("REPLICA", "suffix", $array["suffix"]);
        $sock->SaveConfigFile($ini->toString(), "CyrusReplicaLDAPConfig");
        $sock->SET_INFO("EnableCyrusReplicaCluster", 1);
        $sock->SET_INFO("EnableCyrusMasterCluster", 0);
        $sock->SET_INFO("CyrusReplicaClusterPort", $array["master_cyrus_port"]);
        $sock->SET_INFO("CyrusReplicaClusterServer", $array["master_ip"]);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
        writelogs("Success Enable replica", __FUNCTION__, __FILE__, __LINE__);
        $return["RESULT"] = "{success}";
        $return["REPLY"] = true;
        echo base64_encode(serialize($return));
        writelogs("Success to be a replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
        return;
    }
    if ($array["cmd"] == "disconnect") {
        writelogs("Try to disable replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO("EnableCyrusReplicaCluster", 0);
        writelogs("Success disable replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
    }
    if ($array["cmd"] == "isReplica") {
        if ($sock->GET_INFO("EnableCyrusReplicaCluster") == 1) {
            $return["RESULT"] = "{success}";
            $return["REPLY"] = true;
        } else {
            $return["RESULT"] = "{failed}: not a replica";
            $return["REPLY"] = false;
        }
        echo base64_encode(serialize($return));
    }
}
Example #8
0
    <link href="/public/css/base.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/public/js/jquery.min.js"></script>
    <script type="text/javascript" src="/public/js/vform.js"></script>
    <script type="text/javascript" src="/public/js/app.js"></script>
</head>

<body>
    <div class="outter-wrap">
        <div class="inner-wrap">
            <div id="header">
                <div id="title-site">
                        <a href="/<?php 
echo get_site_lang();
?>
"><h1>USERS MANAGER APP.</h1></a>
					<? if (islogged()) : ?>
						<div id="site-deconnection">
							<?php 
echo ucfirst($_SESSION['user']['first_name']);
?>
 <?php 
echo ucfirst($_SESSION['user']['last_name']);
?>
						</div>
					<? endif  ?>
				</div>
                    <h2 id="title-header"><?php 
echo $title;
?>
</h2>
			</div>
<?php

include_once 'ressources/class.templates.inc';
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.mysql.inc';
include_once 'ressources/class.ini.inc';
include_once 'ressources/class.cyrus.inc';
include_once 'ressources/class.user.inc';
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', null);
ini_set('error_append_string', null);
if (!islogged()) {
    die;
}
if (isset($_POST["OUS"])) {
    IMPORT_OUS();
    die;
}
if (isset($_POST["MEMBERS"])) {
    IMPORT_MEMBERS();
    die;
}
while (list($num, $ligne) = each($_POST)) {
    writelogs("Unable to undertsand: {$num} = {$ligne}", "MAIN", __FILE__, __LINE__);
    echo "Unable to undertsand: {$num} = {$ligne}\n";
}
function islogged($nomurder = 0, $noecho = 0)
{
    $users = new usersMenus();
Example #10
0
<?php

require "../includes/config.php";
islogged();
//if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    //fetch data about the to-be sold stock
    $row = query("SELECT * FROM `stocks` WHERE `id`=? AND `symbol`=?", $_SESSION['id'], $_POST['symbol']);
    $result = $row[0];
    //if no data was found
    if ($row === false || count($result) == 0) {
        apologize("An error has occurred, please try again.");
    } else {
        if ($_POST['num'] > $result['shares']) {
            //thna avilable stocks
            apologize("You can't sell {$_POST['num']} " . "shares you only have {$result["shares"]}.");
        }
    }
    if ($result['shares'] - $_POST['num'] == 0) {
        query("DELETE FROM `stocks` WHERE `symbol`=? AND `id`=?", $_POST['symbol'], $_SESSION['id']);
    } else {
        query("UPDATE `stocks` SET `shares`=(`shares`-?) WHERE `symbol`=?", $_POST['symbol']);
    }
    //lookup the symbol
    $data = lookup($_POST['symbol']);
    //updates user's cash
    query("UPDATE `users` SET `cash`=(`cash`+?) WHERE `id`=?", $_POST['num'] * $data['price'], $_SESSION['id']);
    //update history
    query("INSERT INTO history (action, id, symbol, shares, price) VALUES('s', ?, ?, ?, ?)", $_SESSION['id'], strtoupper($_POST['symbol']), $_POST['num'], $data['price']);
    //render result
    render("../templates/sell_result.php", ["shares" => $_POST['num'], "name" => $data['name'], "symbol" => $_POST['symbol'], "total" => number_format($data['price'] * $_POST['num'], 4, ".", ",")]);