openvpn username password auth

In your config you need to add

username-as-common-name
auth-user-pass-verify /etc/openvpn/verify.php via-file

Then create the file and paste in it

#Now add this code into the file
#!/usr/bin/php

Don’t forget to add users 😉

echo „myfirstuser:password123“ > /etc/openvpn/users

С етикет: , ,
Публикувано в linux

security.mixed_content.block_active_content

This can be set to false in about:config

security.mixed_content.block_active_content

С етикет: ,
Публикувано в linux

Joomla show page content only

To show only page content from joomla article or component you need to add following to the url

&task=display&tmpl=component

С етикет: , ,
Публикувано в Joomla

idea for id storing of files

If you have some time of id in your database and you want to save file associated with this id it’s not a good idea to make dir with id value and save the file there because on some point you will have too much dirs with same name.

For this if the id is 123456 we can create dir from the id but separating all digit in subdir like 1/2/3/4/5/6/file/file.jpg

The last one dir is called file because we can have 1234567 and then in this dir we will have subdir 😉

function gen_id_to_folder_name($id){

$split = str_split($id);

foreach($split as $spl){
$folder_name .=$spl.“/“;
}

return $folder_name.“c/“;
}

С етикет: , , , , , ,
Публикувано в linux, php

mysql server has gone away or connection timeout

If you do a lots of things in one php script this usually takes some time and mysql can gone away 😉 for this when you run new query you can run it with this function which will connect again to mysql if previous connection is closed from timeout


function run_query($sql){
global $link, $db;

if(!mysql_ping($link)){
$link = mysql_connect($db[‘host’], $db[‘user’], $db[‘pass’], true);
mysql_select_db($db[‘db’], $link);
}

return mysql_query($sql, $link);

}

С етикет: , ,
Публикувано в linux, php