Eksport wszystkich baz z MySQL do plików SQL

Eksport wszystkich baz danych z MySQL.

<?php
header('Content-type: text/html; charset=utf-8');
class Config {
   public static $host = '127.0.0.1';
   public static $username = 'root';
   public static $password = '';
   public static $port = 3306;
}

if (!file_exists('dbdumps') || !is_dir('dbdumps'))
   mkdir('dbdumps', 0700);

$dsn = 'mysql:host=' . Config::$host . ';port=' . Config::$port;
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
$dbh = new PDO($dsn, Config::$username, Config::$password, $options);

$result = $dbh->query('SHOW DATABASES;');
if ($result !== false)
   foreach ($result->fetchAll() as $row) {
      $cmd = 'mysqldump -u ' . Config::$username . ' -p' . Config::$password
         . ' ' . $row['Database'] . ' > dbdumps/' . $row['Database'] . '.sql';
      system($cmd);
      $fileSize = filesize('dbdumps/' . $row['Database'] . '.sql');
      echo 'File ' . $row['Database'] . '.sql saved [' . $fileSize . ' bytes] .<br />';
   }

Drupal 6 – Własny blok zmiany języka

Domyślny blok „Przełączanie języków” nie posiada zbyt ciekawych możliwości formatowania. Często tego typu elementy opisuje się w HTML na liście, co później znacznie ułatwia dla tej struktury określanie kaskadowych arkuszy stylów. Poniżej  sposób na zastosowanie swojego bloku bazujący na module locale domyślnie dostarczanym z Drupalem:

<?php
/**
* Implements hook_block();
*/
function hook_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks['custom_language_switcher'] = array(
      'info' => t('Custom Language Switcher'),
    );
  return $blocks;
} else if ($op == 'view') {
  switch ($delta) {
    case 'custom_language_switcher':
      if (variable_get('language_count', 1) > 1
        && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) {
        $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
        $languages = language_list('enabled');
        $links = array();
        foreach ($languages[1] as $language)
          $links[$language->language] = array(
            'href' => $path,
            'title' => $language->native,
            'language' => $language,
            'attributes' => array('class' => 'language-link'),
          );
        drupal_alter('translation_link', $links, $path);

        $block = array(
          'subject' => t('Custom Language Switcher'),
          'content' => _custom_get_language_switcher($links)
        );
      }
      break;
    }
    return $block;
  }
}

function _custom_get_language_switcher($links = array()) {
  global $language;
  $html = '';
  if (count($links)) {
    $html = '<ul class="language-switcher">';
    foreach ($links as $key => $value) {
    $active = '';
      if ($key == $language->language)
        $active = ' class="active"';
      $html .= "\t\t" . '<li' . $active . '><a href="' . url($value['href'], array('language' => $value['language'])) . '"' . $active . '>' . $value['title'] . '</a></li>' . "\n";
    }
    $html .= "\t" . '</ul>' . "\n";
  }
  return $html;
}