Configurer SFR LIBERTALK en SIP sur Android et iPhone (avec media5fone)

EDIT : SFR a fermé le service le 2 janvier 2017 (annonce sur le forum SFR)

Il est possible d’activer le SIP chez SFR. Pour ce faire, il faut se rendre sur son compte SFR et dans les jours qui suivent vous recevrez votre mot de passe par courrier.

Une fois le courrier reçu il s’agit de configurer correctement l’application SIP. Ici nous utiliserons l’application media5fone qui est disponible sur iOS et Android.

Point de vue configuration voici les éléments qu’il vous faut.

Tout d’abord, sur l’écran d’accueil, vous devez choisir “Paramètres SIP personnalisés > Définir manuellement”.
Dans “Titre” vous pouvez entrer “SFR LIBERTALK”.
Dans “Nom d’utilisateur” entrez +3399{Votre numéro de ligne sur 10 caractères} (Exemple: +33990123456789)
Dans “Mot de passe”, celui qui vous a été envoyé par courrier.
Allez dans “Serveurs” :

  • Pour l’adresse SIP entrez l’adresse “ims.mnc010.mcc208.3gppnetwork.org”
  • Pour le port il faut mettre 5064
  • Concernant le “serveur proxy sortant”, vous devez l’activer (“Activer Proxy”).
  • Dans l’adresse du proxy entrez “internet.p-cscf.sfr.net”
  • Dans le port du proxy il faut mettre 5064
  • Activez l’option “Retirer header Route”
  • Maintenant dans la section “Autre” modifiez “Interval d’enregistrement (sec)” avec la valeur 3600
  • Activez aussi “Utiliser rport” dans cette même section

Une fois validé, il va essayer de se connecter et ne va pas réussir, il faut aller dans l’option “Avancé” du compte pour y arriver.
Dans “Avancé” :

  • Configurer le “compte utilisateur”, avec “ID Appelant” qui est “{Votre numéro de ligne sur 10 caractères}” (exemple: 0123456789)
  • Le “Nom d’authentification” est “NDI{votre numéro de ligne sur 10 caractères}.LIBERTALK@sfr.fr” (exemple: NDI0123456789.LIBERTALK@sfr.fr)
  • Descendez plus bas jusqu’à la section “SIP Features” et changez “Méthode de transfert” en “BYE”

Et voilà, après avoir validé, et en étant connecté sur du WiFi, vous devriez pouvoir passer tous les appels que vous souhaitez !

Plus d’infos dans l’assistance de SFR et sur le forum de SFR

For the error “Unknown OS character set ‘ISO-8859-15′”

My crontab keeps sending me this message:

/usr/bin/mysqladmin: Unknown OS character set ‘ISO-8859-15’.
/usr/bin/mysqladmin: Switching to the default character set ‘latin1’.

I followed all that I found on the Internet (resettings my locales, add an export LANG in the init.d script and so on) but the message is still there.

Finally the only thing that worked was to add default-character-set = latin1 in the [client] part of /etc/mysql/my.cnf and also in /etc/mysql/debian.cnf

Subroutine SNMP_Session::pack_sockaddr_in6 redefined

J’ai eu un soucis avec MRTG et ce message d’erreur qui est retourné par le crontab lié à MRTG :

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608

J’ai trouvé plusieurs indications sur Internet, mais ça ne corrigeait jamais complètement le problème. Alors voici ce que j’ai dû faire…

  1. Editer le fichier /etc/mrtg.cfg pour activer IPv6 avec EnableIPv6: yes
  2. Editer le fichier /usr/share/perl5/SNMP_Session.pm pour modifier les lignes 149 et 608 en remplaçant import Socket6; par Socket6->import(qw(inet_pton getaddrinfo));
  3. Editer le fichier /usr/bin/mrtg à la ligne 310 pour remplacer import Socket6; par Socket6->import(qw(inet_pton getaddrinfo));

Et le tour est joué !

Encode accented characters of an URL to the hexadecimal version [PHP]

I’m facing an issue with some accented characters (like ‘é’, ‘è’, ‘à’, …) in an URL and I wanted to convert them to an hex value in PHP. I found nothing on Google so I have finally created my own function for my needs :

function encodeURIHex($str) {
  $len=strlen($str);
  $ret="";
  for ($i=0; $i<$len; $i++) {
    $dec = ord($str[$i]);
    if ($dec > 191 && $dec < 256) $ret .= "%".strtoupper(dechex($dec));
    else $ret .= $str[$i];
  }
  return $ret;
}

Example :

encodeURIHex("Mère"); // -> M%E8re

I used this array to find which values of dec version of my char I wanted to use (from 192 to 255 in my case).

Vérifier du code HTML en PHP

Supposons que vos utilisateurs peuvent entrer du code HTML et que vous souhaitiez vous assurer que les tags sont correctement fermés. Alors vous pouvez utiliser PHP pour faire ça :

  $codeUtilisateur = '<p><b>Mon texte</b>'; // il manque '</p>'
  $doc = new DOMDocument(); // on utilise DOMDocument qui est installé par défaut avec PHP
  $doc->loadHTML($codeUtilisateur);
  $codeRetour = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', $doc->saveHTML()); // on va obtenir : '<p><b>Mon texte</b></p>'

Changer la synthèse vocale par défaut sous Windows 7

Si vous êtes sous Windows 7 64bits, les paramètres de la synthèse vocale ne vous propose que la voix américaine d’Anna quand bien même vous auriez installé la voix de Virginie en français par exemple… C’est qu’il faut passer par une commande spéciale qui ouvre les synthèses vocales en 32bits. Pour cela il suffit d’ouvrir le fichier qui se trouve là : C:\Windows\SysWOW64\Speech\SpeechUX\sapi.cpl

