Author Archive for netlex

13
Apr

Post thumbnails with WordPress 2.5

18
Oct

Mysql + tableaux

Compteur

if (count($TABLEAU)>0):
ksort($TABLEAU);
While (List($KEY,$VALUE)=each($TABLEAU)):
echo (”$KEY -> $VALUE”);
EndWhile;
Endif;

Les tableaux php
_______________________

# connection SQL et ouverture de la base

mysql_connect(”localhost”,”root”,”");

mysql_select_db(”test”);
$res = mysql_query(”select distinct anneR from bfone order by anneR “) ;
$nbans = 0 ;
while ($ligr=mysql_fetch_array($res)) {
$nbans++ ; $ans[$nbans] = $ligr["anneR"] ;
} ; # fin de tant que

A Problèmes et erreurs communes MySQL 5.0.0 alpha

18
Oct

Bash script and cron (Cgi + Perl + Cron)

“TUTORIAL / www.cgi-interactive-uk.com

Bash Shell Script (mysqlbackup)

#!/bin/sh
mysqldump -uroot -ppwd –opt db1 > /sqldata/db1.sql
mysqldump -uroot -ppwd –opt db2 > /sqldata/db2.sql

cd /sqldata/
tar -zcvf sqldata.tgz *.sql
cd /scripts/
perl emailsql.cgi

The first mysqldump statement has 4 parameters passed to it :-

* -u = your MySQL username. (substitute root with your username)
* -p = your MySQL password. (substitute pwd with your password)
* –opt adds the most common and useful command line options, resulting in the quickest possible export. This option automatically includes –add-drop-table, –add-locks, –extended-insert, –quick and –use-locks.
* the database name to extract. (substitute db1 with your database name)
* the > /sqldata/db1.sql redirects all the output to a file called db1.sql in a directory /sqldata/.

Perl script (emailsql.cgi)

After creating the script, you need to make it executable by CHMODing the file permissions to 700.

#!/usr/bin/perl -w

use MIME::Lite;

$msg = MIME::Lite->new(

From => mysqlbackup@yoursite.co.uk,
To => you@yoursite.co.uk,
Subject => sqldata.tgz MySQL backup!,
Type => text/plain,
Data => “Hi You,\n MySQL database backups.”);

$msg->attach(Type=>application/x-tar,
Path =>”/sqldata/sqldata.tgz”,
Filename =>”sqldata.tgz”);

$msg->send;

Adding the Script to Cron

0 2 * * * /myscripts/mysqlbackup
0 5 * * 0 /myscripts/reindex

There are five fields for setting the date and time separated by a space, followed by the name of the script you wish to run. The five time settings are in the following order.

* Minutes - in the range of 0 - 59
* Hour - in the range of 0 - 23
* Day of month - in the range 1 - 31
* Month - in the range 1 -12
* Day of week - in the range 0 - 6 (0 = Sunday)

Any field with a * means run every possible match, so for example a * in the day of month field will run the script every single day of the month at the specified time. (…)

The above example shows my current crontab. The file has two entries, one for each script I wish to run. The first entry tells cron to run the mysqlbackup script every morning at 2am. The second entry runs my search engine indexer every Sunday morning at 5am.”

How to backup your MySQL tables and data every night using a bash script and cron CGI interactive

Cron tab + mod perl

# every monday rebuild all, including pdf
30 03 * * 1 /usr/local/modperl-docs/bin/site_build_force_pdf_index
# update all (only changes/no pdf) every 6 hours
15 6,12,18 * * * /usr/local/modperl-docs/bin/site_build_index
# update all (only changes and pdfs) once a day
15 0 * * * /usr/local/modperl-docs/bin/site_build_pdf_index

The mod_perl documentation

_____________________

Tutorial sur l’utilisation de Mysql avec Perl

CRON

[UNIX] Crontab mkaz.com

Pycron

Internals: Replacing Task Scheduler with Cron

15
Oct

Client-side and Server-side encoding

Récupérer les accents français quand MySql parle latin… au lieu de UTF-8

Apache Server 2.0.54
PHP 5.0.4
MySQL 4.1.12
and WordPress 1.5.1.3

The problem all originates from MySQL 4.1

version 4.1 MySQL supports different language encodings

problem : “Client” encoding language and the “Server” encoding language.

The “Client” was set to Latin-1 encoding
The “Server” was set to UTF-8

“MySQL tries to translate from one language to the other when it puts the information in its Database. The problem is, my WordPress encoding already was UTF-8. So MySQL basically took UTF-8 encoded text (from WordPress) and treated it as Latin-1 encoded text and tried to convert it to UTF-8. Doing that, some characters where fine but more complex ones where not…

To solve this problem, you have to tell MySQL to treat all the stuff from WordPress as UTF-8 stuff.

First open the file: wordpress\wp-includes\wp-db.php

Find line 56, it should read as this:
$this->select($dbname);

Go to the beginning of the line and punch “enter” to make it move one line down and leave a blank line on line 56.

Then place this line at line 56:
$this->query(”SET NAMES ‘utf8′”);

Then your lines should look like this:
56 $this->query(”SET NAMES ‘utf8′”);
57 $this->select($dbname);

“now have a wordpress that can display and retain text in any language your computer can write in :)”

