Jump to content
php.lv forumi

Problēma ar php function


burka

Recommended Posts

Sveicināti.

Griežos pie jums, lai varētu atrisināt savu problēmu ar funkciju. Tātad, lieta sekojoša. Centos izveidot funkciju, kas par katru kliku uz bannera iedod 1 ipunktu (izmantoju IPB 2.3.6 foruma versiju). Protams, uzspiest uz linka būtu iespējams tikai 1x 24h laikā. Pats esmu iesācējs un īsti nezinu, kur varētu būt problēma, jo kad ievietoju kodu, daļa manas lapas pazūd.

 

Funkcija:

function ipunkti($id = "0")
{
  $userid = (int)$id == 0 ? (int)$_COOKIE['id']:(int)$userid;
  $res = mysql_query("SELECT points FROM ibf_members WHERE id = $id");
  $row = mysql_fetch_array($res);
}
function addipunkti($id){
	if(islogin()){
		$click = "<a href='http://wos.lv/d.php?14724' onclick=\"'$update'\">"
		$click2 = "<a href='http://top.unreal.lv/c.php?id=227' onclick=\"'$update'\">"
		$click3 = "<a href='http://top.ieej.lv/in/684/''>http://top.ieej.lv/in/684/' onclick=\"'$update'\">"
		$click4 = "<a href='http://wtop.lv/buttons/p.php?p=117' onclick=\"'$update'\">"
		$click5 = "<a href='http://www.gamesites100.net/in.php?site=24757''>http://www.gamesites100.net/in.php?site=24757' onclick=\"'$update'\">"
		$click6 = "<a href='http://www.8d.lv/b.php?id=271' onclick=\"'$update'\">"
	$update = mysql_query("UPDATE ibf_members SET points = points + 1 WHERE id = $id") or die(mysql_error());
}
}

function alreadyVoted(){
	if(islogin()){
$voted = new DateTime($time);
$daylater = date('Y-m-d H:i:s', strtotime('+1 day', $voted->format('U')));
$canvote = new DateTime($daylater);
$now = new DateTime(date("Y-m-d H:i:s"));

$diff = $canvote->format('U') - $now->format('U'); 

if ( $diff > 0 && $diff < 86400 ) {
    $left = gmdate("H:i:s", $diff);
    echo $left . ' palicis, lai vari balsot atkal.';
} else {
    echo 'Balso!' ;
}
}

Un pats PHP:

<?php include_once 'function.php';?>

<?
if (addipunkti($id)){
	echo'
<script src=http://wos.lv/d.php?14724></script>
<script src=http://top.unreal.lv/c.php?id=227></script>
<a href="http://top.ieej.lv/in/684/" target="_blank">
<img src="http://top.ieej.lv/button2/684/" border="0" alt="Nobalso!">
</a>
<script src="http://wtop.lv/buttons/p.php?p=117"></script>
<a href="http://www.gamesites100.net/in.php?site=24757" title="Counter Strike Top 100" target="_blank"><img src="http://www.Gamesites100.net/images/votebutton.jpg" border="0" alt="Counter Strike Top 100"/></a><!-- End gamesites100 voting code -->		
<script src="http://www.8d.lv/b.php?id=271"></script>';
}
elseif (alreadyVoted()){
	echo'Jau balsoji!';
	}
?>

Un islogin funkcija:

function islogin(){
	if(isset($_COOKIE['member_id']) && isset($_COOKIE['pass_hash'])){
		$hash = smart($_COOKIE['pass_hash']);
		$id = smart($_COOKIE['member_id']);
		$dont_hack = mysql_query("SELECT member_login_key FROM ibf_members WHERE member_login_key = '$hash' AND id = '$id' LIMIT 1") or die(mysql_error());

		$dons = mysql_num_rows($dont_hack) == 1? true : false;
	}else{
		$dons = false;
	}
	return $dons;
}

Ceru, ka palīdzēsiet. :)

Link to comment
Share on other sites

tas arī būtu dīvaini, ja kaut ko uzrādīti reālā lapā. ja tā ir izstrades vide, tad uzliec, lai rāda errorus, ja nav reālā, tad meklē error logus. phpinfo() tev vajadzētu palīdzēt ar to kāda ir tava konfigurācija.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...