1) { $pagination .= "
"; //previous button if ($page > 1) $pagination.= "prev"; else $pagination.= "prev"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } $pagination.= "..."; $pagination.= "$lpm1"; $pagination.= "$lastpage"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "1"; $pagination.= "2"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } $pagination.= "..."; $pagination.= "$lpm1"; $pagination.= "$lastpage"; } //close to end; only hide early pages else { $pagination.= "1"; $pagination.= "2"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } } } //next button if ($page < $counter - 1) $pagination.= "next "; else $pagination.= "next "; $pagination.= "
\n"; } return $pagination; } function clean_compare ($str) { $str = str_replace("$"," ",$str); $str = str_replace("#"," ",$str); $str = str_replace("&"," ",$str); $str = str_replace("*"," ",$str); $str = str_replace("@"," ",$str); $str = str_replace("^"," ",$str); $str = str_replace("~"," ",$str); $str = str_replace("َ","",$str); $str = str_replace("ً","",$str); $str = str_replace("ُ","",$str); $str = str_replace("ٌ","",$str); $str = str_replace("ِ","",$str); $str = str_replace("ٍ","",$str); $str = str_replace("ّ","",$str); $str = str_replace("ْ","",$str); $str = str_replace(" "," ",$str); $str = str_replace(" "," ",$str); $str = trim($str); return ($str); } function htmlDiff($old, $new) { $ret = ''; $diff = diff(explode(' ', $old), explode(' ', $new)); foreach($diff as $k) { if(is_array($k)) { $ret .= (!empty($k['d'])?"":''). (!empty($k['i'])?" ".implode(' ',$k['i'])." ":''); } else $ret .= $k . ' '; } return $ret; } function diff($old, $new) { $maxlen = 0; foreach($old as $oindex => $ovalue) { $nkeys = array_keys($new, $ovalue); foreach($nkeys as $nindex) { $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? $matrix[$oindex - 1][$nindex - 1] + 1 : 1; if($matrix[$oindex][$nindex] > $maxlen) { $maxlen = $matrix[$oindex][$nindex]; $omax = $oindex + 1 - $maxlen; $nmax = $nindex + 1 - $maxlen; } } } if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new)); return array_merge( diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)), array_slice($new, $nmax, $maxlen), diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))); } function shadow ($incoming_word) { global $pieces; foreach ($pieces as $k => $v) $incoming_word = str_replace($v,"".$v."",$incoming_word); echo $incoming_word; } ?> برنامج قارن - شبكة السنة النبوية وعلومها

النص الأول النص الثاني