Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $command = $_POST['command'];
- $location = $_POST['location'];
- $response = [
- 'command' => $command,
- 'location' => $location,
- 'msg' => $message,
- ];
- $resume = [
- 'root' =>[
- 'information' => [
- 'name.info' => 'Nicolas Toporcov',
- 'email.info' => 'ntoporcov@me.com',
- 'telephone.info' => '(904) 704 3653'
- ],
- 'education' => [
- 'university.info' => 'University of North Florida',
- 'degree.info' => 'Bachelor in Communication',
- 'year.info' => '2015'
- ],
- 'skills' => [
- 'basic.list' => ['Adwords','Google Analytics','Deployment','Server Config','Object Oriented Programming'],
- 'intermediate.list' => ['PHP','Git','XMLHR','API Interaction','UX Design','Prototyping'],
- 'advanced.list' => ['HTML','CSS','JQuery','Javascript','Photoshop','Illustrator','InDesign','WordPress','Print Design','UI Design'],
- 'miscellaneous.list' => ['Photography','Videography','Video Editing','Animation']
- ],
- 'experience' => [
- 'gleanview' => [
- 'company.info' => 'GleanView, a Sales and Marketing Solution',
- 'period.info' => 'July 2017 - Now',
- 'position.info' => 'Marketing Front-End Developer and Product Designer',
- 'description.info' => 'GleanView is where I started learning about web development and product
- design from scratch. I’ve been responsible for the entire website and landing
- pages design and development, all google display ads design, company blog
- design and setup in wordpress and more recently product design for the
- software itself.'
- ],
- 'lunic' => [
- 'company.info' => 'Lunic Visuals, Photography and Videography Company',
- 'period.info' => 'January 2017 - Now',
- 'position.info' => 'Co-Owner',
- 'description.info' => 'Lunic is a company I started with my wife to offer Photography and
- Videography. We’ve been doing mostly engagement photoshoots and
- wedding photography and videography. I also designed and developed our
- website in wordpress.'
- ],
- 'JBJ' => [
- 'company.info' => 'Jacksonville Business Journal, a local newspaper about businesses',
- 'period.info' => 'February 2016 - June 2017',
- 'position.info' => 'Graphic Designer',
- 'description.info' => 'The Jacksonville Business Journal was my first full-time employment where
- I was responsible for design. I was responsible for designing, placing and
- managing ads being sold for the weekly newspaper as well as the annual
- Book of Lists. While working at the JBJ I learned a lot about Design in itself,
- specially how to deal with deadlines and handling super short notices.',
- ],
- ]
- ]
- ];
- switch (count($location)){
- case 1:
- $currentLocation = $resume[$location[0]];
- break;
- case 2:
- $currentLocation = $resume[$location[0]] [$location[1]];
- break;
- case 3:
- $currentLocation = $resume[$location[0]] [$location[1]] [$location[2]];
- break;
- case 4:
- $currentLocation = $resume[$location[0]] [$location[1]] [$location[2]] [$location[3]];
- break;
- case 5:
- $currentLocation = $resume[$location[0]] [$location[1]] [$location[2]] [$location[3]] [$location[4]];
- break;
- case 6:
- $currentLocation = $resume[$location[0]] [$location[1]] [$location[2]] [$location[3]] [$location[4]] [$location[5]];
- break;
- }
- switch ($command[0]){
- // show all folders and files in the current directory
- case 'ls':
- $response['msg'] = implode(' ',array_keys($currentLocation));
- break;
- // move to directory
- case 'cd':
- if(array_key_exists($command[1],$currentLocation)){
- //checks if argument is file
- if (substr_count($command[1],'.info') > 0){
- $response['msg'] = '-bash: cd: Invalid Command. Command cd can only be used to choose directory to move to.
- Use rd to read .info files';
- break;
- } elseif (substr_count($command[1],'.list') > 0){
- $response['msg'] = '-bash: cd: Invalid Command. Command cd can only be used to choose directory to move to.
- Use rd to read .list files';
- break;
- }else{
- array_push($location,$command[1]);
- $response['location'] = $location;
- break;
- }
- } elseif($command[1] === '../'){
- if(count($location) > 1){
- $removedElement = array_pop($location);
- $response['location'] = $location;
- }else{
- $response['msg'] = '-bash: Currently in root directory.';
- }
- }
- else{
- $response['msg'] = '-bash: Directory '.$command[1].' not found. Run ls to list files in current directory';
- }
- break;
- // show current directory
- case 'pwd':
- $response['msg'] = implode('/',$location);
- break;
- // read file
- case 'cat':
- //checks if command is about a file, not a directory
- if(substr_count($command[1],'.')){
- //checks if file exists
- if(array_key_exists($command[1],$currentLocation)){
- $value = $currentLocation[$command[1]];
- if (gettype($value) === 'string'){
- $response['msg'] = $command[1].' => '.$value;
- }elseif(gettype($value) === 'array'){
- $value = implode(' ', $value);
- $response['msg'] = $command[1].' => '.$value;
- }
- }else{
- $response['msg'] = '-bash: File '.$command[1].' not found.';
- }
- //checks if they used -a modifier to read all files in directory
- }else if($command[1]==='-a') {
- $messageLines = [];
- foreach($currentLocation as $key => $value){
- if(gettype($value)==='string'){
- array_push( $messageLines,$key.' => '.$value.'<br>');
- }elseif(gettype($value)==='array'){
- if(substr_count($key,'.') > 0){
- $value = implode(' ',$value);
- array_push( $messageLines,$key.' => '.$value.'<br>');
- }
- }
- }
- if(count($messageLines) > 0){
- $response['msg'] = implode($messageLines);
- }else{
- $response['msg'] = '-bash: No readable files found in current directory: '.implode('/',$location);
- }
- // if argument is a directory
- }else{
- $response['msg'] = '-bash: File '.$command[1].' is a directory. It can not be read. Run cd to change directories, or rd -a to read all files in a directory';
- }
- break;
- case 'color':
- $response['msg'] = $command[1];
- break;
- case '-help':
- $response['msg'] =
- '<br><strong>COMMANDS AVAILABLE</strong><br><br>
- ls => Lists all files and directories in current location<br>
- pwd => Shows path of current directory<br>
- cd [dir] => Changes directory to [dir]<br>
- cd ../ => Goes back to the previous directory<br>
- cat [file.ext] => Reads content of file. Explicit file extension is required.<br>
- cat -a => Reads all contents of all readable files in current directory<br>
- color [css] => Changes color of text in terminal. Accepts CSS colors and hex colors.<br>
- -help => shows help dialogue<br><br>';
- break;
- default:
- $response['msg'] = '-bash: '.$command[0].': Command not found. Run -help to see a list of commands';
- };
- echo json_encode($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement