\n"; } } function PrintEditTable() { ?>

Edit news.

Essex Office Supplies, Best source for office supplies, new and used furniture north of Boston.

PORTFOLIO

 
 
 
category_table=$c; $this->news_table=$n; } } // query class class SearchQuery extends BasicHeadLinesClass { var $keywords; var $cat; var $cat_mode; var $date1; var $date2; var $query; var $text_fields; var $cat_field; var $date_field; function SearchQuery($text_fields,$cat_field,$date_field,$c,$n) { $this->BasicHeadLinesClass($c,$n); $this->text_fields=explode(',',$text_fields); $this->cat_field=$cat_field; $this->date_field=$date_field; } function MakeQuery($keywords,$mode,$cat,$cat_mode,$date1,$date2) { $this->query=array(); $n=0; // including sub-categories if ($cat) { if ($cat_mode==1) { $o=new Category($cat,'',0,'',$this->category_table,$this->news_table,''); $sc=implode(',',$o->GetSubCategories ()); $this->query[$n++]=$this->cat_field." in ($sc)"; } else { $this->query[$n++]=$this->cat_field."=$cat"; } } // check date if ($date1) { $this->query[$n++]="UNIX_TIMESTAMP($date_field)-UNIX_TIMESTAMP('$date1')>=0"; } if ($date1) { $this->query[$n++]="UNIX_TIMESTAMP($date_field)-UNIX_TIMESTAMP('$date2')<=0"; } // treat keywords $cc=0; if ($keywords) { $keywords=preg_replace("/\s+/"," ",$keywords); $kk=explode(" ",$keywords); $qq=array(); foreach ($kk as $k) { $c=0; $q=array(); foreach ($this->text_fields as $f) { $q[$c++]="$f LIKE '%$k%'"; } $qq[$cc++]="(".implode(' OR ',$q).")"; } $this->query[$n++]="(".implode(" $mode ",$qq).")"; } // merge all terms $this->query=implode(" AND ",$this->query); return $this->query; } } // all news class AllNews extends BasicHeadLinesClass { var $choice; var $total; var $cnt; var $limit1; var $limit2; function AllNews ($c,$n) { $this->BasicHeadLinesClass($c,$n); $this->total=0; $this->cnt=0; $this->choice=array(); } function CountSearch($keywords,$mode,$cat,$cat_mode,$date1,$date2) { $this->total=0; $s=new SearchQuery('title,text','category','date', $this->category_table,$this->news_table); $q=$s->MakeQuery($keywords,$mode,$cat,$cat_mode,$date1,$date2); if ($q) { $q=" WHERE $q"; } $sql="SELECT count(*) FROM $this->news_table $q"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); if ($row = mysql_fetch_array($r)) { $this->total=$row[0]; } return $this->total; } function Search($keywords,$mode,$cat,$cat_mode,$date1,$date2,$limit1,$limit2,$order) { $this->cnt=0; $this->limit1=$limit1; $this->limit2=$limit2; $this->choice=array(); $s= new SearchQuery("title,text","category","date", $this->category_table,$this->news_table); $q=$s->MakeQuery($keywords,$mode,$cat,$cat_mode,$date1,$date2); if ($q) { $q=" WHERE $q"; } $f="id,date,source,title,text,category,owner"; $o=($order)?" ORDER BY $order ":""; $sql="SELECT $f FROM $this->news_table $q $o LIMIT $limit1,$limit2"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); $this->total=mysql_num_rows($r); while ($row = mysql_fetch_array($r)) { list($id,$date,$source,$title,$text,$category,$owner)=$row; $this->choice[$this->cnt++]=new SingleNews($id,$date,$source,$title,$text,$category,$owner,$this->category_table,$this->news_table); } } function ThinBlueLine () { $s=array(70,90,70,40,30,30); foreach ($s as $k) { echo "

ThinBlueLine(); ?> $k\n"; } echo "\n"; $bg=array("#FFFFFF","#E0E0E0"); $b=0; foreach ($this->choice as $n) { echo "\n"; $owner=GetUserByID($n->owner); $o=new Category($n->category,'',0,'',$this->category_table,$this->news_table,''); $o->CategoryById($o->id); $category=$o->name; $bc="bgcolor=\"".$bg[$b++]."\" height=27"; $b=($b>1)?0:$b; echo "\n"; echo "\n"; echo "\n"; $d=$n->date; $d=preg_replace("/\d\d(\d\d)-(\d\d)-(\d\d)/","$2.$3.$1",$d); echo "\n"; echo "\n"; echo "\n"; echo "\n"; } ?> ThinBlueLine(); ?>
$category".Fit16($n->title)."source\">".substr(Fit16($n->source),0,25)." $d id\">id\">

  limit1>0) { $start=min($this->limit1-10,0); ?> <<Previous 10 limit2<$this->total) { $start=$this->limit2; ?> Next 10>>   

 

 

Category not specified

CountSearch('','',$cat,'','',''); $this->Search('','',$cat,'','','',$start_with,$news_per_page,' title ASC'); echo "

 

News in this category:

\n"; for ($i=0;$i<$this->total;$i++) { $this->choice[$i]->PrintHalf("whole_story.php","cat_param","news_id"); echo "
\n"; } ?>
0) { $s=max($start_with-$news_per_page,0); echo "<<Previous $news_per_page"; } echo "\n"; if ($total>$start_with+$news_per_page) { $s=$start_with+$news_per_page; echo "Next $news_per_page>>"; } } ?>
 

