Ejemplo n.º 1
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $tpl = FWS_Props::get()->tpl();
     $input = FWS_Props::get()->input();
     $cookies = FWS_Props::get()->cookies();
     $scope = $input->get_var('scope', -1, FWS_Input::STRING);
     $name = $input->get_var('name', -1, FWS_Input::STRING);
     $url = PC_URL::get_mod_url();
     $url->set('scope', $scope);
     $url->set('name', $name);
     $surl = clone $url;
     $total = PC_DAO::get_vars()->get_count_for($scope, $name);
     $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, $total);
     $pagination->populate_tpl($url);
     $start = $pagination->get_start();
     $vars = array();
     foreach (PC_DAO::get_vars()->get_list($start, PC_ENTRIES_PER_PAGE, $scope, $name) as $var) {
         /* @var $var PC_Obj_Variable */
         $url = PC_URL::get_mod_url('file');
         $url->set('path', $var->get_file());
         $url->set('line', $var->get_line());
         $url->set_anchor('l' . $var->get_line());
         $vscope = $var->get_scope();
         if ($vscope == PC_Obj_Variable::SCOPE_GLOBAL) {
             $vscope = '<i>Global</i>';
         }
         $vars[] = array('id' => $var->get_id(), 'scope' => $vscope, 'name' => '$' . $var->get_name(), 'type' => $var->get_type(), 'file' => $var->get_file(), 'line' => $var->get_line(), 'url' => $url->to_url());
     }
     $callurl = PC_URL::get_mod_url('filepart');
     $callurl->set('id', '__ID__');
     $callurl->set('type', 'var');
     $this->request_formular();
     $tpl->add_variables(array('vars' => $vars, 'get_code_url' => $callurl->to_url(), 'scope' => $scope, 'name' => $name, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('vars_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'vars_search'));
 }
Ejemplo n.º 2
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $input = FWS_Props::get()->input();
     $doc = FWS_Props::get()->doc();
     $id = $input->get_var('id', 'get', FWS_Input::INTEGER);
     $type = $input->correct_var('type', 'get', FWS_Input::STRING, array('call', 'var', 'func', 'const', 'error'), 'call');
     if ($id === null) {
         $this->report_error();
         return;
     }
     $loc = null;
     switch ($type) {
         case 'call':
             $loc = PC_DAO::get_calls()->get_by_id($id);
             break;
         case 'var':
             $loc = PC_DAO::get_vars()->get_by_id($id);
             break;
         case 'func':
             $loc = PC_DAO::get_functions()->get_by_id($id);
             break;
         case 'const':
             $loc = PC_DAO::get_constants()->get_by_id($id);
             break;
         case 'error':
             $loc = PC_DAO::get_errors()->get_by_id($id);
             if ($loc === null) {
                 $this->report_error();
                 return;
             }
             $loc = $loc->get_loc();
             break;
     }
     if (!is_file($loc->get_file())) {
         $this->report_error();
         return;
     }
     $lines = explode("\n", file_get_contents($loc->get_file()));
     $start_line = max(1, $loc->get_line() - 4);
     $end_line = min(count($lines), $loc->get_line() + 2);
     $code = '';
     for ($i = $start_line; $i <= $end_line; $i++) {
         $code .= $lines[$i - 1] . "\n";
     }
     $code = PC_Utils::highlight_string($code, $start_line, $loc->get_line(), false);
     $renderer = $doc->use_raw_renderer();
     $renderer->set_content($code);
 }
Ejemplo n.º 3
0
 public function run($args)
 {
     $project = FWS_Props::get()->project();
     $options = new PC_Engine_Options();
     $options->set_report_unused(true);
     $options->set_report_argret_strictly($project->get_report_argret_strictly());
     $options->add_project($project->get_id());
     foreach ($project->get_project_deps() as $pid) {
         $options->add_project($pid);
     }
     foreach ($project->get_req() as $r) {
         if ($r['type'] == 'min') {
             $options->add_min_req($r['name'], $r['version']);
         } else {
             $options->add_max_req($r['name'], $r['version']);
         }
     }
     $env = new PC_Engine_Env($options);
     $ascanner = new PC_Engine_StmtScannerFrontend($env);
     $msgs = array();
     foreach ($args as $file) {
         try {
             $ascanner->scan_file($file);
         } catch (PC_Engine_Exception $e) {
             $msgs[] = $e->__toString();
         }
     }
     if (count($env->get_types()->get_calls())) {
         PC_DAO::get_calls()->create_bulk($env->get_types()->get_calls());
     }
     foreach ($env->get_errors()->get() as $err) {
         PC_DAO::get_errors()->create($err);
     }
     foreach ($ascanner->get_vars() as $vars) {
         foreach ($vars as $var) {
             PC_DAO::get_vars()->create($var);
         }
     }
     // write messages to shared data
     $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE);
     $mutex->aquire();
     $data = unserialize($mutex->read());
     /* @var $data PC_JobData */
     $data->add_errors($msgs);
     $mutex->write(serialize($data));
     $mutex->close();
 }
