воскресенье, 25 декабря 2011 г.

PHP sessions across sub domains

Params:
PHP-5.3, Apache-2.2

Problem:
I need a single session for mysite.com and admin.mysite.com domains. I would login on main domain mysite.com, and will be already authorized on sub domains like admin.mysite.com.


Solution:
In script before session start need too setup this session parameters:
session.cookie_path = "/"
session.cookie_domain = ".mysite.com" - dot at the beginning is important, it specify use same sessions on sub domains

Example:
Example for Zend Framework application.


Define site domain name value:
*** public/index.php ***
...
defined('SITE_DOMAIN_NAME')
|| define('SITE_DOMAIN_NAME', (getenv('SITE_DOMAIN_NAME') ? getenv('SITE_DOMAIN_NAME') : 'mysite.com'));
...
It seems, if server value SITE_DOMAIN_NAME is not defined, craete it. We will use it in config file.

You can define SITE_DOMAIN_NAME in .htaccess file, Anyway he need to be configured on every server separately.

*** public/.htaccess ***
...
SetEnv SITE_DOMAIN_NAME mysite.com
...

Further I set session values in config file
*** application/configs/application.ini ***
[production]
...
local.session.cookie_path = "/"
local.session.cookie_domain = "." SITE_DOMAIN_NAME
...
This line  "." SITE_DOMAIN_NAME  is equal to ".mysite.com"

And in Bootstrap.php wee initialize session.
*** application/Bootstrap.php ***
...
protected function _initSession()
{
$localCfg = new Zend_Config($this->getOption('local'), true);
Zend_Session::setOptions($localCfg->session->toArray());
Zend_Session::start();
}
...

пятница, 23 декабря 2011 г.

Zend Framework, bind subdomains to modules

Params:
Zend Framework 1.11, PHP-5.3, Apache 2.2, local pc with Gentoo on board.

Problem:
I want to bind subdomains to certain module of Zend Framework application.
Example: 
http://mysite.com - follow to default module of my app.
http://admin.mysite.com - follow to admin module.
Controllers, actions and params may be various(global variables also):
http://admin.mysite.com/index/index/foo/bar/......
etc.

Solution:
1) Create site with default Zend Framework module structure.
/var/www/mysite.com/
   application/
      configs/
      modules/
         admin/
            controllers/
            views/
         default/
            ......
      Bootstrap.php
   ......

2) Bind DocumentRoot folder of mysite.com, www.mysite.com, admin.mysite.com to the same folder. In my case it's:
/var/www/mysite.com/public

3) In Bootstrap.php file init application router:
 protected function _initRouter()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$hostnameDefaultRoute = new Zend_Controller_Router_Route_Hostname(':module.mysite.com'  , array('module' => 'default'));
$router->addRoute('default', $hostnameDefaultRoute->chain(new Zend_Controller_Router_Route(':lang/:controller/:action/*', array('lang' => 'en', 'controller'=>'index', 'action'=>'index'))));
  $hostnameDefaultRoute = new Zend_Controller_Router_Route_Hostname('mysite.com'  , array('module' => 'default'));
$router->addRoute('www', $hostnameDefaultRoute->chain(new Zend_Controller_Router_Route(':lang/:controller/:action/*', array('lang' => 'ru', 'controller'=>'index', 'action'=>'index'))))
->addRoute('login'  , $hostnameDefaultRoute->chain(new Zend_Controller_Router_Route_Static('login',   array('controller' => 'user', 'action'=>'login'))));
// routes for admin area
$hostnameAdminRoute = new Zend_Controller_Router_Route_Hostname('admin.mysite.com', array('module' => 'admin'));
$router->addRoute('admin' , $hostnameAdminRoute->chain(new Zend_Controller_Router_Route(':lang/:controller/:action/*',   array('lang' => 'en', 'controller'=>'index', 'action'=>'index'))))
->addRoute('settings' , $hostnameAdminRoute->chain(new Zend_Controller_Router_Route_Static('settings', array('controller' => 'config', 'action' => 'list'))));
}
==================================================================
In a result will work this url's:
mysite.com/ -> Module: default, IndexController, indexAction, lang: en
mysite.com/en/index/index -> Module: default, IndexController, indexAction, lang: en
mysite.com/en/index/index/foo/bar -> Module: default, IndexController, indexAction, lang: en , params: foo = bar
mysite.com/login -> Module: default, UserController, loginAction
admin.mysite.com -> Module: admin, indexController, indexAction, lang: en
admin.mysite.com/en/ -> Module: admin, indexController, indexAction, lang: en
admin.mysite.com/settings -> Module: admin, configController, listAction

