/**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\App::isLocal()) {
         $this->registerServiceProviders();
         $this->registerFacadeAliases();
     }
 }
Esempio n. 2
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     } elseif ($e instanceof HttpException && \App::isLocal() === false) {
         Response::json(['result' => false, 'message' => $e->getMessage()])->setStatusCode($e->getStatusCode())->send();
         exit;
     }
     return parent::render($request, $e);
 }
 public function __construct(Advisors $account, array $items = [])
 {
     foreach ($items as $key => $properties) {
         if (!isset($this->lookup[$key])) {
             if (\App::isLocal()) {
                 throw new \Exception('Unknown identifier - ' . $key);
             }
             continue;
         }
         $class = "Destiny\\AdvisorsTwo\\Activity\\" . $this->lookup[$key];
         /** @var Activity $activity */
         $activity = new $class($account, $properties);
         $items[$activity->identifier] = $activity;
     }
     parent::__construct($items);
 }
Esempio n. 4
0
 /**
  * Get the path to a versioned Webpack file.
  *
  * @param  string $extension Asset extension
  * @param  string $bundle Default bundle
  * @return string
  *
  * @throws \InvalidArgumentException
  */
 function webpack($extension, $bundle = 'app')
 {
     static $manifest = null;
     if (is_null($manifest)) {
         $content = @file_get_contents(public_path(config('webpack.build_path', 'build') . '/manifest.json'));
         $manifest = @json_decode($content, true);
     }
     if (isset($manifest[$bundle][$extension])) {
         if (App::isLocal() && !File::exists(public_path($manifest[$bundle][$extension]))) {
             $secure = config('webpack.dev_server.https', false);
             $server = config('webpack.dev_server.ip', '127.0.0.1');
             $port = config('webpack.dev_server.port', 8080);
             $url = 'http' . ($secure ? 's://' : '://') . $server . ':' . $port;
             return $url . $manifest[$bundle][$extension];
         }
         return $manifest[$bundle][$extension];
     }
     throw new InvalidArgumentException("File {$bundle}.{$extension} not defined in asset manifest.");
 }
Esempio n. 5
0
 public function upload()
 {
     $s3 = \Aws\S3\S3Client::factory(array('key' => 'AKIAIUCV4E2L4HDCDOUA', 'secret' => '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', 'region' => 'us-east-1'));
     $key = new Key();
     if (Input::file('key') != null) {
         exec('openssl rsa -noout -in ' . Input::file('key')->getRealPath(), $cli_output, $cli_exec_result_success);
         // lmao why is this logic reversed? and it works?
         if (!$cli_exec_result_success) {
             $s3->putObject(array('Bucket' => App::isLocal() ? 'devkeys.nosprawl.software' : 'keys.nosprawl.software', 'Key' => Input::file('key')->getClientOriginalName(), 'SourceFile' => Input::file('key')->getRealPath()));
             $key->remote_url = Input::file('key')->getClientOriginalName();
         } else {
             return Redirect::to('integrations')->withMessage("Key not added. Please upload a valid PEM file.");
         }
     }
     $key->integration_id = Input::get('integration_id');
     $key->username = Input::get('username');
     $key->password = Input::get('password');
     if ($key->save()) {
         return Redirect::to('integrations')->withMessage("Credentials added.");
     } else {
         return Redirect::to('integrations')->withMessage("Key not added.");
     }
 }
Esempio n. 6
0
 public static function getCache($cache)
 {
     if (App::isLocal()) {
         Cache::forget('DB_Nav');
         Cache::forget('DB_Urls');
         Cache::forget('DB_Option');
         Cache::forget('DB_AdminBlockTypes');
         Cache::forget('DB_AdminResourceName');
         Cache::forget('DB_AdminResource');
         Cache::forget('DB_LocaleFrontEnable');
         Cache::forget('DB_ResourceNavigable');
         Cache::forget('DB_LocalesEnabled');
     }
     if (!Cache::has($cache)) {
         $cachr = new Cachr();
         $cachr->initCache();
     }
     if (Cache::get($cache) === null) {
         $cachr = new Cachr();
         $cachr->initCache();
     }
     return Cache::get($cache);
 }
Esempio n. 7
0
 public static function add($input, $cc_admin = false)
 {
     // set subject
     $input['subject'] = '[BagiKasih] ' . $input['subject'];
     // set sender
     $input['sender_email'] = '*****@*****.**';
     $input['sender_name'] = 'BagiKasih';
     // set status
     $input['status'] = 0;
     $newsletter = new Newsletter();
     foreach ($input as $coulumn => $value) {
         $newsletter->{$coulumn} = $value;
     }
     $newsletter->save();
     try {
         $data = array('content' => $newsletter->message);
         if (!App::isLocal()) {
             // send email
             Mail::send('emails.blank', $data, function ($message) use($newsletter) {
                 $message->from($newsletter->sender_email, $newsletter->sender_name);
                 $message->to($newsletter->recipient_email, $newsletter->recipient_name);
                 if ($cc_admin) {
                     $message->cc('*****@*****.**');
                 }
                 $message->subject($newsletter->subject);
             });
         } else {
             // echo View::make('emails.blank', $data);
         }
         $newsletter->status = 1;
         $newsletter->save();
     } catch (Exception $e) {
         $newsletter->status = 2;
         $newsletter->save();
     }
     return $newsletter;
 }