Ejemplo n.º 4
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $user = FWS_Props::get()->user();
     $folderstr = $input->get_var('folders', 'post', FWS_Input::STRING);
     $exclstr = $input->get_var('exclude', 'post', FWS_Input::STRING);
     $files = array();
     $folders = FWS_Array_Utils::advanced_explode("\n", $folderstr);
     $excl = FWS_Array_Utils::advanced_explode("\n", $exclstr);
     FWS_Array_Utils::trim($excl);
     // determine files to scan
     foreach ($folders as $folder) {
         $folder = trim($folder);
         if (is_file($folder)) {
             $files[] = $folder;
         } else {
             foreach (FWS_FileUtils::get_list($folder, true, true) as $item) {
                 if (!$this->is_excluded($item, $excl)) {
                     $files[] = $item;
                 }
             }
         }
     }
     // clear position, just to be sure
     $storage = new FWS_Progress_Storage_Session('pstmtscan_');
     $storage->clear();
     // store in session
     $user->set_session_data('stmtscan_files', $files);
     // store in project
     $project = FWS_Props::get()->project();
     $project->set_stmt_folders($folderstr);
     $project->set_stmt_exclude($exclstr);
     PC_DAO::get_projects()->update($project);
     // clear previous data in the db
     PC_DAO::get_vars()->delete_by_project($project->get_id());
     PC_DAO::get_calls()->delete_by_project($project->get_id());
     PC_DAO::get_errors()->delete_by_type(PC_Obj_Error::get_types_of(PC_Obj_Error::R_STMTSCANNER), $project->get_id());
     $this->set_redirect(true, PC_URL::get_submod_url(0, 'cliscan'));
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }
Ejemplo n.º 5
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $id = $input->get_var('id', 'get', FWS_Input::STRING);
     if (!FWS_Helper::is_integer($id) || $id <= 0) {
         return 'The id is invalid';
     }
     PC_DAO::get_calls()->delete_by_project($id);
     PC_DAO::get_classes()->delete_by_project($id);
     PC_DAO::get_classfields()->delete_by_project($id);
     PC_DAO::get_constants()->delete_by_project($id);
     PC_DAO::get_errors()->delete_by_project($id);
     PC_DAO::get_functions()->delete_by_project($id);
     PC_DAO::get_vars()->delete_by_project($id);
     $this->set_redirect(false);
     $this->set_success_msg('The project has been cleaned successfully');
     $this->set_show_status_page(true);
     $this->set_action_performed(true);
     return '';
 }
Ejemplo n.º 6
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $idstr = $input->get_var('ids', 'get', FWS_Input::STRING);
     $ids = FWS_Array_Utils::advanced_explode(',', $idstr);
     if (!FWS_Array_Utils::is_numeric($ids)) {
         return 'Got an invalid id-string';
     }
     PC_DAO::get_projects()->delete($ids);
     foreach ($ids as $id) {
         PC_DAO::get_calls()->delete_by_project($id);
         PC_DAO::get_classes()->delete_by_project($id);
         PC_DAO::get_classfields()->delete_by_project($id);
         PC_DAO::get_constants()->delete_by_project($id);
         PC_DAO::get_errors()->delete_by_project($id);
         PC_DAO::get_functions()->delete_by_project($id);
         PC_DAO::get_vars()->delete_by_project($id);
     }
     $this->set_redirect(false);
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }