Perşembe, Ekim 27, 2011

Centos 6 Postgresql 9.1 Install

Today I have changed my mind and decided to begin learning and using Postgresql.
On a Centos 6 host there are some ways of installing Postgresql. I have chosen the easy one: use repos.
Here http://yum.pgrpms.org/repopackages.php is the official Postgresql repos for Red Hat related distros.
I have chosen the x86_64 rpm for Centos 6 and installed it. Later using
yum install postgresql91-server
I have installed three packages postgresql91,postgresql91-server and postgresql91-libs which is enough for now
to start Postgresql 9.1.
Using the instructions at /usr/share/doc/postgresql91-9.1.1/README.rpm-dist , I first did
service postgresql-9.1 initdb and then
service postgresql-9.1 start.Voila!
Now let the journey begin!
Edit:  Here is another place to look instructions
http://www.postgresonline.com/journal/archives/203-postgresql90-yum.html


Çarşamba, Ekim 26, 2011

Eclipse 3.7 PDT on Kubuntu

I have installed Eclipse 3.7 by using repos (universe maybe) and then installed PDT from within Eclipse.
I used the instructions on web page
http://wiki.eclipse.org/PDT/Installation#Install_a_JVM
by adding Indigo update site.
It works.Now its time to grab info about Aptana.

Perşembe, Ekim 06, 2011

Php 5.3 problems

I have stucked with Php 5.3 and Mysql 5.5 packages installed from Remi repo to Centos 5.7 server. So I removed them and decided to use distro's old packages.

Now it seems to work fine. I tr to satisfy Yii's requirements. Although the requirement checker says it is installable to my system, I try to provide more requirements for Yii

namely, APC,Dom,pdo_mysql etc. As you guess when installing packages (pdo_mysql,APC etc)  with pecl some problems happen. One of them happens when installing APC, the error

"make: *** [apc.lo] Error 1". The solution is to install pcre-devel package. I dont think APC is a good optimize, lets use it for the Yii's sake.

Yii journey continues

Since a couple of days I have been geting along with Yii. I follow the instructions from Larry Ullman's page. At first I try nginx as web server,

but when url rewriting and session handling I got some problems. I thought it is because of nginx,ie I mean I dont know the right way to fix nginx.

Then I started httpd and now trying it.As a requirement of Yii installation, I saw pdo_mysql needs to be installed. Now I try to install it.

Salı, Ekim 04, 2011

Yii Nginx Php FastCgi Url Rewrite Configuration

When you use yii url rewrite feature, actually it is configured for the apache web server. For people like me who uses nginx for web serving purposes one needs to do additional configuration to Yii. Here  is a good blog post which suggests a solution for our problem. After doing this one can get better written urls. Thanks for the info William.
Edit: Here is a snippet from Yii CookBook and here is a complete config for Yii,PHPFM and Nginx from Yii's wiki.

iRedMail for Centos 5.7

I tried iRedMail today on a Centos 5.7 server. The installation seems to smooth if you keep the distro's main packages unchanged.

Namely I have had enabled the remi repo which upgrades php and mysql packages. When installing iRedMail the upgraded packages

of mysql gave some syntax errors on some .sql scripts. After some search I manually configured them afterwards. So now iRedMail seems working.

One must notice that iRedMail tried to install required packages dont checking if they are already installed or not. So this is problematic. But there are some

ways disabling this behaviour.

Here are the sql problems I got

ERROR 1064 (42000) at line 4 in file: '/usr/share/doc/policyd-1.82/DATABASE.mysql': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 6 which is resolved by changing all occurences of TYPE with ENGINE in the script.

ERROR 1064 (42000) at line 17 in file: '/var/www/iRedAdmin-0.1.6/docs/samples/iredadmin.sql': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14) NOT NULL DEFAULT CURRENT_TIMESTAMP, which is resolved by deleting the number 14 at TIMESTAMP(14).

Because of those errors the user ireadadmin is not configured and I was getting internal server error at page www.domain.com/ireadadmin. The I found the password of iredadmin user at file /var/www/iredadmin/settings.ini and gave the grants.

Also I got some errors beforehand when initiating mysql server. I recognised that the lines

default-character-set   = utf8

