Esempio n. 1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $formattedEraserList = generateEraserList($this->eraserList);
     foreach ($formattedEraserList as $device) {
         //Create the Phone model
         $phone = Phone::firstOrCreate(['mac' => $device['DeviceName'], 'description' => $device['Description']]);
         //Start creating Eraser
         $tleObj = Eraser::create(['phone_id' => $phone->id, 'ip_address' => $device['IpAddress'], 'eraser_type' => $device['type']]);
         if (isset($device['bulk_id'])) {
             $tleObj->bulks()->attach($device['bulk_id']);
         }
         if ($device['IpAddress'] == "Unregistered/Unknown") {
             $tleObj->result = 'Fail';
             $tleObj->failure_reason = 'Unregistered/Unknown';
             $tleObj->save();
             continue;
         }
         $keys = setKeys($device['Model'], $device['type']);
         if (!$keys) {
             $tleObj->result = 'Fail';
             $tleObj->failure_reason = 'Unsupported Model';
             $tleObj->save();
             return;
         }
         $dialer = new PhoneDialer($device['IpAddress']);
         $status = $dialer->dial($tleObj, $keys);
         //Successful if returned true
         $passFail = $status ? 'Success' : 'Fail';
         $tleObj->result = $passFail;
         $tleObj->save();
     }
 }
Esempio n. 2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //Create the Phone
     $phone = Phone::firstOrCreate(['name' => $this->device['DeviceName'], 'description' => $this->device['Description'], 'model' => $this->device['Model']]);
     // Create the IpAddress
     $ipAddress = IpAddress::firstOrCreate(['ip_address' => $this->device['IpAddress']]);
     // Attach the Phone and IpAddress
     $phone->ipAddresses()->sync([$ipAddress->id], false);
     //Start creating Eraser
     $tleObj = Eraser::create(['device_id' => $phone->id, 'ip_address_id' => $ipAddress->id, 'type' => $this->device['type']]);
     if (isset($this->device['bulk_id'])) {
         $tleObj->bulks()->attach($this->device['bulk_id']);
     }
     if ($this->device['IpAddress'] == "Unregistered/Unknown") {
         $tleObj->result = 'Fail';
         $tleObj->fail_reason = 'Unregistered/Unknown';
         $tleObj->save();
     }
     $keys = setKeys($this->device['Model'], $this->device['type']);
     if (!$keys) {
         $tleObj->result = 'Fail';
         $tleObj->fail_reason = 'Unsupported Model';
         $tleObj->save();
         \Log::debug('Bulk', [$tleObj]);
         return;
     }
     $dialer = new PhoneDialer($tleObj, $this->cluster);
     $status = $dialer->dial($keys);
     //Successful if returned true
     $passFail = $status ? 'Success' : 'Fail';
     $tleObj->result = $passFail;
     $tleObj->save();
 }
Esempio n. 3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $macList = array_column($this->eraserArray, 'MAC');
     $phoneList = new PreparePhoneList();
     $risPortResults = $phoneList->createList($macList);
     foreach ($this->eraserArray as $row) {
         $key = array_search($row['MAC'], array_column($risPortResults, 'DeviceName'));
         $risPortResults[$key]['TLE'] = $row['TLE'];
         $risPortResults[$key]['BULK_ID'] = $row['BULK_ID'];
     }
     //Loop Devices and erase Trust List
     foreach ($risPortResults as $device) {
         //Create the Phone model
         $phone = Phone::firstOrCreate(['mac' => $device['DeviceName'], 'description' => $device['Description']]);
         //Start creating Eraser
         $tleObj = Eraser::create(['phone_id' => $phone->id, 'ip_address' => $device['IpAddress'], 'eraser_type' => $device['TLE']]);
         $tleObj->bulks()->attach($device['BULK_ID']);
         if ($device['IpAddress'] == "Unregistered/Unknown") {
             //Not registered, save as failed
             $tleObj->result = 'Fail';
             $tleObj->failure_reason = 'Unregistered/Unknown';
             $tleObj->save();
             Log::info('Device Unregistered/Unknown.', [$device]);
             continue;
         }
         /*
          * Get the key press series
          */
         $keys = setKeys($device['Model'], $tleObj->eraser_type);
         Log::info('setKeys(),$keys', [$tleObj->eraser_type]);
         if (!$keys) {
             $tleObj->result = 'Fail';
             $tleObj->failure_reason = 'Unsupported Model';
             $tleObj->save();
             return;
         }
         $dialer = new PhoneDialer($device['IpAddress']);
         //Dial the keys
         $status = $dialer->dial($tleObj, $keys);
         //Successful if returned true
         $passFail = $status ? 'Success' : 'Fail';
         $tleObj->result = $passFail;
         $tleObj->save();
         return;
     }
 }
