示例#1
0
 public static function configByName($name)
 {
     $config_line = new ConfigLine(false, $name);
     if ($config_line->fetch()) {
         return $config_line->getValue();
     } else {
         return false;
     }
 }
示例#2
0
 public function __construct($offset = false, $limit = false, $sort_by = false, $order = false)
 {
     $result = array();
     if ($offset !== false) {
         $this->setOffset((int) $offset);
     }
     if ($limit !== false) {
         $this->setLimit((int) $limit);
     }
     if ($sort_by !== false) {
         $this->setSortBy($sort_by);
     }
     if ($order !== false) {
         $this->SetOrder($order);
     }
     // initialize $total_count with the total number of objects in the list (over all pages)
     try {
         $stmt = DB::getInstance()->prepare("SELECT COUNT(*) as total_count\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM config");
         $stmt->execute();
         $total_count = $stmt->fetch(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     $this->setTotalCount((int) $total_count['total_count']);
     //if limit -1 then get all configs
     if ($this->getLimit() == -1) {
         $this->setLimit($this->getTotalCount());
     }
     try {
         $stmt = DB::getInstance()->prepare("SELECT config.id as config_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM config\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase :sort_by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'config_id' then config.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $this->getOrder() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :offset, :limit");
         $stmt->bindParam(':offset', $this->getOffset(), PDO::PARAM_INT);
         $stmt->bindParam(':limit', $this->getLimit(), PDO::PARAM_INT);
         $stmt->bindParam(':sort_by', $this->getSortBy(), PDO::PARAM_STR);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     foreach ($result as $config_line) {
         $config_line = new ConfigLine((int) $config_line['config_id']);
         $config_line->fetch();
         $this->config_line_list[] = $config_line;
     }
 }
示例#3
0
 public function postTwitterMessage($statusMessage)
 {
     //Send Message to twitter
     $config_line = ConfigLine::configByName('twitter_token');
     if (ConfigLine::configByName('twitter_username') and $config_line) {
         $config = array('callbackUrl' => 'http://example.com/callback.php', 'siteUrl' => 'http://twitter.com/oauth', 'consumerKey' => ConfigLine::configByName('twitter_consumer_key'), 'consumerSecret' => ConfigLine::configByName('twitter_consumer_secret'));
         $token = unserialize($config_line);
         $client = $token->getHttpClient($config);
         $client->setUri('https://api.twitter.com/1.1/statuses/update.json');
         $client->setMethod(Zend_Http_Client::POST);
         $client->setParameterPost('status', $statusMessage);
         $response = $client->request();
         if ($response->getStatus() == 200) {
             $message[] = array("Folgendes wurde auf dem Twitteraccount von <a href=\"http://twitter.com/" . ConfigLine::configByName('twitter_username') . "\">" . ConfigLine::configByName('twitter_username') . "</a> angekündigt: <i>\"{$statusMessage}\"</i>", 1);
         } else {
             $message[] = array("Beim senden der Twitternachricht ist folgender Fehler aufgetreten: " . $response->getStatus(), 0);
         }
         Message::setMessage($message);
     }
 }
示例#4
0
     echo $e->getMessage();
     echo $e->getTraceAsString();
 }
 $community = json_decode($configSavedCommunityJson);
 $nodeCount = (int) $result[0]['count'];
 $community->state->nodes = $nodeCount;
 $lastNodeCount = ConfigLine::configByName('last_node_count');
 $now = date('c');
 if ($nodeCount != $lastNodeCount) {
     // nodecount has changed
     // update "lastchange-field"
     $community->state->lastchange = $now;
     Config::writeConfigLine('last_node_count', $nodeCount);
     Config::writeConfigLine('last_node_count_time', $now);
 } else {
     $lastTime = ConfigLine::configByName('last_node_count_time');
     if (!$lastTime) {
         // there has never been a setting stored - store and use current datettime
         Config::writeConfigLine('last_node_count_time', $now);
         $lastTime = $now;
     }
     // write to json
     $community->state->lastchange = $lastTime;
 }
 try {
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 60 * 15));
     header('Content-type: application/json');
     echo json_encode($community, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
 } catch (Exception $e) {
     echo json_encode('Unable to create communityfile: ', $e->getMessage(), "\n");
示例#5
0
<?php

require_once 'runtime.php';
require_once 'lib/core/register.class.php';
require_once 'lib/core/ConfigLine.class.php';
$smarty->assign('enable_network_policy', ConfigLine::configByName('enable_network_policy'));
$smarty->assign('network_policy_url', ConfigLine::configByName('network_policy_url'));
if (empty($_POST)) {
    $smarty->assign('message', Message::getMessage());
    $smarty->display("header.tpl.html");
    $smarty->display("register.tpl.html");
    $smarty->display("footer.tpl.html");
} else {
    //check weather the users wants to register with his openid
    if (isset($_GET['openid'])) {
        $_POST['password'] = Helper::randomPassword(8);
        $_POST['passwordchk'] = $_POST['password'];
    }
    if (Register::insertNewUser($_POST['nickname'], $_POST['password'], $_POST['passwordchk'], $_POST['email'], $_POST['agb'], $_POST['openid'])) {
        header('Location: ./login.php');
    } else {
        if (isset($_GET['openid'])) {
            header("Location: ./register.php?openid={$_GET['openid']}");
        } else {
            header('Location: ./register.php');
        }
    }
}
示例#6
0
文件: api.php 项目: wAmpIre/netmon
 private function config()
 {
     $this->_request['api_key'] = isset($this->_request['api_key']) ? $this->_request['api_key'] : 'a';
     $user = new User(false, false, false, false, false, $this->_request['api_key']);
     if ($user->fetch()) {
         if ($user->getPermission() == 120) {
             if ($this->get_request_method() == "GET" && (isset($this->_request['id']) || isset($this->_request['name']))) {
                 $this->_request['id'] = isset($this->_request['id']) ? $this->_request['id'] : false;
                 $this->_request['name'] = isset($this->_request['name']) ? $this->_request['name'] : false;
                 $config_line = new ConfigLine((int) $this->_request['id'], $this->_request['name']);
                 if ($config_line->fetch()) {
                     $domxmldata = $config_line->getDomXMLElement($this->domxml);
                     $this->response($this->finishxml($domxmldata), 200);
                 } else {
                     $this->error_code = 1;
                     $this->error_message = "Config not found";
                     $this->response($this->finishxml(), 404);
                 }
             }
             die;
         } else {
             $this->error_code = 2;
             $this->error_message = "Your API-Key has not enough permission.";
         }
     } else {
         $this->error_code = 2;
         $this->error_message = "The api_key is not valid.";
     }
     $this->authentication = 0;
     $this->response($this->finishxml(), 401);
 }
示例#7
0
<?php

require_once 'runtime.php';
require_once ROOT_DIR . '/lib/core/Ip.class.php';
require_once ROOT_DIR . '/lib/core/ConfigLine.class.php';
$ip = new Ip((int) $_GET['ip_id']);
if ($ip->fetch()) {
    if ($ip->getNetwork()->getIpv() == 6) {
        $command = "ping6 -c 4 -I " . ConfigLine::configByName("network_connection_ipv6_interface") . " " . $ip->getIp();
    } elseif ($ip->getNetwork()->getIpv() == 4) {
        $command = "ping -c 4 " . $ip->getIp();
    }
} else {
    echo "Could not fetch Info.";
}
$return = array();
echo "Command: " . $command . "<br><br>";
exec($command, $return);
echo "Result:<pre>";
print_r($return);
echo "</pre>";
     /**Insert Batman advanced Interfaces*/
     foreach ($data['batman_adv_interfaces'] as $bat_adv_int) {
         try {
             DB::getInstance()->exec("INSERT INTO crawl_batman_advanced_interfaces (router_id, crawl_cycle_id, name, status, crawl_date)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t VALUES ('{$data['router_id']}', '{$actual_crawl_cycle}', '{$bat_adv_int['name']}', '{$bat_adv_int['status']}', NOW());");
         } catch (PDOException $e) {
             echo $e->getMessage();
         }
     }
     echo "\t\t\tInserting Batman advanced originators into DB\n";
     /**Insert Batman Advanced Originators*/
     $originator_count = count($data['batman_adv_originators']);
     RrdTool::updateRouterBatmanAdvOriginatorsCountHistory($data['router_id'], $originator_count);
     $average_link_quality = 0;
     if (!empty($data['batman_adv_originators'])) {
         foreach ($data['batman_adv_originators'] as $originator) {
             if (ConfigLine::configByName('crawl_direct_originators_only') == 'true' and $originator['originator'] == $originator['nexthop']) {
                 $originator_status = new OriginatorStatus(false, (int) $actual_crawl_cycle, (int) $data['router_id'], $originator['originator'], (int) $originator['link_quality'], $originator['nexthop'], $originator['outgoing_interface'], $originator['last_seen']);
                 $originator_status->store();
                 RrdTool::updateRouterBatmanAdvOriginatorLinkQuality($data['router_id'], $originator['originator'], $originator['link_quality'], time());
                 $average_link_quality = $average_link_quality + $originator['link_quality'];
             }
         }
     }
     $average_link_quality = $average_link_quality / $originator_count;
     RrdTool::updateRouterBatmanAdvOriginatorLinkQuality($data['router_id'], "average", $average_link_quality, time());
     echo "\t\t\tInserting all other Data into DB\n";
     Crawl::insertCrawlData($data);
 } else {
     echo "\t\t\tRouterStatus could not be inserted into DB\n";
 }
 break 2;
示例#9
0
                    break;
                }
            }
        }
    }
}
//load menus
if ($GLOBALS['installed']) {
    $smarty->assign('top_menu', Menus::topMenu());
    $smarty->assign('loginOutMenu', Menus::loginOutMenu());
    $smarty->assign('normal_menu', Menus::normalMenu());
    $smarty->assign('object_menu', Menus::objectMenu());
    $smarty->assign('admin_menu', Menus::adminMenu());
    $smarty->assign('root_menu', Menus::rootMenu());
    $smarty->assign('menu_community_homepage', ConfigLine::configByName('community_homepage'));
    $smarty->assign('menu_community_homepage_name', ConfigLine::configByName('community_homepage_name'));
} else {
    $smarty->assign('installation_menu', Menus::installationMenu());
}
//Give often used variables to smarty
$smarty->assign('zeit', date("d.m.Y H:i:s", time()) . " Uhr");
//This is used for redirection after login
$current_page = "";
if (isset($_SERVER['REQUEST_URI']) and isset($_SERVER['SERVER_NAME'])) {
    $current_page = Helper::curPageURL();
}
//only take actual site if its not an api site, see http://ticket.freifunk-ol.de/issues/466
if (strpos($current_page, "api") === false) {
    $_SESSION['last_page'] = "";
    if (isset($_SESSION['current_page'])) {
        $_SESSION['last_page'] = $_SESSION['current_page'];
示例#10
0
文件: router.php 项目: wAmpIre/netmon
    $router->fetch();
    $smarty->assign('router', $router);
    $networkinterfacelist = new Networkinterfacelist(false, $router->getRouterId(), 0, -1, 'name', 'asc');
    $smarty->assign('networkinterfacelist', $networkinterfacelist);
    $originator_status_list = new OriginatorStatusList($router->getRouterId(), $router->getStatusdata()->getCrawlCycleId(), 0, -1);
    $smarty->assign('originator_status_list', $originator_status_list);
    $eventlist = new Eventlist();
    $eventlist->init('router', $router->getRouterId(), false, 0, 10, 'event_id', 'desc');
    $smarty->assign('eventlist', $eventlist);
    $smarty->display("header.tpl.html");
    $smarty->display("router.tpl.html");
    $smarty->display("footer.tpl.html");
} elseif (isset($_GET['section']) and $_GET['section'] == 'add') {
    //Logged in users can add a new router
    if (Permission::checkPermission(PERM_USER)) {
        $smarty->assign('message', Message::getMessage());
        $smarty->assign('google_maps_api_key', ConfigLine::configByName('google_maps_api_key'));
        $smarty->assign('community_location_longitude', ConfigLine::configByName('community_location_longitude'));
        $smarty->assign('community_location_latitude', ConfigLine::configByName('community_location_latitude'));
        $smarty->assign('community_location_zoom', ConfigLine::configByName('community_location_zoom'));
        $smarty->assign('twitter_token', ConfigLine::configByName('twitter_token'));
        $chipsetlist = new Chipsetlist(false, false, 0, -1);
        $smarty->assign('chipsetlist', $chipsetlist->getList());
        $smarty->display("header.tpl.html");
        $smarty->display("router_new.tpl.html");
        $smarty->display("footer.tpl.html");
    } else {
        Permission::denyAccess(PERM_USER);
    }
} elseif ($_GET['section'] == "store") {
}
示例#11
0
 /**
  * Sends a mail to a user who forgot his password with a new password and a link that lets the user set this new password
  * @author  Clemens John <*****@*****.**>
  * @param $user_id id of the user that wants to set a new password
  * @param $email email of the user that wants to set a new password
  * @param $nickname nickname of the user that wants to set a new password
  * @param $newpassword new plain text password for the user
  * @param $new_password_hash the hash of the new password. This hash is used to generate a link wich makes
  *			    the user able to set this hash for his new password
  * @param $old_password_hash the hash of the old password. This hash is used to generate a link wich makes
  *			    the user able to set this hash for his new password
  * @return boolean true if the mail was sent successfull
  */
 public function sendPassword($user_id, $email, $nickname, $newpassword, $new_password_hash, $old_password_hash)
 {
     $text = "Hallo {$nickname},\n\n";
     $text .= "du hast ein neues Passwort fuer die Netmon-Installation von " . ConfigLine::configByName('community_name') . " angefordert. Deine neuen Logindaten lauten:\n\n";
     $text .= "Nickname: {$nickname}\n";
     $text .= "Passwort: {$newpassword}\n\n";
     $text .= "Bitte bestaetige die Aenderungen mit einem Klick auf diesen Link:\n";
     $text .= ConfigLine::configByName('url_to_netmon') . "/set_new_password.php?user_id={$user_id}&new_passwordhash={$new_password_hash}&oldpassword_hash={$old_password_hash}\n\n";
     $text .= "Hinweis: sollte das Anklicken des Links nicht funktionieren musst du den link vollstaendig in die Adressleiste deines Webbrowsers kopieren.\n\n";
     $text .= "Liebe Gruesse\n";
     $text .= ConfigLine::configByName('community_name');
     if ($GLOBALS['mail_sending_type'] == 'smtp') {
         $config = array('username' => $GLOBALS['mail_smtp_username'], 'password' => $GLOBALS['mail_smtp_password']);
         if (!empty($GLOBALS['mail_smtp_ssl'])) {
             $config['ssl'] = $GLOBALS['mail_smtp_ssl'];
         }
         if (!empty($GLOBALS['mail_smtp_login_auth'])) {
             $config['auth'] = $GLOBALS['mail_smtp_login_auth'];
         }
         $transport = new Zend_Mail_Transport_Smtp($GLOBALS['mail_smtp_server'], $config);
     }
     $mail = new Zend_Mail();
     $mail->setFrom($GLOBALS['mail_sender_adress'], $GLOBALS['mail_sender_name']);
     $mail->addTo($email);
     $mail->setSubject("Neues Netmon Passwort fuer " . ConfigLine::configByName('community_name'));
     $mail->setBodyText($text);
     $mail->send($transport);
     $message[] = array("Dir wurde ein neues Passwort zugesendet.", 1);
     Message::setMessage($message);
     return true;
 }
示例#12
0
<?php

require_once 'runtime.php';
require_once ROOT_DIR . '/lib/core/Ip.class.php';
require_once ROOT_DIR . '/lib/core/ConfigLine.class.php';
$ip = new Ip((int) $_GET['ip_id']);
if ($ip->fetch()) {
    $return = array();
    if ($ip->getNetwork()->getIpv() == 6) {
        $command = "curl -s --max-time 10 -g http://[" . $ip->getIp() . "%25\$(cat /sys/class/net/" . ConfigLine::configByName("network_connection_ipv6_interface") . "/ifindex)]/node.data";
    } elseif ($ip->getNetwork()->getIpv() == 4) {
        $command = "curl -s --max-time 10 -g http://" . $ip->getIp() . "/node.data";
    }
    exec($command, $return);
    $return_string = "";
    foreach ($return as $string) {
        $return_string .= $string;
    }
    $smarty->assign('crawl_data', htmlentities($return_string));
}
$smarty->assign('message', Message::getMessage());
$smarty->display("header.tpl.html");
$smarty->display("show_crawl_data.tpl.html");
$smarty->display("footer.tpl.html");
示例#13
0
文件: config.php 项目: wAmpIre/netmon
     if (!empty($_GET) && isset($_SESSION['TWITTER_REQUEST_TOKEN'])) {
         $token = $consumer->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));
         $_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token);
         // Now that we have an Access Token, we can discard the Request Token
         $_SESSION['TWITTER_REQUEST_TOKEN'] = null;
     } else {
         // Mistaken request? Some malfeasant trying something?
         exit('Invalid callback request. Oops. Sorry.');
     }
     Config::writeConfigLine('twitter_username', $token->getParam('screen_name'));
     Config::writeConfigLine('twitter_token', $_SESSION['TWITTER_ACCESS_TOKEN']);
     $message[] = array('Netmon wurde an den Twitteraccount <a href="https://twitter.com/' . $token->getParam('screen_name') . '">' . $token->getParam('screen_name') . '</a> angebunden.', 1);
     Message::setMessage($message);
     header('Location: ./config.php?section=edit_twitter');
 } elseif ($_GET['section'] == "get_twitter_token") {
     $config = array('callbackUrl' => Config::getConfigValueByName('url_to_netmon') . '/config.php?section=recieve_twitter_token', 'siteUrl' => 'https://api.twitter.com/oauth', 'consumerKey' => ConfigLine::configByName('twitter_consumer_key'), 'consumerSecret' => ConfigLine::configByName('twitter_consumer_secret'));
     $consumer = new Zend_Oauth_Consumer($config);
     // fetch a request token
     $token = $consumer->getRequestToken();
     // persist the token to storage
     $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);
     // redirect the user
     $consumer->redirect();
 } elseif ($_GET['section'] == "edit_hardware") {
     $chipsetlist = new Chipsetlist();
     $smarty->assign('chipsetlist', $chipsetlist->getList());
     $smarty->assign('message', Message::getMessage());
     $smarty->display("header.tpl.html");
     $smarty->display("config_hardware.tpl.html");
     $smarty->display("footer.tpl.html");
 } elseif ($_GET['section'] == "add_hardware") {
示例#14
0
 public function sendNotification($user, $subject, $message)
 {
     if ($user->getNotificationMethod() == 'jabber') {
         $conn = new XMPPHP_XMPP(ConfigLine::configByName('jabber_server'), 5222, ConfigLine::configByName('jabber_username'), ConfigLine::configByName('jabber_password'), 'xmpphp', $server = null, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
         try {
             $conn->connect();
             $conn->processUntil('session_start');
             $conn->presence();
             $conn->message($user->getJabber(), $message);
             $conn->disconnect();
         } catch (XMPPHP_Exception $e) {
             echo $e->getMessage();
         }
     } elseif ($user->getNotificationMethod() == 'email') {
         if ($GLOBALS['mail_sending_type'] == 'smtp') {
             $config['username'] = ConfigLine::configByName('mail_smtp_username');
             $config['password'] = ConfigLine::configByName('mail_smtp_password');
             $config['ssl'] = ConfigLine::configByName('mail_smtp_ssl');
             $config['auth'] = ConfigLine::configByName('mail_smtp_login_auth');
             $transport = new Zend_Mail_Transport_Smtp(ConfigLine::configByName('mail_smtp_server'), $config);
         }
         $mail = new Zend_Mail();
         $mail->setFrom(ConfigLine::configByName('mail_sender_adress'), ConfigLine::configByName('mail_sender_name'));
         $mail->addTo($user->getEmail());
         $mail->setSubject($subject);
         $mail->setBodyText($message);
         $mail->send($transport);
     }
 }