Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /data/e/7/e76990b9-3372-4d88-8089-fce36e16744a/webperfection.net/sub/rady-nosu/wp-content/plugins/seo-ultimate/modules/class.su-module.php on line 1195
Real Solution for Your Problem! - Page 4

Extracting html from domdocument without parsing original node

preserveWhiteSpace = false;
$dom->loadHTML($body);
// $html = $dom->saveHTML();
// var_dump($html);

// create xpath
$xpath = new DOMXPath($dom);
// read everything from body 
$query = '/html/body/* | /html/body/text()';
$entries = $xpath->query($query);
foreach ($entries as $entry) {
var_dump(
// parsed value
    $entry->nodeValue,
// node name (b/div/..)
    $entry->nodeName,
// f.e. comment...
    $entry->nodeType,
// get me the original node (text

		
		
		
		 
  • Comments Off on php domdocument extract text nodes with original html

extract mp3 info with php and rename file on linux box

how to get all mp3 info from a file with php and rename based on this tags

download complete file (rename to .php after): mp3-getinfo-tags-rename-php.txt


<?php
clearstatcache();

/*
%f     Filename without the path [string]
%F     Filename with the path [string]
%k     File size in KB [integer]
%a     Artist [string]
%c     Comment [string]
%g     Musical genre [string]
%G     Musical genre number [integer]
%l     Album name [string]
%n     Track [integer]
%t     Track Title [string]
%y     Year [string]
%C     Copyright flag [string]
%e     Emphasis [string]
%E     CRC Error protection [string]
%L     MPEG Layer [string]
%O     Original material flag [string]
%o     Stereo/mono mode [string]
%p     Padding [string]
%v     MPEG Version [float]
%u     Number of good audio frames [integer]
%b     Number of corrupt audio frames [integer]
%Q     Sampling frequency in Hz [integer]
%q     Sampling frequency in kHz [integer]
%r     Bit  Rate  in  kbps  (type  and meaning affected by -r option)
%m     Playing time: minutes only [integer]
%s     Playing time: seconds only [integer] (usually used  in conjunction with %m)
%S     Total playing time in seconds [integer]
%%     A single percent sign
*/


// my mp3 directory to recusively iterate thrue
$directory = '/mnt/temp/teachings';

// what info i want from my mp3 file - tags
$info = [
  'artist' => '%a',
  'year' => '%y',
  'comment' => '%c',
  'album_name' => '%l',
  'track' => '%n',
  'track_title' => '%t',
  'minutes' => '%m',
  'seconds' => '%s',
];

// what my filename will looks like
$fileFormat = '%artist-%year-%comment-%album_name-%track-M%minutesS%seconds.mp3';

// build format usable for shell and use newline as delimiter
$infoParam = implode('\n', $info);

// what this can be...
print '
';

// scan folders
$rdit = new RecursiveDirectoryIterator($directory);
foreach (new RecursiveIteratorIterator($rdit) as $file) {

    // do the job only for files & mp3 ext
    if($file->isFile() && strtolower($file->getExtension()) == 'mp3') {

        // get me the id3 tags (mp3info v1 on my debian)
        $mp3Info = shell_exec('mp3info -p "' . $infoParam . '" ' . $file);

        // is the info what i expect?
        $mp3InfoArray = explode("\n", $mp3Info);
        if(sizeof($mp3InfoArray) != sizeof($info)) {
            print "check:$file
"; continue; } // make me array with combined $info keys and mp3 info values $mp3InfoArray = array_combine(array_flip($info), $mp3InfoArray); // build new filename $newFile = sprintfa($fileFormat, $mp3InfoArray); // clean a bit $newFile = str_replace([',', '\\', ' ', '/', '%'], '_', $newFile); $newFile = str_replace(['&'], ['and'], $newFile); $newFile = iconv('UTF-8', 'ASCII//TRANSLIT', utf8_encode($newFile));; $newFile = $file->getPath() . '/' . $newFile; // is the new file equal to the old filename? if(strcmp($file, $newFile) != 0) { // does the newfile already exists? if(file_exists($newFile)) { $newFile = substr_replace($newFile, uniqid('-') . '.mp3',-4, 4); } rename($file, $newFile); // what we did with old to new file print "$file:$newFile
"; flush(); } } } function sprintfa ($format, array $values) { foreach ((array)$values as $k => $v) { $format = str_replace("%$k", $v, $format); } return $format; }

Share This:

  • Comments Off on extracting mp3 id3 tags with php

Pri testovani som dostal hlasku:

Fatal error: Maximum function nesting level of ‘100’ reached, aborting! in /usr/share/php/PHPUnit/Util/ErrorHandler.php on line 608

treba upravit php cli config:
/etc/php5/cli/php.ini
a pridat (aj napriek tomu ze xdebug nemam ale zendserver si to tam sam nastavi):
[xdebug]
xdebug.max_nesting_level = 500

Share This:

  • Comments Off on ZendServer nesting level fatal php cli

December 2, 2013 | In: Nepotriedené

Update wiki user password

ako aktualizovat uzivatelske heslo v mediawiki

log to mysql console:
mysql -uroot -p[password]


mysql> use mediawiki;
mysql> UPDATE `user` SET user_password = CONCAT(':A:', MD5('new password 43')) WHERE user_name = 'My.user';

malo by vypisat:

Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Share This:

  • Comments Off on Update wiki user password

If you have problem with with comment formatting in Zend Studio 10

the aid is:

windows->preferences, search for formatter

PHP -> Code Style -> Formatter

(i use PSR-2) press [Edit…] -> Line Wrapping :
maximum line width: 80
indent1
uncheck “Force split” at the bottom
next tab:
general settings:

unecheck last 3 options
bottom: maximim line width 100

Share This:

  • Comments Off on ZendStudio 10.1 and 10.5 wrong comment formatting

na moje prekvapkanie regex v JS nefunguje cez “/asdf/” ale bez:

multi replace string

console.log("my_multi_string_to_replace".replace(/_/gmi," "));

Share This:

  • Comments Off on javascript replace string

September 19, 2013 | In: How-to vychytávky

html header codes

curl -I webperfection.net

lynx -head -dump http://webperfection.net

Share This:

  • Comments Off on html header codes

predtym som ale musel do classmap_generator.php pridat:

require $libPath . '/Zend/Console/Getopt.php';
require $libPath . '/Zend/File/ClassFileLocator.php';

Spustit classmap generator

prejdeme do zlozky so ZF 1.12 a potom v konzole spustit generator:

cd zendframework1/bin
$ php classmap_generator.php -l '../library/Zend/'

vytvori:

zendframework1/bin/library/Zend/autoload_classmap.php

Include classautoloader

ako bonus dostaneme Namespaces v zend 1.12 ako jeho bocny produkt


// index.php
Zend_Loader_AutoloaderFactory::factory(array(
    'Zend_Loader_ClassMapAutoloader' => array(
         '/var/www/dev/library/vendor/zendframework/zendframework1/library/Zend/autoload_classmap.php',
//         '/var/www/dev/library/v3/My_Libs.../autoload_classmap.php',
    ),
    'Zend_Loader_StandardAutoloader' => array(
        'prefixes' => array(
            'Zend' => PATH_ZEND
        ),
        'fallback_autoloader' => true
    )
));

alebo jednoducho, no bez tohoto nemame namespaces:


require_once 'Zend/Loader/ClassMapAutoloader.php';
$loader = new Zend_Loader_ClassMapAutoloader();
// Register the class map:
$loader->registerAutoloadMap($zendClassMapPath);
// Register with spl_autoload:
$loader->register();

Zend optimization – zrychlit pristup na disk

DOLEZITE: treba vyhodit vsetky require

find ./ -name '*.php' \
-not -wholename '*/Application.php' \
-not -wholename '*/Loader*' \
-print0 | xargs -0 \
sed --regexp-extended \
--in-place 's/(require_once)/\/\/ \1/g'

Zend config optimalizacia


// index.php
$configKey = 'PATH_FILE_ZEND_APPLICATION_CONFIG';

$mc = new Memcache();
$mc->connect('localhost', 11211);
$config = $mc->get($configKey);
if (!is_array($config)) {
    $config = new Zend_Config_Ini(PATH_FILE_ZEND_APPLICATION_CONFIG, APPLICATION_ENV);
    $config = $config->toArray();
    $mc->set($configKey, $config, false, 600);
}
// Create application, bootstrap, and run
(new Zend_Application(APPLICATION_ENV, $config))->bootstrap()->run();

na nasom realnom zivom projekte (asi 1500 classes) som bez optcache ziskal 15% zrychlenie, s optcache 60% (zend server 6.1, optimizer+)

Share This:

  • Comments Off on Zend 1.12 optimization – class autoloader + class map + memcache

September 11, 2013 | In: How-to vychytávky

find zlozku/directory

find urcitu zlozku podla depth/hlbky vnorenia

find ./ -maxdepth 1 -type d -name '*mull*'

Share This:

  • Comments Off on find zlozku/directory

zend framework mariadb connection setting

application config:

resources.db.adapter = “pdo_mysql”
resources.db.params.host = “mariadb55.host.xx”
resources.db.params.port = “3310”
resources.db.params.username = “user”
resources.db.params.password = “pass”
resources.db.params.dbname = “db_name”
resources.db.params.charset = utf8
resources.db.params.unix_socket = ‘/tmp/mariadb55.sock’

Share This:

  • Comments Off on Zend Framework + MariaDB 5.5