Esempio n. 4
0
function StaffReport()
{
    global $sourcedir, $context, $txt, $smcFunc;
    require_once $sourcedir . '/Subs-Members.php';
    // Fetch all the board names.
    $request = $smcFunc['db_query']('', '
		SELECT id_board, name
		FROM {db_prefix}boards', array());
    $boards = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $boards[$row['id_board']] = $row['name'];
    }
    $smcFunc['db_free_result']($request);
    // Get every moderator.
    $request = $smcFunc['db_query']('', '
		SELECT mods.id_board, mods.id_member
		FROM {db_prefix}moderators AS mods', array());
    $moderators = array();
    $local_mods = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $moderators[$row['id_member']][] = $row['id_board'];
        $local_mods[$row['id_member']] = $row['id_member'];
    }
    $smcFunc['db_free_result']($request);
    // Get a list of global moderators (i.e. members with moderation powers).
    $global_mods = array_intersect(membersAllowedTo('moderate_board', 0), membersAllowedTo('approve_posts', 0), membersAllowedTo('remove_any', 0), membersAllowedTo('modify_any', 0));
    // How about anyone else who is special?
    $allStaff = array_merge(membersAllowedTo('admin_forum'), membersAllowedTo('manage_membergroups'), membersAllowedTo('manage_permissions'), $local_mods, $global_mods);
    // Make sure everyone is there once - no admin less important than any other!
    $allStaff = array_unique($allStaff);
    // This is a bit of a cop out - but we're protecting their forum, really!
    if (count($allStaff) > 300) {
        fatal_lang_error('report_error_too_many_staff');
    }
    // Get all the possible membergroups!
    $request = $smcFunc['db_query']('', '
		SELECT id_group, group_name, online_color
		FROM {db_prefix}membergroups', array());
    $groups = array(0 => $txt['full_member']);
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>';
    }
    $smcFunc['db_free_result']($request);
    // All the fields we'll show.
    $staffSettings = array('position' => $txt['report_staff_position'], 'moderates' => $txt['report_staff_moderates'], 'posts' => $txt['report_staff_posts'], 'last_login' => $txt['report_staff_last_login']);
    // Do it in columns, it's just easier.
    setKeys('cols');
    // Get each member!
    $request = $smcFunc['db_query']('', '
		SELECT id_member, real_name, id_group, posts, last_login
		FROM {db_prefix}members
		WHERE id_member IN ({array_int:staff_list})
		ORDER BY real_name', array('staff_list' => $allStaff));
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // Each member gets their own table!.
        newTable($row['real_name'], '', 'left', 'auto', 'left', 200, 'center');
        // First off, add in the side key.
        addData($staffSettings);
        // Create the main data array.
        $staffData = array('position' => isset($groups[$row['id_group']]) ? $groups[$row['id_group']] : $groups[0], 'posts' => $row['posts'], 'last_login' => timeformat($row['last_login']), 'moderates' => array());
        // What do they moderate?
        if (in_array($row['id_member'], $global_mods)) {
            $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>';
        } elseif (isset($moderators[$row['id_member']])) {
            // Get the names
            foreach ($moderators[$row['id_member']] as $board) {
                if (isset($boards[$board])) {
                    $staffData['moderates'][] = $boards[$board];
                }
            }
            $staffData['moderates'] = implode(', ', $staffData['moderates']);
        } else {
            $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>';
        }
        // Next add the main data.
        addData($staffData);
    }
    $smcFunc['db_free_result']($request);
}
    $authRow['KPASS'] = passGenerator();
    $authRow['RPASS'] = passGenerator();
    $controlURL .= "&k=" . $authRow['KPASS'];
    $resetURL = $_GET['CONTROLSERVER'] . "authority.php?r=" . $authRow['RPASS'];
    printURL($controlURL, "Control Link");
    printURL($resetURL, "Reset Link");
    $m = new MongoClient("mongodb://*****:*****@localhost/authority");
    $db = $m->authority;
    $c = $db->playnodeca;
    //  $c->insert($authRow);
    $c->update(array("MPDPORT" => $_GET['MPDPORT']), $authRow, array("upsert" => true));
    var_dump($c->findOne());
    //  var_dump($authRow);
    echo "PHEW";
}
function passGenerator()
{
    // http://stackoverflow.com/q/19017694/5045643 :
    $pass = substr(str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 1) . substr(md5(time()), 1);
    return $pass;
}
function printURL($url, $name)
{
    echo "\n    <p>\n      <a href='{$url}'>{$name}</a>\n    </p>\n  ";
}
if (!empty($_GET['r'])) {
    resetKeys($_GET['r']);
}
if (!empty($_GET['EMAIL'])) {
    setKeys($_GET['EMAIL']);
}
Esempio n. 6
0
 /**
  * Report for showing all the forum staff members - quite a feat!
  * functions ending with "Report" are responsible for generating data
  * for reporting.
  * they are all called from action_index.
  * never access the context directly, but use the data handling
  * functions to do so.
  */
 public function action_staff()
 {
     global $txt;
     require_once SUBSDIR . '/Members.subs.php';
     require_once SUBSDIR . '/Boards.subs.php';
     require_once SUBSDIR . '/Membergroups.subs.php';
     // Fetch all the board names.
     $boards = fetchBoardsInfo('all');
     $moderators = allBoardModerators(true);
     $boards_moderated = array();
     foreach ($moderators as $id_member => $rows) {
         foreach ($rows as $row) {
             $boards_moderated[$id_member][] = $row['id_board'];
         }
     }
     // Get a list of global moderators (i.e. members with moderation powers).
     $global_mods = array_intersect(membersAllowedTo('moderate_board', 0), membersAllowedTo('approve_posts', 0), membersAllowedTo('remove_any', 0), membersAllowedTo('modify_any', 0));
     // How about anyone else who is special?
     $allStaff = array_merge(membersAllowedTo('admin_forum'), membersAllowedTo('manage_membergroups'), membersAllowedTo('manage_permissions'), array_keys($moderators), $global_mods);
     // Make sure everyone is there once - no admin less important than any other!
     $allStaff = array_unique($allStaff);
     // This is a bit of a cop out - but we're protecting their forum, really!
     if (count($allStaff) > 300) {
         fatal_lang_error('report_error_too_many_staff');
     }
     // Get all the possible membergroups!
     $all_groups = getBasicMembergroupData(array('all'), array(), null, false);
     $groups = array(0 => $txt['full_member']);
     foreach ($all_groups as $row) {
         $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>';
     }
     // All the fields we'll show.
     $staffSettings = array('position' => $txt['report_staff_position'], 'moderates' => $txt['report_staff_moderates'], 'posts' => $txt['report_staff_posts'], 'last_login' => $txt['report_staff_last_login']);
     // Do it in columns, it's just easier.
     setKeys('cols');
     // Get the latest activated member's display name.
     $result = getBasicMemberData($allStaff, array('moderation' => true, 'sort' => 'real_name'));
     foreach ($result as $row) {
         // Each member gets their own table!.
         newTable($row['real_name'], '', 'left', 'auto', 'left', 200, 'center');
         // First off, add in the side key.
         addData($staffSettings);
         // Create the main data array.
         $staffData = array('position' => isset($groups[$row['id_group']]) ? $groups[$row['id_group']] : $groups[0], 'posts' => $row['posts'], 'last_login' => standardTime($row['last_login']), 'moderates' => array());
         // What do they moderate?
         if (in_array($row['id_member'], $global_mods)) {
             $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>';
         } elseif (isset($boards_moderated[$row['id_member']])) {
             // Get the names
             foreach ($boards_moderated[$row['id_member']] as $board) {
                 if (isset($boards[$board])) {
                     $staffData['moderates'][] = $boards[$board]['name'];
                 }
             }
             $staffData['moderates'] = implode(', ', $staffData['moderates']);
         } else {
             $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>';
         }
         // Next add the main data.
         addData($staffData);
     }
 }