Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Friday, December 25, 2020

How to text spin using a wordpress shorcut

You need to create random text but with sense, for example, you have a web page that have thousand of pages and you would like to create text automatically using text spin technique.

1.- Create a new function inside your Wordpress "Snippets" plugin.

function fun_textspin() {
class Spintax
public function process($text)
return preg_replace_callback(
array($this, 'replace'),
public function replace($text)
$text = $this->process($text[1]);
$parts = explode('|', $text);
return $parts[array_rand($parts)];
$spintax = new Spintax();
$string = '{Hello|Howdy|Hola} to you, {Mr.|Mrs.|Ms.} Smith|Williams|Davis}!';
return $spintax->process($string);

add_shortcode( 'sc_textspin','fun_textspin' );


2.- add the following Shorcut to your wordpress page.

<!-- wp:paragraph -->


<!-- /wp:paragraph -->


Thursday, December 3, 2020

How to connect to Wordpress SQL using shortcuts


Yo need to access to any database table connected to your wordpress or maybe an external one to extract any information and process it.


Use this TestSQLand add is to your wordpress functions.php of "Code Snipper" plugin:

function TestSQL_Function( $atts ) {
$link = mysqli_connect("localhost", "user", "****", "DATABASENAME");
$sql = "SELECT * FROM table";
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_array($result)){
            $line = $line.$row['fielname1']."(".$row['fieldname2'].")";
return $line;
        // Free result set
    } else{
        return "No records matching your query were found.";
} else{
    return "ERROR: Could not able to execute $sql. " . mysqli_error($link);
// Close connection
add_shortcode( 'TestSQL', 'TestSQL_Function' );

Now, you only need to add the wordpress shortcut [TestSQL] in your wordpres post or page.

Monday, November 16, 2020

Protect your CMS Backoffice login without plugins


You are working with a Wordpress or Joomla CMS and you need to protect your back-office login to avoid massive attacks or hacking, but you are not sure to use a plugin to do that, you are looking to know what are the page in the corresponding CMS to edit to add your own script.


It's quite easy to protect your CMS back office, it depend of the CMS that you are working on, you can do this using a little script to avoid any access to the login screen.

The script is something like this one:

if ( ($vip!='')  ) {
  echo "<div id='errmessage'>Forbbiden to:".$vip."</div>";

Now, you only need to add this lines of code to the following files, it depend of the site and/or page that you would like to protect.

With this script, only connections to your site from the choose IP will be able to access to your site, if your IP is not static, you will need to update this script or maybe use another one that use other check rather than the remote ip connected to the site.


  • Frontoffice:  
  • BackOffice:  

  • Login:  /httpdocs/wp-login.php

Sunday, November 15, 2020

Can't access to wordpress multi-site wp-admin


You have setup the standard Wordpress multi site configuration in Wordpress ( using "directories" not subdomains ) and create one or more sub sites; the problems is that when you try to access to the sub-site web view or sub-site wp-admin you get a 404 error and it's not possible to view the template styles files or login into the wp-admin to manage the sub site.


you have to apply a different configuration in the .httpaccess file, just apply the next configuration:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]


index.php in wordpress friendly url


After the automatic installation using a word press template installation wizard, you see that the permanent links have the "index.php" in the friendly url; you need to remove index.php from friendly url.


To fix this problem you have to go to settings, permanent links, custom structure, there you will se something like this:


You only need to change it like this:


Tuesday, October 27, 2020

How to scrap elements from external website


You need to pic information from a public website and process it internally to do some staff.


You can use PHP Simple HTML DOM parse as the easy way, follow the next steps:

  1. Download the sources from the oficial web site
  2. copy all files into your web server
  3. create a new file example.php
  4. use this code:


$context = stream_context_create();

stream_context_set_params($context, array(

            'ignore_errors' => true, 

            'max_redirects' => 3)


$html = file_get_html('', 0, $context);

$articles_titles = $html->find(".ue-c-cover-content__link");

foreach($articles_titles as $article_title) {

    echo "<BR>\t\t".$article_title->plaintext."\n";




echo "<BR>";echo "<BR>";echo "<BR>";

echo "<BR>OK";

Information That's it, now you only need to analyse the information that you get as html and process it in your function or program, take care about your objective, the server that you use to extract the information can ban your IP; to avoid that it's possible to use a proxy as is indicated int he source link.


Monday, October 19, 2020

How to setup PHP mvc minimun model without any framework


You need to create a minimum web site or web app using php model but it's preferred to use any framework to avoid load the system without any unnecessary code.


Create the following folder and fields structure in the server.

Use the next code in each file:

$samp=new sample_model();
class Connect{
    public static function connection(){
        $connection=new mysqli("localhost", "root", "pwd", "mvc");
        $connection->query("SET * FROM table 'UTF8' ");
        return $connection;

class sample_model{
    private $DB;
    private $sample;
    public function __construct(){
    public function get_samplequery(){
        $query=$this->db->query("select * from table;");
        return $this->query;

<html lang="es">
        <meta charset="UTF8" />
        <?php echo "put your database query here"        ?>