4) Also you can use route names in view helper URL. In view script:
echo $this->url(array(), 'www') will output 'mysite.com/en/index/index'
echo $this->url(array('foo' => 'bar'), 'www') will output 'mysite.com/en/index/index/foo/bar'
echo $this->url(array(), 'login') will output 'mysite.com/login'
echo $this->url(array('page' => 1), 'admin') will output 'admin.mysite.com/en/index/index/page/1'
echo $this->url(array(), 'settings') will output 'admin.mysite.com/settings'
Also you can specify controllers and actions
echo $this->url(array('controller' => 'post', 'action' => 'list'), 'www') will output 'mysite.com/en/post/list'
echo $this->url(array('action' => 'print', 'id' => 2), 'admin') will output 'admin.mysite.com/en/index/print/id/2'

воскресенье, 18 декабря 2011 г.

Magento, change emails count in newsletter queue

Params:
Magento 1.6.0

Problem:
When cron execute newsletters, the count of emails which will be send is limited to 20 per request.

Solution:
Notice: This is bad solution!
Edit script app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
Find string :
$countOfSubscritions = 20;
and set the value which you need. For me is "8" - limit of my hosting (emails count per request).

четверг, 15 декабря 2011 г.

Gentoo emerge: "A file is not listed in the Manifest ..."

Params:

Linux moon 2.6.39-gentoo-r3 #4 SMP Wed Aug 31 17:44:51 EEST 2011 i686 AMD Athlon(tm) XP 2000+ AuthenticAMD GNU/Linux

Problem:
When I do emerge <some_package> or upgrade my gentoo, emerge give me bulk of messages like this:
!!! A file is not listed in the Manifest '<package_ebuild>'
also have this warning:
Digest verification failed ...

Solution:
1) Download latest-portage snapshot from some gentoo mirrors:
    > cd /
    > wget ftp://gentoo.kiev.ua/snapshots/portage-20111214.tar.xz
2) Move /usr/portage directory for backup purposes:
     > mkdir /root/temp
     > mv /usr/portage /root/temp/
3) Extracting the portage snapshot:
    > tar xvjf /portage-20111214.tar.xz -C /usr
    > rm /portage-20111214.tar.xz
4) Sync new portage:
    > emerge --sync

That's all now you can update the system or .....
I don't know if this is correct solution, but it working for me.

воскресенье, 4 декабря 2011 г.

Where Magentoconnect manager save downloaded packages

Params:
Magento 1.6.0

Problem:
I have installed some package from magentoconnect, and I want to look inside this package.

Solution:
It saved here:
<path_to_magento_store_folder>/downloader/.cache/community/<package_name>.tgz

пятница, 25 ноября 2011 г.

Gentoo emerge: "Digest verification failed"

Params:
Linux moon 2.6.39-gentoo-r3 #4 SMP Wed Aug 31 17:44:51 EEST 2011 i686 AMD Athlon(tm) XP 2000+ AuthenticAMD GNU/Linux


Problem:
I have this error when trying emerge some applications

Calculating dependencies |  * Digest verification failed:
 * /usr/portage/dev-python/pygobject/pygobject-2.28.6.ebuild
 * Reason: Filesize does not match recorded size
 * Got: 3824
 * Expected: 3826
... done!


Solution:
> emerge --sync
> ebuild /usr/portage/dev-python/pygobject/pygobject-2.28.6.ebuild digest
> emerge --sync