skip-locking  at my.cnf  causing mysql die. So I commented them out and mysql began working.

What I learnt form this journey:

1- Keep the distro's packages unchanged if you want to use iRedMail.

2- Let iRedMail install those packages,ie. remove the packages which are pre-installed.

 

Pazartesi, Ekim 03, 2011

Php 5.3 Fastcgi contd

I found a way of starting php fastcgi processes thanks to howtoforge,.com article

Actually I have tried php-fpm with no success and didnt try any further. But it was really simple.

One needs to set

cgi.fix_pathinfo=0

at php.ini. And with proper user and group account names on

/etc/php-fpm.d/www.conf file, php-fpm just works.

 

Cumartesi, Ekim 01, 2011

Centos Remi Php 5.3 Fastcgi etc

Recently looking for centos 5.6 server's php update. Some 3rd party repos over there to choose from beside the centos testing repo. Tried Remi,Ius repos.

Generally there are dependency problems about packages and problems with fast cgi on php.

Dependency problems are crazy and discouraging.

When you upgrade to php 5.2 or 5.3 previously working fast-cgi programs could become not working.

Possible maybe-working cgi programs are spawn-fcgi and php-fpm.

Here are some working commands

 yum --enablerepo=remi install php-common php php-suhosin php-cli php-mysql mysql

spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -C 5 -U php

Cuma, Eylül 30, 2011

Upgrading php5.1 and mysql5.0 on Centos 5.6

On a vps environment I needed to upgrade php and mysql packages. I installed remi repo and did this command

yum --enablerepo=remi install php-common php php-suhosin php-cli php-mysql mysql

which warns that mysql and php packages are replaced with ones originating from remi's repo not from the rhel or fedora.

Now php is upgraded to 5.3.8 and mysql to 5.5.16

Çarşamba, Eylül 28, 2011

Draytek Router logs to central OpenBSD syslog server

OMG I spent 4-5 hours trying to send Draytek logs to an OpenBSD box. At last succeeded. Damn syslog has no information about facilities, previledeges etc.Without knowing anything about what kind of logs (I mean facilites,priviledeges etc) Draytek sends to openbsd I found a web page finally talking about the same problem. Inspired with this web page and after much time realising that syslog.conf DONT accept SPACES but TABS (OMG this made me crazy) I have succeeded relaying logs to OpenBSD box. Thanks to this web page  which enlightened me that it is mandatory to use tabs. Now I have lines like

local0.* /var/log/router-firewall.log
local1.* /var/log/router-vpn.log
local2.* /var/log/router-user.log
local3.* /var/log/router-call.log
local4.* /var/log/router-wan.log
local5.* /var/log/router-adsl.log

in syslog.conf which are seperated by TABS not SPACES. I still dont know what happens if I put another router into the same scheme or if another program sends logs to such damn facilities local0-7. Now it is working enough for me.

Edit: OMG I found a previous bookmark of mine from delicious which is about understanding the facility and previleges from routers packets.

Here it is. Shame on me.


Draytek Router logs to central OpenBSD syslog server

OMG I spent 4-5 hours trying to send Draytek logs to an OpenBSD box. At last succeeded. Damn syslog has no information about facilities, previledeges etc.Without knowing anything about what kind of logs (I mean facilites,priviledeges etc) Draytek sends to openbsd I found a web page finally talking about the same problem. Inspired with this web page and after much time realising that syslog.conf DONT accept SPACES but TABS (OMG this made me crazy) I have succeeded relaying logs to OpenBSD box. Thanks to this web page  which enlightened me that it is mandatory to use tabs. Now I have lines like
local0.* /var/log/router-firewall.log
local1.* /var/log/router-vpn.log
local2.* /var/log/router-user.log
local3.* /var/log/router-call.log
local4.* /var/log/router-wan.log
local5.* /var/log/router-adsl.log

in syslog.conf which are seperated by TABS not SPACES. I still dont know what happens if I put another router into the same scheme or if another program sends logs to such damn facilities local0-7. Now it is working enough for me.




Update: As mentioned in this page the received packets have some info like <150> or <174> etc. These numbers inside <> signs indicate which facility and severity value used. For example 150=10010110 and last 3 digits represents the severity 110=6 which is .info and the remaining digits 10010=18 which is facility local2 according to rfc section 4.1.1. Thus in syslogd.conf  file to capture these packets, one needs a line like  

