Jump to content

Syntax error, unexpected '=', expecting ')'


rtrdogs

Recommended Posts

Hello,

 

I just downloaded a script from hotscripts and when I upload the files, I get this error:

 

Parse error: syntax error, unexpected '=', expecting ')' in path/to/api.php on line 289

 

Can someone help me locate the unexpected "=" please? I don't have dreamweaver to find the line # and when I went through all of the "=" signs in wordpad, I couldn't identify the bad code it was referring to.

 

I appreciate the help in advance.

 

 

<?php

// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
//     Instead, you can link to the homepage of this code:
//     http://www.php-development.ru/php-scripts/search-engine.php
// (3) Use this code as a part of another product.
//     If you want to do it you should receive my permission.
//
// YOU MAY
// (1) Use this code on your website.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.


// ***** Parse HTML ************************************************************

function enclose($start, $end1, $end2)
{
  return "$start((?:[^$end1]|$end1(?!$end2))*)$end1$end2";
}

function parse($html, &$title, &$text, &$anchors, $start = false, $end = false)
{
  $pstring1 = "'[^']*'";
  $pstring2 = '"[^"]*"';
  $pnstring = "[^'\">]";
  $pintag   = "(?:$pstring1|$pstring2|$pnstring)*";
  $pattrs   = "(?:\\s$pintag){0,1}";

  $pcomment = enclose("<!--", "-", "->");
  $pscript  = enclose("<script$pattrs>", "<", "\\/script>");
  $pstyle   = enclose("<style$pattrs>", "<", "\\/style>");
  $pexclude = "(?:$pcomment|$pscript|$pstyle)";

  $ptitle   = enclose("<title$pattrs>", "<", "\\/title>");
  $panchor  = "<a(?:\\s$pintag){0,1}>";
  $phref    = "href\\s*=[\\s'\"]*([^\\s'\">]*)";

  if ($title !== false)
    $title = preg_match("/$ptitle/iX", $html, $title) ? $title[1] : '';

  if ($text  !== false)
  {
    $text  = $html;

    if ($start !== false && ($pos = strpos($text, $start)) !== false)
      $text = substr($text, $pos+strlen($start));
    if ($end   !== false && ($pos = strpos($text, $end  )) !== false)
      $text = substr($text, 0, $pos);

    $text  = preg_replace("/$pexclude/iX",   " ", $text);
    $text  = preg_replace("/<$pintag>/iX",   " ", $text);
    $text  = preg_replace("/\\s+| /iX", " ", $text);
  }

  if ($anchors !== false)
  {
    $html = preg_replace("/$pexclude/iX", " ", $html);

    preg_match_all("/$panchor/iX", $html, $anchors);
    $anchors = $anchors[0];

    reset($anchors);
    while (list($i, $x) = each($anchors))
      $anchors[$i] = preg_match("/$phref/iX", $x, $x) ? $x[1] : '';

    $anchors = array_unique($anchors);
  }
}


// ***** URL Functions *********************************************************

// ***** Parse URL *****

function url_parse($url)
{
  $error_reporting = error_reporting(E_ERROR | E_PARSE);
  $url = parse_url($url);
  error_reporting($error_reporting);
  return $url;
}

// ***** Extract Scheme *****

function url_scheme($url, $scheme = 'http')
{
  if(!($url = url_parse($url))) return $scheme;
  return isset($url['scheme']) ? $url['scheme'] : $scheme;
}

// ***** Extract Host *****

define('URL_HOST_DEFAULT', 0);
define('URL_HOST_APPEND',  1);
define('URL_HOST_STRIP',   2);

function url_host($url, $www = 0, $lower = true)
{
  if(!($url = url_parse($url))) return '';
  $url = $lower ? strtolower($url['host']) : $url['host'];
  if ($www == URL_HOST_APPEND && strpos($url, 'www.') !== 0) return 'www.' . $url;
  if ($www == URL_HOST_STRIP  && strpos($url, 'www.') === 0) return substr($url, 4);
  return $url;
}

