1.ابتدا کد زیر را در دیتابیس ایمپورت کنید :
CREATE TABLE IF NOT EXISTS `group_likes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `group_id` int(10) unsigned NOT NULL, `who` int(5) unsigned NOT NULL, `date` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) );2. حال به فولدر themes/[Your Theme]/js رفته و فایل inside.js را باز کنید و در انتهای آن کد زیر را قرار دهید :
function likegroup(id){ $('#ecld').fadeIn('slow'); $.post(siteurl+'ajax/like-group/r:', { uid:id }, function(data,statuse){ if(statuse=='success') { $('#grouplike').html(data); $('#ecld').fadeOut('slow'); } }); }3. حال به فولدر system/controllers رفته و فایلی با نام group_like.php و کدهای زیر بسازید :
<?php /// 20script.ir | Tavousi.name /// P30search@gmail.com | tamirtavoosi@yahoo.com include 'conf_main.php'; ///////////////////////////////////// $db = mysql_connect($C->DB_HOST,$C->DB_USER,$C->DB_PASS) or die("Could not connect: ".mysql_error()); mysql_select_db($C->DB_NAME,$db) or die("Error in selecting the database:".mysql_error()); mysql_query("SET NAMES utf8"); ///////////////////////////////////// if(mysql_num_rows(mysql_query('SELECT * FROM groups WHERE `id`="'.$_GET['uid'].'"'))) { if(mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_GET['uid'].'"')) == '0') { print 'without Like'; } else { function getinfo($id) { $qo=mysql_query('SELECT * FROM users WHERE `id`="'.$id.'"'); while($r=mysql_fetch_array($qo)) { if(empty($r['avatar'])) { print '<a href="'.$C->SITE_URL.$r['username'].'"><img style="border:1px #C0C0C0 solid; padding:1px; margin:1px;" src="'.$C->SITE_URL.'/i/avatars/thumbs2/_noavatar_user.gif"/></a>'; } else { print '<a href="'.$C->SITE_URL.$r['username'].'"><img style="border:1px #C0C0C0 solid; padding:1px; margin:1px;" src="'.$C->SITE_URL.'/i/avatars/thumbs2/'.$r['avatar'].'"/></a>'; } } } print 'Likers : '; $qo=mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_GET['uid'].'"'); while($r=mysql_fetch_array($qo)) { getinfo($r['who']); } } } else {echo 'ERR';} ?>4.سپس در همان فولدر مجددا فایلی با نام ajax_like-group.php و کدهای زیر بسازید :
<?php /// 20script.ir | Tavousi.name /// P30search@gmail.com | tamirtavoosi@yahoo.com if( $this->user->is_logged ) { include 'conf_main.php'; ///////////////////////////////////// $db = mysql_connect($C->DB_HOST,$C->DB_USER,$C->DB_PASS) or die("Could not connect: ".mysql_error()); mysql_select_db($C->DB_NAME,$db) or die("Error in selecting the database:".mysql_error()); mysql_query("SET NAMES utf8"); ///////////////////////////////////// if(mysql_num_rows(mysql_query('SELECT * FROM groups WHERE `id`="'.$_POST['uid'].'"'))) { $idu=$this->user->id; $query=mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_POST['uid'].'" AND `who`="'.$idu.'"'); if(mysql_num_rows($query) == '1') { mysql_query('DELETE FROM group_likes WHERE `who`="'.$idu.'" AND `group_id`="'.$_POST['uid'].'"'); $num=mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_POST['uid'].'"')); if($num == '0') { print "<script>$('#grouplike').html('Like'); $('#plike').html('Whitout Like');$('#plike').attr('style', 'float:right;'); $('#plike').attr('onclick', ''); </script> "; } else { ?><script> $('#grouplike').html('Like'); $('#plike').html('<?= $num ?>'); $("#plike").attr('style', "color:#1975E1;cursor:pointer;float:right;"); $("#plike").attr('onclick', "javascript:void window.open('group_like?uid=<?= $_POST['uid'] ?>','1364312840185','width=700,height=200,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;"); </script> <? }} else { $arr=''; $qoi=mysql_query('SELECT * FROM groups_admins WHERE `group_id`="'.$_POST['uid'].'"'); while($r=mysql_fetch_array($qoi)) { $arr.=$r['user_id'].','; } $array = array(trim($arr,',')); if(in_array($idu,$array)) { $num=mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_POST['uid'].'"')); if($num == '0') { print ' <script> $("#plike").html(""); $("#plike").attr("style", ""); $("#grouplike").attr("onclick", ""); $("#grouplike").html("You Can not Like your Group <br> sorry . you have not like."); </script> '; } else { print ' <script> $("#plike").html(""); $("#plike").attr("style", ""); $("#grouplike").attr("onclick", ""); $("#grouplike").html("You Can not Like your Group <br> '.$num.' People Liked you."); </script> '; }} else { mysql_query('INSERT INTO group_likes (`group_id`, `who`, `date`) VALUES ("'.$_POST['uid'].'","'.$idu.'","'.time().'")'); $num=mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$_POST['uid'].'"')); ?> <script> $('#grouplike').html('DisLike'); $('#plike').html('<?= $num ?>'); $("#plike").attr('style', "color:#1975E1;cursor:pointer;float:right;"); $("#plike").attr('onclick', "javascript:void window.open('group_like?uid=<?= $_POST['uid'] ?>','1364312840185','width=700,height=200,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;");</script> <? } } } } else {echo 'ERR';} ?>5.حال به فولدر themes/[Your Theme]/html بروید و فایل group.php را باز کنید و دنبال کد زیر بگردید :
<div id="profileavatar"><img src="<?= $C->IMG_URL.'avatars/'.$D->g->avatar ?>" alt="" /></div>
<?php ///////////////////////////////////// $db = mysql_connect($C->DB_HOST,$C->DB_USER,$C->DB_PASS) or die("Could not connect: ".mysql_error()); mysql_select_db($C->DB_NAME,$db) or die("Error in selecting the database:".mysql_error()); mysql_query("SET NAMES utf8"); ///////////////////////////////////// $numlike=mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$D->g->id.'"')); if(mysql_num_rows(mysql_query('SELECT * FROM group_likes WHERE `group_id`="'.$D->g->id.'" AND `who`="'.$this->user->id.'"')) == '1') { ?> <div id="profileavatar"> <img src="<?= $C->SITE_URL ?>themes/<?= $C->THEME ?>/imgs/fbloader.gif" id="ecld" style="display:none;"/> <a style="cursor:pointer;" id="grouplike" onclick="likegroup('<?= $D->g->id ?>')">DisLike</a><span id="plike" style="float:right;"> <? if($numlike == '0') { ?> Whitout Like <? } else { ?> <a href="<?= $C->SITE_URL ?>profile_like?uid=<?= $D->g->id ?>" onclick="javascript:void window.open('<?= $C->SITE_URL ?>group_like?uid=<?= $D->g->id ?>','1364312840185','width=700,height=200,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;"><?= $numlike ?></a> <? } ?> </span></div> <? } else { ?> <div id="profileavatar" class="like-profile"> <img src="<?= $C->SITE_URL ?>themes/<?= $C->THEME ?>/imgs/fbloader.gif" id="ecld" style="display:none;"/> <a style="cursor:pointer;" id="grouplike" onclick="likegroup('<?= $D->g->id ?>')">Like</a><span id="plike" style="float:right;"> <? if($numlike == '0') { ?> Whitout Like <? } else { ?> <a href="<?= $C->SITE_URL ?>group_like?uid=<?= $D->g->id ?>" onclick="javascript:void window.open('<?= $C->SITE_URL ?>profile_like?uid=<?= $D->g->id ?>','1364312840185','width=700,height=200,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;"><?= $numlike ?></a> <? } ?> </span></div> <? } ?>
http://bayanbox.ir/user/kianit/images/fbloader.gif?view