query('DELETE FROM ' . $cookie_switch_prefs_table . ' WHERE id = ' .$_GET['delete_id']); $wpdb->query('DELETE FROM ' . $cookie_switch_tracking_table . ' WHERE pref_id = ' . $_GET['delete_id']); } $wpdb->show_errors(); if(!empty($_POST['save_new']) && !empty($_POST['tracking_code']) && !empty($_POST['trigger_code']) && !empty($_POST['redirect_target']) && !empty($_POST['name'])) { $wpdb->insert( $cookie_switch_prefs_table, array( 'created' => current_time('mysql'), 'trigger_code' => ($_POST['trigger_code']), 'redirect_target' => ($_POST['redirect_target']), 'tracking_code' => ($_POST['tracking_code']), 'name' => ($_POST['name']) ) ); }*/ ?>

Welcome to SEO Image Renamer

Suspicous Images

Here you can see all all images that do have suspicious names in your database.

Note: We flag an image as suspicous if the name of the following vendors appers in it: Stock, Fotolia, corbisimages, gettyimages, dreamstime, sxc!

'; echo '

Reload with all images shown: Show all Images

'; } else echo '

Show only suspicious images: Show suspicious Images

'; ?>
show_errors(); $sql = sprintf( 'SELECT a.ID as image_post_id, a.post_name as image_post_name, a.post_mime_type as image_mime_type, b.ID as parent_post_id, b.post_title as parent_post_title, b.post_content as parent_post_content, c.meta_value as image_path, c.meta_id as image_meta_id'. ' FROM %sposts as a ' . ' LEFT JOIN %sposts as b ON a.post_parent = b.ID '. ' LEFT JOIN %spostmeta as c ON a.ID = c.post_id AND c.meta_key = "_wp_attached_file" '. ' WHERE a.post_mime_type LIKE "image%%"' ,$wpdb->prefix ,$wpdb->prefix ,$wpdb->prefix); if(!isset($_GET['seoir_showall'])) { $sql = $sql . sprintf(" AND a.post_name REGEXP '%s'", implode('|', $suspicious_imagename_parts)); } $results = $wpdb->get_results($sql,'ARRAY_A'); $uploaddir = wp_upload_dir(); foreach($results as $result) { preg_match_all('#<(h2|strong)>(.*)<\/(h2|strong)>#Ui', $result['parent_post_content'], $matches); $keyword_occurence = array_flip(array_count_values($matches[2])); array_walk($keyword_occurence, create_function('&$v,$k', '$v = preg_replace(array("#ß#","#ä#","#ü#","#ö#","#Ä#","#Ü#", "#Ö#","#\s#", "#[^\w-]#"), array("ss","ae","ue","oe","Ae","Ue","Oe","-", ""), $v);')); //$sorted_keyword_occurence = sort($keyword_occurence); $suggested_name = array_pop($keyword_occurence); //$img = new Imagick($uploaddir['basedir'].'/'.$result['meta_value']); $exif = @read_exif_data($uploaddir['basedir'].'/'.$result['image_path']); $exif_data = empty($exif['COMPUTED']['Copyright']) ? empty($exif['Copyright']) ? $exif['Artist'] : $exif['Copyright'] : $exif['COMPUTED']['Copyright']; printf( ' ', $uploaddir['baseurl'].'/'.$result['image_path'], htmlspecialchars($result['image_meta_id']), htmlspecialchars($result['image_post_name']), htmlspecialchars($result['image_mime_type']), $exif_data, $result['image_meta_id'], htmlspecialchars($result['image_post_id']), substr(htmlspecialchars($result['parent_post_title']), 0, 20).'...', $suggested_name, implode('
Image ID Image Name Image Type Kritische EXIF-Daten Volle EXIF-Daten Post ID Post Name Suggested Name
%s %s %s %s Show %s %s
show_errors(); $sql = sprintf( 'SELECT a.post_name as image_post_name, a.post_mime_type as image_mime_type, a.post_parent, c.meta_id as image_id, c.meta_value as old_image_path '. ' FROM %sposts as a ' . ' LEFT JOIN %spostmeta as c ON a.ID = c.post_id AND c.meta_key = "_wp_attached_file" '. ' WHERE a.ID = %d' ,$wpdb->prefix ,$wpdb->prefix ,$image_post_id); $result = $wpdb->get_row($sql,'ARRAY_A'); $uploaddir = wp_upload_dir(); $image_parts = pathinfo($result['old_image_path']); $new_image_name = $image_name . '.' . $image_parts['extension']; $new_image_path = $image_parts['dirname'] . '/'. $new_image_name; deEXIFyImage($uploaddir['basedir'].'/'.$result['old_image_path'], $uploaddir['basedir'].'/'.$new_image_path); #alt="Die e-Zigarette im Case." //LATER //replace the image name in the parent post $wpdb->query( sprintf('UPDATE %sposts SET post_content = replace(post_content, \'%s\',\'%s\') WHERE ID = %d ', $wpdb->prefix, strtolower($image_parts['filename']), $image_name, $result['post_parent'] ) ); $wpdb->query( sprintf('UPDATE %sposts SET post_content = replace(post_content, \'%s\',\'%s\') WHERE ID = %d ', $wpdb->prefix, $image_parts['filename'], $image_name, $result['post_parent'] ) ); //now replace the image post $wpdb->query( sprintf('UPDATE %sposts SET post_name = "%s", guid = replace(guid, \'%s\',\'%s\') WHERE ID = %d ', $wpdb->prefix, $image_name, strtolower($image_parts['filename']), $image_name, $image_post_id ) ); //now replace the image post $wpdb->query( sprintf('UPDATE %sposts SET post_name = "%s", guid = replace(guid, \'%s\',\'%s\') WHERE ID = %d ', $wpdb->prefix, $image_name, $image_parts['filename'], $image_name, $image_post_id ) ); //now we replace the meta filename $wpdb->query( sprintf('UPDATE %spostmeta SET meta_value = replace(meta_value, \'%s\',\'%s\') WHERE post_id = %d AND meta_key = "_wp_attached_file" ', $wpdb->prefix, strtolower($image_parts['filename']), $image_name, $image_post_id ) ); $wpdb->query( sprintf('UPDATE %spostmeta SET meta_value = replace(meta_value, \'%s\',\'%s\') WHERE post_id = %d AND meta_key = "_wp_attached_file" ', $wpdb->prefix, $image_parts['filename'], $image_name, $image_post_id ) ); //now we rebuild the meta array $sql = sprintf( 'SELECT meta_value '. ' FROM %spostmeta ' . ' WHERE meta_key = "_wp_attachment_metadata" AND post_id = %d' ,$wpdb->prefix ,$image_post_id); $result = $wpdb->get_row($sql,'ARRAY_A'); $meta_array = unserialize($result['meta_value']); $dir_parts = pathinfo($meta_array['file']); $meta_array['file'] = str_ireplace($image_parts['filename'], $image_name, $meta_array['file']); foreach($meta_array['sizes'] as $key => $thumbnail) { $meta_array['sizes'][$key]['file'] = str_ireplace($image_parts['filename'], $image_name, $thumbnail['file']); deEXIFyImage($uploaddir['basedir'].'/'.$dir_parts['dirname'] . '/' .$thumbnail['file'], $uploaddir['basedir'].'/'.$dir_parts['dirname'] . '/' .$meta_array['sizes'][$key]['file']); } $meta_array['image_meta'] = array(); $wpdb->query( sprintf('UPDATE %spostmeta SET meta_value = "%s", WHERE post_id = %d AND meta_key = "_wp_attachment_metadata" ', $wpdb->prefix, mysql_real_escape_string(serialize($meta_array)), $image_post_id ) ); } function deEXIFyImage($old_p, $new_p) { try { $img = new Imagick($old_p); $img->stripImage(); $img->writeImage($new_p); $img->clear(); $img->destroy(); #@unlink($old_p); // cause images can be multiple } catch(Exception $e) { echo 'Exception caught: ', $e->getMessage(), "\n"; throw new Exception('DONE'); } }