Example #1
0
 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();
 }
 function render()
 {
     $network = new Network();
     $this->network_links = $network->get();
     $this->inner_HTML = $this->generate_inner_html();
     $links = parent::render();
     return $links;
 }
Example #3
0
 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']);
 }
 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');
 }
 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;
 }
Example #6
0
 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;
     }
 }
Example #7
0
 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);
 }
 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();
     }
 }
 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'];
 }
Example #10
0
 /**
  * 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);
 }
 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;
 }
 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;
 }
Example #13
0
 public function getNetwork()
 {
     if (!$this->_network instanceof Network_Interface) {
         $this->_network = Network::create($this);
     }
     return $this->_network;
 }
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));
}
 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;
     }
 }
/** how to use this file
 *
 * include this file where you want to call auto_email_notification
 *  then create a function in this file as it is depicted in                           *  extra['notify_owner']['<-case->']['caption'] field of network info
 *  for examaple 'some_joins_a_network'
 *  within that function return if extra['notify_owner']['<-case->']['value'] !=       *  NET_NONE means no notification
 *  other wise set variables that is to be used in mail/message subject body
 *  then call function $this->switch_destination($destination)
 *
 */
function auto_email_notification($activity_type, $params)
{
    if (!PA::$network_info) {
        return;
    }
    //setting common variables
    $notification = new EmailNotification();
    //mail to
    if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
        $network_owner_id = SUPER_USER_ID;
    } else {
        $network_owner_id = Network::get_network_owner(PA::$network_info->network_id);
    }
    $notification->network_owner = User::map_ids_to_logins($network_owner_id);
    $notification->owner = new User();
    foreach ($notification->network_owner as $key => $value) {
        $notification->owner->load((int) $key);
    }
    $notification->to = $notification->owner->email;
    $owner_name = $notification->owner->login_name;
    //mail from
    $notification->from = (int) PA::$login_uid;
    $array_of_data = array('to' => $notification->to, 'from' => $notification->from, 'owner_name' => $owner_name, 'params' => $params);
    $notification->send($activity_type, $array_of_data);
}
function setup_module($column, $moduleName, $obj)
{
    global $content_type, $show_media, $uid, $group_ids, $paging, $error_msg, $login_uid;
    $extra = unserialize(PA::$network_info->extra);
    $authorized_users = array();
    if (!empty($show_media)) {
        $authorized_users = array($show_media->author_id, PA::$network_info->owner_id);
        if ($extra['network_content_moderation'] == NET_YES && Network::item_exists_in_moderation($show_media->content_id, $show_media->parent_collection_id, 'content') && !in_array($login_uid, $authorized_users)) {
            $error_msg = 1001;
            return 'skip';
        }
    }
    switch ($column) {
        case 'middle':
            $obj->mode = PUB;
            $obj->content_id = $_REQUEST['cid'];
            $obj->uid = $uid;
            $obj->media_data = $show_media;
            $obj->Paging["page"] = $paging["page"];
            $obj->Paging["show"] = $paging["show"];
            break;
        default:
            return 'skip';
            break;
    }
}
 public function log_in($uid, $remember_me, $login_source)
 {
     $user_type = Network::get_user_type(PA::$network_info->network_id, $uid);
     if ($user_type == DISABLED_MEMBER) {
         throw new CNException(USER_ACCESS_DENIED, 'Your account has been temporarily disabled by the administrator.');
     }
     $logged_user = new User();
     // load user
     $logged_user->load((int) $uid);
     $logged_user->set_last_login();
     PA::$login_user = $logged_user;
     register_session($logged_user->login_name, $logged_user->user_id, $logged_user->role, $logged_user->first_name, $logged_user->last_name, $logged_user->email, $logged_user->picture);
     if ($remember_me) {
         // set login cookie
         if ($this->login_cookie->is_new()) {
             $this->login_cookie->new_session($uid);
         }
         $cookie_value = $this->login_cookie->get_cookie();
         $cookie_expiry = time() + LoginCookie::$cookie_lifetime;
         // update tracking info
         $this->login_cookie->update_tracking_info($_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR']);
     } else {
         // clear login cookie
         $cookie_value = "";
         $cookie_expiry = 0;
     }
     // remember series ID, so we can destroy session on logout
     $_SESSION['login_series'] = $this->login_cookie->get_series();
     // remember login source, so we know if it's safe to let user change password, etc
     $_SESSION['login_source'] = $login_source;
     // set new cookie for next login!  (or delete cookie, if not remembering login)
     setcookie(PA_Login::$cookie_name, $cookie_value, $cookie_expiry, PA::$local_url, "." . PA::$domain_suffix);
 }
 public function getProducts($id)
 {
     $category = Category::find($id);
     $network = Network::where('category_id', '=', $id)->get();
     $product = Product::where('category_id', '=', $id)->paginate(9);
     $phone = Product::where('category_id', '=', $id)->get();
     return View::make('products.index')->with('category', $category)->with('network', $network)->with('product', $product)->with('phone', $phone);
 }
Example #20
0
File: Server.php Project: 0-php/AI
 /**
  * @uses Network::saveToFile()
  * @uses Network::train()
  * @uses saveToHost()
  */
 protected function trainByHost()
 {
     $this->saveToHost();
     if ($this->objNetwork instanceof Network) {
         $this->objNetwork->saveToFile($this->strDir . '/' . $_POST['username'] . '.dat');
         $this->objNetwork->train();
     }
 }
Example #21
0
 /**
  * @func   void
  * @return void
  */
 public function __construct()
 {
     echo 'tss1 controller works<br/>';
     /*
     load::service('validator');
     
     $rules = array
     (
         'name' => 'alpha|required',
         'year' => 'num|required',
     );
     
     $Validation = new Validator();
     $Validation->validate($_POST, $rules);
     
     if (!$Validation->passed())
     {
         $Validation->goBackWithErrors();
     }
     
     if (!empty($Validation->getErrors()))
     {
         print_r($Validation->getErrors());
     }
     */
     load::library(SF::STRINGS);
     load::library(SF::NETWORK);
     #$test_string = Strings::generate_password(4);
     $test_string = Strings::generatePassword(4);
     var_dump($test_string);
     $numeric_test = (int) '-abc12.3edf';
     // this SHOULD FALL AND THROW AN ERROR
     #var_dump(Strings::strip_to_numeric($numeric_test));
     var_dump(Strings::StripToNumeric($numeric_test));
     #var_dump(Network::get_client_lang());
     var_dump(Network::getClientLang());
     exit;
     // database testing
     $data = Entries::getData();
     var_dump($data);
     /*
     load::library(SF::DEBUG);
     //load::library(SF::DEBUG)->func('pr'); // will only load clean_str()
     
     ExecuteTime::start();
     
     $parameters = array
     (
         'key'      => '1e46165dsa5ds4a',
         'action'   => 'push',
         'userid'   => 1234998,
         'keywords' => 'test'
     );
     
     ExecuteTime::end();
     echo ExecuteTime::display();
     */
 }
function check_error($skip = NULL)
{
    global $invalid_network_address;
    $mandatory_vars = array('address' => 'Network Address', 'name' => 'Network Title', 'tagline' => 'Network Sub Title', 'category' => 'Network Category', 'desc' => 'Network Description');
    if (!empty($skip)) {
        if (is_array($skip)) {
            foreach ($skip as $key => $value) {
                if (array_key_exists($value, $mandatory_vars)) {
                    unset($mandatory_vars[$value]);
                }
            }
        } elseif (is_string($skip)) {
            if (array_key_exists($skip, $mandatory_vars)) {
                unset($mandatory_vars[$skip]);
            }
        }
    }
    $error = FALSE;
    $error_msg = 'Network could not be saved due to following errors:<br />';
    if ($_POST['action'] == 'edit') {
        unset($mandatory_vars['address']);
    }
    //check for mandatory vars
    foreach ($mandatory_vars as $key => $value) {
        $_POST[$key] = trim($_POST[$key]);
        if (empty($_POST[$key])) {
            $error = TRUE;
            $error_msg .= $value . ' can\'t be empty<br />';
        }
        if ($key == 'address') {
            if (!empty($_POST[$key])) {
                if (strlen($_POST[$key]) < 3) {
                    $error = TRUE;
                    $error_msg .= $value . ' can\'t be less than 3 characters<br />';
                } elseif (strlen($_POST[$key]) > 20) {
                    $error = TRUE;
                    $error_msg .= $value . ' can\'t be more than 20 characters<br />';
                } elseif (!Validation::validate_alpha_numeric($_POST[$key])) {
                    $error = TRUE;
                    $error_msg .= $value . ' should be alphanumeric and  spaces are not allowed<br />';
                } elseif (Network::check_already($_POST[$key])) {
                    $error = TRUE;
                    $error_msg .= $value . ' is not available<br />';
                } elseif (in_array($_POST[$key], $invalid_network_address)) {
                    $error = TRUE;
                    $error_msg .= ' Special subdomain names like www,ftp, mail, smtp, pop etc. are not allowed in network address.<br />';
                }
            }
        }
    }
    //...end foreach
    if ($error) {
        $r = array('error' => TRUE, 'error_msg' => $error_msg);
    } else {
        $r = FALSE;
    }
    return $r;
}
 function render()
 {
     $this->title = __("Network Statistics");
     $param['network_id'] = PA::$network_info->network_id;
     $this->network_statistics = Network::get_network_statistics($param);
     $this->inner_HTML = $this->generate_inner_html($this->network_statistics);
     $network_stats = parent::render();
     return $network_stats;
 }
Example #24
0
 /**
  * Start a phantomjs server in the background. Set port, server js file, additional files and log file.
  *
  * @param  string $file       the server js file
  * @param  integer $port      the port to start the server on
  * @param  string $additional additional file, passed to the js server
  * @param  string $log_file
  * @return string             the pid of the newly started process
  */
 public static function start($file, $port, $additional = NULL, $log_file = '/dev/null')
 {
     if (!Network::is_port_open('localhost', $port)) {
         throw new Exception('Port :port is already taken', array(':port' => $port));
     }
     if ($log_file !== '/dev/null' and !is_file($log_file)) {
         throw new Exception('Log file (:log_file) must be a file or /dev/null', array(':log_file' => $log_file));
     }
     return shell_exec(strtr('nohup :command > :log 2> :log & echo $!', array(':command' => self::command($file, $port, $additional), ':log' => $log_file)));
 }
Example #25
0
 public function settings()
 {
     $user_id = Auth::user()->id;
     $networks = Network::where('user_id', '=', $user_id)->get();
     $settings = Settings::where('user_id', '=', $user_id)->first();
     $schedules = Schedule::where('user_id', '=', $user_id)->get();
     $default_networks = json_decode($settings->default_networks);
     $page_data = array('networks' => $networks, 'default_networks' => $default_networks, 'default_schedule' => $settings->schedule_id, 'schedules' => $schedules, 'api_key' => $settings->api_key);
     $this->layout->title = 'Settings';
     $this->layout->content = View::make('admin.settings', $page_data);
 }
Example #26
0
 public function onTelnetDisconnected(Telnet $telnet, IO_Stream_Interface $stream)
 {
     $this->_network->unregisterStream($stream);
     if (self::STATE_FINISH !== $this->_state) {
         $msg = 'Something went wrong :(';
     } else {
         $msg = 'Everything is ok :)';
     }
     $this->_print($msg);
     $this->_continue = false;
 }
 function generate_inner_html($links)
 {
     global $network_info;
     if ($this->market_report == TRUE) {
         // if marketting report is to be viewed
         $params = NULL;
         $inner_template = dirname(__FILE__) . '/center_inner_market_report.tpl';
         $next_prev_navigation = 'marketing_report';
         if ($this->email_sorting == NULL || $this->email_sorting == 'all') {
             $params = array('network_id' => $network_info->network_id, 'neglect_owner' => FALSE, 'cnt' => TRUE);
             // setting variables for pagination
             $this->Paging["count"] = Network::get_members($params);
             unset($params['cnt']);
             $params['show'] = $this->Paging['show'];
             $params['page'] = $this->Paging['page'];
             $users = Network::get_members($params);
             $this->email_addresses = $users['users_data'];
         } else {
             if ($this->email_sorting == 'dormant') {
                 $params = array("order_by" => 3);
                 // 3 for sort by dormant user
             }
             $this->Paging["count"] = Ranking::get_top_ranked_users(TRUE, $params);
             $params['show'] = $this->Paging['show'];
             $params['page'] = $this->Paging['page'];
             $this->email_addresses = Ranking::get_top_ranked_users(FALSE, $params);
         }
         // Set pagination variable
         $Pagination = new Pagination();
         $Pagination->setPaging($this->Paging);
         $this->page_first = $Pagination->getFirstPage();
         $this->page_last = $Pagination->getLastPage();
         $this->page_links = $Pagination->getPageLinks();
     } else {
         $inner_template = dirname(__FILE__) . '/center_inner_private.tpl';
         $next_prev_navigation = 'mis_count';
     }
     $obj_inner_template =& new Template($inner_template);
     $obj_inner_template->set('links', $links);
     $obj_inner_template->set('email_domain_array', $this->email_domain_array);
     $obj_inner_template->set('blog_post', $this->blog_post);
     $obj_inner_template->set('images', $this->images);
     $obj_inner_template->set('profile_views', $this->profile_views);
     $obj_inner_template->set('profile_visits_by_user', $this->profile_visits_by_user);
     $obj_inner_template->set('relationship_stats', $this->relationship_stats);
     $obj_inner_template->set('emails', $this->email_addresses);
     $obj_inner_template->set('page_first', $this->page_first);
     $obj_inner_template->set('page_last', $this->page_last);
     $obj_inner_template->set('page_links', $this->page_links);
     $obj_inner_template->set('parameters', Ranking::get_parameters());
     $obj_inner_template->set('config_navigation_url', network_config_navigation($next_prev_navigation));
     $inner_html = $obj_inner_template->fetch();
     return $inner_html;
 }
Example #28
0
function AppCentre_App_Check_ISBUY($appid)
{
    global $zbp;
    $postdate = array('email' => $zbp->Config('AppCentre')->shop_username, 'password' => $zbp->Config('AppCentre')->shop_password, 'appid' => $appid,     );
    $http_post = Network::Create();
    $http_post->open('POST', APPCENTRE_API_URL . APPCENTRE_API_APP_ISBUY);
    $http_post->setRequestHeader('Referer', substr($zbp->host, 0, -1) . $zbp->currenturl);
    $http_post->send($postdate);
    $result = json_decode($http_post->responseText, true);
    return $result;
}
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable
  */
 public function loadModel()
 {
     if ($this->_nw === null) {
         if ($id !== isset($_GET['id'])) {
             $this->_nw = Network::model()->findByPk($_GET['id']);
         }
         if ($this->_nw === null || $this->_nw->userId != Yii::app()->user->id) {
             throw new CHttpException(404, 'The requested network does not exist.');
         }
     }
     return $this->_nw;
 }
 public function render()
 {
     if (empty($this->links)) {
         $this->links = Network::get_largest_networks(false, 5, 1);
     }
     $this->inner_HTML = $this->generate_inner_html($this->links);
     if ($this->mode == SORT_BY) {
         $content = $this->inner_HTML;
     } else {
         $content = parent::render();
     }
     return $content;
 }