How to connect to mysql from nodejs, with ES6 promise
Introduction I had to develop a small automation to query some old mysql data…
September 04, 2017
I use drupal-7 in my website. I used to write articles and put images in that from google or from free image sources. Initially, I usually put image urls from their website only. i.e. I have img tag on my website, and source of image as external url of image from their website.
Image tags (example image tag):
Now, manytimes, external sources removed their images, and my website/page left with no image, which is not a good impression for my users. This article is to find those articles/blogs which have this issue.
<h2>Code</h2>
```php
/**
* See if a drupal node has images within my domain or not
**/
function requireModification($nid) {
$nd = node_load($nid);
//read body of node
$body = $nd->body['und'][0]['value'];
$doc = new DOMDocument();
$doc->loadHTML($body);
//fetch all images in body of node
$tags = $doc->getElementsByTagName('img');
$imgArr = array();
foreach ($tags as $tag) {
//read src tag, source of image
$imgSrc = $tag->getAttribute('src');
//checking if image path is an http path and not in my domain
if ((strpos($imgSrc, 'http') === 0) && (strpos($imgSrc, 'https://s3.amazonaws.com/images.MYDOMAIN.com') !== 0)) {
return true;
}
}
return false;
}
//My node type name
$node_type = "article";
$result = db_query("SELECT nid FROM node WHERE type = :nodeType ", array(':nodeType'=>$node_type));
$nids = array();
foreach ($result as $obj) {
if (requireModification($obj->nid) === true) {
$nids[] = $obj->nid;
}
}
//printing node ids, which have images apart from my domain
print_r($nids);
Introduction I had to develop a small automation to query some old mysql data…
Introduction We will see how we can install Python 3.7 on Windows without UI. i…
Introduction This post is about syncing your mongodo database data to…
You can either do tail -f drupal.log or open it in an editor like vim.
Introduction We often require to execute in timed manner, i.e. to specify a max…
Introduction You have a view with 4-5 fields to display. Suppose, there are two…
Introduction This post has the complete code to send email through smtp server…
Introduction In a normal email sending code from python, I’m getting following…
Introduction In one of my app, I was using to talk to . I have used some event…
Introduction So you have a Django project, and want to run it using docker image…
Introduction It is very important to introduce few process so that your code and…
Introduction In this post, we will see a sample Jenkin Pipeline Groovy script…