local2.info  /var/log/router2.log 

Salı, Haziran 28, 2011

Php urlencode and Curl

I struggle again with curl and html parsing. The VIEWSTATE variables are sometimes hard to deal with. Strange enough, php and curl adds +%0A to the end of an urlencoded variable. And as you might guess this poisons the VIEWSTATE mechanism. A workaround that I used is to trim +%0A at the end of urlencoded strings by substr function.

Perşembe, Mayıs 12, 2011

Clonezilla and Windows XP cloning

This was a long and tiring day.I learned a lot about clonezilla and windows xp. I first tried to clone partitions and whole disks in different ways. In clonezilla terms these are device to image file or device to device. I couldnt much succeded in device to device option. May be due to lack of reading howto and wiki. Clonezilla first asks the device or place where  the image is going to be stored or read from. That comes to me weird at the beginning to me but later I got used to it. I cloned partitions or disks to images which are located in usb disks,local disks or even on an ssh server.This was fun. Then when it comes to restore the problems begin :) .OK. Yes there are some problems which are behind the doors and waiting you after or while restoring images. Firstly Clonezilla cant restore to a smaller hard drive or partition. To make it restore to a smaller drive in FAQ it is stated that one must use gparted or else to shrink the original partition before making the image. So this is one thing. If you wish to restore to a smaller disk first you must make the original drive smaller. Secondly Clonezilla is very strict about partition names. Namely if you wish to restore an image taken from partition say /dev/sda5 to a partition /dev/sda6 you must make some modifications on the image files. I have done manual modifications by sed and I think I was close the solution. My case was very different. I had a weird install of Windows XP. It was installed to second partition on the disk. And while changing the names I guess there happened a mistake. Because it is installed on the second partition boot loader was written to first partition and so was boot.ini file. I got some "ntldr is missing" and "boot.ini file is missing" or like that errors which I overcame with using recovery console of Windows XP install cd.It was another informative story for me. I learned to use copying bootloader files and rebuilding boot.ini file as stated in http://support.microsoft.com/kb/330184 http://www.quickonlinetips.com/archives/2005/12/ntldr-is-missing-press-any-key-to-restart/ .I wanted to restore an image which was for /dev/sda5 to a partition on /dev/sdb1. I was almost succesful. Almost because now XP doesnt boot ie. boot hangs displaying blue windows logo.

Today also I learned much about IDE drives and bios options. I used 2 old ide drives and a cdrom for these hacks. It was another informative story.

Clonezilla seems to be a good solution for cloning but be very aware of how to restore your images.

BTW I heard another cloning solution for Windows which is named FOG. It has some numerous other features than clonezilla. This would be another days' story.

Perşembe, Nisan 28, 2011

Windows 7 Windows Explorer fix

On a computer when right clicked on the desktop one was getting the alert saying that "Windows Explorer stopped working.Trying to find solutions.." etc. I first tried to do "sfc /scannow" on a root command prompt which gave that everything is OK. Then I started investigating the cause of Windows Explorer's crash by navigating through Event Viewer. And I found entries which clued that explorer.exe's crash is due to shell extensions dll file. Then I realised that there is a good shell extensions viewer provided free by Nirsoft at http://www.nirsoft.net/utils/shexview.html. Thanks to these guys I used the program and found the third party extension which I guess infected by a malicious program. First disabled it and checked that if it causes the crash, then removed the Registry keys of it. Voila now the explorer.exe is working just fine.

 

Salı, Nisan 26, 2011

Pdf Editing with Openoffice.org

Yes thats true and awesome. You can edit pdf files (with some restrictions) on openoffice.org 3.0+. You must install the oracle-pdfimport extension. Nice work!

Çarşamba, Nisan 20, 2011

VirtualBox 4.0 Closed Source Edition On Ubuntu Server 10.10