Esempio n. 8
0
 /**
  * Show chat home view
  * 
  * @return View
  */
 public function showView()
 {
     $users = array();
     $user = UserController::getUser(Auth::user());
     if ($user instanceof Teacher) {
         $sectionCodes = SectionCode::where('teacher_id', new MongoId($user->_id))->where('status', true)->get();
         foreach ($sectionCodes as $sectionCode) {
             foreach ($sectionCode->teamleaders_id as $id) {
                 array_push($users, Student::find($id));
             }
             $users = array_unique($users);
         }
     } else {
         if ($user instanceof Student) {
             $sectionCodes = SectionCode::whereIn('students_id', array(new MongoId($user->_id)))->where('status', true)->get();
             foreach ($sectionCodes as $sectionCode) {
                 foreach ($sectionCode->students_id as $id) {
                     if ($id != Auth::id()) {
                         array_push($users, Student::find($id));
                     }
                 }
                 $count = SectionCode::whereIn('teamleaders_id', array(Auth::id()))->where('_id', new MongoId($sectionCode->_id))->count();
                 if ($count > 0) {
                     array_push($users, Teacher::find($sectionCode->teacher_id));
                 }
                 $users = array_unique($users);
             }
         } else {
             if ($user instanceof University) {
                 return View::make('error.403');
             }
         }
     }
     $ip = App::isLocal() ? '127.0.0.1' : '104.131.3.39';
     return View::make('chat.home')->with(array('contacts' => $users, 'user' => $user, 'ip' => $ip));
 }
