public function deleteAction()
 {
     if (check_RequestMethod('GET')) {
         $user_apps_data = appsModel::getApps((int) $_GET['id_user']);
         if (is_array($user_apps_data)) {
             foreach ($user_apps_data as $v) {
                 appsModel::deleteData($v['id_application']);
                 appsModel::deleteApp2PlatformData($v['id_application']);
                 appsModel::deleteLogData($v['id_application']);
             }
         }
         userModel::deleteData((int) $_GET['id_user']);
         header("Location: " . $this->makeURI(array('action' => 'list')));
         die;
     } else {
         _404();
     }
 }
Beispiel #2
0
 public function getHttpCodeAction()
 {
     $resources = array();
     $id_application = $_GET['id_application'];
     $id_platform = $_GET['id_platform'];
     if (check_RequestMethod('GET')) {
         set_Json_header();
         $app_data = appsModel::getApplicationData($id_application);
         $platform_data = platformModel::getPlatformData($id_platform);
         /*  bool   CURLOPT_FRESH_CONNECT - TRUE to force the use of a new connection instead of a cached one.
          *  string CURLOPT_USERAGENT     - The contents of the "User-Agent: " header to be used in a HTTP request.
          *  array  CURLOPT_HTTPHEADER     - An array of HTTP header fields to set, in the format array('Content-type: text/plain', 'Content-length: 100')
          *  bool   CURLOPT_RETURNTRANSFER - TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
          * */
         $response_data = apiModel::getRequestInfo($app_data['url_application'], array(CURLOPT_FRESH_CONNECT => true, CURLOPT_USERAGENT => $platform_data['UA_string'], CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => true));
         print_r($response_data);
         $resources = $this->getResources($app_data['url_application'], $response_data['html']);
         if (is_array($resources)) {
             foreach ($resources as $v) {
                 $r = apiModel::getRequestInfo($v, array(CURLOPT_FRESH_CONNECT => true, CURLOPT_USERAGENT => $platform_data['UA_string'], CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => true));
                 $response_data['size_download'] += $r['size_download'];
             }
         }
         $last_log_data = logModel::getLastLogs($id_application, $id_platform);
         $log_data = array('id_application' => $id_application, 'id_platform' => $id_platform, 'HTTP_code' => !count(apiModel::$errors) ? $response_data['http_code'] : apiModel::$errors[0], 'date_check' => date('Y-m-d H:i:s', time()), 'id_user' => authModel::getCurrentUserId(), 'size_download' => $response_data['size_download'], 'download_content_length' => $response_data['download_content_length'], 'redirect_url' => $response_data['redirect_url'], 'request_header' => $response_data['request_header'], 'weight_diff' => $response_data['size_download'] - $last_log_data[$id_application][$id_platform]['size_download'], 'app_resources' => implode(', ', $resources));
         if (($id_check_log = logModel::checkInBase($log_data, array('date_check', 'app_resources'))) !== false) {
             logModel::updateData($log_data + array('id_check_log' => $id_check_log));
         } else {
             $id_check_log = logModel::insertData($log_data);
         }
         $log_data = logModel::getLog($id_check_log);
         print json_encode($log_data + array('curl_response' => $response_data, 'last_log' => $last_log_data));
         die;
     } else {
         _404();
     }
 }
 private function getForm($data)
 {
     // data from last page reload. Save it and unset
     list($errors, $messages, $user_data) = appsModel::getSession(array('errors', 'messages', 'user_data'));
     appsModel::unsetSession(array('errors', 'messages', 'user_data'));
     // get platforms
     $platforms = platformModel::getPlatforms();
     // app to platforms link
     $app2platform = appsModel::getApp2PlatformData($data['user_data']['id_application']);
     return $this->render('apps_form', $data + array('errors' => $errors, 'messages' => $messages, 'user_data' => $user_data, 'platforms' => $platforms, 'app2platform' => $app2platform, 'back_url' => $this->makeURI(array('action' => 'list'))));
 }