Ok trying to configure a windows xp guest on this server, I did the directions on the manual at virtualbox.org. I used VBoxHeadless which is great for a server environment. Previously I tried virtual OSE provided by Ubuntu repos whose version is 3.2.8 at the time.But it seemed that OSE doesnt support vrdp although here is a post claiming otherwise http://forums.freebsd.org/showthread.php?t=13499. Then I decided to install closed source edition from the provider according to this post http://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.0-on-a-headless-ubuntu-10.10-server.Everything worked fine and I installed the guest host. Then I noticed that there are two mouse pointers and the resolution is not adjustable. Then after some work I reinvented (remembered) that one must need to install guest additions thing too. After installing it now the machine working nice.

Cuma, Mart 11, 2011

Getting along with Django

These days I am tackling with Django on a centos server. I installed django package downloaded from its site.Started a simple app. Now trying to use

database mysql. When it ocmes to mysql I needed to install some packages like mysql-devel,python-devel and most importantly MySQL-python (notice the capital letters).

An older version of this is in centos stable repos.After some search I learned I can install it in different ways like compiling or using test repo.I chose

the former and installed python-setuptools. And then I realised that there is easy_install in this package which helps me installing the required MySQL-python

package. And voila.

Çarşamba, Şubat 23, 2011

Getting along with JQuery,Validation,Masked Input

JQuery is a nice library with whom I havent played till yesterday. Since yesterday I am struggling with this nice library, actually not solely with it but with validation plugin. That plugin is nice too but when it comes to integrating it with another plugin which you guess Masked Input, I was having problems. Because my form is dinamic and I am adding elements whose names are the as previous ones, I have struggled a lot. But at the end I did what I wanted to do. This

jQuery.validator.addMethod("acceptreg", function(value, element, param) {
  return value.match(new RegExp("^" + param + "$"));
});

small code piece helped me a lot when validating text and phone fields and their integration with Masked Input. I know validation plugin normally does validate against phone but my case was different. I declared such a method as described above and used it inside with

tel: {
required: true, minlength:11, maxlength:11,acceptreg: "[0-9]{3}-[0-9]{7}"
},

I did some dom manipulation with dom adding and removing dom elements too.I struggled a lot but after I am pleased to work deeper with javascript and JQuery.

 

Salı, Şubat 15, 2011

Centos mcelog reports incorrect record size

On a centos 5.5 64 bit server I was getting mcelog errors from cron.hourly/mcelog.cron stating

"/etc/cron.hourly/mcelog.cron:

mcelog: warning: record length longer than expected. Consider update"

As a workaround I did add 2>&1 to the last line of /etc/cron.hourly/mcelog.cron file as mentioned in Known Issues in this page

http://elrepo.org/tiki/kernel-ml

 

 

Centos Sendmail Problem

On a centos 5.5 server I was getting sendmail errors which I didnt want to try to solve. Then I installed postfix as an alternative and it does the job now.

 

Perşembe, Şubat 03, 2011

An Encryption Method

Lately I have been told to make a new encryption method as an assignment. The method should be not preused and tried before. So it was me who is supposed to invent a new encryption method.

I have thought of Rubik's cube and placing the letters of the alphabet on this cube. Then the coordinates of each letter would be send as ciphertext. Thinking on it lead to some diffucilties. So I decided to

take another way. I believe that a good  encryption technique is still available by using Rubik's cube but for now I quitted. Instead, I thought of 3x3 or 5x5 squares on which we place the letters beginning from

an arbitrary letter but obeying the order. So here is an example with a 3x3 square

 

2HIJ
1KLM
0NOP
 012

With such a layout we represent each letter on this square using the pivot letter (lets say) L

H=L02   I=L12   J=L 22   K=L01  L=L11  M=L21 etc.  On a 5x5 square we will have similar representations of letters.

Even one can generalize this to an (2n+1)x(2n+1) square.

So as understood, when we change the pivot letter, the encryption changes. So a letter will have many encryptions.

As a rule for this method of encryption, if we used a 5x5 square then we need to declare it after the pivot letter.

So in that case say your encryption would look like M=K531  where K is the pivot letter. But if we used a 3x3 square then

we omit and simply write as shown above.

As another rule of this method of encryption, if a pivot table is used more than one successive encrypitions then we dont

declare each time the pivot letter and instead write like this K5311203  which when decrypted says we used a K pivotted 5x5 square

and the coordinates of 3 encrypted letters are 31,12,03 according to this square.