Vous verrez les autres langues que vous avez installées.

Sharepoint 2010 and IE in standard mode (issues with IE9/IE10)

I wanted to have a masterpage for Sharepoint 2010 with a HTML5 Doctype… unfortunately Sharepoint 2010 has been coded without standards, so lot of things are now broken.

I spent some time to find the broken functions. I’ve created a file that is called just after <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server"/>, and you can download it here (.js file).

I overwrite some functions to make the “Multiple lines of text” to work and same thing for the “People Picker”, and other stuff. That could be useful for someone else.

Also I found that the Gantt View doesn’t work in Standard Mode. So I’ve also overwritten some functions to make it OK in IE8, IE9 and IE10: fix_grid_sp2010.js. This file must be called at the bottom of your masterpage (in my case it’s just after the </form>) with something like :

<script type="text/javascript">
// <![CDATA[
if (typeof SP !== "undefined" && typeof SP.JsGrid !== "undefined") document.write('<script type="text/javascript" src="/dir/_catalogs/masterpage/My_Standard/js/fix_grid_sp2010.js"></'+'script>');
// ]]>
</script>

gRaphaël pie chart animated to change the values [JavaScript]

I wanted to be able to change the values for a pie chart created with gRaphaël. After some tries I finally created a new method called changeValues that is available in my fork of gRaphaël.
Below is an example:

Move your mouse over one slice from the first chart to see the second one that change.

JavaScript APIs you’ve never heard of (And some you have)

From this video I’ve discovered several JS API I didn’t know. Let’s list them:

1) Use children instead of childNodes to list the children nodes of a DOM element:

<ul>
  <li>Hello</li>
  <li>world</li>
  <li>!</li>
</ul>
<script>
document.getElementById('test').childNodes.length; // 7 -> because it also returns the text nodes
document.getElementById('test').children.length; // 3
</script>

Support: all browsers, but from IE6 to IE8 it will also return the comments nodes <!-- -->

2) Use nextElementSibling / previousElementSibling / firstElementChild / lastElementChild instead of nextSibling / previousSibling / firstChild / lastChild, because the second one will return the text nodes, but no the first one:

<script>
document.getElementById('test').firstChild; // #textNode
document.getElementById('test').firstElementChild; // LI
</script>

Support: IE9+, FF3.5+, Chrome.

3) Use contains() to indicates whether a node is a descendent of a given node:

<body>
<ul>
  <li>
  <li id="test">
  <li>
</ul>
</body>
<script>
document.body.contains(document.getElementById('test')); // TRUE
</script>

Support: all browsers.

4) Insert an HTML element with insertAdjacentHTML (see on MDN):

<div id="one">one</div>
<script>
// the first param of insertAdjacentHTML can be :
// <!-- beforebegin --><div id="one"><!-- afterbegin -->one<!--beforeend --></div><!-- afterend -->
document.getElementById('one').insertAdjacentHTML('afterend', '
two
'); // At this point, the new structure is: //
one
two
</script>

Support: all browsers.

5) If you want to replace a node you can either use replaceChild or outerHTML. See outerHTML on MDN.

Support: all browsers.

6) Input.setSelection() sets the start and end positions of the current text selection in an <input> element. That could be useful to put the caret in a particular place (see on MDN):

var textbox=document.getElementById('my-input');
textbox.setSelectionRange(textbox.value.length,textbox.value.length); // the caret will be at the end of the input text

Support: All browsers, except for IE (only from IE9).

7) The document.activeElement returns the currently focused element (see details on MDN):

document.getElementById('my-input').focus();
document.activeElement; // #my-input

Support: all browsers.

8) The new FormData is part of the XMLHttpRequest Level 2 and permits to easily construct a set of key/value pairs representing form fields and their values and then send them with the send() command (see more on MDN):

var data=new FormData();
data.append("name","Paul");
data.append("age",15);
var xhr = new XMLHttpRequest();
xhr.open("post", "/submit", true);
xhr.send(data);

Support: it’s quite well supported, except from IE from version 10 only

Note: the video gives more functions regarding the XMLHttpRequest Level 2

9) Element.matchesSelector() permits to test a CSS selector over an element. It’s prefixed so we’ll create a function:

<div><span class="title" id="test">Hello world!</span></div>
if (!Element.prototype.matchesSelector) {
  Element.prototype.matchesSelector = function(css) {
    if (this.webkitMatchesSelector) return this.webkitMatchesSelector(css)
    if (this.mozMatchesSelector) return this.mozMatchesSelector(css)
    if (this.msMatchesSelector) return this.msMatchesSelector(css)
    if (this.oMatchesSelector) return this.oMatchesSelector(css)
  } 
}

var span=document.getElementById('test');
span.matchesSelector('#test'); // true
span.matchesSelector('.title'); // true
span.matchesSelector('div > span'); // true

Support: all browsers, except for IE starting from IE9.

10) getBoundingClientRect permits to know the size and the position of an element in the viewport:

var div=document.getElementById('test');
var rect=div.getBoundingClientRect();
// in pixels, relative to the viewport
rect.left;
rect.top;
rect.right; // relative to left
rect.bottom; // relative to top
rect.width;
rect.height;

Support: all browsers, however with IE<8 there is a bug that adds 2 to the different positions.

11) document.elementFromPoint(x,y) returns the element that is in the (x,y) coordinates. For example, this is useful to know over which element the mouse is.

Support: all browsers.

Raphaëljs plugins for different charts [gRaphaël]

There is gRaphaël that provides several useful plugins to create some different charts like the pie charts, the line charts and so on, based on the Raphaël JS library. unfortunately, the owner doesn’t update his files very often, even if there are several pull requests from the users. So I decided to fork the main repository to fix the issues that I found and that others found: gRaphaël fork