// ***** Extract Path *****

function url_path($url)
{
  if(!($url = url_parse($url))) return '';
  $url = isset($url['path']) ? explode('/', $url['path']) : Array();
  if (reset($url) === '') array_shift($url);
  if (end  ($url) === '' || strpos(end($url), '.') !== false) array_pop($url);
  return implode('/', $url);
}

// ***** Extract Filename *****

function url_file($url, $convert = Array())
{
  if(!($url = url_parse($url))) return '';
  $url = isset($url['path']) ? end(explode('/', $url['path'])) : '';
  $url = (strpos($url, '.') !== false) ? $url : '';
  foreach ($convert as $i => $x) $url = preg_replace($i, $x, $url);
  return $url;
}

// ***** Extract Extension *****

function url_ext($url, $convert = Array())
{
  if(!($url = url_parse($url))) return '';
  $url = isset($url['path']) ? end(explode('/', $url['path'])) : '';
  $url = (strpos($url, '.') !== false) ? end(explode('.', $url)) : '';
  foreach ($convert as $i => $x) $url = preg_replace($i, $x, $url);
  return $url;
}

// ***** Extract Query *****

define('URL_QUERY_NOESCAPE', 0);
define('URL_QUERY_ESCAPE',   1);

function url_query($url, $escape = 0, $exclude = Array())
{
  if(!($url = url_parse($url))) return '';
  if (!isset($url['query'])) return '';
  $url = preg_split('/(&(?!amp;)|&)/', $url['query']);

  foreach ($url as $i => $x)
  {
    $x = explode('=', $x);
    if (!in_array($x[0], $exclude)) unset($url[$i]);
  }

  sort($url);
  return implode($escape ? '&' : '&', $url);
}

// ***** Concat *****

function url_concat($base, $rel)
{
  $scheme = url_scheme($base);
  $host   = url_host  ($base);
  $path   = url_path  ($base);

  if ($rel{0} == '/')
       return "$scheme://$host$rel";
  else if ($path === '')
            return "$scheme://$host/$rel";
       else return "$scheme://$host/$path/$rel";
}

// ***** Normalize *****

function url_normalize($url,
                       $scheme  = 'http',
                       $www     = 0,
                       $convert = Array(),
                       $escape  = 0,
                       $exclude = Array())
{
  $scheme = url_scheme($url, $scheme);
  $host   = url_host  ($url, $www);
  $path   = url_path  ($url);
  $file   = url_file  ($url, $convert);
  $query  = url_query ($url, $escape, $exclude);

  if ($scheme === '' || $host === '') return '';

  if ($path === '')
       return "$scheme://$host/$file"       . ($query ? "?$query" : "");
  else return "$scheme://$host/$path/$file" . ($query ? "?$query" : "");
}


// ***** Index Website *********************************************************

define('INDEX_HOST_DEFAULT', 0);
define('INDEX_HOST_APPEND',  1);
define('INDEX_HOST_STRIP',   2);