Here is an encryption of message "TOPSECRET"

R542R5430232G22I5131033P20.

Here are others T11J52131W533L503343103Y523, P20N532Z52403C00F12O10D21T11, Q10O112120N534L534U12B501V22 etc.

The restrictions to this method is that we can only use capital English letters and nothing even a space is not supported.

I have implemented a php script to encrypt and decrypt messages sent by this way.

Here is the script.

<?php
//Bu Program Ingiliz alfabesindeki buyuk harflerle yazilmis bosluksuz bir metni sifreler ve cozer.
//Programda phpnin chr ve ord fonksiyonlari kullanilmak istendigi ve kolay olmasi icin sadece buyuk harfler
//secildi.Aslinda diger harf ve karakterler array kullanilarak istenildigi gibi sifrelenebilir.
//Programda boslugu eklemek program bitince aklima geldi.Eklemek de vakit alacagi icin yapamadim.
//O yuzden su anda bosluksuz metinleri sifreliyor.
//Semalarimiz 3x3 ve 5x5 boyutlarinda.Aslinda genellestirilebilir.
//Kullanilan sema 5x5 boyutunda ise ciphertexte 5 ekleniyor.3x3 ise  hicbir sey eklenmiyor.
//Pivot degismedi ise ciphertexte yazilmiyor.Sadece koordinatlar ekleniyor.
//Sifreleme yontemi hic bir yerden alinti degildir.
//Koordinat bulmak icin gerekli arrayleri elle olusturdum.Size daha once gonderdigim word dosyasindaki koordinat bulma
//formullerini dogru ama eksiklik var.Array varken algoritma yazmak da gereksiz diye dusundum.
//Ornegin $arr3=array(-4=>"02",-3=>"12",-2=>"22",-1=>"01",0=>"11",1=>"21",2=>"00",3=>"10",4=>"20");
//arrayinde 02 koordinatindaki bir harf 3x3luk semada pivot harften 4 onceki harftir(ASCII sirasinda gore)
//Yazan Sinan Iyisoy

function pivotbul($sifrelenecek,$sema)
{
//Sifrelemede kullanmak icin bir pivot bulur.Pivotun uygun sartlarda secilmesi gereklidir.
//Semanin boyutu 3 ise Sifrelenecek olan harfin pivot harfe uzakligi -4 ve 4 arasinda olmalidir
//Semanin boyutu 5 ise bu uzaklik -12 ve 12 arasinda olmalidir.Aksi halde harf karenin disinda kalir.
//O yuzden uygun pivot bulana kadar doner.

    if($sema==3) $uzaklik=4;
    if($sema==5) $uzaklik=12;

    do
    {
    //A ile Z arasinda bir harf secelim. A nin ASCII degeri 65, Z nin 90.
    $pivot=rand(65,90);
    }
    while(abs(ord($sifrelenecek)-$pivot)>$uzaklik);
    // Aradaki fark uzakliktan buyuk olmamali.
    return $pivot;

}


function koordinatbul($fark,$sema)
    {
//Ascii degerleri arasindaki farka bakarak ciphertextin semadaki koordinatlarini bulur.
//Bu fonksiyon encrypt etmede kullanilir.
//Farka bakarak harfin semadaki koordinatlarini bulalim.
    $arr3=array(-4=>"02",-3=>"12",-2=>"22",-1=>"01",0=>"11",1=>"21",2=>"00",3=>"10",4=>"20");
    $arr5=array(-12=>"04",-11=>"14",-10=>"24",-9=>"34",-8=>"44",-7=>"03",-6=>"13",-5=>"23",-4=>"33",-3=>"43",
    -2=>"02",-1=>"12",0=>"22",1=>"32",2=>"42",3=>"01",4=>"11",5=>"21",6=>"31",7=>"41",8=>"00",9=>"10",10=>"20",11=>"30",12=>"40");
    if($sema==3) $koordinat=$arr3[$fark];
    if($sema==5) $koordinat=$arr5[$fark];

    return $koordinat;
    }