But if you have a bulk of this warning, or you have also this warning:
A file is not listed in the Manifest '<package_ebuild>'
Then read this solution http://uommo.blogspot.com/2011/12/gentoo-emerge-file-is-not-listed-in.html

понедельник, 14 ноября 2011 г.

LDOCE5 no sound solution.

Params:
Linux solar 2.6.38-gentoo-r6 #21 SMP Wed Nov 9 21:29:55 EET 2011 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
You must had installed and configured 'alsa-oss'

Problem:
No sound in LDOCE5 application.

Solution:
Add 'aoss' to exec ldoce5 command.
Desktop link:
Edit desktop file ldoce5.desktop. Add 'aoss' in the command on Exec line
Exec=aoss '/<path_to_ldoce5_install_dir>/ldoce5//ldoce5'


Also you can create command in user '~/.bashrc' file. Add this line in your .bashrc file
alias ldoce5="aoss /<path_to_ldoce5_install_dir>/ldoce5/ldoce5"
And after reboot you can use 'ldoce5' command to execute application with fixed sound.

May be you have "aoss32" instead "aoss", it also working, trying.

вторник, 1 ноября 2011 г.

PHP sendmail, save mails in local filesystem folder

Params:
OS: Gentoo
Language: PHP 5.3.8

Problem:
Save mails sended from PHP script in local filesystem folder.
View them by KMail

Solution:
Make all changes relative to your distro.
1) Create script fakesendmail.sh

#!/bin/sh 
prefix="/home/<my_username>/temp/sendmail/new"
numPath="/home/<my_username>/temp/sendmail"
if [ ! -f $numPath/num ]; then
    echo "0" > $numPath/num
fi
num=`cat $numPath/num`
num=$(($num + 1))
echo $num > $numPath/num 
name="$prefix/letter_$num.txt"
while read line
do
     echo $line >> $name
done
chmod 777 $name


/bin/true


I saved it in folder /home/<my_username>/Applications/

Don't forget set appropriate pathes in script.

2) Make this script executable: console> chmod +x fakesendmail.sh


3) Create folders for mails: 


console> mkdir 
/home/<my_username>/temp/sendmail/


console> mkdir 
/home/<my_username>/temp/sendmail/cur


console> mkdir 
/home/<my_username>/temp/sendmail/new


console> mkdir 
/home/<my_username>/temp/sendmail/tmp


4) Change folder properties: console> chmod 777 -R 
/home/<my_username>/temp/sendmail/


5) Make changes in php.ini file (on gentoo: /etc/php/apache2-php5.3/php.ini)


Change path to sendmail script to our new script:


sendmail_path = /home/<my_username>/Applications/fakesendmail.sh
6) Open KMail and create new incoming account.
Kontact->Settings->Configure KMail->Accounts->Add Account
In opened window choose "Maildir mailbox" and set appropriate folder "
/home/<my_username>/temp/sendmail"



воскресенье, 30 октября 2011 г.

Regular expression to ignore escaped quotes within quotes

Params:
Language: PHP

Problem:
I have string:
$text = '[[["my tree \",and to and \"\" something \'\"else","moe derevo \" , a takzhe i\" \"nechto \" drugoe",""]],,"en",,[["en"]],2]';
I need only quoted part of it:  my tree \",and to and \"\" something \'\"else


Solution:

$pattern = '/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"/imsu'; // Use this regular expression
$match = '';
preg_match($pattern, $text, $match);
var_dump($match[1]);

And you will see: my tree \",and to and \"\" something \'\"else

вторник, 25 октября 2011 г.

Magento database add table prefix

Problem:
Store setup was without database table prefix.
Now I need to move magento database to existing db with tables from another application.

Parameters:
Magento version 1.6.0

Solution:
Create script "add_db_prefix.php" in your store public catalog. Listing:


<?php
$database_host = "localhost"; // Here database server, ip or domain name
$database_user = "<your_db_user>";
$database_password = "<your_db_user_password>";
$magento_database = "<your_db_name>";
$table_prefix = "mage_"; // Table prefix wich you want!!!

