svg rounded corner and shadow

shadow (like css shadow-box)

At least with Firefox you can use a filter, like the following:

.shadow{filter: drop-shadow(8px 6px 6px gray);}

rounded corner

The simplest way to round the corners of a box is to

  • use rect element with rx and ry attributes (such as rx="20" ry="20")
  • and define the style of rect with stroke-linejoin:round; and something like stroke:[your color]; stroke-width:[the width you like];

You can see the following example

box rounded

php list and link folder’s files

an old way

There is an old way, the following:

<?php
     $path = "./";
     $narray=array();
     $dir_handle = @opendir($path) or die("Unable to open $path");
     echo "";
     $i=0;
     while($file = readdir($dir_handle))
     {
     if($file != '.' && $file != '..' && $file != 'index.php' && $file != 'normal.inc')
     {
     //echo "<a href='$path/$file'>$file</a><br/>";
     $narray[$i]=$file;
     $i++;
     }
     }
     sort($narray);

	   echo "<ul>";	            
     for($i=0; $i<sizeof($narray); $i++)
	   {
	    $filename = str_replace(".html", "", $narray[$i]) & str_replace(".php", "", $narray[$i]);
	   echo "<li><a href='$path$narray[$i]'>$filename</a></li>";
	   }
	   
	   echo "</ul>";
	   //closing the directory
	   closedir($dir_handle);
?>

a new way: glob

<?php
	   echo "<ul>";	  
$phpfiles = glob("*?[!index]?.php");
foreach ($phpfiles as $phpfile){
     echo '<li><a href="'.$phpfile.'">'.pathinfo($phpfile, PATHINFO_FILENAME).'</a></li>'; 
}	   
	   echo "</ul>";
?>

as you can see, the code is much simpler.

  • With this code: glob(“*?[!index]?.php”) we have set to list all php files except index.php.
  • with this other: ‘.pathinfo($phpfile, PATHINFO_FILENAME).’ we have set to show only filenames without extension

of course we could set a subfolder as well, with a code like the following:

$phpfiles = glob("[subfolder-name]/*?[!index]?.php");

php/msql keywords as hashtags

php separate all items in a mysql field

You can use the explode syntax, as in the following exapmple:

$keywords = $row['keywords'];
foreach (explode(',', $keywords) as $key) {
    echo "<span><a href="\hashtag.php?tag=$key\">{$key}</a></span>";
}

In the example we have a mysql field (keywords) with many items comma separated (such as : “truth, soul, body, mind” and so on).

And we obtain to have as many links from each item toward a specific target, as they are (that is: 3 links if you have 3 items, 7 links fi you have 7 ones).

In this way you can get a system of hashtags for your database keywords.

other steps

You need of two files, let we call them hashtag.php and hashtag-index.php.

The content of hashtag.php could be something like:

<?php  
 //hashtag.php  
 if(isset($_GET["tag"]))  
 {  
      $tag = preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '', $_GET["tag"]);

//to beautify and stylize, but not necessary BEGIN
      $title=$tag;
      include "$root/intell/header-intell.inc";      
//to beautify and stylize, but not necessary END      

      $connect = mysqli_connect("localhost", "[mysql user]", "[mysql password]", "[mysql database]");  
      
      mysqli_set_charset($connect, 'utf8mb4');  // procedural style
      
      $query = "SELECT * FROM [your table] WHERE [your fileds with tags] LIKE '%".$tag."%';  
      $result = mysqli_query($connect, $query);  
      if(mysqli_num_rows($result) > 0)  
      {  
           while($row = mysqli_fetch_array($result))  
           {  
                echo "<h2>$row[title]</h2>
                <blockquote><p>$row[text]</p></blockquote>
                <p><i>$row[author]</i><br />";
                $keywords = $row['keywords'];
                foreach (explode(',', $keywords) as $key) {
                echo "<span><a href=\"hashtag.php?tag=$key\">{$key}</a></span>";
                }
                echo "</p>";
           }  
      }  
      else  
      {  
           echo '<p>No Data Found</p>';  
      }  
 }  
 ?>  

the conte of hashtag-index.php should be something like:

