public static function ajax_delete()
 {
     global $wpdb;
     $send_response = function ($todo) use($wpdb) {
         if (!$todo) {
             // free disk space
             $wpdb->query('OPTIMIZE TABLE ' . \Podlove\Model\DownloadIntent::table_name());
             // clear caches
             \Podlove\Cache\TemplateCache::get_instance()->setup_purge();
             // mark migration as done
             delete_option('podlove_tracking_delete_head_requests');
         }
         \Podlove\AJAX\Ajax::respond_with_json(array('todo' => $todo));
     };
     // get user agent IDs to delete
     $sql = "\n\t\t\tSELECT\n\t\t\t\tid \n\t\t\tFROM\n\t\t\t\t" . \Podlove\Model\UserAgent::table_name() . " ua\n\t\t\tWHERE\n\t\t\t\tuser_agent LIKE \"libwww-perl/%\" \n\t\t\t\tOR user_agent LIKE \"curl/%\" \n\t\t\t\tOR user_agent LIKE \"PritTorrent/%\"\n\t\t";
     $user_agent_ids = $wpdb->get_col($sql);
     if (!count($user_agent_ids)) {
         $send_response(0);
     }
     // delete
     $sql = "\n\t\tDELETE\n\t\t\tFROM " . \Podlove\Model\DownloadIntent::table_name() . "\n\t\t\tWHERE user_agent_id IN (" . implode(",", $user_agent_ids) . ")\n\t\t\tLIMIT 25000\n\t\t";
     $wpdb->query($sql);
     $sql = "\n\t\tDELETE\n\t\t\tFROM " . \Podlove\Model\DownloadIntentClean::table_name() . "\n\t\t\tWHERE user_agent_id IN (" . implode(",", $user_agent_ids) . ")\n\t\t\tLIMIT 25000\n\t\t";
     $wpdb->query($sql);
     // see how much is left to delete
     $sql = "\n\t\tSELECT\n\t\t\tCOUNT(*) \n\t\tFROM\n\t\t\t" . \Podlove\Model\DownloadIntent::table_name() . " \n\t\tWHERE\n\t\t\tuser_agent_id IN (" . implode(",", $user_agent_ids) . ")\n\t\t";
     $send_response($wpdb->get_var($sql));
 }
 public static function delete()
 {
     $id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
     $template = Template::find_by_id($id);
     if (!$id || !$template) {
         Ajax::respond_with_json(array("success" => false));
     } else {
         $template->delete();
         Ajax::respond_with_json(array("success" => true));
     }
 }
 public static function create()
 {
     $episode_id = (int) $_REQUEST['episode_id'];
     $episode_asset_id = (int) $_REQUEST['episode_asset_id'];
     if (!$episode_id || !$episode_asset_id) {
         die;
     }
     if (isset($_REQUEST['slug'])) {
         self::simulate_temporary_episode_slug($_REQUEST['slug']);
     }
     $file = MediaFile::find_or_create_by_episode_id_and_episode_asset_id($episode_id, $episode_asset_id);
     Ajax::respond_with_json(array('file_id' => $file->id, 'file_size' => $file->size, 'file_url' => $file->get_file_url()));
 }
Ejemplo n.º 4
0
 public function fetch_bitlove_url()
 {
     \Podlove\AJAX\Ajax::respond_with_json(array('bitlove_url' => self::get_bitlove_feed_url($_REQUEST['feed_id'])));
 }
 public function ajax_validate_feed()
 {
     $feed_id = $_REQUEST['feed_id'];
     $redirect = $_REQUEST['redirect'] == '0' ? FALSE : TRUE;
     $feed = \Podlove\Model\Feed::find_by_id($feed_id);
     // Delete feed source transient
     $errors_and_warnings = \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationErrorsandWarnings($feed->id, $redirect);
     // renew transients
     set_transient('podlove_dashboard_feed_validation_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationIcon($feed->id, $redirect), 3600 * 24);
     set_transient('podlove_dashboard_feed_information_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getInformation($feed->id, $redirect), 3600 * 24);
     if ($redirect === TRUE) {
         set_transient('podlove_dashboard_feed_r_validation_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationIcon($feed->id, $redirect), 3600 * 24);
         set_transient('podlove_dashboard_feed_r_information_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getInformation($feed->id, $redirect), 3600 * 24);
     }
     \Podlove\AJAX\Ajax::respond_with_json(array('validation_icon' => \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationIcon($feed->id, $redirect)));
 }