Просмотр поста

.
Fobos

Вобщем вот что получилось index.php

<?php
define('_IN_JOHNCMS', 1);
require_once('../incfiles/core.php');
require_once ("../incfiles/head.php");
include'function.php';
include'conf.php';



if(!isset($_POST['url'])){
echo'<form method="post" action="./do.php">';
echo'Ваша ссылка:<br />';
echo'<input name="url" type="text" value="http://" /><br />';
echo'<input type="submit" value="Укоротить" />
</form>';
echo'*Сервис предназначен для уменьшения ссылки<br/>Например:<br/>http://site.com/link/go/index.php?go=12324 на http://'.$_SERVER['HTTP_HOST'].'/435<br/>';
}
require_once ("../incfiles/end.php");
?>


do.php
<?php

define('_IN_JOHNCMS', 1);

$textl = 'Укоротитель ссылок';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
include'function.php';
include'conf.php';

if(!isset($_POST['kol'])){
$buff=file_get_contents("data.dat");
$id = newid();
$url = htmlspecialchars($_POST['url']);
$fopen=fopen("data.dat","w");
fputs($fopen, $id.":|:".$url."\r\n"."$buff");
fclose($fopen);

echo'Ваша новая ссылка: http://'.$domen.&#039;/'.$papka.$id.'<br />';
echo'Скопировать:<br />';
echo'<input type="text" value="http://'.$domen.'/'.$papka.$id.'" /><br />';

}


require_once ("../incfiles/end.php");
?>


function.php
<?php

function number($str) { 
$str = abs(intval($str));  
return $str;
}

function filter($str) { 
$str = htmlspecialchars($str);  
return $str;
}

function newid() {
$file=file('data.dat');
if (!empty($file[0])) {
$ex=explode(':|:',$file[0]);
return intval($ex[0])+1;
} else {
return '1'; }

}
?>


func.php
<?
$domen = '5element.tk';
$papka = 'lc/';
?>

теперь все отображается но оно по прежнему не пашет.
файл data.dat сохраняет введеный адрес:
1:|:http:// johncms.com/forum/index.php?type=topic&id=2493

адрес получается такой: http://5element.tk/lc/1
но не рабочий(