EcoCatLady
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: MySQL spawns rogue processesThat’s a great suggestion. I’ve been leery of upgrading because last time I did it caused major problems on the server – I ended up with incompatible versions of php and apache and all hell broke loose. I’m actually thinking of migrating to a new server altogether (been on this one for years now) so that is probably my next step.
Forum: Fixing WordPress
In reply to: MySQL spawns rogue processesWell… I don’t really know what’s supposed to be there. The log shows a time adjustment every hour on the hour, and an entry for every time an FTP connection was established – some of the FTP lines show my home IP address (I FTPd some theme changes this morning), others show unfamiliar IPs not sure what that means… I did upagrade a few plugins… but none of the “not me” FTP requests are around the time of the crash.
The only thing around the time of the crash was this line:
Nov 12 14:44:01 server named[3128]: client 183.56.172.145#20000: query (cache) ‘760291168.www.baidu.com/A/IN’ denied
I have no idea what it means.
Forum: Fixing WordPress
In reply to: MySQL spawns rogue processesp.s. I think mysql logs might be more helpful… except that I haven’t figured out how to enable them, and my research suggests this can be dangerous as it can really slow things down. Do you have any experience with mysql logs?
Forum: Fixing WordPress
In reply to: MySQL spawns rogue processesNothing out of the ordinary in the apache access logs – just typical GET requests, but the apache error logs show hundreds of lines that read:
[Sat Nov 12 15:04:12 2016] [warn] child process 19108 still did not exit, sending a SIGTERM
the process number increments 19490, then it throws this line for each process sequentially:
[Sat Nov 12 15:04:13 2016] [error] child process 19108 still did not exit, sending a SIGKILL
But Googling it looks like that could be from restarting Apache… so probably not the cause of the problem.
Hi there,
I haven’t actually installed this plugin – I was hoping you’d figured out how to redirect to an image if the hotlink was embedded in a page, vs. to a page if the hotlinked image was opened in a separate browser window/tab. From what I’m reading here looks like it’s an either/or solution at this point – which is sort of where I’m stuck myself.
If you do figure out how to get it to redirect to an image vs. page in those different circumstances, I’ll be installing this plugin pronto!
BTW – just thought I’d share this bit of code. This was my original code redirecting to the actual post where the image was first uploaded. Can’t take credit for it all as various chunks came from different forums, but it’s nice because if the hotlink points to a wordpress generated thumbnail of the image rather than the original, it still takes you to the original post. This, of course, only works if you uploaded the image as a child to a post – if you uploaded it directly to the library then the image won’t have a parentID and it won’t work.
This worked like a charm, but I wouldn’t recommend using it on a big site or a site with many hotlinks coming in. With my site it slowed the server down to a crawl. So… I’m currently working on a less elegant solution that won’t require loading wordpress for every hotlink request that comes in. Anyhow, if any part of this is helpful to you, please feel free to use it.
<?php define( 'WP_USE_THEMES', false ); require('wp-blog-header.php'); function pn_get_attachment_id_from_url( $attachment_url = '' ) { global $wpdb; $attachment_id = false; // If there is no url, return. if ( '' == $attachment_url ) return; // Get the upload directory paths $upload_dir_paths = wp_upload_dir(); // Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) { // If this is the URL of an auto-generated thumbnail, get the URL of the original image $attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url ); // Remove the upload path base directory from the attachment URL $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url ); // Finally, run a custom database query to get the attachment ID from the modified attachment URL $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) ); } return $attachment_id; } // set the image url $inurl=$_GET['p']; $attachment_url= "http://" . $_SERVER['HTTP_HOST'] ."/".$inurl; // store the image ID in a var $image_id = pn_get_attachment_id_from_url($attachment_url); // get post where image appears $parent = get_post_field( 'post_parent', $image_id); $link = get_permalink($parent); // add header header( "Location:$link" ) ; ?>