[0] > http: [3] > 1234 $source = array_pop($source_raw); //last value of array, i.e. 1234 $trg = $_POST['link']; $trg = ltrim($trg, "https://"); // i.e. http://www.rahvaraamat.ee/dawda/dawd?123123==123 $trg = ltrim($trg, "http://"); // i.e. www.rahvaraamat.ee/dawda/dawd?123123==123 $trg_exp = explode("/", $trg); //generate array i.e. [0] => www.rahvaraamat.ee, [1] => dawda $target = array_shift($trg_exp); //get target i.e. [www.rahvaraamat.ee] $type = $_POST['type']; // get ID as type (optional) //if type is lehitse $pos = strpos($_POST['klass'], "lehitse"); if($pos !== false) { $src_raw = explode('-', $_POST['type']); $source = array_pop($src_raw); $type = 'lehitse'; $target = 'pdf'; } // //if banner $pos = strpos($target, "raamatumaailm"); if($pos !== false) { $source = '0'; $target = 'node/'.array_pop($trg_exp); } // $ip = $_SERVER["REMOTE_ADDR"]; $ts = mktime(); $dbhost = 'd21204.mysql.zone.ee'; $dbuser = 'd21204sa27893'; $dbpass = '63bWdC'; $dbname = 'd21204sd21172'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die; mysql_select_db($dbname) or die(mysql_error()); $sql = "INSERT INTO statistics_track "; $sql .= "VALUES ('', '".$source."', '".$target."', '".$ip."', '".$type."', '".$ts."');"; $q = mysql_query($sql); ?>