\">\n\t\t\t\n\t\t\t
| Website URL: | \n\t\t\t\t\t\turl}\" /> | \n\t\t\t\t\t\t\n\t\t\t\t\t |
| Website title: (one pr. line) | \n\t\t\t\t\t\t\n\t\t\t\t\t\t | \n\t\t\t\t\t |
| Description: | \n\t\t\t\t\t\t\n\t\t\t\t\t\t | \n\t\t\t\t\t |
| Alternative backlinks: (one pr. line) | \n\t\t\t\t\t\t\n\t\t\t\t\t\t | \n\t\t\t\t\t |
| Rules: | \n\t\t\t\t\t\t\n\t\t\t\t\t\t | \n\t\t\t\t\t |
| Mass add | \n\t\t\tBatch import links into LinkEX | \n\t\t
| Send email | \n\t\t\tSend an email to one or more webmasters | \n\t\t
| Autoadd | \n\t\t\tAutomatically add your site to other link exchange scripts. (BETA. Let me know how it works for you) | \n\t\t
| Pagerank Test | \n\t\t\tHaving problems with PageRank? Use this tool to debug the communication with Google. | \n\t\t
END;
$pr = new PageRank;
$url = 'http://linkex.dk';
echo "Testing pagerank for: $url\n";
echo "Calculation Google Cookie (expecting 773196802182)\n";
$cookie = $pr->getCH( $url );
echo " $cookie - ";
if ( $cookie == "773196802182" ) {
echo "passed\n";
$host = $pr->hosts[ mt_rand( 0, sizeof( $pr->hosts ) - 1 ) ];
$ip = linkex::gethostbyname( $host, true );
echo "Requesting info from Google (using $host - $ip)\n";
$fp = fsockopen( $ip, 80, $errno, $error, 2 );
if ( $fp ) {
$header = '';
$header .= "GET /search?client=navclient-auto&ch=" . $cookie . "&features=Rank&q=info:" . $url . " HTTP/1.1\r\n" ;
$header .= "Host: ".$host."\r\n" ;
$header .= "Connection: Close\r\n\r\n" ;
fwrite( $fp, $header );
$data = '';
while ( !feof( $fp ) ) {
$data .= fgets( $fp, 128 );
}
fclose( $fp );
if ( preg_match( '#(HTTP/\d+\.\d+\s+(\d{3}))#Umis', $data, $res ) ) {
if ( $res[2] == '200' ) {
echo " ".$res[1]."\n";
if ( ( $pos = strpos( $data, 'Rank_' ) ) !== false ) {
$pagerank = intval( trim( substr( $data, $pos + 9 ) ) );
echo " PageRank for $url - $pagerank\n";
echo " Test ended successfully\n";
} else {
echo " Did not find Rank_ in body of document\n";
echo "\n".htmlentities( $data );
}
} else {
echo "\n".htmlentities( $data );
}
} else {
$data = explode( "\n", str_replace( "\r", '', $data ) );
echo " Get invalid response from $host - ".$data[0]."\n";
}
} else {
echo " unable to create socket to $host - $error\n";
}
} else {
echo "failed\n";
}
echo <<
END;
break; // }}}
}
break;
case 'upgrade':
function debug( $str ) { // {{{
echo "";
linkex::flush();
} // }}}
echo template::header( array( 'title' => 'Upgrading LinkEX' ) );
$legend = 'Upgrading LinkEX';
echo "\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\n";
echo template::footer();
linkex::flush();
if ( ( $fp = @fopen( 'index.php', 'a' ) ) === false ) {
// Unable to write to index.php
debug( 'Cannot open index.php for writing. Please check the permissions.' );
exit;
}
fclose ( $fp );
debug( 'Cheking file permissions.. done' );
if ( @copy( __FILE__, BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'index.'.date( 'Ymd' ).'.php' ) === false ) {
debug( 'Unable to backup LinkEX script' );
exit;
}
debug( 'Backing up current version.. done' );
$md5 = linkex::fetch( 'http://linkex.dk/releases/current.md5' );
if ( ( $error = linkex::get( 'error', $md5, false ) ) !== false ) {
debug( 'Error while fetching version checkum ('.$md5['error'].')' );
exit;
} else if ( strlen( trim( linkex::get( 'contents', $md5, '' ) ) ) != 32 ) {
debug( 'Invalid response while fetching version checksum.' );
exit;
}
$checksum = trim( linkex::get( 'contents', $md5, '' ) );
debug( 'Fetching new version checksum.. ['.$checksum.']' );
$script = linkex::fetch( 'http://linkex.dk/releases/current.tar' );
if ( ( $error = linkex::get( 'error', $md5, false ) ) !== false ) {
debug( 'Error while fetching new script ('.$md5['error'].')' );
exit;
}
debug( 'Fetching new version data file.. done' );
$script = linkex::get( 'contents', $script, '' );
if ( strcmp( strtolower( md5( $script ) ), strtolower( $checksum ) ) != 0 ) {
debug( 'Verifying script checksum.. Error! Checksum mismatch' );
exit;
}
debug( 'Verifying script checksum.. done' );
linkex::fileput( __FILE__, $script );
debug( 'Installing new version.. done' );
debug( '
Upgrade complete.' );
break;
default:
linkex::redirect( BASEURI, 404 );
}
} else {
echo template::header( array( 'title' => 'Please login', 'metarobots' => 'noindex,follow' ) );
echo "\n\t\n\n";
echo template::footer();
}
break;
case 'check':
@set_time_limit( 0 );
// Remote check
function checkoutput( $code, $str ) { // {{{
die( "{$code}:{$str}\n" );
} // }}}
// {{{ Is this thing enabled?
if ( intval( $config->remoteenable ) == 0 ) {
checkoutput( 1, 'Remote access is not enabled' );
}
// }}}
// {{{ IP check
if ( intval( $config->remotelimitips ) == 1 ) {
$ips = $config->remoteips;
$found = false;
$remote = linkex::get( 'REMOTE_ADDR', $_SERVER, '' );
foreach( $ips AS $ip ) {
if ( linkex::compareIPs( $ip, $remote ) == 0 ) {
$found = true;
break;
}
}
if ( $found !== true ) {
checkoutput( 2, 'Your IP ('.$remote.') is not in the accepted IP list' );
}
}
// }}}
// {{{ Passphrase check
if ( ( $pass = $config->remotepass ) && strlen( $pass ) > 0 ) {
if ( linkex::get( 'passphrase', $_GET, false ) != $pass ) {
checkoutput( 3, 'Invalid or missing passphrase' );
}
}
// }}}
$report = linkex::verifybacklinks( linkex::listfiles( BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'links' . DIRECTORY_SEPARATOR ) );
if ( $config->remotesummary == 1 ) {
$report = template::report( $report );
linkex::mail( $config->email, 'Link verification report', $report );
}
checkoutput( 0, 'OK' );
break;
case 'about':
echo template::header( array( 'title' => 'About', 'metarobots' => 'noindex,follow' ) );
echo template::about();
echo template::footer();
break;
case 'logout':
$path = dirname( linkex::get( 'SCRIPT_NAME', $_SERVER, '/' ) );
setcookie( '_authcookie', '', time() - 3600, $path );
unset( $_SESSION['_authcookie'] );
linkex::redirect( BASEURI, 301 );
case '':
// Add link
if ( !LOGGEDIN && intval( $config->disablepublicform ) == 1 ) {
echo template::header( array( 'title' => 'Add link', 'metadescription' => 'Exchange hardlinks with '.$config->domain ) );
echo "\n\t\n\n";
echo template::footer();
} else {
if ( sizeof( $_POST ) > 0 ) {
if (
(
intval( $config->usecaptcha ) == 0
) || (
intval( $config->usecaptcha ) == 1 &&
linkex::get( 'captcha', $_POST, false ) &&
linkex::get( 'captcha', $_SESSION, false ) && linkex::get( 'result', $_SESSION['captcha'], false ) &&
$_POST['captcha'] == $_SESSION['captcha']['result']
)
) {
$link = new link;
$link->wmip = $_SERVER['REMOTE_ADDR'];
$link->lurl = htmlentities( linkex::get( 'lurl', $_POST, '' ) );
if (
$config->disablerecipfield == 1 && !LOGGEDIN &&
$config->samedomain != 2
) {
$link->rurl = $link->lurl;
} else {
$link->rurl = htmlentities( linkex::get( 'rurl', $_POST, '' ) );
}
// Damn stupid noobish exploit
$link->anchor = trim( linkex::get( 'anchor', $_POST, '' ) );
$link->description = trim( linkex::get( 'description', $_POST, '' ) );
$link->categories = linkex::get( 'categories', $_POST, $config->defaultcategories );
if ( !is_array( $link->categories ) ) {
$link->categories = array( $link->categories );
}
$link->categories = linkex::map( 'intval', $link->categories );
$link->email = htmlentities( trim( linkex::get( 'email', $_POST, '' ) ) );
// Start link validation
// {{{ Check the anchor
if ( strlen( $link->anchor ) == 0 ) {
$errors[] = 'Please fill out the title';
}
// }}}
// {{{ Check the lurl
if ( strlen( $link->lurl ) == 0 ) {
$errors[] = 'Please fill out the URL';
} else if ( !preg_match( '/^https?:\/\/(.*\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?\.[a-z]+(.*)?/i', $link->lurl ) ) {
$errors[] = 'The URL "'.$link->lurl.'" in invalid';
}
// }}}
// {{{ Check the email
if ( strlen( $link->email ) == 0 ) {
$errors[] = 'Please enter an email address';
} else if ( !preg_match( '/\S+@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.[a-z]+(.*)?/i', $link->email ) ) {
$errors[] = 'The email "'.$link->email.'" is invalid';
}
// }}}
// {{{ Check the rurl
if ( intval( $config->disablerecipfield ) == 0 ) {
if ( strlen( $link->rurl ) == 0 ) {
$errors[] = 'Please fill out the reprocial URL';
} else if ( !preg_match( '/^https?:\/\/(.*\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?\.[a-z]+(.*)?/i', $link->rurl ) ) {
$errors[] = 'The reprocial URL "'.$link->rurl.'" in invalid';
}
}
// }}}
// {{{ Check the categories
if ( $config->publiccategories == 1 ) {
if ( sizeof( $link->categories ) == 0 ) {
$errors[] = 'Please select a category';
}
}
// }}}
$link->update();
$link->updateIPs();
// {{{ indexexchange
if ( $config->indexexchange == 1 ) {
$elems = @parse_url( $link->lurl );
if ( linkex::get( 'path', $elems, '/' ) != '/' ) {
$errors[] = 'Only index exchanges allowed';
}
if ( $link->lurl != $link->rurl ) {
$elems = @parse_url( $link->rurl );
if ( linkex::get( 'path', $elems, '/' ) != '/' ) {
$errors[] = 'Only index exchanges allowed';
}
}
}
// }}}
// {{{ noquerystring
if ( $config->noquerystring == 1 ) {
if ( strpos( $link->lurl, '?' ) !== false ) {
$errors[] = 'No querystrings allowed';
}
if ( $link->rurl != $link->lurl && strpos( $link->rurl, '?' ) !== false ) {
$errors[] = 'No querystrings allowed';
}
}
// }}}
// {{{ Same domain?
switch( intval( $config->samedomain ) ) {
case 1:
if ( linkex::compareURLs( $link->ldom, $link->rdom ) != 0 ) {
$errors[] = 'The submitted URLs must be on the same domain';
}
break;
case 2:
if ( intval( $config->disablerecipfield ) == 0 && linkex::compareURLs( $link->ldom, $link->rdom ) == 0 ) {
$errors[] = 'The submitted URLs must be on different domains';
}
break;
}
// }}}
// {{{ Check the length's
if ( sizeof( $errors ) == 0 && (( LOGGEDIN && linkex::get( 'skiplengths', $_POST, 0 ) == 0 ) || !LOGGEDIN ) ) {
// First the title
if ( $config->titlelength > 0 ) {
if ( $config->titlelengthtype == 'w' ) {
// Max words
if ( sizeof( preg_split( '#\s+#', $link->anchor ) ) > $config->titlelength ) {
$errors[] = sprintf( 'Your site title is too long' );
}
} else {
// Max len
if ( strlen( $link->anchor ) > $config->titlelength ) {
$errors[] = sprintf( 'Your site title is too long' );
}
}
}
// Then the description
if ( $config->descriptionlength > 0 ) {
if ( $config->descriptionlengthtype == 'w' ) {
// Max words
if ( sizeof( preg_split( '#\s+#', $link->description ) ) > $config->descriptionlength ) {
$errors[] = sprintf( 'Your site description is too long' );
}
} else {
// Max len
if ( strlen( $link->description ) > $config->descriptionlength ) {
$errors[] = sprintf( 'Your site description is too long' );
}
}
}
}
// }}}
// {{{ Check for dublicate domains/ips
if ( ( LOGGEDIN && linkex::get( 'skipdupes', $_POST, 0 ) == 0 ) || !LOGGEDIN ) {
$linkids = linkex::listfiles( BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'links' . DIRECTORY_SEPARATOR );
$ipcount = 0;
foreach ( $linkids AS $lid ) {
$l = new link( $lid );
$ipcount += ( linkex::compareIPs( $l->rdomip, $link->rdomip ) == 0 ) ? 1:0;
if ( $config->linkbotuniquedomains == 1 ) {
if ( linkex::compareURLs( $link->ldom, $l->ldom ) == 0 ) {
$errors[] = 'We allready have a link to "'.$l->ldom.'"';
break;
} else if ( linkex::compareURLs( $link->rdom, $l->rdom ) == 0 ) {
$errors[] = 'We allready have a link from "'.$l->rdom.'"';
break;
}
} else {
if ( linkex::compareURLs( $link->lurl, $l->lurl ) == 0 ) {
$errors[] = 'We allready have a link to "'.$l->lurl.'"';
break;
} else if ( linkex::compareURLs( $link->rurl, $l->rurl ) == 0 ) {
$errors[] = 'We allready have a link from "'.$l->rdom.'"';
break;
}
}
unset( $l );
}
if (
intval( $config->linkbotuniqueips )>0 &&
$ipcount >= intval( $config->linkbotuniqueips )
) {
$errors[] = 'We allready have '.intval($ipcount).' links from "'.$link->rdomip.'"';
}
}
// }}}
// {{{ Check the blacklist
if ( ( LOGGEDIN && linkex::get( 'skipblacklist', $_POST, 0 ) == 0 ) || !LOGGEDIN ) {
if ( sizeof( $errors ) == 0 && linkex::get( 'skipblacklist', $_POST, 0 ) == 0 && ( $reason = $link->blacklisted() ) !== false ) {
$errors[] = $reason;
}
}
// }}}
// {{{ Make sure a backlink is present
$link->lastchecked = time();
if (
sizeof( $errors ) == 0 &&
( ( LOGGEDIN && linkex::get( 'skipbacklinkcheck', $_POST, 0 ) == 0 ) || !LOGGEDIN ) &&
( ( $config->linkbackrequired == 1 ) || ( intval( $config->maxoutboundlinks ) > 0 ) ) &&
( $e=$link->hasBacklink() ) &&
linkex::get( 'res', $e, 0 ) != 0
) {
switch( linkex::get( 'res', $e, 0 ) ) {
case '1':
$errors[] = 'Unable to verify backlink. '.linkex::get( 'reason', $e, '' );
break;
case '2':
$errors[] = 'None of the links found on "'.$link->rurl.'" could be accepted. ' .
linkex::get( 'reason', $e, '' );
break;
case '4':
$errors[] = 'The anchor text of the backlink did not match the req'.'uired anchor text.';
break;
case '8':
$errors[] = 'None of the links found on "'.$link->rurl.'" could be accepted. ' .
linkex::get( 'reason', $e, '' );
break;
case '16':
$errors[] = linkex::get( 'reason', $e, '' );
break;
default:
$errors[] = 'Iternal error';
break;
}
}
$link->skipcheck = ( LOGGEDIN && linkex::get( 'skipbacklinkcheck', $_POST, 0 ) == 1 ) ? 1:0;
// }}}
// {{{ Check the min PageRank
// The pagerank must be checked if:
// ( config->minpagerank > 0 && !LOGGEDIN ) || ( LOGGEDIN && linkex::get( 'skippagerank', $_POST, 0 ) == 0 )
if (
sizeof( $errors ) == 0 &&
$config->minpagerank > 0 &&
!( LOGGEDIN && linkex::get( 'skippagerank', $_POST, 0 ) != 0 )
) {
if ( $link->getPageRank( false ) < $config->minpagerank ) {
$errors[] = 'We require a min. PR'.$pr.', your site has a PR'.$link->getPageRank( false ).'';
}
}
// }}}
if ( sizeof( $errors ) == 0 ) {
$link->save();
if ( !LOGGEDIN && strlen( $config->email ) > 4 ) {
$_SERVER['HTTP_HOST'] = str_replace( 'www.', '', strtolower( linkex::get( 'HTTP_HOST', $_SERVER, 'unknown' ) ) );
$host = $_SERVER['HTTP_HOST'];
$pagerank = $link->getPageRank();
linkex::mail( $config->email, 'LinkEX: new link @ '.linkex::get( 'HTTP_HOST', $_SERVER, 'unknown' ), "This is a message from {$host}.\n\nA new link was just added:\nEmail: {$link->email}\nLink URL: {$link->lurl} (IP:{$link->ldomip})\nRecip URL: {$link->rurl} (IP:{$link->rdomip})\nAnchor text: {$link->anchor}\nPageRank: {$pagerank}\n\n\n" );
}
echo template::header( array( 'title' => 'Link added' ) );
echo "\n\t\n\n";
echo template::footer();
exit;
}
} else {
// Captcha failed
$errors[] = 'Spam check failed. Please retry';
}
}
echo template::header( array( 'title' => 'Add link', 'metadescription' => 'Exchange hardlinks with '.$config->domain.'. Instant linkexchange' ) );
echo template::rules();
echo template::linkdetails();
echo template::linkform();
echo template::footer();
}
break;
default:
linkex::redirect( BASEURI, 404 );
}
}
} else {
$_username = linkex::get( '_username', $_POST, '' );
$_password1 = linkex::get( '_password1', $_POST, '' );
$_password2 = linkex::get( '_password2', $_POST, '' );
$_email = linkex::get( '_email', $_POST, '' );
$_url = linkex::get( '_url', $_POST, 'http://'.linkex::get( 'HTTP_HOST', $_SERVER, '' ) );
$_anchor = linkex::get( '_anchor', $_POST, '' );
if ( linkex::get( 'ok', $_POST, false ) !== false ) {
// Form is posted
// {{{ Check if we have a username
if ( strlen( trim( $_username ) ) == 0 ) {
$errors[] = 'Please enter a username';
}
// }}}
// {{{ Check the password(s)
if ( strlen( trim( $_password1 ) ) == 0 ) {
$errors[] = 'Please enter a password';
} else if ( trim( $_password1 ) != trim( $_password2 ) ) {
$errors[] = 'The two passwords did not match, please try again.';
}
// }}}
// {{{ Check the email
if ( strlen( trim( $_email ) ) == 0 ) {
$errors[] = 'Please enter an email address';
} else if ( !preg_match( '/\S+@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.[a-z]+(.*)?/i', $_email ) ) {
$errors[] = 'The email "'.$_email.'" is invalid';
}
// }}}
// {{{ Check the URL
if ( strlen( trim( $_url ) ) == 0 ) {
$errors[] = 'Please fill out the URL of your website';
} else if ( !preg_match( '/^https?:\/\/(.*\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?\.[a-z]+(.*)?/i', $_url ) ) {
$errors[] = 'The URL "'.$_url.'" in invalid';
}
// }}}
// {{{ Check the anchor
if ( strlen( trim( $_anchor ) ) == 0 ) {
$errors[] = 'Please fill out the title of your website';
}
// }}}
if ( sizeof( $errors ) == 0 ) {
$dirs = array(
BASEDIR . DIRECTORY_SEPARATOR .'data',
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'categories' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'blacklist' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'links' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'output' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR,
BASEDIR . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR
);
foreach( $dirs AS $d ) {
if ( !is_dir( $d ) && @mkdir( $d, 0777 ) === false ) {
$errors[] = 'Unable to create directory "'.$d.'"';
break;
}
@chmod( $d, 0777 );
}
$config = new config;
$config->password = md5( $_username .'---'. $_password1 );
$config->email = $_email;
$config->url = $_url;
$config->anchor = array( $_anchor );
$config->defaultcategories = array( '1001' );
if ( sizeof( $errors ) == 0 ) {
$config->save();
linkex::fileput(
BASEDIR . DIRECTORY_SEPARATOR .'data'. DIRECTORY_SEPARATOR .'config'. DIRECTORY_SEPARATOR .'uid', '1000' );
$cat = new category;
$cat->name = 'Default';
$cat->save();
unset( $cat );
echo template::header( array( 'title' => 'Installation complete' ) );
echo "\n\t\n\n";
echo template::footer();
exit;
}
}
}
echo template::header( array( 'title' => 'Installation' ) );
echo "\n\t\n\n";
echo "\n\t\n\n";
echo template::footer();
}
?>
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /data/www/virtuals/formanek/html/links/index.php:799) in /data/www/virtuals/formanek/html/links/index.php on line 815
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /data/www/virtuals/formanek/html/links/index.php:799) in /data/www/virtuals/formanek/html/links/index.php on line 815
LinkEX » Add link