function index($roots, &$urls, $max, $ext_parse, $www, $convert, $exclude,
               &$titles, &$texts, $extensions, $start, $end)
{
  $time   = microtime(true);
  $parsed = 0;

  foreach ($urls as $i => $url)
    $urls[$i] = url_normalize($url, 'http', $www, $convert, URL_QUERY_NOESCAPE, $exclude);

  for ($ind = 0; isset($urls[$ind]); $ind++)
  {
    if (trim($urls[$ind]) === '')
    {
      unset($urls[$ind]);
      continue;
    }

    // ***** Check URL *****

    $in_root = false;
    foreach ($roots as $i => $root)
      $in_root = $in_root || strpos($urls[$ind], $root) === 0;

    if (!$in_root)
    {
      if (!$ext_parse) continue;
      if ($titles === false && $texts === false) continue;
    }

    if (!in_array(url_ext($urls[$ind]), $extensions)) continue;

    // ***** Get Contents *****

    $error_reporting = error_reporting(E_ERROR | E_PARSE);
    $html = file_get_contents($urls[$ind]);
    error_reporting($error_reporting);

    if ($html === false)
    {
      unset($urls[$ind]);
      continue;
    }

    // ***** Parse URL *****

    $parsed++;

    $title = $titles !== false;
    $text  = $texts  !== false;
    parse($html, $title, $text, $anchors, $start, $end);

    if ($titles !== false) $titles[$ind] = $title;
    if ($texts  !== false) $texts [$ind] = $text;

    // ***** Extract Anchors *****

    if (!$in_root ||count($urls) > $max) continue;

    foreach ($anchors as $i => $x)
    {
      $x = preg_replace("/#.*/X", "", $x);
      if ($x == '' || preg_match("/^(\\w)+?!\/\/)/X", $x)) continue;
      if (!preg_match("/^(\\w)+:\/\//X", $x)) $x = url_concat($urls[$ind], $x);
      $x = url_normalize($x, 'http', $www, $convert, URL_QUERY_NOESCAPE, $exclude);
      if (!in_array($x, $urls) && (count($urls) < $max)) $urls[] = $x;
    }
  }

  return Array("time" => microtime(true)-$time, "parsed" => $parsed);
}


// ***** Separate Links ********************************************************