$db = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($magento_database);
$result = mysql_query("SHOW TABLES") or die('Err');
while (($row = mysql_fetch_array($result)) != false) {
    $old_table = $row[0];
    if (preg_match('/'.$table_prefix.'/', $old_table)) {
        echo "Table $old_table already done<br/>\n";
        continue;
    }

    $new_table = $table_prefix.$old_table;
    echo "Renaming $old_table to $new_table<br/>\n";
    $query = "RENAME TABLE `$old_table`  TO `$new_table`";
    mysql_query($query);
}
?>

Do not forget change db conection data in script!
Follow to the url: http://<your_store_domain_name>/add_db_prefix.php
Now all tables in db with new prefix.
And of course you need setup table prefix in your store config file.
Edit config: "app/etc/local.xml"
Find string: "<table_prefix><![CDATA[]]></table_prefix>"
Put there your new table prefix: "<table_prefix><![CDATA[mage_]]></table_prefix>"

среда, 19 октября 2011 г.

Magento Admin Notification bugfix

Magento v.1.6
Trouble:
Every time when I am login to the admin panel see this message:"Reminder: Change Magento`s default phone numbers and callouts before site launch"
It's really damn annoying.


Sollution:
Copy the file app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php
to app/code/local/Mage/AdminNotification/Model/Resource 
Create these folders if they does not exists.
And edit this php script.
Line 102. Find:
$select $adapter->select()
                ->from($this->getMainTable())
                ->where('url=?'$item['url']);
Replace it by:$select $adapter->select()
                ->
from($this->getMainTable())
                ->
where('url=? OR url IS NULL'$item['url'])
                ->
where('title=?'$item['title']);

Delete all your notifications.


Thanks to Payserv http://www.magentocommerce.com/boards/viewthread/246247/

понедельник, 3 октября 2011 г.

Move Magento store to another server


Actions
  • Create DB backup (phpmyadmin or etc.)
  • Import backup to server DB.
  • Copy all magento files to the server.
  • Edit config for DB connection. (app/etc/local.xml)
  • Clear Magento cache folder (var/cache/)

In phpmyadmin.
  1. open table core_config_data
  2. Find rows where column "path" equal "web/unsecure/base_url" and "web/secure/base_url".
  3. Edit these rows. Set appropriate site domain name.

воскресенье, 2 октября 2011 г.

Magento Connect Manager problems

Errors on page Magento Connect Manager(MCM):
1) "Warning: Your Magento folder does not have sufficient write permissions."
2) "Config file does not exists" or something like that
3) MCM tab "Settings" Deployment Type "Local Filesystem" is inactive

Solution (Your magento installation folder here /var/www/<domain_name>/public/):
Change folders permission
> chmod -v 777 /var/www/<domain_name>/public/
> chmod -v 777 /var/www/<domain_name>/public/downloader/

воскресенье, 18 сентября 2011 г.

Gentoo installation (x86)

> passwd (new password for root)
> /etc/init.d/sshd start
> ifconfig eth0 192.168.0.4 broadcast 192.168.0.255 netmask 255.255.255.0 up
> route add default gw 192.168.0.1
> nano -w /etc/resolv.conf
            nameserver 109.86.2.2
            nameserver 109.86.2.21
> ping google.com (check net)

> ssh root@192.168.0.4 (On another host)
> fdisk /dev/hda (check file system)
> mke2fs -j /dev/hda1
> mkreiserfs /dev/hda5
> mkswap /dev/hda2
> swapon /dev/hda2
> mount /dev/hda5 /mnt/gentoo

