q("SELECT * FROM authors WHERE id='".intval($_GET["id"])."'"); } else { $author = $mysql->q("SELECT * FROM authors WHERE firstname='".urldecode($_GET["fn"])."' AND lastname='".urldecode($_GET["ln"])."'"); } $page = (!$_GET["page"]) ? 1 : $_GET["page"]; $pagesize = getconfig('pagesize'); $author["dtborn"] = ($author["dtborn"]!=0) ? $author["dtborn"] : ''; $author["dtdie"] = ($author["dtdie"]!=0) ? $author["dtdie"] : ''; $params["firstname"] = ucfirst(strtolower($author["firstname"])); $params["lastname"] = ucfirst(strtolower($author["lastname"])); $sql = "SELECT * FROM authors_stat WHERE author_id = '{$author['id']}'"; $stat = $mysql->q($sql); if (is_array($stat)){ $sql = "UPDATE authors_stat SET count=count+1 WHERE author_id = '{$author['id']}'"; } else { $sql = "INSERT INTO authors_stat (author_id, count) VALUES ('{$author['id']}', 1)"; } $mysql->execute($sql); $word = ""; if(!empty($_GET['w'])){ $word = " AND quote LIKE '%" . addslashes($_GET['w']) . "%' "; } $quotes = $mysql->fetch("SELECT * FROM quotes WHERE authorid='".$author["id"]."' $word LIMIT ".(($page -1 ) * $pagesize).", ". $pagesize); $total = $mysql->getcount('quotes', "authorid='".$author["id"]."' $word"); if (sizeof($quotes)>0) { $b = 1; foreach ($quotes as $key=>$quote) { $cats = array(); for ($i = 0; $i < 5; $i++){ if (!$quote["cat$i"]) continue; //slowly, can decrease perfomance $sql = "SELECT name FROM cats WHERE id = {$quote["cat$i"]}"; $cat = $mysql->fetch($sql); if (empty($cat[0]['name'])) continue; array_push($cats, "".ucfirst(strtolower($cat[0]['name'])).""); } $vars['banner'] = null; // first google ads banner if($b == FIRST_BANNER_AFTER){ $code = $mysql->getval('banners', 'code', "name LIKE '%".FIRST_BANNER_NAME."%'"); $vars['banner'] = $code; } // put google ads banner after 10 quotes if(count($quotes)!= 10 && $b == 10){ $code = $mysql->getval('banners', 'code', "name LIKE '%".FIRST_BANNER_NAME."%'"); $vars['banner'] = $code; } if((count($quotes)<=$SECOND_BANNER_AFTER && $b == count($quotes)) || $b == $SECOND_BANNER_AFTER){ $SECOND_BANNER_AFTER += 10; $code = $mysql->getval('banners', 'code', "random = '1' order by rand() limit 1"); $vars['banner'] = $code; } // put the google ads banner at the bottom af page if there is not enough quotes if(count($quotes) == $b && count($quotes) < FIRST_BANNER_AFTER && $b != 10){ $code = $mysql->getval('banners', 'code', "name LIKE '%".FIRST_BANNER_NAME."%'"); $vars['banner'] = $code; } $vars["text"] = $quote["quote"]; $vars["quoteid"] = $quote["id"]; $vars["categories"] = implode(' - ', $cats); $b++; $template->assign_block_vars("quote", $vars); } } ob_start(); $paging = new paging($page, $total, $pagesize); $paging->setTitle(""); $paging->setNPlinks(false); if (isset($_GET['id'])){ $paging->setFormat("?page=%d&id=".$_GET["id"]); } else { $paging->setFormat("?page=%d&fn=".$_GET["fn"]."&ln=".$_GET["ln"]); } print $paging->getHTML(); $params["paging"] = ob_get_contents(); ob_end_clean(); //seo stuff, very basic $params['header'] = preg_replace("/\([^<]*)\<\/title\>/", "".$params["firstname"]." ".$params["lastname"]." - Kjente sitater og ordtak", $params['header']); $params['header'] = preg_replace("/\/", "", $params['header']); $params['header'] = preg_replace("/\/", "", $params['header']); $template->assign_vars($params); $template->pparse("forfatter"); ?>