Esempio n. 9
0
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::model('country', 'Country');
Route::model('city', 'City');
Route::model('user', 'User');
Route::model('social_target_category', 'SocialTargetCategory');
Route::model('social_action_category', 'SocialActionCategory');
Route::model('event_category', 'EventCategory');
Route::model('donation', 'Donation');
Route::model('newsletter', 'Newsletter');
Route::model('photo', 'Photo');
// Implements
// Admin Panel
if (App::isLocal()) {
    $admin_domain = 'admin.bagikasih.dev';
} else {
    $admin_domain = 'admin.bagikasih.com';
}
Route::group(array('domain' => $admin_domain), function () {
    // login
    Route::get('/signin', array('as' => 'signin', 'uses' => 'AdminBaseController@admin'));
    Route::post('/signin', array('as' => 'signin.post', 'uses' => 'AdminBaseController@admin'));
    Route::group(array('before' => 'admin'), function () {
        Route::get('/signout', array('as' => 'signout', 'uses' => 'AdminBaseController@signout'));
        Route::get('/setting', array('as' => 'admin.setting', 'uses' => 'AdminBaseController@setting'));
        Route::post('/setting', array('as' => 'admin.setting.post', 'uses' => 'AdminBaseController@setting'));
        Route::get('/', array('as' => 'admin.dashboard', 'uses' => 'AdminDashboardController@index'));
        // SOCIAL TARGET
        Route::get('/social-target', array('as' => 'admin.social-target', 'uses' => 'AdminSocialTargetController@index'));
 public function postComplete()
 {
     $this->loadQuestions();
     $this->howfit = Session::get('result');
     $this->baseline = Session::get('baseline');
     $validate_data = Input::except('_token');
     $rules = array('fname' => 'required', 'sname' => 'required', 'email' => 'required', 'company' => 'required', 'country' => 'required', 'terms' => 'required');
     $validator = Validator::make($validate_data, $rules);
     if ($validator->passes()) {
         Session::put('user', $validate_data);
         $screener1 = $this->quiz['demographics']['pages']['page1']['questions']['s1']['selected'];
         $screener2 = $this->quiz['demographics']['pages']['page2']['questions']['s2']['selected'];
         $screener3 = $this->quiz['demographics']['pages']['page3']['questions']['s3']['selected'];
         //update source
         $currentLocal = App::getLocale();
         $localQuestions = $currentLocal == 'en' ? '' : $currentLocal;
         $source = array('C_emailAddress' => $validate_data['email'], 'C_FirstName' => $validate_data['fname'], 'C_LastName' => $validate_data['sname'], 'C_Company' => $validate_data['company'], 'C_Country' => $validate_data['country'], 'C_BusPhone' => $validate_data['phone'], 'C_Job_Responsibilities_1' => $screener1 == Config::get($localQuestions . 'questions.screeners.pages.page1.questions.s1.options.0.label') ? "IT" : "Business / Operations", 'C_NumberofEmployees_Range_1' => $screener2, 'form_source' => Input::get('form_source'));
         Session::put('source', $source);
         //save in db
         $user = new User();
         $user->fname = $validate_data['fname'];
         $user->lname = $validate_data['sname'];
         $user->email = $validate_data['email'];
         $user->company = $validate_data['company'];
         $user->country = $validate_data['country'];
         $user->tel = $validate_data['phone'];
         $user->referer = $validate_data['referer'];
         $user->quiz = json_encode($this->quiz);
         $user->result = json_encode($this->howfit);
         $user->save();
         $this->userid = $user->id;
         $validate_data['userid'] = $user->id;
         //generate report
         $this->generateReport();
         $curloc = App::getLocale();
         /*if(!App::isLocal()){
         			//send guzzle request
         			$client = new GuzzleHttp\Client();
         			$url = 'https://s2048.t.eloqua.com/e/f2.aspx';
         			//$url = 'http://www.google.com';
         			try {
         				$request = $client->createRequest('GET', $url);
         				$query = $request->getQuery();
         				$query['elqFormName'] = Lang::get('general.extFormName');
         				$query['elqSiteID'] = '2048';
         				foreach($source as $key=>$item){
         					$query[$key] = $item;
         				}
         								
         				$response = $client->send($request);
         			} catch (GuzzleHttp\Exception\RequestException $e) {
         				
         				Mail::queue('emails.errors', array('process'=>'Guzzle', 'message'=>$e->getMessage(), 'time'=>date('l jS \of F Y h:i:s A')), function($message)
         				{
         					$message->to('*****@*****.**', 'Roark McColgan')->subject('Error on Converged Infrastructure - Maturity Benchmark! ('.$curloc.')');
         				});
         			}
         		}*/
         $subject = Lang::get('email.report');
         //send mail to user
         Mail::queue('emails.' . $curloc . 'download', array('fname' => $validate_data['fname'], 'sname' => $validate_data['sname'], 'userid' => $validate_data['userid']), function ($message) use($validate_data, $subject, $curloc) {
             $message->to($validate_data['email'], $validate_data['fname'] . ' ' . $validate_data['sname'])->subject($subject);
         });
         //send mail to notification people
         if (App::isLocal()) {
             $emails = ['*****@*****.**'];
         } else {
             $emails = ['*****@*****.**', '*****@*****.**'];
         }
         Mail::queue('emails.notification', array('fname' => $validate_data['fname'], 'sname' => $validate_data['sname'], 'email' => $validate_data['email'], 'company' => $validate_data['company'], 'phone' => $validate_data['phone'], 'screener1' => $this->quiz['demographics']['pages']['page1']['questions']['s1']['selected'], 'screener2' => $this->quiz['demographics']['pages']['page2']['questions']['s2']['selected'], 'screener3' => $this->quiz['demographics']['pages']['page3']['questions']['s3']['selected'], 'score' => $this->howfit['overall']['score'], 'rating' => $this->howfit['overall']['rating'], 'userid' => $validate_data['userid']), function ($message) use($validate_data, $emails, $curloc) {
             $message->to($emails)->subject('Conferged Infrastructure Quiz completed (' . $curloc . ')');
         });
         $vars = array('heading' => Lang::get('general.title'), 'sub1' => Lang::get('general.hi') . ', ' . $validate_data['fname'], 'sub2' => Lang::get('general.soon'), 'tweet' => $this->baseline['overall']['types'][$this->howfit['overall']['rating']]['tweet'], 'colour' => 'orange', 'script' => ['
                     _gaq.push([\'_trackEvent\', \'Form Submit\', \'Registration\']);
                     '], 'quiz' => $this->quiz);
         /*if(Cookie::has('quiz_progress')){
         			$progress_id = Cookie::get('quiz_progress');
         			$progress = Progress::find($progress_id);
         			if($progress) $progress->delete();
         		}
         		$cookie = Cookie::forget('quiz_progress');*/
         //return View::make('thankyou',$vars)->withCookie($cookie);
         return View::make('thankyou', $vars);
     }
     Input::flashExcept('_token');
     return Redirect::to(getLang() . 'quiz/complete')->withErrors($validator);
 }
Esempio n. 11
0
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    // Throw 404 error on ModelNotFoundException
    if ($exception instanceof Illuminate\Database\Eloquent\ModelNotFoundException) {
        $code = 404;
    }
    switch ($code) {
        case 403:
            return Response::view('errors.403', ['title' => 'Erreur 403 – ' . Config::get('typicms.' . App::getLocale() . '.websiteTitle'), 'lang' => App::getLocale(), 'bodyClass' => 'error-403'], $code);
        case 404:
            return Response::view('errors.404', ['title' => 'Erreur 404 – ' . Config::get('typicms.' . App::getLocale() . '.websiteTitle'), 'lang' => App::getLocale(), 'bodyClass' => 'error-404'], $code);
    }
    if (!App::isLocal()) {
        return Response::view('errors.500', ['title' => 'Erreur 500 – ' . Config::get('typicms.' . App::getLocale() . '.websiteTitle'), 'lang' => App::getLocale(), 'bodyClass' => 'error-500'], 500);
    }
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenace mode is in effect for this application.
|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
Esempio n. 12
0
	<head>
		<meta charset="utf-8">
	</head>
	<body style="margin: 0; padding: 0; background: #eee;">
		<table cellspacing="0" cellpadding="0" width="100%">
			<tr>
				<td style="background: #343434; padding-top: 4px; padding-bottom: 4px;" width="10%"></td>
				<td style="background: #343434; padding-top: 4px; padding-bottom: 4px;">
					<a href="http://nosprawl.com"><img style="display: block; float: left;" height="43" src="http://s3.amazonaws.com/us-east-1-resources-nosprawl/email_logo.png"></a>
					<div style="color: #fff; font-family: Helvetica, Arial; float: left; font-size: 1.4em; padding-top: 13px; padding-left: 13px; position: relative;">Welcome</div>
				</td>
				<td style="background: #343434; padding-top: 4px; padding-bottom: 4px;" width="10%"></td>
			</tr>
		</table>
		<table cellspacing="0" cellpadding="0" width="100%">
			<tr>
				<td style="background: #eee; padding-top: 4px; padding-bottom: 4px;" width="10%"></td>
				<td style="background: #eee; padding-top: 4px; padding-bottom: 4px;">
					<div style="color: #fff; font-family: Helvetica, Arial; font-size: 1em; padding-top: 20px; padding-bottom: 20px; line-height: 1.7em; position: relative; color: #343434;">Hi {{ $data['name'] }},<br />You&rsquo;ve been added as a subuser on {{ User::find($data['parent_user_id'])->company_name }}&rsquo;s NoSprawl account.</div>
					
					<div style="display: block; font-family: Helvetica, Arial; font-size: 1em; color: #343434; line-height: 1.7em; margin-top: 0; padding-top: 0;">Please <a href="<?php 
echo App::isLocal() ? 'http://localhost:8000/signup/' : 'http://my.nosprawl.com/signup/';
echo $data['user_confirmation_token'];
?>
">activate your account now</a>.</div>
					<div style="display: block; font-family: Helvetica, Arial; font-size: 1em; color: #343434; line-height: 1.7em; margin-top: 0; padding-top: 0;"><br />Thank you,<br />The NoSprawl Team</div>
				</td>
				<td style="background: #eee; padding-top: 4px; padding-bottom: 4px;" width="10%"></td>
			</tr>
		</table></body>
</html>
Esempio n. 13
0
 protected function js_assets($type, $mobile = false)
 {
     $current_version = File::get(__DIR__ . "/../../.version");
     if ($mobile == false) {
         $basejsfiles = array('/js/jquery.maskedinput.min.js', '/js/jquery.jgrowl.js', '/js/jquery.selectboxes.js', '/js/jquery-migrate-1.2.1.js', '/js/jquery.ajaxQueue.js', '/js/i18n/grid.locale-en.js', '/js/jquery.jqGrid.min.js', '/js/jquery.timepicker.min.js', '/js/fullcalendar.js', '/js/jquery-idleTimeout.js', '/js/jquery.iframer.js', '/js/jquery.serializeObject.js', '/js/jquery.signaturepad.min.js', '/js/json2.min.js', '/js/highcharts.js', '/js/exporting.js', '/js/jquery.dform-1.1.0.js', '/js/grid.addons.js', '/js/grid.postext.js', '/js/grid.setcolumns.js', '/js/jquery.contextmenu.js', '/js/jquery.searchFilter.js', '/js/jquery.tablednd.js', '/js/jquery.chosen.min.js', '/js/ui.multiselect.js', '/js/jquery.themeswitcher.js', '/js/jquery.color.js', '/js/jquery.Jcrop.min.js', '/js/jquery.realperson.js', '/js/tagit-themeroller.js', '/js/jquery.jstree.js', '/js/jquery.populate.js', '/js/jquery.ocupload.js', '/js/jstz-1.0.4.min.js', '/js/jquery.cookie.js', '/js/bluebutton.js', '/js/wColorPicker.min.js', '/js/wPaint.min.js', '/js/plugins/main/wPaint.menu.main.min.js', '/js/plugins/text/wPaint.menu.text.min.js', '/js/plugins/shapes/wPaint.menu.main.shapes.min.js', '/js/plugins/file/wPaint.menu.main.file.min.js', '/js/jqueryui-editable.min.js', '/js/jquery.touchswipe.min.js', '/js/jquery.ui.touch-punch.min.js', '/js/jquery-textrange.js', '/js/jquery.autosize.min.js', '/js/timecube.jquery.js', '/js/toastr.min.js', '/js/main.js');
     } else {
         $basejsfiles = array('/js/jquery.maskedinput.min.js', '/js/jquery-idleTimeout.js', '/js/jstz-1.0.4.min.js', '/js/jquery.cookie.js', '/js/bluebutton.js', '/js/jquery-textrange.js', '/js/toastr.min.js', '/js/nativedroid.js', '/js/jquery.timepicker.min.js', '/js/jquery.selectboxes.js', '/js/mobile.js');
     }
     if (Session::get('group_id') == '1') {
         $homejsfiles = array('/js/searchbar.js', '/js/dashboard.js', '/js/setup.js', '/js/users.js', '/js/extensions.js', '/js/schedule_admin.js', '/js/update.js', '/js/logs.js', '/js/schedule.js');
     }
     if (Session::get('group_id') == '2' || Session::get('group_id') == '3' || Session::get('group_id') == '4') {
         $homejsfiles = array('/js/searchbar.js', '/js/dashboard.js', '/js/demographics.js', '/js/options.js', '/js/messaging.js', '/js/schedule.js', '/js/billing.js', '/js/financial.js', '/js/office.js');
         if (Session::get('patient_centric') == 'yp' && Session::get('group_id') == '2') {
             $homejsfiles[] = '/js/setup.js';
         }
     }
     if (Session::get('group_id') == '100') {
         $homejsfiles = array('/js/dashboard.js', '/js/demographics.js', '/js/messaging.js', '/js/schedule.js', '/js/issues.js', '/js/encounters.js', '/js/t_messages.js', '/js/medications.js', '/js/supplements.js', '/js/allergies.js', '/js/immunizations.js', '/js/documents.js', '/js/forms.js', '/js/graph.js');
     }
     $chartjsfiles = array('/js/chart.js', '/js/demographics.js', '/js/searchbar.js', '/js/options.js', '/js/menu.js', '/js/issues.js', '/js/encounters.js', '/js/medications.js', '/js/supplements.js', '/js/allergies.js', '/js/alerts.js', '/js/immunizations.js', '/js/print.js', '/js/billing.js', '/js/documents.js', '/js/t_messages.js', '/js/lab.js', '/js/rad.js', '/js/cp.js', '/js/ref.js', '/js/messaging.js', '/js/schedule.js', '/js/financial.js', '/js/office.js', '/js/graph.js', '/js/image.js');
     $response = '';
     if (App::isLocal()) {
         foreach ($basejsfiles as $basejsfile) {
             $response .= HTML::script($basejsfile);
         }
         if ($type == 'home') {
             foreach ($homejsfiles as $homejsfile) {
                 $response .= HTML::script($homejsfile);
             }
         }
         if ($type == 'chart') {
             foreach ($chartjsfiles as $chartjsfile) {
                 $response .= HTML::script($chartjsfile);
             }
         }
     } else {
         $jsfilename = '/temp/' . $current_version . '_' . $type . '_' . time() . '.js';
         $jsfile = __DIR__ . '/../../public' . $jsfilename;
         $str = '';
         foreach ($basejsfiles as $basejsfile) {
             $basejsfile1 = __DIR__ . '/../../public/' . $basejsfile;
             $str .= File::get($basejsfile1);
         }
         if ($type == 'home') {
             foreach ($homejsfiles as $homejsfile) {
                 $homejsfile1 = __DIR__ . '/../../public/' . $homejsfile;
                 $str .= File::get($homejsfile1);
             }
         }
         if ($type == 'chart') {
             foreach ($chartjsfiles as $chartjsfile) {
                 $chartjsfile1 = __DIR__ . '/../../public/' . $chartjsfile;
                 $str .= File::get($chartjsfile1);
             }
         }
         File::put($jsfile, $str);
         $response .= HTML::script($jsfilename);
     }
     return $response;
 }
Esempio n. 14
0
 private function tweetMail($id, $obj, $action = null)
 {
     if ($mp3->price == 'paid') {
         // Send an email to the new user letting them know their music has been uploaded
         $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik pou vann.'];
         TKPM::sendMail('emails.user.buy', $data, 'mp3');
     } elseif (Auth::guest() && Input::has('email')) {
         $mp3->userEmail = Input::get('email');
         $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik'];
         TKPM::sendMail('emails.user.guest3', $data, 'guest3');
     }
     // Send an email to the new user letting them know their music has been uploaded
     $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik'];
     TKPM::sendMail('emails.user.mp3', $data, 'mp3');
     if (!App::isLocal()) {
         TKPM::tweet($mp3, 'mp3');
     }
 }
Esempio n. 15
0
 public static function asset($asset, $size = 'null')
 {
     $imgSize = ['thumbs' => 'uploads/images/thumbs/', 'images' => 'uploads/images/', 'show' => 'uploads/images/show/', 'tiny' => 'uploads/images/thumbs/tiny/', 'profile' => 'uploads/images/thumbs/profile/', 'null' => ''];
     $relativeUrl = $imgSize[$size] . $asset;
     if (App::isLocal()) {
         return asset($relativeUrl);
     }
     $cdnUrl = 'http://tkpm.cdn.tikwenpam.net/';
     return url($cdnUrl . $relativeUrl);
 }
 public function fire($job, $data)
 {
     $output = new Symfony\Component\Console\Output\ConsoleOutput();
     $node = Node::find($data['message']['node_id']);
     $s3 = \Aws\S3\S3Client::factory(array('key' => 'AKIAIUCV4E2L4HDCDOUA', 'secret' => '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', 'region' => 'us-east-1'));
     $all_keys = Key::where('integration_id', '=', $data['message']['integration_id'])->get();
     foreach ($all_keys as $pem_key_reference) {
         if ($pem_key_reference->remote_url) {
             $unique_key_name = rand(0, 9999) . $pem_key_reference->remote_url;
             $key_bucket = App::isLocal() ? 'devkeys.nosprawl.software' : 'keys.nosprawl.software';
             $s3->getObject(array('Bucket' => $key_bucket, 'Key' => $pem_key_reference->remote_url, 'SaveAs' => '/tmp/' . $unique_key_name));
             // Shouldn't need these two lines at all.
             exec('chmod 400 /tmp/' . $unique_key_name);
             $empty = null;
             $s3_resource_root = App::isLocal() ? 'http://agent.nosprawl.software/dev/' : 'http://agent.nosprawl.software/';
             $latest_version = exec("curl -s " . $s3_resource_root . "latest", $empty);
             $latest_version_url = $s3_resource_root . $latest_version;
             $ssh = new Net_SSH2($node->public_dns_name);
             $ssh->enableQuietMode();
             $ssh->enablePTY();
             $key = new Crypt_RSA();
             $key->loadKey(file_get_contents('/tmp/' . $unique_key_name));
             exec('rm -rf /tmp/' . $unique_key_name);
             if (!$ssh->login($pem_key_reference->username, $key)) {
                 continue;
             } else {
                 $possible_installers = ["yum", "apt-get"];
                 foreach ($possible_installers as $possible_installer) {
                     $installer_check_result = false;
                     $found = false;
                     $ssh->exec("sudo " . $possible_installer . " -y install ruby");
                     $install_result = $ssh->read();
                     $output->writeln($install_result);
                     $install_exit_status = $ssh->getExitStatus();
                     if ($install_exit_status == 0) {
                         Queue::push('DeployAgentToNode', array('message' => array('node_id' => $node->id, 'integration_id' => $node->integration->id)));
                         return $job->delete();
                     }
                 }
             }
         } else {
             $output->writeln("This is what we do if all we have is a password.");
             continue;
         }
     }
     // If we got to this point we were unable to install Curl automatically.
     $problem = new Problem();
     $problem->description = "Couldn't install Curl.";
     $problem->reason = "Unable to automatically install Curl. Please install it manually.";
     $problem->node_id = $node->id;
     $problem->save();
     $remediation = new Remediation();
     $remediation->name = "Retry Deployment";
     $remediation->queue_name = "DeployAgentToNode";
     $remediation->problem_id = $problem->id;
     $remediation->save();
     $remediation = new Remediation();
     $remediation->name = "Cancel";
     $remediation->queue_name = "CancelDeployAgentToNode";
     $remediation->problem_id = $problem->id;
     $remediation->save();
     return $job->delete();
 }
Esempio n. 17
0
 public function store()
 {
     // return Input::all();
     $email_rule = Auth::guest() ? 'required' : '';
     $rules = ['name' => 'required|min:6', 'mp3' => 'required|mimes:mpga|max:64000000', 'image' => 'required|image', 'email' => $email_rule];
     $messages = ['name.required' => Config::get('site.validate.name.required'), 'name.min' => Config::get('site.validate.name.min'), 'mp3.required' => Config::get('site.validate.mp3.required'), 'mp3.mimes' => Config::get('site.validate.mp3.mimes'), 'mp3.size' => Config::get('site.validate.mp3.size'), 'image.required' => Config::get('site.validate.image.required'), 'image.image' => Config::get('site.validate.image.image'), 'email.required' => Config::get('site.validate.email.required')];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         if (Request::ajax()) {
             $response = [];
             $response['success'] = false;
             $response['errors'] = $validator->messages();
             return $response;
         }
         return Redirect::to('/mp3/up')->withErrors($validator)->withInput();
     }
     $storedMP3 = MP3::whereName(Input::get('name'))->first();
     if ($storedMP3) {
         if (Request::ajax()) {
             $response = [];
             $response['success'] = true;
             $response['url'] = $storedMP3->price == 'paid' ? "/mp3/{$storedMP3->id}/edit" : "/mp3/{$storedMP3->id}";
             return $response;
         }
         return Redirect::to("mp3/{$storedMP3->id}");
     }
     /****** MP3 Uploading *******/
     $price = Input::get('price');
     $name = Input::get('name');
     $mp3 = Input::file('mp3');
     $mp3_size = TKPM::size($mp3->getClientsize());
     $mp3_ext = $mp3->getClientOriginalExtension();
     $mp3_name = Str::slug($name, '-') . '-' . Str::random(32) . '.' . $mp3_ext;
     $mp3_upload_path = Config::get('site.mp3_upload_path');
     $mp3_success = $mp3->move($mp3_upload_path, $mp3_name);
     /************ Image Uploading *****************/
     $img = Input::file('image');
     $img_type = $img->getMimeType();
     $img_ext = $img->getClientOriginalExtension();
     $img_name = Str::slug($name, '-') . '-' . Str::random(32) . '.' . $img_ext;
     $img_upload_path = Config::get('site.image_upload_path');
     $img_success = $img->move($img_upload_path, $img_name);
     if ($img_success) {
         TKPM::image($img_name, 250, 250, 'thumbs');
         TKPM::image($img_name, 100, null, 'thumbs/tiny');
         TKPM::image($img_name, 640, 360, 'show');
     }
     $admin_id = User::whereAdmin(1)->first()->id;
     $user_id = Auth::check() ? Auth::user()->id : $admin_id;
     if ($mp3_success && $img_success) {
         $mp3 = new MP3();
         $mp3->name = ucwords($name);
         $mp3->mp3name = $mp3_name;
         $mp3->image = $img_name;
         $mp3->user_id = $user_id;
         $mp3->category_id = Input::get('cat');
         $mp3->size = $mp3_size;
         if ($price == 'free') {
             $mp3->publish = 1;
         }
         $mp3->price = $price;
         if (!$price) {
             $mp3->publish = 1;
             $mp3->price = 'free';
         }
         $mp3->description = Input::get('description');
         $mp3->save();
         /************** GETID3 **************/
         TKPM::tag($mp3, $img_name, $img_type);
         /******* Flush the cache ********/
         Cache::flush();
         if ($mp3->price == 'paid') {
             // Send an email to the new user letting them know their music has been uploaded
             $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik pou vann.'];
             TKPM::sendMail('emails.user.buy', $data, 'mp3');
         } elseif (Auth::guest() && Input::has('email')) {
             $mp3->userEmail = Input::get('email');
             $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik'];
             TKPM::sendMail('emails.user.guest3', $data, 'guest3');
         } else {
             // Send an email to the new user letting them know their music has been uploaded
             $data = ['mp3' => $mp3, 'subject' => 'Felisitasyon!!! Ou fèk mete yon nouvo mizik'];
             TKPM::sendMail('emails.user.mp3', $data, 'mp3');
         }
         if (!App::isLocal()) {
             TKPM::tweet($mp3, 'mp3');
         }
         if (Request::ajax()) {
             $response = [];
             $response['success'] = true;
             $response['url'] = $price == 'paid' ? "/mp3/{$mp3->id}/edit" : "/mp3/{$mp3->id}";
             return $response;
         }
         Cache::forget('latest.musics');
         if ($price == 'paid') {
             return Redirect::to("mp3/{$mp3->id}/edit");
         }
         return Redirect::to('mp3/' . $mp3->id);
     } else {
         if (Request::ajax()) {
             $response = [];
             $response['success'] = false;
             $response['message'] = 'Nou regrèt men nou pa reyisi mete mizik ou a. Eseye ankò.';
             return $response;
         }
         return Redirect::to(Request::url())->with('message', 'Nou regrèt men nou pa reyisi mete mizik ou a. Eseye ankò.');
     }
 }
Esempio n. 18
0
 public function fire($job, $data)
 {
     $output = new Symfony\Component\Console\Output\ConsoleOutput();
     $node = Node::find($data['message']['node_id']);
     // Make sure node exists
     if (!$node) {
         $output->writeln("node doesn't exist anymore. no need for this job.");
         return $job->delete();
     }
     // Make sure node isn't terminated
     /*if($node->service_provider_status == "terminated") {
     			return $job->delete();
     		}*/
     // Make sure node is running
     if ($node->service_provider_status != "running") {
         return $job->release();
         $output->writeln("node is not running");
     }
     // Keys are always stored on S3. This is the NoS account.
     $s3 = \Aws\S3\S3Client::factory(array('key' => 'AKIAIUCV4E2L4HDCDOUA', 'secret' => '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', 'region' => 'us-east-1'));
     $all_keys = Key::where('integration_id', '=', $data['message']['integration_id'])->get();
     $unique_key_name = null;
     $cmdout = null;
     // Make sure the user has added credentials for this integration
     if ($all_keys->isEmpty()) {
         $problem = new Problem();
         $problem->description = "Couldn't deploy agent";
         $problem->reason = "No credentials added for this integration.<br /><br />You can manage your integration credentials on the <a href='#'>integrations</a> page.<br />Or <a href='#'>deploy manually</a>.";
         $problem->node_id = $node->id;
         $problem->long_message = true;
         $problem->save();
         $remediation = new Remediation();
         $remediation->name = "Cancel";
         $remediation->queue_name = "CancelDeployAgentToNode";
         $remediation->problem_id = $problem->id;
         $remediation->save();
         $remediation = new Remediation();
         $remediation->name = "Retry";
         $remediation->queue_name = "DeployAgentToNode";
         $remediation->problem_id = $problem->id;
         $remediation->save();
         return $job->delete();
     }
     $eventually_logged_in = false;
     foreach ($all_keys as $pem_key_reference) {
         if ($pem_key_reference->remote_url) {
             $unique_key_name = rand(0, 9999) . $pem_key_reference->remote_url;
             $key_bucket = App::isLocal() ? 'devkeys.nosprawl.software' : 'keys.nosprawl.software';
             $s3->getObject(array('Bucket' => $key_bucket, 'Key' => $pem_key_reference->remote_url, 'SaveAs' => '/tmp/' . $unique_key_name));
             exec('chmod 400 /tmp/' . $unique_key_name);
             $empty = null;
             $s3_resource_root = App::isLocal() ? 'http://agent.nosprawl.software/dev/' : 'http://agent.nosprawl.software/';
             $latest_version = exec("curl -s " . $s3_resource_root . "latest", $empty);
             $latest_version_url = $s3_resource_root . $latest_version;
             $ssh = new Net_SSH2($node->public_dns_name);
             $ssh->enableQuietMode();
             $ssh->enablePTY();
             $key = new Crypt_RSA();
             $key->loadKey(file_get_contents('/tmp/' . $unique_key_name));
             exec('rm -rf /tmp/' . $unique_key_name);
             if (!$ssh->login($pem_key_reference->username, $key)) {
                 $output->writeln("ssh fail.");
                 continue;
             } else {
                 $output->writeln("we are in ssh just fine.");
                 // Let's look for any problems running sudo first.
                 $ssh->exec("sudo whoami");
                 $exit_status = $ssh->getExitStatus();
                 if (!$exit_status && $exit_status != 0) {
                     // User can't sudo without a password. We can't auto-install.
                     $problem = new Problem();
                     $problem->description = "Couldn't deploy agent";
                     $problem->reason = "User '" . $pem_key_reference->username . "' doesn't have passwordless sudo priviliges. Please either enable  it or <a class='problem_cta_btn' href='#'>Manually deploy the NoSprawl Agent</a>";
                     $problem->node_id = $node->id;
                     $problem->long_message = true;
                     $problem->save();
                     $remediation = new Remediation();
                     $remediation->name = "Cancel";
                     $remediation->queue_name = "CancelDeployAgentToNode";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     $remediation = new Remediation();
                     $remediation->name = "Retry";
                     $remediation->queue_name = "DeployAgentToNode";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     return $job->delete();
                 }
                 $result = $ssh->read();
                 $output->writeln($result);
                 // Check for problems with curl
                 $ssh->exec("curl --help");
                 $curl_result = $ssh->read();
                 $curl_exit_status = $ssh->getExitStatus();
                 if ($curl_exit_status != 0) {
                     $problem = new Problem();
                     $problem->description = "Couldn't deploy agent";
                     $problem->reason = "cURL isn&rsquo;t installed.";
                     $problem->node_id = $node->id;
                     $problem->save();
                     $remediation = new Remediation();
                     $remediation->name = "Install cURL";
                     $remediation->queue_name = "InstallCurlAndRetryDeployment";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     $remediation = new Remediation();
                     $remediation->name = "Cancel";
                     $remediation->queue_name = "CancelDeployAgentToNode";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     return $job->delete();
                 }
                 $ssh->exec("(curl " . $latest_version_url . " > nosprawl-installer.rb) && sudo ruby nosprawl-installer.rb && rm -rf nosprawl-installer.rb");
                 $installer_result = $ssh->read();
                 $installer_exit_status = $ssh->getExitStatus();
                 if ($installer_exit_status == 0) {
                     // Everything is good.
                     $node->limbo = false;
                     $node->save();
                     return $job->delete();
                 } else {
                     $problem = new Problem();
                     $problem->description = "Couldn't deploy agent";
                     $problem->reason = "Ruby isn't installed.";
                     $problem->node_id = $node->id;
                     $problem->save();
                     $remediation = new Remediation();
                     $remediation->name = "Install";
                     $remediation->queue_name = "InstallRubyAndRetryDeployment";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     $remediation = new Remediation();
                     $remediation->name = "Cancel";
                     $remediation->queue_name = "CancelDeployAgentToNode";
                     $remediation->problem_id = $problem->id;
                     $remediation->save();
                     return $job->delete();
                 }
                 return $job->delete();
             }
         } else {
             $output->writeln("This is what we do if all we have is a password.");
             continue;
         }
     }
     if (!$eventually_logged_in) {
         $problem = new Problem();
         $problem->description = "Couldn't deploy agent";
         $problem->reason = "None of the credentials provided were sufficient to connect to this node. Manage your credentials on the <a href='#'>integrations</a> page.<br />Or <a href='#'>deploy manually</a>.";
         $problem->node_id = $node->id;
         $problem->long_message = true;
         $problem->save();
         $remediation = new Remediation();
         $remediation->name = "Cancel";
         $remediation->queue_name = "CancelDeployAgentToNode";
         $remediation->problem_id = $problem->id;
         $remediation->save();
         $remediation = new Remediation();
         $remediation->name = "Retry";
         $remediation->queue_name = "DeployAgentToNode";
         $remediation->problem_id = $problem->id;
         $remediation->save();
         return $job->delete();
     }
 }
Esempio n. 19
0
function version($update = false)
{
    static $version;
    if (!App::isLocal()) {
        $update = true;
    }
    if ($version && !$update) {
        return trim($version);
    }
    $versionFile = base_path('.version.php');
    if (!is_file($versionFile) || $update) {
        // @todo - go back to tag description
        exec('git describe --always', $version);
        $version = array_shift($version) ?: '0-unknown';
        if ($version[0] == 'v') {
            $version = substr($version, 1);
        }
        file_put_contents($versionFile, "<?php return '{$version}';");
    } else {
        $version = (require $versionFile);
    }
    return trim($version);
}