> mkdir /mnt/gentoo/boot
> mount /dev/hda1 /mnt/gentoo/boot
> date (check current date)
> date --set "28 Aug 2011 12:03"
> cd /mnt/gentoo
> wget http://gentoo.inode.at/releases/x86/current-stage3/stage3-i686-20110809.tar.bz2
> tar xvjpf stage3-i686-20110809.tar.bz2
> wget http://gentoo.inode.at/snapshots/portage-latest.tar.bz2
> tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
> nano -w /mnt/gentoo/etc/make.conf (Configure compilation parameters and set gentoo mirrors)
> cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
> mount -t proc none /mnt/gentoo/proc
> mount -o bind /dev /mnt/gentoo/dev
> chroot /mnt/gentoo /bin/bash
> env-update
> source /etc/profile
> export PS1="(chroot) $PS1"
> emerge --sync
> ls -FGg /etc/make.profile
> ls /usr/portage/profiles/default/linux/x86/10.0/
> less /usr/portage/profiles/use.desc
> nano -w /etc/make.conf (set USE flags)
> nano -w /etc/locale.gen (set localization parameters)
           ru_UA.UTF-8 UTF-8                                                                                       
           en_US.UTF-8 UTF-8
> locale-gen
> ls /usr/share/zoneinfo/ (find your time zone)
> cp /usr/share/zoneinfo/Europe/Kiev  /etc/localtime
> USE="-doc symlink" emerge gentoo-sources
> ls -l /usr/src/linux (check kernel symlink)
> emerge pciutils -av
> cd /usr/src/linux
> make menuconfig (configure kernel)
> make && make modules_install
> cp arch/i386/boot/bzImage /boot/linux-2.6.39-gentoo-r3_1
> nano -w /etc/fstab (configure partitions)
> nano -w /etc/conf.d/hostname
> nano -w /etc/conf.d/net
> cd /etc/init.d
> ln -s net.lo net.eth1
> rc-update add net.eth1 default
> nano -w /etc/hosts
> passwd
> nano -w /etc/rc.conf
> nano -w /etc/conf.d/keymaps
> nano -w /etc/conf.d/clock
> emerge syslog-ng
> rc-update add syslog-ng default
> emerge vixie-cron
> rc-update add vixie-cron default
> emerge sys-apps/mlocate
> emerge reiserfsprogs (you must setup programms to maintenance)
> emerge dhcpcd
> emerge grub
> grub
      grub> root (hd0,0)
      grub> setup (hd0)
      grub> quit
> exit
> cd
> umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
> reboot

Midnight Commander file association and execution

Set KDE file association in mc for all users.
Edit config file "/etc/mc/mc.ext"

For example we set association for video files:
**************************************************
### Video ###
........

include/video                                                                                                      
<------>Open=(kfmclient exec %f >/dev/null 2>&1 &)
**************************************************
Use this string for other application if need.

Examples for other ENV:
# for XFCE
Open=(exo-open %f >/dev/null 2>&1 &)
#for Gnome
Open=(gnome-open %f >/dev/null 2>&1 &)

среда, 7 сентября 2011 г.

воскресенье, 28 августа 2011 г.

Gentoo installation (x86)

> passwd (new password for root)
> /etc/init.d/sshd start
> ifconfig eth0 192.168.0.4 broadcast 192.168.0.255 netmask 255.255.255.0 up
> route add default gw 192.168.0.1
> nano -w /etc/resolv.conf
            nameserver 109.86.2.2
            nameserver 109.86.2.21
> ping google.com (check net)

> ssh root@192.168.0.4 (On another host)
> fdisk /dev/hda (check file system)
> mke2fs -j /dev/hda1
> mkreiserfs /dev/hda5
> mkswap /dev/hda2
> swapon /dev/hda2
> mount /dev/hda5 /mnt/gentoo

> mkdir /mnt/gentoo/boot
> mount /dev/hda1 /mnt/gentoo/boot
> date (check current date)
> date --set "28 Aug 2011 12:03"
> cd /mnt/gentoo
> wget http://gentoo.inode.at/releases/x86/current-stage3/stage3-i686-20110809.tar.bz2
> tar xvjpf stage3-i686-20110809.tar.bz2
> wget http://gentoo.inode.at/snapshots/portage-latest.tar.bz2
> tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
> nano -w /mnt/gentoo/etc/make.conf (Configure compilation parameters and set gentoo mirrors)
> cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
> mount -t proc none /mnt/gentoo/proc
> mount -o bind /dev /mnt/gentoo/dev
> chroot /mnt/gentoo /bin/bash
> env-update
> source /etc/profile
> export PS1="(chroot) $PS1"
> emerge --sync
> ls -FGg /etc/make.profile
> ls /usr/portage/profiles/default/linux/x86/10.0/
> less /usr/portage/profiles/use.desc
> nano -w /etc/make.conf (set USE flags)
> nano -w /etc/locale.gen (set localization parameters)
           ru_UA.UTF-8 UTF-8                                                                                       
           en_US.UTF-8 UTF-8
