update v1.0.4

This commit is contained in:
sujitprasad
2016-01-04 18:05:45 +05:30
parent 372485336b
commit 4864e5a3f1
529 changed files with 20956 additions and 8178 deletions

View File

@@ -0,0 +1,249 @@
<?php namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests;
use Illuminate\Http\Request;
//supports
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Collection;
//classes
use Input;
use Config;
use Validator;
use Zipper;
use App;
use Lang;
use Cache;
use File;
/**
* SlaController
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class LanguageController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Switch language at runtime
* @param type "" $lang
* @return type response
*/
public function switchLanguage($lang) {
//if(Cache::has('language'))
//{
// return Cache::get('language');
//} else return 'false';
// Cache::put('language',$)
if(array_key_exists($lang, Config::get('languages'))) {
// dd(array_key_exists($lang, Config::get('languages')));
// app()->setLocale($lang);
Cache::forever('language', $lang);
// dd(Cache::get('language'));
// dd()
} else {
return Redirect::back()->with('message', 'Language package not found in your lang directroy.');
}
return Redirect::back();
}
/**
*Shows language page
*@return type response
*/
public function index(){
return view('themes.default1.admin.helpdesk.language.index');
}
/**
*Shows Language upload form
*@return type response
*/
public function getForm(){
return view('themes.default1.admin.helpdesk.language.create');
}
/**
*Provide language datatable to language page
*@return type
*/
public function getLanguages()
{
$path = 'code/resources/lang';
$values = scandir($path); //Extracts names of directories present in lang directory
$values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..'
return \Datatable::collection(new Collection($values))
->addColumn('language', function($model){
return Config::get('languages.'.$model);
})
->addColumn('id', function($model){
return $model;
})
->addColumn('status',function($model){
if(Lang::getLocale()===$model){return "<span style='color:green'>".Lang::trans("lang.active")."</span>"; } else return "<span style='color:red'>".Lang::trans("lang.inactive")."</span>";
})
->addColumn('Action', function($model){
if(Lang::getLocale()===$model){
return "<a href='change-language/".$model."'><input type='button' class='btn btn-info btn-xs btn-flat' disabled value='". Lang::trans("lang.disable")."'/></a>
<a href='change-language/".$model."' class='btn btn-danger btn-xs btn-flat' disabled><i class='fa fa-trash' style='color:black;'> </i> ". Lang::trans("lang.delete")."</a>";
} else {
return "<a href='change-language/".$model."'><input type='button' class='btn btn-info btn-xs btn-flat' value='". Lang::trans("lang.enable")."'/></a>
<a href='delete-language/".$model."' class='btn btn-danger btn-xs btn-flat'><i class='fa fa-trash' style='color:black;'> </i> ". Lang::trans("lang.delete")."</a>";
}
})
->searchColumns('language','id')
->make();
}
/**
*handle language file uploading
*@return response
*/
public function postForm() {
// getting all of the post data
$file = array(
'File' => Input::file('File'),
'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code')
);
// setting up rules
$rules = array(
'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required',
'iso-code' => 'required|max:2'
); // and for max size
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::back()->withInput()->withErrors($validator);
} else {
//Checking if package already exists or not in lang folder
$path = 'code/resources/lang';
if (in_array(Input::get('iso-code'), scandir($path))) {
//sending back with error message
Session::flash('fails', "Language package already exists.");
Session::flash('link',"change-language/".Input::get('iso-code'));
return Redirect::back()->withInput();
} elseif (!array_key_exists(Input::get('iso-code'), Config::get('languages'))){//Checking Valid ISO code form Languages.php
//sending back with error message
Session::flash('fails', "Enter correct ISO-code");
return Redirect::back()->withInput();
} else {
// checking file is valid.
if (Input::file('File')->isValid()) {
$name = Input::file('File')->getClientOriginalName(); //uploaded file's original name
$destinationPath = 'code/public/uploads/'; // defining uploading path
$extractpath = 'code/resources/lang/'.Input::get('iso-code');//defining extracting path
mkdir($extractpath); //creating directroy for extracting uploadd file
//mkdir($destinationPath);
Input::file('File')->move($destinationPath, $name); // uploading file to given path
\Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath);//extracting file to give path
//check if Zip extract foldercontains any subfolder
$directories = File::directories($extractpath);
//$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
if(!empty($directories)){ //if extract folder contains subfolder
$success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang
//$success2 = File::delete($destinationPath.'/'.$name);
if($success){
//sending back with error message
Session::flash('fails', 'Error in directory structure. Zip file must contain language php files only. Try Again.');
return Redirect::back()->withInput();
}
} else {
// sending back with success message
Session::flash('success', "uploaded successfully.");
Session::flash('link',"change-language/".Input::get('iso-code'));
return Redirect::route('LanguageController');
}
} else {
// sending back with error message.
Session::flash('fails', 'uploaded file is not valid');
return Redirect::route('form');
}
}
}
}
/**
*allow user to download language template file
*@return type
*/
Public function download()
{
return response()->download('code/public/downloads/en.zip');
}
/**
* This function is used to delete languages
* @param type $lang
* @return type response
*/
public function deleteLanguage($lang){
if($lang !== App::getLocale()){
$deletePath = 'code/resources/lang/'.$lang; //define file path to delete
$success = File::deleteDirectory($deletePath); //remove extracted folder and it's subfolder from lang
if($success){
//sending back with success message
Session::flash('success', 'Language package deleted successfully.');
return Redirect::back();
} else {
//sending back with error message
Session::flash('fails', 'Language package does not exist.');
return Redirect::back();
}
} else {
//sending back with error message
Session::flash('fails', 'Language package can not be deleted when it is active.');
return redirect('languages');
}
}
}