One final note, your Database must be a UTF-8 Database and your WordPress encoding must be UTF-8 also. For wordpress, you can find this in Options/Reading.

Japanese Characters not displaying right!

The patch we found that seems to have worked for some people but not for others was to add the line $this->query (”SET NAMES ‘utf8′”); after line 43 in wp-db.php.
http://wordpress.org/support/topic/48459?replies=6

PHP, MySQL 4.1 and UTF-8

09
Oct

Character Encoding + Transformation

After the damage has occured, the best way, it seems, to clean this up is to run multiple SQL queries in the phpmyadmin console emulating find/replace on the wp_posts table:

UPDATE wp_posts SET post_content = replace(post_content, “bad”, “good”)

Gestion des accents français

1/ exporter sous MySQL dans le bon encodage (sous wordpress, généralement UTF-8).

2/ encodage correct des accents dans les fichiers :

wp_posts, wp_comments, link_categories etc

update wp_posts set post_title=replace(post_title,“é”,“é”);
update wp_posts set post_title=replace(post_title,“Ô,“à”);
update wp_posts set post_title=replace(post_title,“ઔ,“ê”);
update wp_posts set post_title=replace(post_title,“à´”,“ô”);
update wp_posts set post_title=replace(post_title,“࢔,“â”);
update wp_posts set post_title=replace(post_title,“ਔ,“è”);
update wp_posts set post_title=replace(post_title,“௔,“ï”);
update wp_posts set post_title=replace(post_title,“à®”,“î”);
update wp_posts set post_title=replace(post_title,“à©”,“é”);
update wp_posts set post_title=replace(post_title,“à»”,“û”);
update wp_posts set post_title=replace(post_title,“à§”,“ç”);

update wp_posts set post_content=replace(post_content,“é”,“é”);
update wp_posts set post_content=replace(post_content,“Ô,“à”);
update wp_posts set post_content=replace(post_content,“ઔ,“ê”);
update wp_posts set post_content=replace(post_content,“à´”,“ô”);
update wp_posts set post_content=replace(post_content,“࢔,“â”);
update wp_posts set post_content=replace(post_content,“ਔ,“è”);
update wp_posts set post_content=replace(post_content,“௔,“ï”);
update wp_posts set post_content=replace(post_content,“à®”,“î”);
update wp_posts set post_content=replace(post_content,“à©”,“é”);
update wp_posts set post_content=replace(post_content,“à»”,“û”);
update wp_posts set post_content=replace(post_content,“à§”,“ç”);

migration : http://codex.wordpress.org/Moving_WordPress (english)

page en français : Migration wordpress un guide pas à pas pour votre migration. (revolunet)

Transition vers WordPress 2.0.4 et transformation d’une base de données iso-8859-15 au format UTF-8 Wireless

Redirection

Redirection par un fichier .htaccess à la racine du blog sur xxx.domaine.fr/wordpress :

RedirectMatch permanent /wordpress/(.*) http://newsite.com/$1

WordPress 2.0 Upgrade Problems: Character Encoding + Transformation

Blogs Imported (categories)

01
Oct

AJAHT

What’s in a name? That which we call a rose
By any other word would smell as sweet
.”

Romeo and Juliet (II, ii, 1-2)

Introducing AJAHT Rod Divilbiss 12/06/2006

01
Oct

Migration en cours - Undergoing migration to a new host

netlexfrance.com et netlexfrance.info sont en cours de migration sur un autre serveur.

Les deux sites seront remis progressivement en service dans les prochains jours.