> locale-gen
> ls /usr/share/zoneinfo/ (find your time zone)
> cp /usr/share/zoneinfo/Europe/Kiev  /etc/localtime
> USE="-doc symlink" emerge gentoo-sources
> ls -l /usr/src/linux (check kernel symlink)
> emerge pciutils -av
> cd /usr/src/linux
> make menuconfig (configure kernel)
> make && make modules_install
> cp arch/i386/boot/bzImage /boot/linux-2.6.39-gentoo-r3_1
> nano -w /etc/fstab (configure partitions)
> nano -w /etc/conf.d/hostname
> nano -w /etc/conf.d/net
> cd /etc/init.d
> ln -s net.lo net.eth1
> rc-update add net.eth1 default
> nano -w /etc/hosts
> passwd
> nano -w /etc/rc.conf
> nano -w /etc/conf.d/keymaps
> nano -w /etc/conf.d/clock
> emerge syslog-ng
> rc-update add syslog-ng default
> emerge vixie-cron
> rc-update add vixie-cron default
> emerge sys-apps/mlocate
> emerge reiserfsprogs (you must setup programms to maintenance)
> emerge dhcpcd
> emerge grub
> grub
      grub> root (hd0,0)
      grub> setup (hd0)
      grub> quit
> exit
> cd
> umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
> reboot

пятница, 12 августа 2011 г.

LDOCE5 on linux arch x86_64

Longman Dictionary of Contemporary English 5 on linux arch x86_64
> uname -a
Linux solar 2.6.38-gentoo-r6 #13 SMP Mon Jul 11 00:10:55 EEST 2011 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux

1) Mount the iso (or cdrom):
> mount -o loop -t iso9660 /<path_to_iso>/ldoce5.iso /mnt/cdrom
2) Enter to cdrom folder:
> cd /mnt/cdrom
3) Execute the command:
> linux32 ./linux/setup.sh

You will see instalation window. Install, and use it! :)
Otherwise google search in help... :(

суббота, 30 июля 2011 г.

Webcam captured stream

1) USE FLAGS: 3dnow 3dnowext X alsa amr bzip2 encode hardcoded-tables mmx mmxext mp3 network ssse3 theora threads v4l v4l2 vorbis x264 xvid zlib

2) emerge media-video/ffmpeg -av

3) nano -w /etc/ffserver.conf

