/** @function __construct() the constructor for this class.  Sets up when class is called.
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     header('X-Content-Type-Options: nosniff');
     header('Strict-Transport-Security: max-age=16070400; includeSubDomains');
     header('X-XSS-Protection: 1; mode=block');
     header('X-Frame-Options: deny');
     header('Cache-Control: no-cache');
     header("Content-type: Text/Plain");
     $this->FOGCore->valdata('peer_id', true);
     $this->FOGCore->valdata('port');
     $this->FOGCore->valdata('info_hash', true);
     // Make sure data is setup:
     !$_REQUEST['key'] ? $_REQUEST['key'] : '';
     $this->downloaded = !$_REQUEST['downloaded'] ? 0 : intval($_REQUEST['downloaded']);
     $this->uploaded = !$_REQUEST['uploaded'] ? 0 : intval($_REQUEST['uploaded']);
     $this->left = !$_REQUEST['left'] ? 0 : intval($_REQUEST['left']);
     $this->FOGCore->valdata('key');
     $this->checkPort();
     $this->peer = $this->PeerGen();
     $this->torrent = $this->TorrentGen();
     $this->peer_torrent = $this->PeerTorrentGen();
     // User Agent is required.
     !$_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] = 'N/A' : null;
     if ($_REQUEST['event'] && $_REQUEST['event'] === 'stopped') {
         $this->stopTorrent();
     }
     if ($_REQUEST['numwant'] && ctype_digit($_REQUEST['numwant']) && $_REQUEST['numwant'] <= $this->FOGCore->getSetting('FOG_TORRENT_PPR') && $_REQUEST['numwant'] >= 0) {
         $this->numwant = intval($_REQUEST['numwant']);
     }
     $this->doTheWork();
 }
 /** @function __construct() constructs the base elements
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     if (!$this->FOGUser) {
         $this->FOGUser = unserialize($_SESSION['FOG_USER']);
     }
 }
 public function __construct()
 {
     // FOGBase Constructor
     parent::__construct();
     // Save class & method values into class - used many times through out
     $this->classValue = $GLOBALS[$this->classVariable] ? preg_replace('#[^\\w]#', '_', urldecode($GLOBALS[$this->classVariable])) : (preg_match('#mobile#i', $_SERVER['PHP_SELF']) ? 'homes' : 'home');
     $this->methodValue = preg_replace('#[^\\w]#', '_', urldecode($GLOBALS[$this->methodVariable]));
     // No default value as we want to detect an empty string for 'list' or 'search' default page
     // Hook in to allow search pages to be adjusted as needed.
     $this->HookManager->processEvent('SEARCH_PAGES', array('searchPages' => &$this->searchPages));
 }
 /** __construct($mac)
 		Stores the MAC of which to system to wake.
 	*/
 public function __construct($mac)
 {
     parent::__construct();
     $this->arrMAC = array();
     foreach ((array) $mac as $MAC) {
         $MAC = $this->getClass('MACAddress', $MAC);
         if ($MAC->isValid()) {
             $this->arrMAC[] = $MAC->__toString();
         }
     }
 }
 /** __construct() initiates the database class
  * @return if the class is valid or not
  */
 public function __construct()
 {
     try {
         parent::__construct();
         if (!DATABASE_TYPE || !DATABASE_HOST || !DATABASE_USERNAME || !DATABASE_NAME) {
             throw new Exception('Configuration is missing an item');
         }
         $this->valid = $this;
     } catch (Exception $e) {
         $this->error('Failed: %s->%s(): Error: %s', array(get_class($this), __FUNCTION__, $e->getMessage()));
     }
 }
 public function __construct($id, $name, $port, $image, $eth, $clients, $imagetype, $osid)
 {
     parent::__construct();
     $this->intID = $id;
     $this->strName = $name;
     $this->intPort = $this->FOGCore->getSetting('FOG_MULTICAST_PORT_OVERRIDE') ? $this->FOGCore->getSetting('FOG_MULTICAST_PORT_OVERRIDE') : $port;
     $this->strImage = $image;
     $this->strEth = $eth;
     $this->intClients = $clients;
     $this->intImageType = $imagetype;
     $this->deathTime = null;
     $this->intOSID = $osid;
     $this->dubPercent = null;
 }
 /** __construct()
 		Different constructor from FOG Base
 	*/
 public function __construct()
 {
     // FOGBase contstructor
     parent::__construct();
     // Set child classes name
     $this->childClass = preg_replace('#_?Manager$#', '', get_class($this));
     // Get child class variables
     $this->classVariables = get_class_vars($this->childClass);
     // Set required child variable data
     $this->aliasedFields = $this->classVariables['aliasedFields'];
     $this->databaseTable = $this->classVariables['databaseTable'];
     $this->databaseFields = $this->classVariables['databaseFields'];
     $this->databaseFieldsFlipped = array_flip($this->databaseFields);
     $this->databaseFieldClassRelationships = $this->classVariables['databaseFieldClassRelationships'];
 }
 /** @param data
  * Initializer of the objects themselves.
  */
 public function __construct($data = '')
 {
     /** FOGBase constructor
      * Allows the rest of the base of fog to come
      * with the object begin called
      */
     parent::__construct();
     try {
         /** sets if to print controller debug information to screen/log/either/both*/
         $this->debug = false;
         /** sets if to print controller general information to screen/log/either/both*/
         $this->info = false;
         // Error checking
         if (!count($this->databaseFields)) {
             throw new Exception('No database fields defined for this class!');
         }
         // Flip database fields and common name - used multiple times
         $this->databaseFieldsFlipped = array_flip($this->databaseFields);
         // Created By
         if (array_key_exists('createdBy', $this->databaseFields) && !empty($_SESSION['FOG_USERNAME'])) {
             $this->set('createdBy', $this->DB->sanitize($_SESSION['FOG_USERNAME']));
         }
         if (array_key_exists('createdTime', $this->databaseFields)) {
             $this->set('createdTime', $this->nice_date()->format('Y-m-d H:i:s'));
         }
         // Add incoming data
         if (is_array($data)) {
             $this->data = $data;
         } else {
             if (is_numeric($data)) {
                 if ($data === 0 || $data < 0) {
                     throw new Exception(sprintf('No data passed, or less than zero, Value: %s', $data));
                 }
                 $this->set('id', $data)->load();
             }
         }
     } catch (Exception $e) {
         $this->error('Record not found, Error: %s', array($e->getMessage()));
     }
     return $this;
 }
 /** __construct() initiates the constructor of the pages */
 public function __construct($name = '')
 {
     $this->debug = false;
     $this->info = false;
     parent::__construct();
     if (!empty($name)) {
         $this->name = $name;
     }
     $this->title = $this->name;
     $this->delformat = "?node={$this->node}&sub=delete&{$this->id}={$_REQUEST[id]}";
     $this->linkformat = "?node={$this->node}&sub=edit&{$this->id}={$_REQUEST[id]}";
     $this->membership = "?node={$this->node}&sub=membership&{$this->id}={$_REQUEST[id]}";
     $this->request = $this->REQUEST = $this->DB->sanitize($_REQUEST);
     $this->REQUEST['id'] = $_REQUEST[$this->id];
     $this->request['id'] = $_REQUEST[$this->id];
     $this->post = $this->isPOSTRequest();
     $this->ajax = $this->isAJAXRequest();
     $this->childClass = preg_replace('#ManagementPage#', '', preg_replace('#Mobile#', '', get_class($this)));
     $this->menu = array('search' => $this->foglang['NewSearch'], 'list' => sprintf($this->foglang['ListAll'], _($this->childClass . 's')), 'add' => sprintf($this->foglang['CreateNew'], _($this->childClass)));
     $this->formAction = sprintf('%s?%s', $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']);
     $this->HookManager->processEvent('SEARCH_PAGES', array('searchPages' => &$this->searchPages));
     $this->HookManager->processEvent('SUB_MENULINK_DATA', array('menu' => &$this->menu, 'submenu' => &$this->subMenu, 'id' => &$this->id, 'notes' => &$this->notes));
 }
 /** @function __construct the constructor to build the basic defaults
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->handle = @curl_multi_init();
     $this->contextOptions = array(CURLOPT_HTTPGET => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 10000, CURLOPT_TIMEOUT_MS => 10000, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 20, CURLOPT_HEADER => false);
 }
 public function __construct()
 {
     parent::__construct();
     $this->makeReport();
 }
 /** @function __construct() builds the menu base elements
  * @param $Host the host to work across or null otherwise
  * @return void
  */
 public function __construct($Host = null)
 {
     parent::__construct();
     $this->loglevel = 'loglevel=' . $this->FOGCore->getSetting('FOG_KERNEL_LOGLEVEL');
     // Setups of the basic construct for the menu system.
     $StorageNode = current($this->getClass('StorageNodeManager')->find(array('isEnabled' => 1, 'isMaster' => 1)));
     // Sets up the default values stored in the server. Lines 51 - 64
     $webserver = $this->FOGCore->resolveHostname($this->FOGCore->getSetting('FOG_WEB_HOST'));
     $webroot = '/' . ltrim(rtrim($this->FOGCore->getSetting('FOG_WEB_ROOT'), '/'), '/') . '/';
     $this->web = "{$webserver}{$webroot}";
     $this->bootexittype = $this->FOGCore->getSetting('FOG_BOOT_EXIT_TYPE') == 'exit' ? 'exit' : ($this->FOGCore->getSetting('FOG_BOOT_EXIT_TYPE') == 'sanboot' ? 'sanboot --no-describe --drive 0x80' : ($this->FOGCore->getSetting('FOG_BOOT_EXIT_TYPE') == 'grub' ? 'chain -ar http://' . rtrim($this->web, '/') . '/service/ipxe/grub.exe --config-file="rootnoverify (hd0);chainloader +1"' : 'exit'));
     $ramsize = $this->FOGCore->getSetting('FOG_KERNEL_RAMDISK_SIZE');
     $dns = $this->FOGCore->getSetting('FOG_PXE_IMAGE_DNSADDRESS');
     $keymap = $this->FOGCore->getSetting('FOG_KEYMAP');
     $memdisk = 'memdisk';
     $memtest = $this->FOGCore->getSetting('FOG_MEMTEST_KERNEL');
     // Default bzImage and imagefile based on arch received.
     $bzImage = $_REQUEST['arch'] == 'x86_64' ? $this->FOGCore->getSetting('FOG_TFTP_PXE_KERNEL') : $this->FOGCore->getSetting('FOG_TFTP_PXE_KERNEL_32');
     $kernel = $bzImage;
     $imagefile = $_REQUEST['arch'] == 'x86_64' ? $this->FOGCore->getSetting('FOG_PXE_BOOT_IMAGE') : $this->FOGCore->getSetting('FOG_PXE_BOOT_IMAGE_32');
     $initrd = $imagefile;
     // Adjust file info if host is valid.
     if ($Host && $Host->isValid()) {
         $Host->get('kernel') ? $bzImage = $Host->get('kernel') : null;
         $kernel = $bzImage;
         $this->HookManager->processEvent('BOOT_ITEM_NEW_SETTINGS', array('Host' => &$Host, 'StorageGroup' => &$StorageGroup, 'StorageNode' => &$StorageNode, 'memtest' => &$memtest, 'memdisk' => &$memdisk, 'bzImage' => &$bzImage, 'initrd' => &$initrd, 'webroot' => &$webroot, 'imagefile' => &$imagefile));
     }
     // Sets the key sequence.  Only used if the hidden menu option is selected.
     $keySequence = $this->FOGCore->getSetting('FOG_KEY_SEQUENCE');
     if ($keySequence) {
         $this->KS = new KeySequence($keySequence);
     }
     // menu Access sets if the menu is displayed.  Menu access is a url get variable if a user has specified hidden menu it will override if menuAccess is set.
     if (!$_REQUEST['menuAccess']) {
         $this->hiddenmenu = $this->FOGCore->getSetting('FOG_PXE_MENU_HIDDEN');
     }
     $timeout = ($this->hiddenmenu ? $this->FOGCore->getSetting('FOG_PXE_HIDDENMENU_TIMEOUT') : $this->FOGCore->getSetting('FOG_PXE_MENU_TIMEOUT')) * 1000;
     $this->timeout = $timeout;
     // Generate the URL to boot from.
     $this->booturl = "http://{$webserver}{$webroot}service";
     // Store the host call into class global.
     $this->Host = $Host;
     // Capone menu setup.
     $CaponePlugInst = $_SESSION['capone'];
     $DMISet = $CaponePlugInst ? $this->FOGCore->getSetting('FOG_PLUGIN_CAPONE_DMI') : false;
     // If it is installed store the needed elements into variables.
     if ($CaponePlugInst) {
         $this->storage = $this->FOGCore->resolveHostname($StorageNode->get('ip'));
         $this->path = $StorageNode->get('path');
         $this->shutdown = $this->FOGCore->getSetting('FOG_PLUGIN_CAPONE_SHUTDOWN');
     }
     // Create menu item if not exists and Capone is installed as well as the DMI is specified.
     if ($CaponePlugInst && $DMISet) {
         // Check for fog.capone if the pxe menu entry exists.
         $PXEMenuItem = current($this->getClass('PXEMenuOptionsManager')->find(array('name' => 'fog.capone')));
         // If it does exist, generate the updated arguments for each call.
         if ($PXEMenuItem && $PXEMenuItem->isValid()) {
             $PXEMenuItem->set('args', "mode=capone shutdown={$this->shutdown} storage={$this->storage}:{$this->path}");
         } else {
             $PXEMenuItem = new PXEMenuOptions(array('name' => 'fog.capone', 'description' => 'Capone Deploy', 'args' => "mode=capone shutdown={$this->shutdown} storage={$this->storage}:{$this->path}", 'params' => null, 'default' => '0', 'regMenu' => '2'));
         }
         $PXEMenuItem->save();
     }
     // Specify the default calls.
     $this->memdisk = "kernel {$memdisk}";
     $this->memtest = "initrd {$memtest}";
     $this->kernel = "kernel {$bzImage} {$this->loglevel} initrd={$initrd} root=/dev/ram0 rw ramdisk_size={$ramsize} keymap={$keymap} web={$webserver}{$webroot} consoleblank=0" . ($this->FOGCore->getSetting('FOG_KERNEL_DEBUG') ? ' debug' : '');
     $this->initrd = "imgfetch {$imagefile}";
     // Set the default line based on all the menu entries and only the one with the default set.
     $defMenuItem = current($this->getClass('PXEMenuOptionsManager')->find(array('default' => 1)));
     $this->defaultChoice = "choose --default " . ($defMenuItem && $defMenuItem->isValid() ? $defMenuItem->get('name') : 'fog.local') . (!$this->hiddenmenu ? " --timeout {$timeout}" : " --timeout 0") . ' target && goto ${target}';
     // Register the success of the boot to the database:
     $iPXE = current($this->getClass('iPXEManager')->find(array('product' => $_REQUEST['product'], 'manufacturer' => $_REQUEST['manufacturer'], 'file' => $_REQUEST['filename'])));
     if ($iPXE && $iPXE->isValid()) {
         if ($iPXE->get('failure')) {
             $iPXE->set('failure', 0);
         }
         if (!$iPXE->get('success')) {
             $iPXE->set('success', 1);
         }
         if (!$iPXE->get('version')) {
             $iPXE->set('version', $_REQUEST['ipxever']);
         }
     } else {
         if (!$iPXE || !$iPXE->isValid()) {
             $iPXE = new iPXE(array('product' => $_REQUEST['product'], 'manufacturer' => $_REQUEST['manufacturer'], 'mac' => $Host && $Host->isValid() ? $Host->get('mac') : 'no mac', 'success' => 1, 'file' => $_REQUEST['filename'], 'version' => $_REQUEST['ipxever']));
         }
     }
     $iPXE->save();
     if ($_REQUEST['username'] && $_REQUEST['password']) {
         $this->verifyCreds();
     } else {
         if ($_REQUEST['delconf']) {
             $this->delHost();
         } else {
             if ($_REQUEST['key']) {
                 $this->keyset();
             } else {
                 if ($_REQUEST['sessname']) {
                     $this->sesscheck();
                 } else {
                     if ($_REQUEST['aprvconf']) {
                         $this->approveHost();
                     } else {
                         if (!$Host || !$Host->isValid()) {
                             $this->printDefault();
                         } else {
                             $this->getTasking();
                         }
                     }
                 }
             }
         }
     }
 }
 /** __construct() initiates
  * @param $MAC the mac either string or object
  * @return void
  */
 public function __construct($MAC)
 {
     parent::__construct();
     $this->tmpMAC = $MAC;
     $this->setMAC();
 }
 public function __construct()
 {
     parent::__construct();
     while (@ob_end_clean()) {
     }
     $isMobile = preg_match('#/mobile/#i', @$_SERVER['PHP_SELF']);
     $dispTheme = 'css/' . ($_SESSION['theme'] ? $_SESSION['theme'] : 'default/fog.css');
     if (!file_exists(BASEPATH . '/' . $dispTheme)) {
         $dispTheme = 'css/default/fog.css';
     }
     if (!$isMobile) {
         $this->addCSS('css/jquery-ui.css');
         $this->addCSS('css/jquery.organicTabs.css');
         $this->addCSS($dispTheme);
     } else {
         $this->addCSS('css/main.css');
     }
     $this->addCSS('../management/css/font-awesome.css');
     $this->isHomepage = !$_REQUEST['node'] || in_array($_REQUEST['node'], array('home', 'dashboard', 'schemaupdater', 'client', 'logout', 'login')) || in_array($_REQUEST['sub'], array('configure', 'authorize')) || !$this->FOGUser || !$this->FOGUser->isLoggedIn();
     if ($this->FOGUser && $this->FOGUser->isLoggedIn()) {
         if (!$isMobile) {
             $this->main = array('home' => array($this->foglang['Home'], 'fa fa-home fa-2x'), 'user' => array($this->foglang['User Management'], 'fa fa-users fa-2x'), 'host' => array($this->foglang['Host Management'], 'fa fa-desktop fa-2x'), 'group' => array($this->foglang['Group Management'], 'fa fa-sitemap fa-2x'), 'image' => array($this->foglang['Image Management'], 'fa fa-picture-o fa-2x'), 'storage' => array($this->foglang['Storage Management'], 'fa fa-download fa-2x'), 'snapin' => array($this->foglang['Snapin Management'], 'fa fa-files-o fa-2x'), 'printer' => array($this->foglang['Printer Management'], 'fa fa-print fa-2x'), 'service' => array($this->foglang['Service Configuration'], 'fa fa-cogs fa-2x'), 'task' => array($this->foglang['Task Management'], 'fa fa-tasks fa-2x'), 'report' => array($this->foglang['Report Management'], 'fa fa-file-text fa-2x'), 'about' => array($this->foglang['FOG Configuration'], 'fa fa-wrench fa-2x'), $_SESSION['PLUGSON'] ? 'plugin' : '' => $_SESSION['PLUGSON'] ? array($this->foglang['Plugin Management'], 'fa fa-cog fa-2x') : '', 'logout' => array($this->foglang['Logout'], 'fa fa-sign-out fa-2x'));
         } else {
             $this->main = array('home' => array($this->foglang['Home'], 'fa fa-home fa-2x'), 'host' => array($this->foglang['Host Management'], 'fa fa-desktop fa-2x'), 'task' => array($this->foglang['Task Management'], 'fa fa-tasks fa-2x'), 'logout' => array($this->foglang['Logout'], 'fa fa-sign-out fa-2x'));
         }
         $this->main = array_unique(array_filter($this->main), SORT_REGULAR);
         $this->HookManager->processEvent('MAIN_MENU_DATA', array('main' => &$this->main));
         foreach ($this->main as $link => $title) {
             $links[] = !$isMobile ? $link : ($link != 'logout' ? $link . 's' : $link);
         }
         if (!$isMobile) {
             $links = array_merge((array) $links, array('hwinfo', 'client', 'schemaupdater'));
         }
         if ($_REQUEST['node'] && !in_array($_REQUEST['node'], $links)) {
             $this->FOGCore->redirect('index.php');
         }
         $this->menu = !$isMobile ? '<center><ul>' : '<div id="menuBar">';
         foreach ($this->main as $link => $title) {
             $activelink = !$isMobile ? $_REQUEST['node'] == $link || !$_REQUEST['node'] && $link == 'home' ? $activelink = 1 : 0 : ($_REQUEST['node'] == $link . 's' || !$_REQUEST['node'] && $link == 'home' ? 1 : 0);
             $this->menu .= !$isMobile ? sprintf('<li><a href="?node=%s" title="%s"%s><i class="%s"></i></a></li>', $link, $title[0], $activelink ? ' class="activelink"' : '', $title[1]) : sprintf('<a href="?node=%s"%s><i class="%s"></i></a>', $link != 'logout' ? $link . 's' : $link, $activelink ? ' class="activelink"' : '', $title[1]);
         }
         $this->menu .= !$isMobile ? '</ul></center>' : '</div>';
     }
     if ($this->FOGUser && $this->FOGUser->isLoggedIn() && !preg_match('#/mobile/#i', $_SERVER['PHP_SELF'])) {
         $files = array('js/jquery-latest.js', 'js/jquery-migrate-1.2.1.min.js', 'js/jquery.tipsy.js', 'js/jquery.progressbar.js', 'js/jquery.tmpl.js', 'js/jquery.organicTabs.js', 'js/jquery.placeholder.js', 'js/jquery.disableSelection.js', 'js/jquery-ui.min.js', 'js/flot/jquery.flot.js', 'js/flot/jquery.flot.time.js', 'js/flot/jquery.flot.pie.js', 'js/flot/jquery.flot.JUMlib.js', 'js/flot/jquery.flot.gantt.js', 'js/jquery-ui-timepicker-addon.js', 'js/hideShowPassword.min.js', 'js/fog/fog.js', 'js/fog/fog.main.js');
         if ($_REQUEST['sub'] == 'membership') {
             $_REQUEST['sub'] = 'edit';
         }
         $filepaths = array("js/fog/fog.{$_REQUEST['node']}.js", "js/fog/fog.{$_REQUEST['node']}.{$_REQUEST['sub']}.js");
         foreach ($filepaths as $jsFilepath) {
             if (file_exists($jsFilepath)) {
                 array_push($files, $jsFilepath);
             }
         }
         $pluginfilepaths = array(BASEPATH . "/lib/plugins/{$_REQUEST['node']}/js/fog.{$_REQUEST['node']}.js", BASEPATH . "/lib/plugins/{$_REQUEST['node']}/js/fog.{$_REQUEST['node']}.{$_REQUEST['sub']}.js");
         foreach ($pluginfilepaths as $pluginfilepath) {
             if (file_exists($pluginfilepath) && !file_exists("js/fog/" . basename($pluginfilepath))) {
                 $newfile = "js/fog/" . basename($pluginfilepath);
                 file_put_contents($newfile, file_get_contents($pluginfilepath));
             }
         }
         if ($this->isHomepage) {
             array_push($files, 'js/fog/fog.dashboard.js');
             if (preg_match('#MSIE [6|7|8|9|10|11]#', $_SERVER['HTTP_USER_AGENT'])) {
                 array_push($files, 'js/flot/excanvas.js');
             }
         }
     } else {
         if (!preg_match('#/mobile/#i', $_SERVER['PHP_SELF'])) {
             $files = array('js/jquery-latest.js', 'js/jquery.progressbar.js', 'js/fog/fog.js', 'js/fog/fog.login.js');
         }
     }
     foreach ((array) $files as $path) {
         if (file_exists($path)) {
             $this->addJavascript($path);
         }
     }
 }