Category Archives: Php

Instalam FFMpeg si FFMPEG-PHP Extension pe Centos


yum install ffmpeg ffmpeg-devel

If you get package not found, then you will need to add few lines in the yum repository for dag packages installation. Create a file named dag.repo in /etc/yum.repos.d with the following contents on it

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

then

yum install ffmpeg ffmpeg-devel

 daca are probleme cu keia sau ceva de genu asta eu am rezolvata asa:

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

astea(http://www.mysql-apache-php.com/ffmpeg-install.htm) zic asa:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Install FFMPEG-PHP Extension

 

wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
tar -xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0/

phpize

daca nu e instalat: yum install php-devel

./configure

Daca zice ceva cu no acceptable C compiller PATH bla bla, ii dam asa: yum groupinstall "Development tools"

make

Daca da eroare de genu: "ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: Б─≤PIX_FMT_RGBA32Б─≥ undeclared (first use in this function)", facem asa:

Fix: With the latest version of ffmpeg-php (0.6.0), update ffmpeg_frame.c and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

vi ffmpeg_frame.c

:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

:w :q!

./configure

make

make install

yum install ffmpeg ffmpeg-devel

WP n-a generat _wp_attachment_metadata pentru fisiere media.

Nu stiu din ce cauza nu sau generat(din cauza asta imaginile in admin -> media nu se afiseaza ca se pune atributul width si height egal cu 1), dar ca sa le generez din nou am facut un script de reparare:

in wp-includes/post.php dupa linia 4250, ce contine

$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );

am adaugatun cod de verificare:

if (!$data){
        $file_name = str_replace('http://domeniu.com/wp-content/uploads/', WP_CONTENT_DIR . '/uploads/', $post -> guid);
        $attach_data = wp_generate_attachment_metadata( $post->ID,  $file_name);
          wp_update_attachment_metadata( $post->ID,  $attach_data );
        
        $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
}

iar acum doar parcurgem toata galeria media ca sa se genereze datele pentru toate imaginile.

WP – schimbam domeniul sau directorul.

Exista cazuri cand tre sa mutam un wordperss platforma de pe un domeniu pe altl, sau pe acelas domeniu in alt director, ca sa mearga pe nou tre sa updatam baza de date:

UPDATE wp_options SET option_value = REPLACE(option_value,'www.olddomain.com','www.newdomain.com') WHERE option_name = "siteurl" OR option_name = "home";
UPDATE wp_posts SET post_content = REPLACE(post_content,'www.olddomain.com','www.newdomain.com');

Export fisier in UTF8 format

Atunci cand avem treaba cu diacritice, sau caractere speciale ne intimpinam cu tot felul de probleme la codificare, una dintre care este export a datelor in fisier, ca sa se exporte corect si editorul in care se va deschide fisierulk sa stie ca e format utf8 facem asa:

 

header ('Content-Type: application/download');
            header('Expires: 0');
            header('Cache-Control: private');
            header('Pragma: cache');
            header ('Content-Transfer-Encoding: binary');
            header('Content-Encoding: UTF-8');
            header('Content-type: text/csv; charset=UTF-8');
            //header("Content-type: application/vnd.ms-excel");
            header("Content-disposition: csv; filename=" . date("Y-m-d") .".csv; size=".strlen($sExportContent));
            echo "\xEF\xBB\xBF"; \\Ii zice editorului ca e fisier in format UTF-8
            print $sExportContent;
            exit;

UTF-8 pe site

Ca sa nu avem probleme cu diacritice, chirilica, si alte caractere nestandarte facem urmatoarele:

In  HEAD bagam:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

In cod php bagam la inceput:

 

mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
//ob_start('mb_output_handler'); - aici tre de vazut daca e bine sau nu cu asta

La creare baza de date facem asa:

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_Unicode_ci;

Iar la conectare la baza de date setam urmatoarele:

SET NAMES utf8;
SET CHARACTER SET utf8;

Probleme n-ar trebui sa mai apara…

P.S. : Daca pina acum campurile erau latin si contineau caractere speciale, sa nu le perdem pentru fiecare camp in parte tre sa exacutam urmatorul query:

UPDATE `tabel` SET <field> = convert(binary convert(<field> using latin1) using utf8);