function encrypt($string)
{
//Bu fonksiyon girilen metni sifreler.
//Sifreleme icin once bir pivot ve sema secer.Bu sema ve pivotun olusturdugu semada harfin koordinatlarini ciphertexte ekler.
//Metni sifrelerken zar atar.Eger zar 1 ise yeni bir pivot harf belirler.Ve sifrelenecek metni ona gore sifreler.
//Eger zar 2 ise ve sartlar uygunsa eski pivota gore sifreler.Sartlar uygun degilse yeni pivot secer.
//Default sema 3 tur.Eger sema 3 ise bu bilgiyi ciphertexte yazmaz.5 ise yazar.
//Pivot degistiyse yeni pivotu ciphertexte ekler.Degismediyse eklemez.
$sifrelenmis="";
$pivot="";
$eskisema="";

for($i=0;$i<strlen($string);$i++)
    {


    //Sifrelenecek olan harf

    $harf=$string[$i];

    //Harfin ASCII degeri

    $ascii=ord($harf);
     

    $zar=rand(1,2);
    if($pivot!="")
        {
            if($zar==1)  //Zar bir ise yeni pivot isteyelim degilse eski pivotla devam
                {
                //Sifreleme icin pivot harfi bulalim
                $sema=rand(1,2)*2+1;
                $pivot=pivotbul($harf,$sema);
                $pivotekle=true;  //$pivotekle yeni pivot secildigi icin yeni pivotu ciphertexte ekler
               
                }
            else
            {
                // Yeni pivot secmedik.Ama $farki kontrol etmeliyiz.Aksi halde harf karenin disinda olur.Karenin disindaysa yeni pivot seciyoruz.
                if(($sema==3 && abs($pivot-$ascii)>4) || ($sema==5 && abs($pivot-$ascii)>12))
                {
                $sema=rand(1,2)*2+1;
                $pivot=pivotbul($harf,$sema);
                $pivotekle=true;
                }
                else
                {
                $sema=$eskisema;  //pivot degismedi.Sema da degismemeli.
                $pivotekle=false;
                }
               
            }
        }
    else //Hic pivot yoksa bir pivot bulalim
        {
        $sema=rand(1,2)*2+1;
        $pivot=pivotbul($harf,$sema);
        $pivotekle=true;
        }

    $fark=$ascii-$pivot;
    $koordinat=koordinatbul($fark,$sema);
    if($pivotekle)
    {
   
    $sifrelenmis.=chr($pivot);
    if($sema==5)  //$sema 5 olunca 5 oldugunu belirtiyoruz.3 ise bir sey yapmiyoruz.
    {
    $sifrelenmis.=$sema;
    }
    }

    $eskisema=$sema;
    $sifrelenmis.=$koordinat;
    }

return $sifrelenmis;
}


function terskoordinatbul($tersfark,$sema)
    {
    //Koordinatlara bakarak ciphertext ile pivot arasindaki ascii deger farkini bulur.
    //Bu fonksiyon decrypt etmede kullanilir.
   
    $arr3=array("02"=>-4,"12"=>-3,"22"=>-2,"01"=>-1,"11"=>0,"21"=>1,"00"=>2,"10"=>3,"20"=>4);
    $arr5=array("04"=>-12,"14"=>-11,"24"=>-10,"34"=>-9,"44"=>-8,"03"=>-7,"13"=>-6,"23"=>-5,"33"=>-4,"43"=>-3,
    "02"=>-2,"12"=>-1,"22"=>0,"32"=>1,"42"=>2,"01"=>3,"11"=>4,"21"=>5,"31"=>6,"41"=>7,"00"=>8,"10"=>9,"20"=>10,"30"=>11,"40"=>12);
    if($sema==3) $koordinat=$arr3[$tersfark];
    if($sema==5) $koordinat=$arr5[$tersfark];

    return $koordinat;
    }



