rendered paste bodyfunction updateTopic( $topic_id , $status ) {
// our function to check if a topic has been read or not
if ( isset( $this->logged['id'] ) ) {
$post_indicate->user_id = $this->logged['id'];
} else {
$post_indicate->user_id = 0;
}
$post_indicate->time = time();
$post_indicate->type = $status;
$post_indicate->check = $this->sql->sql_query( "SELECT * FROM `".$this->tbl_prefix."post_indicate` WHERE `user_id` = '".$post_indicate->user_id."'" , 1 );
$post_indicate->num = $this->sql->sql_num_rows( $post_indicate->check );
if ( $post_indicate->num > 0 ) {
$post_indicate->row = $this->sql->sql_fetch_array( $post_indicate->check );
$post_indicate->recently_viewed = unserialize( $post_indicate->row['recently_viewed'] );
if ( $post_indicate->type == '1' ) {
if ( !isset( $post_indicate->recently_viewed[''.$topic_id.''] ) ) {
$post_indicate->recently_viewed[''.$topic_id.''] .= array(
$topic_id => "1",
);
}
$post_indicate->new_recently_viewed = serialize( $post_indicate->recently_viewed );
$this->sql->sql_query( "UPDATE `".$this->tbl_prefix."post_indicate` SET `recently_viewed` = '".$post_indicate->new_recently_viewed."', `time` = '".$post_indicate->time."' WHERE `user_id` = '".$post_indicate->user_id."'" , 1 );
} else {
$post_indicate->loop_rows = $this->sql->sql_query( "SELECT * FROM `".$this->tbl_prefix."post_indicate`" , 1 );
while ( $post_indicate->loop_row = $this->sql->sql_fetch_array( $post_indicate->loop_rows ) ) {
$post_indicate->this_recently_viewed = unserialize( $post_indicate->loop_row['recently_viewed'] );
if( !isset( $post_indicate->this_recently_viewed[''.$topic_id.''] ) ) {
unset( $post_indicate->this_recently_viewed[''.$topic_id.''] );
}
$post_indicate->new_this_recently_viewed = serialize( $post_indicate->this_recently_viewed );
$this->sql->sql_query( "UPDATE `".$this->tbl_prefix."post_indicate` SET `recently_viewed` = '".$post_indicate->new_this_recently_viewed."', `time` = '".$post_indicate->time."' WHERE `user_id` = '".$post_indicate->loop_row['user_id']."'" , 1 );
}
}
} elseif ( $post_indicate->num == 0 ) {
if ( $post_indicate->type == '1' ) {
$post_indicate->insert_recently_viewed = array();
$post_indicate->insert_recently_viewed[''.$topic_id.''] .= array(
$topic_id => "1",
);
$post_indicate->insert_recently_viewed = serialize( $post_indicate->insert_recently_viewed );
$this->sql->sql_query( "INSERT INTO `".$this->tbl_prefix."post_indicate` (time,user_id,recently_viewed) VALUES('".$post_indicate->time."','".$post_indicate->user_id."','".$post_indicate->insert_recently_viewed."')" , 1 );
} else {
$post_indicate->loop_rows = $this->sql->sql_query( "SELECT * FROM `".$this->tbl_prefix."post_indicate`" , 1 );
while ( $post_indicate->loop_row = $this->sql->sql_fetch_array( $post_indicate->loop_rows ) ) {
$post_indicate->this_recently_viewed = unserialize( $post_indicate->loop_row['recently_viewed'] );
if( !isset( $post_indicate->this_recently_viewed[''.$topic_id.''] ) ) {
unset( $post_indicate->this_recently_viewed[''.$topic_id.''] );
}
$post_indicate->new_this_recently_viewed = serialize( $post_indicate->this_recently_viewed );
$this->sql->sql_query( "UPDATE `".$this->tbl_prefix."post_indicate` SET `recently_viewed` = '".$post_indicate->new_this_recently_viewed.", `time` = '".$post_indicate->time." WHERE `user_id` = '".$post_indicate->loop_row['user_id']."'" , 1 );
}
}
}
// our function to check if a topic has been read or not
}