Merci de votre patience et de votre compréhension.

______________

netlexfrance.com and netlexfrance.info are currently unavailable due to the migration process to another host.

Both sites will be reinstalled progressively as soon as possible.

Thank you for your comprehension.

25
Sep

MySql relation table

How can I use the relation table in Query-by-example?

Here is an example with the tables persons, towns and countries, all located in the database mydb. If you don’t have a pma_relation table, create it as explained in the configuration section. Then create the example tables:

CREATE TABLE REL_countries (
country_code char(1) NOT NULL default ”,
description varchar(10) NOT NULL default ”,
PRIMARY KEY (country_code)
) TYPE=MyISAM;

INSERT INTO REL_countries VALUES (’C', ‘Canada’);

CREATE TABLE REL_persons (
id tinyint(4) NOT NULL auto_increment,
person_name varchar(32) NOT NULL default ”,
town_code varchar(5) default ‘0′,
country_code char(1) NOT NULL default ”,
PRIMARY KEY (id)
) TYPE=MyISAM;

INSERT INTO REL_persons VALUES (11, ‘Marc’, ‘S’, ”);
INSERT INTO REL_persons VALUES (15, ‘Paul’, ‘S’, ‘C’);

CREATE TABLE REL_towns (
town_code varchar(5) NOT NULL default ‘0′,
description varchar(30) NOT NULL default ”,
PRIMARY KEY (town_code)
) TYPE=MyISAM;

INSERT INTO REL_towns VALUES (’S', ‘Sherbrooke’);
INSERT INTO REL_towns VALUES (’M', ‘Montréal’);

To setup appropriate links and display information:

* on table “REL_persons” click Structure, then Relation view
* in Links, for “town_code” choose “REL_towns->code”
* in Links, for “country_code” choose “REL_countries->country_code”
* on table “REL_towns” click Structure, then Relation view
* in “Choose field to display”, choose “description”
* repeat the two previous steps for table “REL_countries”

Then test like this:

* Click on your db name in the left frame
* Choose “Query”
* Use tables: persons, towns, countries
* Click “Update query”
* In the fields row, choose persons.person_name and click the “Show” tickbox
* Do the same for towns.description and countries.descriptions in the other 2 columns
* Click “Update query” and you will see in the query box that the correct joins have been generated
* Click “Submit query”

18
Sep

Mod_rewrite

Mod_rewrite, ou la réécriture des URL “à la volée”

Le fichier .htaccess :

AuthName “Protected Area”
AuthType Basic
AuthUserFile /var/www/virtual/site.com/htdocs/repertoire/.htpasswd
require valid-user

AuthUserFile /home/login/.htpasswd
AuthGroupFile /dev/null
AuthName “Acces Restreint”
AuthType Basic

require valid-user

Protéger les images :

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.site.info/.*$ [NC]
ReWriteRule .*\.(gif|png|jpe?g)$ - [F]

12
Sep

Fonctions PHP

strcmp($str1, $str2) : compare en binaire les 2 chaînes, retourne un entier négatif si $str1$str2, nul si $str1=$str2.
strncmp($str1, $str2, $i) : comme strcmp() mais sur les $i premiers caractères.
strcasecmp($str1, $str2) : comme strcmp() mais insensible à la case.
strncasecmp($str1, $str2) : comme strncmp() mais insensible à la case.
strnatcmp($str1, $str2) : comme strcmp() mais dans l’ordre « naturel ».
strnatcasecmp($str1, $str2) : comme strcasecmp() mais dans l’ordre « naturel ».

strstr($str1, $str2) : retourne le contenu de $str1 depuis la première occurrence de $str2 jusqu’à la fin.
stristr($str1, $str2) : comme strstr() mais insensible à la casse.
strrchr($str1, $str2) : comme strstr() mais à partir de la dernière occurrence.
substr($str, $i [, $n]) : retourne la sous-chaîne de $str débutant à la position $i jusqu’à $n.
addslashes($str) : retourne la chaîne $str dont les caractères ‘, ‘’ et \ sont protégés par un antislash.
stripslashes($str) : fonction réciproque de addslashes.
quotemeta($str) : ajoute un antislash devant les caractères suivants : . \\ + * ? [ ^ ] ( $ ).
htmlspecialchars($str) : convertit tous les caractères spéciaux en leur code HTML, par exemple .



 

August 2008
M T W T F S S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031

Recent Comments