function decrypt($string)
{
//Bu fonksiyon cypertexti harf harf okuyarak decrypt yapar.
//Bu okuma sirasinda eger bulunan bir alfabetik harf ise bufferdaki sifreli metni cozer.
//Eger bulunan 5 ise sema degerini 5 yapar.
//Eger bulunan bunlarin harincindeyse buffera atar.
//Default sema degeri 3tur.

$buffer="";
$cozum="";
for($i=0;$i<strlen($string);$i++)
    {
    //Desifrelenecek olan harf

    $harf=$string[$i];
    $ascii=ord($harf);
    if($ascii>=65 && $ascii<=90)
    {
        if($buffer!="")  //Daha once pivot bulunmus,decrypt baslasin
        {
            if($sema=="") //Daha once $sema bulunmamis o zaman $sema 3
            {
            $sema=3;
            }
            for($j=0;$j<strlen($buffer);$j++)
                {
                if($j%2==0) //Ikiser ikiser rakamlari almaliyiz
                {
                $terskoordinat=$buffer[$j].$buffer[$j+1];
                $tersfark=terskoordinatbul($terskoordinat,$sema);
                $cozum.=chr($pivot+$tersfark);
                }
                }
            $buffer="";
        }
    $pivot=$ascii;
    $sema="";
    }
    elseif($harf==5)
    {
    $sema=5;
    }
    else
    {
    $buffer.=$harf;  //Eger okunan deger ne pivot ne de sema ise buffera atiyoruz.
    }
   
   
    }
   
   
    //Donguden kalan buffer icin decrypt yapmaliyiz.Dongu bitiyor ama islenmemis buffer kaliyor.
        if($sema=="") //Daha once $sema bulunmamis o zaman $sema 3
            {
            $sema=3;
            }
        for($j=0;$j<strlen($buffer);$j++)
            {
            if($j%2==0)
            {
            $terskoordinat=$buffer[$j].$buffer[$j+1];
            $tersfark=terskoordinatbul($terskoordinat,$sema);
            $cozum.=chr($pivot+$tersfark);
            }
            }
        $buffer="";
       
   
    return $cozum;

}


//Ornek kullanim

$r=encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
echo $r."\n";
echo decrypt($r)."\n";





?>

 

Salı, Ocak 25, 2011

Windows Server Anomalities

Lately I have been struggling on port forwarding to a windows 2003 server from different modems. There were 4 modems pointing to same windows server port.

I couldnt have succeeded in forwarding all these same ports from 4 modems to this server. Some were pointing some wasnt. I finally realised that this is a stupid mistake

about windows routing configuration. I have had enabled the auto metric configuration for the gateways. But that was the wrong thing I did. There were different metrics

for each gateway and this was causing the trouble. I changed them to same number and voila. All ports are forwarding coreectly.

 

Çarşamba, Ocak 19, 2011

Centos Nginx PHP APC FastCGI 2 (Dealing with problems)

My journey to nginx continues with problems that follow up. I have had 3-4 problems to get nginx work. But after resolving them voila. It works now :)

The problems were:

directory index of "/usr/share/nginx/html/vhosts/domain.com/subdomains/data/" is forbidden -> Solved by writing the correct domain name to nginx.conf or any of virtual host files.

No input file specified -> Solved by writing the full path of php scripts to one of my virtual host conf.

FastCGI sent in stderr: "PHP Fatal error:  Uncaught exception 'Zend_Session_Exception' with message
 'Zend_Session::start() - /usr/share/nginx/html/vhosts/lib/Zend/Session.php(Line:438): Error #2 session_start()

-> which is solved by giving correct ownership to folders /var/lib/php and /var/lib/php/session. Before those folders owned by

root.apache and I changed them to root.php where php is the correct user.

Now lets benchmark the sites!

 

Centos Nginx PHP APC FastCGI

These days I am working on centos vps installation. I try nginx for the first time and heard that it will be delicious when it is served with php,apc and fastcgi.

I began by enabling EPEL repos to centos. Installed php and its required modules. Then nginx and applied its fast-cgi patch according to nginx's wiki site.

Alternatively one can use spawn-fcgi program, I installed but not using right now. Then it comes apc. For that install php-pear and then "pecl install apc".

If you get an error like "ERROR: make failed" as in my case, try installing pcre-devel and after that pecl install apc works. And lets try if all is working.

 

Cuma, Ocak 07, 2011

"ssh_exchange_identification connection closed" error

I have getting these messages from a windows install of bash and ssh when I try connecting to this host.

The problem was about reverse dns resolution.Ssh cant resolve reverse dns's of clients and because of

"ALL:PARANOID:DENY" directive on /etc/hosts.allow file on this host, it was refusing the connections.

To resolve it I commented out this directive and restarted the service and ohh.