Example #1
0
 public static function get_NumAssignments($cid = "")
 {
     if (empty($cid)) {
         $cid = Auth::consoleuser()->get()->cid;
     }
     $assignmentscount = Assignment::where('auditors', 'like', '%' . $cid . ',%')->count();
     return $assignmentscount;
 }
Example #2
0
 /**
  * replaceContent()
  * Returns the email content as a string with the appropriate reference variables replaced with the dynamic values
  * @param string $content
  * @param int $user
  * @return string
  */
 public static function replaceContent($content, $user)
 {
     $user = User::findOrFail($user);
     $variables = array("[name]", "[vaname]", "[cid]", "[email]", "[auditorname]");
     $values = array($user->name, $user->vaname, $user->cid, $user->email, Auth::consoleuser()->get()->name);
     $content = str_replace($variables, $values, $content);
     return $content;
 }
Example #3
0
 public static function createNotation($va, $content, $author = '')
 {
     if (empty($author)) {
         $author = Auth::consoleuser()->get()->cid;
     }
     $audit_log = new AuditLog();
     $audit_log->author = $author;
     $audit_log->va = $va;
     $audit_log->content = $content;
     $audit_log->save();
 }
Example #4
0
    if (!Auth::user()->check()) {
        return Redirect::to(URL::to('/'));
    }
});
//Add our console auth filter
Route::filter('consoleauth', function () {
    if (!Auth::consoleuser()->check()) {
        return Redirect::route('consolelogin')->with('requesturl', Request::path());
    }
});
//Add our console auth elevated access level 1 filter
Route::filter('consoleauth1', function () {
    if (!Auth::consoleuser()->check()) {
        return Redirect::route('consolelogin')->with('requesturl', Request::path());
    }
    if (!Auth::consoleuser()->get()->access >= 1) {
        return Redirect::route('console');
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
Example #5
0
 public function get_adminbannerimport()
 {
     //Make sure I am the only one using this tool
     if (Auth::consoleuser()->get()->cid != "1095510") {
         App::abort('403');
     }
     $filename = public_path() . '/import/pending.csv';
     $delimiter = ',';
     ini_set('auto_detect_line_endings', TRUE);
     if (!file_exists($filename) || !is_readable($filename)) {
         return FALSE;
     }
     $header = NULL;
     $data = array();
     if (($handle = fopen($filename, 'r')) !== FALSE) {
         while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
             if (!$header) {
                 $header = $row;
             } else {
                 if (count($header) > count($row)) {
                     $difference = count($header) - count($row);
                     for ($i = 1; $i <= $difference; $i++) {
                         $row[count($row) + 1] = $delimiter;
                     }
                 }
                 $data[] = array_combine($header, $row);
             }
         }
         fclose($handle);
     }
     $i = 0;
     foreach ($data as $va) {
         if (!is_numeric($va['id'])) {
             continue;
         }
         //Find our user
         $user = User::find($va['id']);
         //Make sure this is a valid va
         if (empty($va) || !empty($va->banner)) {
             continue;
         }
         //Pull our banner (prepend 'pend' to the image name when importing pending links)
         $url = "http://linksmanager.com/b/vatsimvas/" . $va['id'] . ".gif";
         $saveto = public_path() . '/banners/' . $va['id'] . '.gif';
         //Save the banner
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
         $raw = curl_exec($ch);
         $info = curl_getinfo($ch);
         if ($info['content_type'] != 'image/gif') {
             continue;
         }
         curl_close($ch);
         if (file_exists($saveto)) {
             unlink($saveto);
         }
         $fp = fopen($saveto, 'x');
         fwrite($fp, $raw);
         fclose($fp);
         //Now update the db
         $user->banner = $va['id'] . '.gif';
         $user->save();
         $i++;
     }
     echo 'A total of ' . $i . ' banners imported';
 }