Keywords not specified

CountSearch($keywords,' AND ',$cat,'','',''); $this->Search($keywords,' AND ',$cat,'','','',$start_with,$news_per_page,' title ASC'); echo "

 

News in this category:

\n"; for ($i=0;$i<$this->total;$i++) { $this->choice[$i]->PrintHalf("whole_story.php","cat_param","news_id"); echo "
\n"; } ?>
0) { $s=max($start_with-$news_per_page,0); echo "<<Previous $news_per_page"; } echo "\n"; if ($total>$start_with+$news_per_page) { $s=$start_with+$news_per_page; echo "Next $news_per_page>>"; } ?>
id; } function Category($id=-1,$tag='',$parent=0,$name='',$c,$n,$l) { $this->BasicHeadLinesClass($c,$n); $this->id=$id; $this->tag=$tag; $this->parent=$parent; $this->name=$name; $this->link=$l; } function CategoryByIdWhat($what_field,$what_value) { $sql="SELECT id,tag,parent,name,linkurl FROM $this->category_table WHERE $what_field='$what_value' LIMIT 1"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); if ($row = mysql_fetch_array($r)) { list($this->id,$this->tag,$this->parent,$this->name,$this->link)=$row; } } function CategoryById($id) { $this->CategoryByIdWhat("id",$id); } function CategoryByTag($tag) { $this->CategoryByIdWhat("tag",$tag); } function CategoryByName($name) { $this->CategoryByIdWhat("name",$name); } function CategoryFromParams() { $p=(isset($_POST))?$_POST:$_GET; $p=$_POST; $this->id=$p["id_cat"]; $this->tag=$p["tag"]; $this->parent=$p["parent"]; $this->name=$p["name"]; $this->link=$p["linkurl"]; } // create new record in the category table function Save() { if ($this->id==-1) { $sql="INSERT INTO $this->category_table (tag,parent,name,linkurl) VALUES ( '$this->tag',$this->parent,'$this->name','$this->link')"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); $sql="SELECT id FROM $this->category_table ORDER BY id DESC LIMIT 1"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); if ($row = mysql_fetch_array($r)) { $this->id=$row[0]; } } else { $sql="UPDATE $this->category_table SET tag='$this->tag',parent=".$this->parent. ", name='$this->name',linkurl='$this->link' WHERE id=".$this->id; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); } return; } function CountSubCategories () { $c=0; $id=$this->id; $q="SELECT count(*) AS c FROM $this->news_table WHERE parent=$id"; if ($r=mysql_query($q)) { if ($a=mysql_fetch($r)) { $c+=$a[0]; } } $q="SELECT id FROM $this->category_table WHERE parent=$id"; if ($r=mysql_query($q)) { while ($a=mysql_fetch_assoc($r)) { $o=new Category($a[0],'',0,'',$this->category_table,$this->news_table,''); $c+=$o->CountSubCategories(); } } return $c; } function CountNewsInTheCategory () { $c=0; $id=$this->id; $q="SELECT count(*) AS c FROM $this->news_table WHERE category=$id"; if ($r=mysql_query($q)) { if ($a=mysql_fetch($r)) { $c=$a[0]; } } return $c; } function CountNewsInTheCategoryExtended () { $c=0; $id=$this->id; $q="SELECT count(*) AS c FROM $this->news_table WHERE category=$id"; if ($r=mysql_query($q)) { if ($a=mysql_fetch($r)) { $c+=$a[0]; } } $q="SELECT id FROM $this->category_table WHERE parent=$id"; if ($r=mysql_query($q)) { while ($a=mysql_fetch_assoc($r)) { $o=new Category($a[0],'',0,'',$this->category_table,$this->news_table,''); $c+=$o->CountNewsInTheCategoryExtended(); } } return $c; } function GetSubCategories () { $id=$this->id; $q="SELECT id FROM $this->category_table WHERE parent=$id"; $i=0; $a=array(); if ($r=mysql_query($q)) { while ($k=mysql_fetch_array($r)) { $a[$i++]=$k[0]; } } for ($n=0;$n<$i;$n++) { $o=new Category($a[$n],'',0,'',$this->category_table,$this->news_table,''); $b=$o->GetSubCategories(); if (count($b)>0) { $a=array_merge($a,$b); } } return $a; } function DeleteCategory() { $q="DELETE FROM $this->news_table WHERE category=$this->id"; $r=mysql_query($q) or Die("Failed executing $q:". mysql_error()); $a=$this->GetSubCategories(); for ($i=0;$iBasicHeadLinesClass($c,$n); } function PrintSublevel($id,$sl,$cur,$mode) { $q="SELECT id,tag,name FROM $this->category_table WHERE parent=$id ORDER BY name ASC"; $r=mysql_query($q) or die("Can't execute query $q: ".mysql_error()); while ($a=mysql_fetch_assoc($r)) { $nam =str_repeat("-",$sl).$a["name"]; $v=$a["name"]; switch ($mode) { case 0: $v=$a["id"]; break; case 1: $v=$a["tag"]; } $eid = $a["id"]; echo ""; $this->PrintSublevel($eid,$sl+1,$cur,$mode); } } function PrintCategoriesCombo ($comboname,$cur,$mode) { echo ""; } function PrintTREE_ITEM_SubLevel($id) { global $category_general; $q="SELECT id,tag,name,linkurl FROM $this->category_table WHERE parent=$id"; $r=mysql_query($q) or die("Can't execute query $q: ".mysql_error()); $i=0; while ($a=mysql_fetch_assoc($r)) { if ($i>0) { echo ","; } else { $i=1; } $v=$a["name"]; $eid = $a["id"]; $ll = $a["linkurl"]; if (!$ll) { $ll="'$category_general?cat=$eid'"; } else { $ll="'$ll'"; } echo "['$v',$ll"; $q="SELECT count(*) FROM $this->category_table WHERE parent=$eid"; $r1=mysql_query($q) or die("Can't execute query $q: ".mysql_error()); $a1=mysql_fetch_array($r1); if ($a1[0]>0) { echo ","; $this->PrintTREE_ITEM_SubLevel($eid); } echo "]"; } } function PrintCategoriesTree () { ?> id; } // create the news object function SingleNews($id=-1,$date,$source,$title,$text,$category,$owner,$c,$n) { $this->BasicHeadLinesClass($c,$n); $this->id=$id; $this->date=$date; $this->source=$source; $this->title=$title; $this->text=$text; $this->category=$category; $this->owner=$owner; } function NewsByID() { $sql="SELECT date,source,title,text,category,owner FROM $this->news_table WHERE id=$this->id"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); if ($row = mysql_fetch_array($r)) { list($this->date,$this->source,$this->title, $this->text,$this->category,$this->owner)=$row; } } function KillMe() { $sql="DELETE FROM $this->news_table WHERE id=$this->id"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); $this->id=-1; } function NewsFromParams() { $p=(isset($_POST))?$_POST:$_GET; $p=$_POST; if (!$p["news_id"]) { return 0; } $this->id=$p["news_id"]; $this->date=$p["news_date"]; $this->source=$p["news_source"]; $this->title=$p["news_title"]; $this->owner=$p["news_owner"]; $this->text=$p["news_text"]; $this->category=$p["category"]; if (!$p["news_title"]) { return 0; } return 1; } // create new record in the news table function Save() { if ($this->id==-1) { $sql="INSERT INTO $this->news_table (date,source,title,text,category,owner) VALUES ( NOW(),'$this->source','".htmlspecialchars(addslashes($this->title))."', '".htmlspecialchars(addslashes($this->text))."',$this->category,$this->owner)"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); $sql="SELECT id,date FROM $this->news_table ORDER BY id DESC LIMIT 1"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); if ($row = mysql_fetch_array($r)) { list($this->id,$this->date)=$row; } return $this->id; } else { $sql="UPDATE $this->news_table SET date='$this->date',source='$this->source', title='".htmlspecialchars(addslashes($this->title))."', text='".htmlspecialchars(addslashes($this->text))."', category=$this->category WHERE id=$this->id"; $r = mysql_query($sql) or Die("Failed executing $sql:". mysql_error()); } } // Print Form function PrintEditForm() { ?>

 Create the news.

   
  category: category_table,$this->news_table); $c->PrintCategoriesCombo("category",-1,0); ?>
    title:
    source:
    text:
     

You can add the images only after you have created the news. Please add news and then you can add images.

 
title; ?>
 
 
text); $t=substr($t,0,$quater_symbols); $t=preg_replace("/\n/","
",$t); $t=preg_replace("/\s\S+$/","...",$t);; echo $t; ?>
 
    title, "; $d=$this->date; $d=preg_replace("/\d\d(\d\d)-(\d\d)-(\d\d)/","$2.$3.$1",$d); echo $d; ?>  
 

text,0,$half_symbols); $t=preg_replace("/\s\S+$/","...",$t);; require_once("news_images.php"); $t=CheckImages($t); $t=preg_replace("/\n/","
",$t); echo $t; ?>

   
    title, "; $d=$this->date; $d=preg_replace("/\d\d(\d\d)-(\d\d)-(\d\d)/","$2.$3.$1",$d); echo $d; ?>  
 

text; require_once("news_images.php"); $text=CheckImages($text); $t=preg_replace("/\n/","
",$text); echo $t; ?>

  title;?>   PHP Fatal error: Class 'AllNews' not found in E:\web\essexoffice.com\www\news\news.php on line 6