function separate($roots, $urls,
                  &$int_pages = Array(),
                  &$int_loads = Array(),
                  &$ext_pages = Array(),
                  &$ext_loads = Array(),
                  $extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php'))
{
  foreach ($urls as $i => $url)
  {
    if (trim($url) === '') continue;

    $in_root = false;
    foreach ($roots as $j => $root)
      $in_root = $in_root || strpos($url, $root) === 0;

    if ($in_root)
    {
      if (in_array(url_ext($url), $extensions))
           $int_pages[$i] = $url;
      else $int_loads[$i] = $url;
    }
    else
    {
      if (in_array(url_ext($url), $extensions))
           $ext_pages[$i] = $url;
      else $ext_loads[$i] = $url;
    }
  }
}


// ***** Debug Query ***********************************************************

function mysql_query_debug($str)
{
  $result = mysql_query($str);

  if (mysql_error())
    echo "<hr /><b>Message:</b> " . mysql_error() . "<br /><b>Query:</b> $str<hr />";

  return $result;
}


// ***** TMySQL_KeyVal *********************************************************

class TMySQL_KeyVal
{
  var $tbl    = null;
  var $prefix = null;

  // ***** Init *****

  function Init($tbl, $prefix)
  {
    $this->tbl    = $tbl;
    $this->prefix = $prefix;
  }

  // ***** CreateTable *****

  function CreateTable($drop = false)
  {
    if ($drop) mysql_query_debug("drop table if exists {$this->tbl}");


    mysql_query_debug(
    "create table {$this->tbl}
     ({$this->prefix}id     integer unsigned not null auto_increment,
      {$this->prefix}hash   integer unsigned not null default 0,
      {$this->prefix}key    varchar(255)     not null unique,
      {$this->prefix}val    text             not null,
      {$this->prefix}weight integer unsigned not null default 0,
      {$this->prefix}time   integer unsigned not null default 0,
      index {$this->prefix}hash ({$this->prefix}hash),
      primary key ({$this->prefix}id),
      fulltext ({$this->prefix}val))
      engine = myisam");
  }

  // ***** Set *****

  function Set($key, $val, $weight = false)
  {
    $hash = '0x' . substr(md5($key), 0, ;
    $key  = mysql_real_escape_string($key);
    $val  = mysql_real_escape_string($val);
    $time = time();

    $result = mysql_query_debug(
              "select * from {$this->tbl}
               where {$this->prefix}hash = $hash &&
                     {$this->prefix}key  = '$key'");

    if (!mysql_num_rows($result))
    {
      mysql_query_debug(
      "insert into {$this->tbl} ({$this->prefix}hash, {$this->prefix}key, {$this->prefix}val, {$this->prefix}time)
       values ($hash, '$key', '', $time)");

      $result = mysql_query_debug(
                "select * from {$this->tbl}
                 where {$this->prefix}hash = $hash &&
                       {$this->prefix}key  = '$key'");
    }

    $id = mysql_fetch_assoc($result);
    $id = $id["{$this->prefix}id"];

    if ($weight === false)
    {
      mysql_query_debug("update {$this->tbl}
                         set    {$this->prefix}val = '$val'
                         where  {$this->prefix}id  = $id");
      return $id;
    }

    if ($weight === true)
    {
      mysql_query_debug("update {$this->tbl}
                         set    {$this->prefix}val    = '$val',
                                {$this->prefix}weight = {$this->prefix}weight+1
                         where  {$this->prefix}id     = $id");
      return $id;
    }

    $weight = (integer)$weight;
    mysql_query_debug("update {$this->tbl}
                       set    {$this->prefix}val    = '$val',
                              {$this->prefix}weight = $weight
                       where  {$this->prefix}id     = $id");
    return $id;
  }

  // ***** Get *****

  function Get($key, $weight = false)
  {
    $val = $this->GetByKey($key, $weight);
    return $val ? $val['val'] : false;
  }

  // ***** GetById *****

  function GetById($id, $weight = false)
  {
    $id = (integer)$id;

    $result = mysql_query_debug(
              "select {$this->prefix}id     'id',
                      {$this->prefix}key    'key',
                      {$this->prefix}val    'val',
                      {$this->prefix}weight 'weight',
                      {$this->prefix}time   'time'
               from {$this->tbl} where {$this->prefix}id = $id");
    $result = mysql_fetch_assoc($result);

    if ($result && $weight)
      mysql_query_debug("update {$this->tbl}
                         set    {$this->prefix}weight = {$this->prefix}weight+1
                         where  {$this->prefix}id     = {$result['id']}");

    return $result;
  }

  // ***** GetByIds *****

  function GetByIds($ids)
  {
    if (count($ids) == 0) return Array();

    $ids = "(" . implode(",", $ids) . ")";

    $result = mysql_query_debug(
              "select {$this->prefix}id     'id',
                      {$this->prefix}key    'key',
                      {$this->prefix}val    'val',
                      {$this->prefix}weight 'weight',
                      {$this->prefix}time   'time'
               from {$this->tbl} where {$this->prefix}id in $ids");

    $data = Array();
    while($row = mysql_fetch_assoc($result)) $data[$row['id']] = $row;
    return $data;
  }

  // ***** GetByKey *****

  function GetByKey($key, $weight = false)
  {
    $hash = '0x' . substr(md5($key), 0, ;
    $key  = mysql_real_escape_string($key);

    $result = mysql_query_debug(
              "select {$this->prefix}id     'id',
                      {$this->prefix}key    'key',
                      {$this->prefix}val    'val',
                      {$this->prefix}weight 'weight',
                      {$this->prefix}time   'time'
               from {$this->tbl}
               where {$this->prefix}hash = $hash &&
                     {$this->prefix}key  = '$key'");
    $result = mysql_fetch_assoc($result);

    if ($result && $weight)
      mysql_query_debug("update {$this->tbl}
                         set    {$this->prefix}weight = {$this->prefix}weight+1
                         where  {$this->prefix}id     = {$result['id']}");

    return $result;
  }

  // ***** GetAll *****

  function GetAll()
  {
    $result = mysql_query_debug(
              "select {$this->prefix}id     'id',
                      {$this->prefix}key    'key',
                      {$this->prefix}val    'val',
                      {$this->prefix}weight 'weight',
                      {$this->prefix}time   'time'
               from {$this->tbl}
               order by {$this->prefix}weight desc, {$this->prefix}id");

    $data = Array();
    while($row = mysql_fetch_assoc($result)) $data[$row['id']] = $row;
    return $data;
  }

  // ***** Clear *****

  function Clear($key)
  {
    $hash = '0x' . substr(md5($key), 0, ;
    $key  = mysql_real_escape_string($key);

    mysql_query_debug(
    "delete from {$this->tbl}
     where {$this->prefix}hash = $hash && {$this->prefix}key = '$key'");
  }

  // ***** Clear Id *****

  function ClearId($id)
  {
    $id = (integer)$id;
    mysql_query_debug("delete from {$this->tbl} where {$this->prefix}id = $id");
  }

  // ***** Clear All *****

  function ClearAll($key)
  {
    mysql_query_debug("delete from {$this->tbl}");
  }
}


// ***** TMySQL_WordId *********************************************************

class TMySQL_WordId
{
  var $tbl    = null;
  var $prefix = null;

  // ***** Init *****

  function Init($tbl, $prefix)
  {
    $this->tbl    = $tbl;
    $this->prefix = $prefix;
  }

  // ***** CreateTable *****

  function CreateTable($drop = false)
  {
    if ($drop) mysql_query_debug("drop table if exists {$this->tbl}");

    mysql_query_debug(
    "create table {$this->tbl}
     ({$this->prefix}word   varchar(255)     not null default '',
      {$this->prefix}id     integer unsigned not null default 0,
      {$this->prefix}count  integer unsigned not null default 0,
      unique index {$this->prefix}ind ({$this->prefix}word, {$this->prefix}id))
     engine = myisam");
  }

  // ***** Fill *****

  function Fill($id, $word2count)
  {
    foreach ($word2count as $i => $x)
      if ($i != '')
           $word2count[$i] = "(\"$i\",$id,$x)";
      else unset($word2count[$i]);
    $word2count = implode(",", $word2count);

    mysql_query_debug("insert into {$this->tbl} values $word2count;");
  }

  // ***** Count Entries *****

  function CountEntries()
  {
    $result = mysql_query_debug("select count(*) n from {$this->tbl};");
    $row    = mysql_fetch_assoc($result);
    return $row['n'];
  }

  // ***** Count Words *****

  function CountWords()
  {
    $result = mysql_query_debug(
              "select count(distinct {$this->prefix}word) n from {$this->tbl};");
    $row    = mysql_fetch_assoc($result);
    return $row['n'];
  }

  // ***** Count Ids *****

  function CountIds()
  {
    $result = mysql_query_debug(
              "select count(distinct {$this->prefix}id) n from {$this->tbl};");
    $row    = mysql_fetch_assoc($result);
    return $row['n'];
  }

  // ***** Clear Id *****

  function ClearId($id)
  {
    $id = (integer)$id;
    mysql_query_debug("delete from {$this->tbl} where {$this->prefix}id = $id;");
  }
}


// ***** Word forms ************************************************************

function wordforms($words)
{
  if (!$GLOBALS["src_word_forms"]) return $words;

  $forms = Array();

  foreach ($words as $i => $word)
  {
    $word    = strtolower(trim($word));
    $forms[] = $word;

    if (preg_match("/^(.*([^aeiou]))$/", $word, $matches))
       array_push($forms, "{$matches[1]}s",
                          "{$matches[1]}{$matches[2]}ed",
                          "{$matches[1]}{$matches[2]}ing");

    if (preg_match("/^(.*)e$/", $word, $matches))
      array_push($forms, "{$matches[1]}es", "{$matches[1]}ed", "{$matches[1]}ing");
  }

  return array_unique($forms);
}

// ***** Excerpt ***************************************************************

function excerpt($words, $exact, $text, $maxlen)
{
  $bolds = "([^a-zA-Z>])(" . implode("|", $words) . ")([^a-zA-Z<])";
  $words = "[^a-zA-Z](?:" . implode("|", $words) . ")[^a-zA-Z]";

  if (count($exact) > 0)
  {
    $exact = "[^a-zA-Z](?:" . implode("[^a-zA-Z]+", $exact) . ")[^a-zA-Z]";
    $large = preg_split("/($exact)/iX", " $text ", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    $parts = Array();
    for ($i = 0; $i < count($large); $i++)
      if (preg_match("/($exact)/iX", $large[$i]))
           $parts[] = $large[$i];
      else $parts   = array_merge($parts, preg_split("/($words)/iX", " {$large[$i]} ", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
  }
  else
  {
    $exact = ".*";
    $parts = preg_split("/($words)/iX", " $text ", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  }

  $start = 0;
  $count = 0;

  for ($i = 0; $i < count($parts); $i++)
  {
    $flag = false;
    $len  = 0;
    for ($j = $i; $j < count($parts); $j++)
    {
      $flag = $flag || preg_match("/($exact)/iX", $parts[$j]);
      $len += strlen($parts[$j]);
      if ($len >= $maxlen) break;
    }
    if ($flag && $j-$i > $count)
    {
      $start = $i;
      $count = $j-$i;
    }
  }

  $result = '';
  for ($i = $start; $i < $start+$count; $i++) $result .= $parts[$i];

  if ($start-1 >= 0)
  {
    $part = preg_split("/([^a-z])/iX", $parts[$start-1], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    for ($i = count($part)-1; $i > count($part)-10 && $i >= 0; $i--) $result = $part[$i] . $result;
  }

  if ($start+$count < count($parts))
  {
    $part = preg_split("/([^a-z])/iX", $parts[$start+$count], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    for ($i = 0; $i < count($part) && $i <= 10; $i++) $result .= $part[$i];
  }

  $result = preg_replace("/$bolds/iX", "$1<b>$2</b>$3", $result);
  $result = preg_replace("/$bolds/iX", "$1<b>$2</b>$3", $result);
  $result = preg_replace("/$bolds/iX", "$1<b>$2</b>$3", $result);
  return trim($result);
}

// ***** Search ****************************************************************

function search($words, $allwords, $nowords, $exact, $offset, $limit, &$numrows)
{
  $words       = wordforms(array_merge($words, $allwords, $exact));
  $count       = count($allwords);
  $somewords   = wordforms($words);
  $somewords[] = '-=-=-=-=-=-=-=-=-=-=';
  $somewords   = "('" . implode("','", $somewords) . "')";
  $allwords [] = '-=-=-=-=-=-=-=-=-=-=';
  $allwords    = "('" . implode("','", $allwords ) . "')";
  $nowords  [] = '-=-=-=-=-=-=-=-=-=-=';
  $nowords     = "('" . implode("','", $nowords  ) . "')";

  if (count($exact) > 0)
       $phrase = "urls_val regexp '.*" . implode("[^a-zA-Z]+", $exact) . ".*'";
  else $phrase = "1";

  $result = mysql_query_debug(
            "select sql_calc_found_rows
                    urls_key, urls_val,
                    sum(index_count) word_weight,
                    sum(index_word in $somewords) somewords_count,
                    sum(index_word in  $allwords)  allwords_count,
                    sum(index_word in   $nowords)   nowords_count
             from {$GLOBALS['src_index']->tbl},
                  {$GLOBALS['src_urls']->tbl}
             where (index_word in $somewords ||
                    index_word in $allwords  ||
                    index_word in $nowords
                   ) && urls_id = index_id
             group by index_id
             having somewords_count > 0      &&
                    allwords_count  = $count &&
                    nowords_count   = 0      &&
                    $phrase
             order by word_weight desc
             limit $offset, $limit");

  $numrows = mysql_query_debug("select found_rows() NN");
  $numrows = mysql_fetch_assoc($numrows);
  $numrows = $numrows["NN"];

  $pages   = Array();

  while($page = mysql_fetch_assoc($result))
  {
    $url   = $page['urls_key'];
    $val   = unserialize($page['urls_val']);
    $title = $val['title'];
    $text  = $val['text' ];

    $pages[] = Array("url"     => $url,
                     "title"   => $title,
                     "excerpt" => excerpt($words, $exact, $text, 100));
  }

  return $pages;
}

// ***** Display ***************************************************************

function display($results, $words, $allwords, $nowords, $exact, $q,
                 $offset, $limit, $numrows, $time,
                 $template_all, $template_ind, $template_cur, $template_ref, $template_non)
{
  if ($numrows == 0)
  {
    echo $template_non;
    return;
  }

  $ind = "";

  for ($i = 0; $i < (integer)(($numrows+$limit-1)/$limit); $i++)
  {
    $trans = Array("%%page%%"     => $i+1,
                   "%%offset%%"   => $i*$limit,
                   "%%words%%"    => urlencode(implode(' ', $words   )),
                   "%%allwords%%" => urlencode(implode(' ', $allwords)),
                   "%%nowords%%"  => urlencode(implode(' ', $nowords )),
                   "%%exact%%"    => urlencode(implode(' ', $exact   )),
                   "%%q%%"        => urlencode($q));
    if ($i*$limit == $offset)
         $ind .= strtr($template_cur, $trans);
    else $ind .= strtr($template_ind, $trans);
  }


  $ref = "";

  foreach ($results as $i => $result)
  {
    $trans = Array("%%url%%"     => $result["url"],
                   "%%title%%"   => $result["title"],
                   "%%excerpt%%" => $result["excerpt"]);

    $ref .= strtr($template_ref, $trans);
  }

  $trans = Array("%%ind%%"     => $ind,
                 "%%ref%%"     => $ref,
                 "%%numrows%%" => $numrows,
                 "%%time%%"    => $time);
  echo strtr($template_all, $trans);
}

?>

Link to comment
Share on other sites

You forgot to close off your function indication @ line 288

 

// ***** Separate Links ********************************************************

function separate($roots, $urls,       <===RIGHT THERE
                  &$int_pages = Array(),
                  &$int_loads = Array(),
                  &$ext_pages = Array(),
                  &$ext_loads = Array(),
                  $extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php'))
{

//it should look like this
// ***** Separate Links ********************************************************

function separate($roots, $urls,)  //<===this
                  &$int_pages = Array(),
                  &$int_loads = Array(),
                  &$ext_pages = Array(),
                  &$ext_loads = Array(),
                  $extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php'))
{

Link to comment
Share on other sites

Unfortunately, that gives me the error:

 

Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE or T_CONST in /path/to/search/api.php on line 288

 

When I change the code to:

 

function separate($roots, $urls,)
                  &$int_pages = Array(),
                  &$int_loads = Array(),
                  &$ext_pages = Array(),
                  &$ext_loads = Array(),
                  &$extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php')

 

Without the second ')' at the end of the last line, I get:

 

Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE or T_CONST in /path/to/api.php on line 288

 

I'm not sure what the problem is. I've tried the developer's demo and it works fine. I've contacted him to see if I can get a file replacement because it's obviously working on his site.

 

Any other changes you can see that need to be made before I ditch the script and search for a new one?

Link to comment
Share on other sites

function separate($roots, $urls,
                  &$int_pages = Array(),
                  &$int_loads = Array(),
                  &$ext_pages = Array(),
                  &$ext_loads = Array(),
                  $extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php'))
{

 

really is this...

 

function separate($roots, $urls, &$int_pages = Array(), &$int_loads = Array(), &$ext_pages = Array(), &$ext_loads = Array(), $extensions = Array('', 'asp', 'aspx', 'cgi', 'htm', 'html', 'php'))
{

 

so whitespace is the only issue there...

 

line 289, would be "&$int_pages = Array(),", the whitespace might be affecting it, you could also try adding another set of brackets around each parameter containing =.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.