# Порт, на котором будет работать ffserver                                                                                                                                        
#Port 12345                                                                                                                                                                      
Port 8090                                                                                                                                                                        
# Адрес, на котором будет работать ffserver.                                                                                                                                      
# Если указать 0.0.0.0 то будут использованы все доступные адреса                                                                                                                
BindAddress 0.0.0.0                                                                                                                                                              
# Максимальное количество обслуживаемых соединений                                                                                                                                
MaxHTTPConnections 2000                                                                                                                                                          
# Максимальное количество клиентов                                                                                                                                                
MaxClients 1000                                                                                                                                                                  
# Максимальная используемая полоса (в килобитах)                                                                                                                                  
MaxBandwidth 2000                                                                                                                                                                
# Файл журнала. Формат подобен формату лога apache                                                                                                                                
CustomLog /var/log/ffserver-access.log                                                                                                                                            
# Описываем источник                                                                                                                                                              
<Feed webcam.ffm>                                                                                                                                                                
<------># Временный файл для хранения промежуточных данных                                                                                                                        
<------>File /tmp/webcam.ffm                                                                                                                                                      
<------># Максимальный размер файла с промежуточными данными                                                                                                                      
<------>FileMaxSize 3M                                                                                                                                                            
<------># Команда для запуска источника.                                                                                                                                          
<------># Адрес для отправки данных источником автоматически будет добавлен в конец этой строки                                                                                  
<------>Launch ffmpeg -s 640x480 -f video4linux2 -i /dev/video0                                                                                                                  
<------># С каких адресов может обращаться источник                                                                                                                              
<------>ACL allow 127.0.0.1                                                                                                                                                      
</Feed>                                                                                                                                                                          
# Описываем первый поток. Это будет поток в формате flv                                                                                                                          
<Stream webcam.flv>                                                                                                                                                              
<------># Источник потока                                                                                                                                                        
<------>Feed webcam.ffm                                                                                                                                                          
<------># Используемый формат                                                                                                                                                    
<------>Format flv                                                                                                                                                                
<------># Используемый кодек                                                                                                                                                      
<------>VideoCodec flv                                                                                                                                                            
<------># Частота кадров                                                                                                                                                          
<------>VideoFrameRate 30                                                                                                                                                        
<------># Размер буфера                                                                                                                                                          
<------>VideoBufferSize 80000                                                                                                                                                    
<------># Битрейт                                                                                                                                                                
<------>VideoBitRate 200                                                                                                                                                          
<------># Минимальное и максимальное качество                                                                                                                                    
<------>VideoQMin 1                                                                                                                                                              
<------>VideoQMax 5                                                                                                                                                              
<------># Размер видео. Дожно совпадать с размером видео на источнике                                                                                                            
<------>VideoSize 640x480                                                                                                                                                        
<------># Время ожидания перед началом отправки данных клиенту (в секундах)                                                                                                      
<------>PreRoll 1                                                                                                                                                                
<------># Звук мы транслировать не будем                                                                                                                                          
<------>NoAudio                                                                                                                                                                  
</Stream>                                                                                                                                                                        
# Второй поток. Это SWF-файл с FLV-потоком внутри                                                                                                                                
# Всё остальное по аналогии                                                                                                                                                      
<Stream webcam.swf>                                                                                                                                                              
<------>Feed webcam.ffm                                                                                                                                                          
<------>Format swf                                                                                                                                                                
<------>VideoCodec flv                                                                                                                                                            
<------>VideoFrameRate 30                                                                                                                                                        
<------>VideoBufferSize 80000                                                                                                                                                    
<------>VideoBitRate 200                                                                                                                                                          
<------>VideoQMin 1                                                                                                                                                              
<------>VideoQMax 5                                                                                                                                                              
<------>VideoSize 640x480                                                                                                                                                        
<------>PreRoll 1                                                                                                                                                                
<------>NoAudio                                                                                                                                                                  
</Stream>                                                                                                                                                                        
# При обращении к индексной страницы ffserver будем отображать текущий статус сервера                                                                                            
<Stream index.html>                                                                                                                                                              
<------>Format status                                                                                                                                                            
</Stream>

4) ffserver -f /etc/ffserver.conf


5)In browser follow url http://localhost:8090


6) On your page <embed src="http://<server address>:8090/webcam.swf" width=640 height=480 />


URLs:
http://www.mianet.ru/linux-gentoo-ffserver-a-ffmpeg
http://zenway.ru/page/ffserver

воскресенье, 10 июля 2011 г.

Webcam SVEN IC-960 WEB on Gentoo

>lsusb
  ...
  Bus 001 Device 005: ID 0c45:62f1 Microdia 

0c45 <- Vendor ID
62f1 <- Product ID

> dmesg
  ...
  [  113.897438] usb 1-4.2: Manufacturer: Sonix Technology Co., Ltd.
  ...

For more info about driver, installation, dpendencies, ... read kernel documentation
> less /usr/src/linux/Documentation/video4linux/sn9c102.txt

Drivers SN9C1* - not for my camera
Kernel configuration by this tutorial http://en.gentoo-wiki.com/wiki/Webcam
But without support of GSPCA drivers.
My driver is "USB Video Class (UVC)" (uvcdriver)
Also enable all v4l and v4l2 support in kernel
And no other devices can't be pluged to the same bus with webcamera (there is some driver bug, I hope developers fix that)