<?php
// (1) DATABASE CONFIG
// ! CHANGE THESE TO YOUR OWN !
define('DB_HOST', 'localhost');
define('DB_NAME', '[your database');
define('DB_CHARSET', 'utf8');
define('DB_USER', '[your mysql user]');
define('DB_PASSWORD', '[your mysql password]');

// (2) CONNECT TO DATABASE
try {
  $pdo = new PDO(
    "mysql:host=" . DB_HOST . ";charset=" . DB_CHARSET . ";dbname=" . DB_NAME,
    DB_USER, DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES => false ]
  );
} catch (Exception $ex) {
  die($ex->getMessage());
}

// (3) SEARCH
$stmt = $pdo->prepare("SELECT * FROM `[mysql table name]` WHERE `keywords` LIKE ?");
$stmt->execute(["%" . $_POST['search'] . "%", "%" . $_POST['search'] . "%", "%" . $_POST['search'] . "%"]);
$results = $stmt->fetchAll();
if (isset($_POST['ajax'])) { echo json_encode($results); }
?>

afterwards obviously you could adjust the css according to your needs.

Of course you can have as many other php files as you want, where you usually store you database content, in which you can add the kewwords as hashtags, with a code like the following:

echo "</p><p class=\"keywords\">";
$keywords = $row['keywords'];
foreach (explode(',', $keywords) as $key) {
    echo "<span><a href=\"hashtag.php?tag=$key\">{$key}</a></span>";
}
echo "</p>";}

regex replace keeping a part of a string

Today I managed to replace (in html file links and anchors) absolute paths with relative ones.

I needed to keep the anchors and links number.

I did so:

search: href="#_ftn([0-9])">
replace: href="#_ftnref\1" id="_ftn\1">

In this way href=”#_ftn1 was replaced by  href="#_ftnref1" id="_ftn1", href=”#_ftn2 was replaced by  href="#_ftnref2" id="_ftn2", and so on.

For numbers with two digits

searchhref="#_ftn([0-9][0-9])">
replacehref="#_ftnref\1" id="_ftn\1">

Only the search string is to be modified, if you have more digits (f.e. [0-9][0-9][0-9][0-9] if you have numbers with four digits, such as 1276), not the replace one (so don’t write \1\1

update wordpress in localhost

First of all backup your database follwing these insctructions.

  1. Get the latest WordPress zip (or tar.gz) file.
  2. Unpack the zip file that you downloaded.
  3. Deactivate plugins.
  4. Delete the old wp-includes and wp-admin directories on your web host (through your FTPor shell access).
  5. Using FTP or your shell access, upload the new wp-includes and wp-admin directories to your web host, in place of the previously deleted directories.
  6. Upload the individual files from the new wp-content folder to your existing wp-content folder, overwriting existing files. Do NOT delete your existing wp-content folder. Do NOT delete any files or folders in your existing wp-content directory (except for the one being overwritten by new files).
  7. Upload all new loose files from the root directory of the new version to your existing WordPress root directory.

NOTE – you should replace all the old WordPress files with the new ones in the wp-includes and wp-admin directories and sub-directories, and in the root directory (such as index.phpwp-login.php and so on). Don’t worry – your wp-config.php will be safe.

Be careful when you come to copying the wp-content directory. You should make sure that you only copy the files from inside this directory, rather than replacing your entire wp-content directory. This is where your themes and plugins live, so you will want to keep them. If you have customized the default or classic themes without renaming them, make sure not to overwrite those files, otherwise you will lose your changes. (Though you might want to compare them for new features or fixes..)

Lastly you should take a look at the wp-config-sample.php file, to see if any new settings have been introduced that you might want to add to your own wp-config.php.

More details here.

folding code in Kate

Today I noticed that if I write [b]BEGIN[/b] in a row that row is the beginning of a collapsable section, until a row with [b]END[/b].
F.e. /* — BEGIN common tags — / as beginnning and / — END common tags — */ as end.
And I can have nested collpsable sections, even in an html file ( , f. e.)

svg with external image embedded

All browsers have this limitation: they not allow to show an svg with an external image embedded, such as

<image x="2" y="2" width="somewidth" height="someheight" xlink:href="myimage.jpg">

even though the image is in local.

For security reasons.