Skip to content

Instantly share code, notes, and snippets.

@seebz
seebz / tiny-pma.php
Created December 6, 2012 13:25
Tiny Php.Mysql.Administration
<?php
/*
* Configuration
*/
define('DB_HOST', 'localhost');
define('DB_USER', 'username');
@seebz
seebz / xml2array.php
Last active October 13, 2015 20:17
XML 2 Array
<?php
// http://jaspreetchahal.org/php-xml-to-array-simplest-way/
function xml2array($xml) {
$obj = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
$json = json_encode($obj);
return json_decode($json, true);
}
?>
@seebz
seebz / xml2array.php
Created December 10, 2012 10:27
XML 2 Array + namespaces
<?php
// http://php.net/manual/en/class.simplexmlelement.php#108867
function xml2array($xml) {
function normalize_xml2array($obj, &$result) {
$data = $obj;
if (is_object($data)) {
$data = get_object_vars($data);
foreach($obj->getDocNamespaces() as $ns_name => $ns_uri) {
<?php
function array2xml($arr, $root = false, $header = false) {
if (! function_exists('is_hash')) {
function is_hash($var) {
return ( is_array($var) && array_keys($var) !== range(0, count($var)-1) );
}
}
if (! function_exists('normalize_array2xml')) {
@seebz
seebz / gist:4673786
Created January 30, 2013 14:51
Titre des archives CTP disposant d'une page WP
<?php
/**
* Titre des archives CTP disposant d'une page WP
*/
add_filter('post_type_archive_title', 'fhp_post_type_archive_title');
function fhp_post_type_archive_title($title)
{
$post_type = get_query_var('post_type')
@seebz
seebz / .htaccess
Last active December 12, 2015 09:39
PHP maintenance mode
RewriteEngine On
#RewriteBase /
# On autorise l'accès à notre adresse IP
#RewriteCond %{REMOTE_HOST} !^123\.123\.123\.123
# On évite de boucler
RewriteCond %{REQUEST_URI} !^/503\.php
RewriteRule .* 503.php [L]
@seebz
seebz / proxy.php
Created February 11, 2013 13:42
PHP mod_proxy
<?php
// .Htacesss
// ---------
/*
<IfModule mod_rewrite.c>
RewriteEngine on
@seebz
seebz / script.sh
Last active December 18, 2015 05:49
Implementation d'un service de contrôle de daemons PHP (à améliorer)
#!/bin/bash
#
# Exécute diverses tâches `PHP` en boucle
#
# Liste des tâches à exécuter en boucle
TASKS=(
"script-1.php"
--
-- from `utf8_general_ci` to `utf8_unicode_ci`
--
-- Génère la requêtes de convertion de la DB `{DB_NAME}`
SELECT CONCAT('ALTER DATABASE `', schema_name, '` DEFAULT COLLATE utf8_unicode_ci;')
FROM information_schema.schemata
@seebz
seebz / preferences
Last active December 22, 2015 05:29
Debian "next stable" repositories
# Release (Testing / Jessie)
# --------------------------
# Main / Security
Package: *
Pin: release o=Debian,n=jessie
Pin-Priority: 700
# Multimedia
Package: *