View File

@@ -47,6 +47,14 @@ class SettingsController extends Controller {
$this->middleware('roles');
}
/**
* Main Settings Page
* @return type view
*/
public function settings() {
return view('themes.default1.admin.helpdesk.setting');
}
/**
* @param int $id
* @return Response

View File

@@ -111,11 +111,12 @@ class MailController extends Controller {
$thread_id = $thread_id->id;
foreach($mail->getAttachments() as $attachment) {
// dd($attachment);
$support = "support";
// echo $_SERVER['DOCUMENT_ROOT'];
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
$filepath = explode('../../../../../../public/',$attachment->filePath);
$filepath = explode('../../../../../../public',$attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/public/".$filepath[1];
$path = public_path().'/'.$filepath[1];

View File

@@ -17,6 +17,8 @@ use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
/* Include login validator */
use Mail;
use Auth;
// Model
// use App\Model\helpdesk\Utility\Limit_Login;
/**
* ---------------------------------------------------
@@ -146,14 +148,45 @@ class AuthController extends Controller {
* @return type Response
*/
public function postLogin(LoginRequest $request) {
// $email = $request->input('email');
// $password = Hash::make($request->input('password'));
// $remember = $request->input('remember');
// dd([$email,$password,$remember]);
// Set login attempts and login time
$loginAttempts = 1;
$credentials = $request->only('email', 'password');
if ($this->auth->attempt($credentials, $request->has('remember'))) {
$email = $request->email;
// $ip_address = $_SERVER['REMOTE_ADDR'];
// $limit_login = Limit_Login::where('email' , '=' , $email)->where('ip_address', '=', $ip_address)->first();
// if(isset($limit_login)) {
// }
// If session has login attempts, retrieve attempts counter and attempts time
if (\Session::has('loginAttempts')) {
$loginAttempts = \Session::get('loginAttempts');
$loginAttemptTime = \Session::get('loginAttemptTime');
$credentials = $request->only('email', 'password');
// If attempts > 3 and time < 10 minutes
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
return redirect()->back()->with('error', 'Maximum login attempts reached. Try again in a while');
}
// If time > 10 minutes, reset attempts counter and time in session
if (time() - $loginAttemptTime > 600) {
\Session::put('loginAttempts', 1);
\Session::put('loginAttemptTime', time());
}
} else // If no login attempts stored, init login attempts and time
{
\Session::put('loginAttempts', $loginAttempts);
\Session::put('loginAttemptTime', time());
}
// If auth ok, redirect to restricted area
\Session::put('loginAttempts', $loginAttempts + 1);
if ($this->auth->attempt($credentials, $request->has('remember'))) {
if(Auth::user()->role == 'user') {
return \Redirect::route('home');
return \Redirect::route('/');
} else {
return redirect()->intended($this->redirectPath());
}
@@ -164,6 +197,7 @@ class AuthController extends Controller {
'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(),
]);
// Increment login attempts
}
/**
@@ -173,4 +207,101 @@ class AuthController extends Controller {
protected function getFailedLoginMessage() {
return 'This Field do not match our records.';
}
}
// public function postLogin(LoginRequest $request) {
// $email = $request->input('email');
// $counter = 0;
// $user = User::where('email','=',$email)->first();
// if($user) {
// if($user->active == 1) {
// $credentials = $request->only('email', 'password');
// while($counter < 10) {
// if($this->auth->attempt($credentials) === false) {
// $counter++;
// }
// }
// if ($this->auth->attempt($credentials, $request->has('remember'))) {
// if(Auth::user()) {
// if(Auth::user()->role == 'vendor') {
// return \Redirect::route('vendors.index');
// } elseif(Auth::user()->role == 'admin') {
// return \Redirect::route('admin.dashboard');
// } elseif(Auth::user()->role == 'sadmin') {
// return \Redirect::route('sadmin.dashboard');
// } else {
// return redirect()->intended($this->redirectPath());
// }
// } else {
// return redirect()->back()->with('message','Account Inactive, Please wait for Admin to approve.');
// }
// }
// } else {
// return redirect()->back()->with('message','Account Inactive, Please wait for Admin to approve.');
// }
// }
// return redirect($this->loginPath())
// ->withInput($request->only('email', 'remember'))
// ->withErrors(['email' => $this->getFailedLoginMessage(), 'password' => $this->getFailedLoginMessage(), ]);
// }
// public function authenticate() {
// // Set login attempts and login time
// $loginAttempts = 1;
// // If session has login attempts, retrieve attempts counter and attempts time
// if (Session::has('loginAttempts')) {
// $loginAttempts = Session::get('loginAttempts');
// $loginAttemptTime = Session::get('loginAttemptTime');
// // If attempts > 3 and time < 10 minutes
// if ($loginAttempts > 3 && (time() - $loginAttemptTime <= 600)) {
// return redirect()-back()->with('error', 'maximum login attempts reached. Try again in a while');
// }
// // If time > 10 minutes, reset attempts counter and time in session
// if (time() - $loginAttemptTime > 600) {
// Session::put('loginAttempts', 1);
// Session::put('loginAttemptTime', time());
// }
// } else // If no login attempts stored, init login attempts and time
// {
// Session::put('loginAttempts', $loginAttempts);
// Session::put('loginAttemptTime', time());
// }
// // If auth ok, redirect to restricted area
// if (Auth::attempt(['email' => 'someone@example.com'])) {
// return redirect()->intended('dashboard');
// }
// // Increment login attempts
// Session::put('loginAttempts', $loginAttempts + 1);
// }
// public function postLogin(LoginRequest $request) {
// // $email = $request->input('email');
// // $password = Hash::make($request->input('password'));
// // $remember = $request->input('remember');
// // dd([$email,$password,$remember]);
// $credentials = $request->only('email', 'password');
// if ($this->auth->attempt($credentials, $request->has('remember'))) {
// if(Auth::user()->role == 'user') {
// return \Redirect::route('home');
// } else {
// return redirect()->intended($this->redirectPath());
// }
// }
// return redirect($this->loginPath())
// ->withInput($request->only('email', 'remember'))
// ->withErrors([
// 'email' => $this->getFailedLoginMessage(),
// 'password' => $this->getFailedLoginMessage(),
// ]);
// }
}

View File

@@ -145,7 +145,7 @@ class InstallController extends Controller {
}
if (Config::get('database.install') == '%0%') {
if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view4');
return View::make('themes/default1/installer/helpdesk/view3');
} else {
return Redirect::route('prerequisites');
}
@@ -281,7 +281,7 @@ class InstallController extends Controller {
public function database() {
if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') {
return View::make('themes/default1/installer/helpdesk/view5');
return View::make('themes/default1/installer/helpdesk/view4');
} else {
return Redirect::route('configuration');
}
@@ -302,7 +302,7 @@ class InstallController extends Controller {
Session::forget('step1');
Session::forget('step2');
Session::forget('step3');
return View::make('themes/default1/installer/helpdesk/view6');
return View::make('themes/default1/installer/helpdesk/view5');
} else {
return Redirect::route('configuration');
}
@@ -420,7 +420,7 @@ class InstallController extends Controller {
File::put($path22, $content23);
try {
return View::make('themes/default1/installer/helpdesk/view7');
return View::make('themes/default1/installer/helpdesk/view6');
} catch (Exception $e) {
return Redirect::route('npl');
}