本文整理汇总了PHP中Network类的典型用法代码示例。如果您正苦于以下问题:PHP Network类的具体用法?PHP Network怎么用?PHP Network使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Network类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get()
{
$profile_uid = intval($_GET['p']);
$load = argc() > 1 && argv(1) == 'load' ? 1 : 0;
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
echo array_key_exists('msie', $_GET) && $_GET['msie'] == 1 ? '<div>' : '<section>';
$mod = new Network();
$text = $mod->get($profile_uid, $load);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
// $text = preg_replace($pattern, $replace, $text);
/*
if(! $load) {
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
*/
echo str_replace("\t", ' ', $text);
echo array_key_exists('msie', $_GET) && $_GET['msie'] == 1 ? '</div>' : '</section>';
echo "</body></html>\r\n";
// logger('update_network: ' . $text);
killme();
}
示例2: render
function render()
{
$network = new Network();
$this->network_links = $network->get();
$this->inner_HTML = $this->generate_inner_html();
$links = parent::render();
return $links;
}
示例3: insertCrawlData
public function insertCrawlData($data)
{
$router_data = Router_old::getRouterInfo($data['router_id']);
$actual_crawl_cycle = Crawling::getActualCrawlCycle();
$last_endet_crawl_cycle = Crawling::getLastEndedCrawlCycle();
/**Insert Router Interfaces*/
foreach ($data['interface_data'] as $sendet_interface) {
//Update RRD Graph DB
$interface_last_endet_crawl = Interfaces::getInterfaceCrawlByCrawlCycleAndRouterIdAndInterfaceName($last_endet_crawl_cycle['id'], $data['router_id'], $sendet_interface['name']);
$traffic_rx_bps = round(($sendet_interface['traffic_rx'] - $interface_last_endet_crawl['traffic_rx']) / $GLOBALS['crawl_cycle'] / 60);
$traffic_rx_bps = $traffic_rx_bps < 0 ? 0 : $traffic_rx_bps;
$traffic_tx_bps = round(($sendet_interface['traffic_tx'] - $interface_last_endet_crawl['traffic_tx']) / $GLOBALS['crawl_cycle'] / 60);
$traffic_tx_bps = $traffic_tx_bps < 0 ? 0 : $traffic_tx_bps;
//Set default indizies to prevent from warnings
$sendet_interface['wlan_frequency'] = isset($sendet_interface['wlan_frequency']) ? preg_replace("/([A-Za-z])/", "", $sendet_interface['wlan_frequency']) : "";
$sendet_interface['wlan_mode'] = isset($sendet_interface['wlan_mode']) ? $sendet_interface['wlan_mode'] : "";
$sendet_interface['wlan_essid'] = isset($sendet_interface['wlan_essid']) ? $sendet_interface['wlan_essid'] : "";
$sendet_interface['wlan_bssid'] = isset($sendet_interface['wlan_bssid']) ? $sendet_interface['wlan_bssid'] : "";
$sendet_interface['wlan_tx_power'] = isset($sendet_interface['wlan_tx_power']) ? $sendet_interface['wlan_tx_power'] : 0;
//check if interface already exists
$networkinterface_test = new Networkinterface(false, (int) $data['router_id'], $sendet_interface['name']);
//if interface not exist, create new
if (!$networkinterface_test->fetch()) {
$networkinterface_new = new Networkinterface(false, (int) $data['router_id'], $sendet_interface['name']);
$networkinterface_id = $networkinterface_new->store();
} else {
$networkinterface_id = $networkinterface_test->getNetworkinterfaceId();
}
//save crawl data for interface
$networkinterface_status = new NetworkinterfaceStatus(false, (int) $actual_crawl_cycle['id'], (int) $networkinterface_id, (int) $data['router_id'], $sendet_interface['name'], $sendet_interface['mac_addr'], (int) $sendet_interface['mtu'], (int) $sendet_interface['traffic_rx'], (int) $traffic_rx_bps, (int) $sendet_interface['traffic_tx'], (int) $traffic_tx_bps, $sendet_interface['wlan_mode'], $sendet_interface['wlan_frequency'], $sendet_interface['wlan_essid'], $sendet_interface['wlan_bssid'], (int) $sendet_interface['wlan_tx_power'], false);
$networkinterface_status->store();
//Update RRDDatabase
$rrd_path_traffic_rx = ROOT_DIR . "/rrdtool/databases/router_{$data['router_id']}_interface_{$sendet_interface['name']}_traffic_rx.rrd";
if (!file_exists($rrd_path_traffic_rx)) {
exec("rrdtool create {$rrd_path_traffic_rx} --step 600 --start " . time() . " DS:traffic_rx:GAUGE:700:U:U DS:traffic_tx:GAUGE:900:U:U RRA:AVERAGE:0:1:144 RRA:AVERAGE:0:6:168 RRA:AVERAGE:0:18:240");
}
exec("rrdtool update {$rrd_path_traffic_rx} " . time() . ":" . round($traffic_rx_bps / 1000, 2) . ":" . round($traffic_tx_bps / 1000, 2));
//add unknown ipv6 link local addresses to netmon
//prepare data
$ipv6_link_local_addr = explode("/", $sendet_interface['ipv6_link_local_addr']);
$ipv6_link_local_netmask = isset($ipv6_link_local_addr[1]) ? (int) $ipv6_link_local_addr[1] : 64;
$ipv6_link_local_addr = Ip::ipv6Expand($ipv6_link_local_addr[0]);
//first try to determine network of given address
$ipv6_link_local_network = Ip::ipv6NetworkFromAddr($ipv6_link_local_addr, (int) $ipv6_link_local_netmask);
$network = new Network(false, false, $ipv6_link_local_network, (int) $ipv6_link_local_netmask, 6);
if ($network->fetch()) {
//if network found, then try to add ip address
$ip = new Ip(false, (int) $networkinterface_id, $network->getNetworkId(), $ipv6_link_local_addr);
$ip->store();
}
}
RrdTool::updateRouterClientCountHistory($data['router_id'], $data['client_count']);
}
示例4: postNetwork
public function postNetwork()
{
$posted = Input::all();
$Network = new Network();
$Network->category_id = $posted['category_id'];
$Network->country_id = $posted['country_id'];
$Network->network_name = $posted['network_name'];
$Network->delivery_time = $posted['delivery_time'];
$Network->price = $posted['price'];
$Network->save();
return Redirect::back()->with('success', 'Network has been successfully added');
}
示例5: render
function render()
{
$network = new Network();
$extra = unserialize(PA::$network_info->extra);
$this->network_data = '';
if (!empty($extra['network_feature'])) {
$network->network_id = $extra['network_feature'];
$this->network_data = $network->get();
}
$this->inner_HTML = $this->generate_inner_html();
$content = parent::render();
return $content;
}
示例6: __construct
public function __construct($user_id = false, $ipv = false, $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 networks\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(user_id = :user_id OR :user_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(ipv = :ipv OR :ipv=0)");
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
$stmt->bindParam(':ipv', $ipv, PDO::PARAM_INT);
$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 ressource records
if ($this->getLimit() == -1) {
$this->setLimit($this->getTotalCount());
}
try {
$stmt = DB::getInstance()->prepare("SELECT id as network_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM networks\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(user_id = :user_id OR :user_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(ipv = :ipv OR :ipv=0)\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 'create_date' then networks.create_date\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(':user_id', $user_id, PDO::PARAM_INT);
$stmt->bindParam(':ipv', $ipv, PDO::PARAM_INT);
$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 $network) {
$network = new Network((int) $network['network_id']);
$network->fetch();
$this->networklist[] = $network;
}
}
示例7: networks
public function networks()
{
$networks = Network::where('user_id', '=', Auth::user()->id)->get();
$page_data = array('network_count' => count($networks), 'networks' => $networks);
$this->layout->title = 'Networks';
$this->layout->content = View::make('admin.networks', $page_data);
}
示例8: handlePOST
public function handlePOST($request_data)
{
global $mothership_info;
if (!empty($request_data['request'])) {
//code for requesting
$this->error = FALSE;
$this->success = FALSE;
try {
$request_sent = Network::join(PA::$network_info->network_id, PA::$login_uid);
if (!empty($request_sent)) {
$this->success = TRUE;
}
} catch (PAException $e) {
$join_error = $e->message;
$this->error = TRUE;
}
if (!empty($this->error)) {
$this->error_msg = sprintf(__('Your request to join this network could not be sent due to following reason: %s. You can go back to the home network by clicking Return to home network'), $join_error);
} else {
$this->success_msg = __('Your request to join this network has been successfully sent to the moderator of this network. The Moderator will check this request and approve or deny the request. You can go back to mother network by clicking the button Return to home network');
}
$this->mode = 'msg_display';
}
if (!empty($request_data['back'])) {
//redirect to mother network
global $mothership_info;
$this->message = __('Return to home network successfully.');
$this->redirect2 = NULL;
$his->queryString = NULL;
$this->isError = FALSE;
$this->setWebPageMessage();
}
}
示例9: get_links
function get_links()
{
// Loading the Searching data
if ($this->sort_by == 'alphabetic') {
$this->sort_by = 'login_name';
$sorting_direction = 'ASC';
} else {
$this->sort_by = 'created';
$sorting_direction = 'DESC';
}
global $network_info;
$users = array();
if ($this->search_data) {
// load users on the basis of the search parameters.
$users_count = User::user_search($this->search_data, $this->viewer_uid, $network_info->network_id);
$this->Paging["count"] = $users_count['total_users'];
$users = User::user_search($this->search_data, $this->viewer_uid, $network_info->network_id, FALSE, $this->Paging["show"], $this->Paging["page"], 'U.' . $this->sort_by, $sorting_direction);
} else {
$this->Paging["count"] = Network::get_network_members($network_info->network_id, array('cnt' => TRUE));
$params = array('page' => $this->Paging["page"], 'show' => $this->Paging["show"], 'sort_by' => $this->sort_by, 'direction' => $sorting_direction);
$users = Network::get_network_members($network_info->network_id, $params);
}
// echo "<pre>" . print_r($users,1) . "</pre>";
$this->users_data = $users['users_data'];
}
示例10: ephimeral_port
/**
* Find an open port in a given range, trying several times.
* Return FALSE if no open port is found after a timeout (1 second by default)
*
* @param string $host
* @param integer $range_start
* @param integer $range_end
* @param integer $timeout
* @return integer|boolean
*/
public static function ephimeral_port($host, $range_start = 1000, $range_end = 5000, $timeout = 1000)
{
return Attempt::make(function () use($host, $range_start, $range_end) {
$port = rand($range_start, $range_end);
return Network::is_port_open($host, $port) ? $port : FALSE;
}, $timeout);
}
示例11: get_links
private function get_links()
{
//get total count
$param = array('network_id' => PA::$network_info->network_id, 'cnt' => TRUE, 'neglect_owner' => TRUE);
//search by login name, including full names also
if (!empty($this->keyword)) {
$param['search_keyword'] = $this->keyword;
$param['also_search_fullname'] = true;
}
$param['sort_by'] = $this->sort_by;
$param['direction'] = $this->direction;
$param['show_waiting_users'] = true;
$this->Paging["count"] = Network::get_members($param);
//now we dont need $param['cnt']
unset($param['cnt']);
$param['show'] = $this->Paging['show'];
$param['page'] = $this->Paging['page'];
//get actual list
$users = Network::get_members($param);
$links = $users['users_data'];
$objects = array('network' => true, 'groups' => array(), 'forums' => array());
//echo serialize($objects);
// echo '<pre>'.print_r($links,1).'</pre>';
return $links;
}
示例12: getBoardsInfo
private function getBoardsInfo()
{
$boards_info = array();
$this->nid = isset($this->shared_data['network_id']) ? $this->shared_data['network_id'] : PA::$network_info->network_id;
$boards = PaForumBoard::listPaForumBoard("network_id = {$this->nid} AND is_active = 1", 'type', 'ASC', 10);
if (count($boards) > 0) {
for ($i = 0; $i < count($boards); $i++) {
$title = $boards[$i]->get_title();
$type = $boards[$i]->get_type();
$boards_info[$i]['title'] = strlen($title) <= self::max_title_length ? $title : substr($title, 0, self::max_title_length + 3) . '...';
$boards_info[$i]['type'] = $type;
$net_id = $boards[$i]->get_network_id();
if (Network::is_mother_network($net_id)) {
$address = 'www';
} else {
$network = Network::get_by_id((int) $net_id);
$address = $network->address;
}
$url = "http://{$address}." . PA::$domain_suffix . PA_ROUTE_FORUMS . "/network_id=" . $net_id;
switch ($type) {
case PaForumBoard::network_board:
break;
case PaForumBoard::group_board:
$url .= "&gid=" . $boards[$i]->get_owner_id();
break;
case PaForumBoard::personal_board:
$url .= "&user_id=" . $boards[$i]->get_owner_id();
break;
}
$boards_info[$i]['url'] = $url;
}
}
return $boards_info;
}
示例13: getNetwork
public function getNetwork()
{
if (!$this->_network instanceof Network_Interface) {
$this->_network = Network::create($this);
}
return $this->_network;
}
示例14: auto_email_notification
function auto_email_notification($activity_type, $params)
{
global $network_info;
global $to, $mail_type, $mail_sub_msg_array, $from, $no_id, $network_owner, $subject, $message, $owner;
if (!$network_info) {
return;
}
//setting common variables
//mail to
if ($network_info->type == MOTHER_NETWORK_TYPE) {
$network_owner_id = SUPER_USER_ID;
} else {
$network_owner_id = Network::get_network_owner($network_info->network_id);
}
$network_owner = User::map_ids_to_logins($network_owner_id);
$owner = new User();
foreach ($network_owner as $key => $value) {
$owner->load((int) $key);
}
$to = $owner->email;
$owner_name = $owner->login_name;
//mail from
$from = (int) $_SESSION['user']['id'];
$array_of_data = array('to' => $to, 'from' => $from, 'owner_name' => $owner_name, 'params' => $params);
call_user_func_array($activity_type, array($array_of_data));
}
示例15: get_user_links
function get_user_links()
{
$extra = unserialize(PA::$network_info->extra);
if (Network::is_mother_network(PA::$network_info->network_id)) {
$uid = SUPER_USER_ID;
} else {
$uid = Network::get_network_owner(PA::$network_info->network_id);
}
$condition = array('user_id' => $uid, 'is_active' => 1);
$limit = 5;
// 5 lists to be display on home page
$Links = new NetworkLinks();
$category_list = $Links->load_category($condition, $limit);
if (!empty($category_list)) {
for ($counter = 0; $counter < count($category_list); $counter++) {
$links_data_array[$counter]['category_id'] = $category_list[$counter]->category_id;
$links_data_array[$counter]['category_name'] = $category_list[$counter]->category_name;
$Links->user_id = $uid;
$condition = array('category_id' => $category_list[$counter]->category_id, 'is_active' => 1);
$limit = 5;
// 5 links to be display on home page
$links_array = $Links->load_link($condition, $limit);
$links_data_array[$counter]['links'] = $links_array;
}
return $links_data_array;
}
}