network_id, $_SESSION['user']['id'] ); if( !$page_access ) { if( $user_type == DISABLED_MEMBER ) { $redirect_url = $base_url.'/homepage.php?msg=7003'; } else if( empty( $user_type ) || $user_type == NETWORK_WAITING_MEMBER) { $redirect_url = $base_url.'/homepage.php?msg=7002'; } else { $redirect_url = NULL; } if( $redirect_url ) { header("Location:$redirect_url"); exit; } } } }//____eof__do_redirect ob_start(); $time = gmdate('D, d M Y H:i:s').'GMT'; header("Last-Modified: $time"); header("Expires: $time"); header("Pragma: no-cache"); return 1; } } function register_session($login_name,$user_id,$role,$first_name,$last_name,$email,$picture=NULL){ session_start(); $_SESSION['user']['name'] = $login_name; $_SESSION['user']['id'] = $user_id; $_SESSION['user']['role'] = $role; $_SESSION['user']['first_name'] = $first_name; $_SESSION['user']['last_name'] = $last_name; $_SESSION['user']['email'] = $email; $_SESSION['user']['picture'] = $picture; } function has_html(& $s) { return (preg_match('/<[^>]+>/',$s)) ? true : false; } function chop_string($string, $length=30, $link = "") { global $base_url; if (has_html($string)) { $san = new InputSanitizer(); $san->passthrough = TRUE; // we want no HTML filtering here $return = $san->process($string, $length); } else { $return = substr($string, 0, $length); if(strlen($string) > $length) { $return .= ".."; /*if($length >= DESCRIPTION_LENGTH && !empty($link)) { $return .= "
read more.."; }*/ } } $return = nl2br($return); return $return; } function filter_all_post(&$post_array, $strip_all_tags = FALSE, $allow_tags_everywhere = FALSE) { $filt = Validation::get_input_filter($strip_all_tags); if ($allow_tags_everywhere) $filt->htmlAllowedEverywhere = TRUE; $post_array = $filt->process($post_array); } //Function will take the comma separated tags as argument and return the array of these comma seprated tags function tags_string_to_array($tagstring) { $tags = array(); if(strlen($tagstring) > 0) { $tags_array = explode(",",$tagstring); foreach($tags_array as $value) { $tags[] = $value; } } return $tags; } // Function will take an array as argument and return the delimiter separated string function tags_array_to_string($tagarray, $delimiter = ',') { $tagstring = ""; if(count($tagarray) > 0) { for($counter = 0; $counter < count($tagarray); $counter++) { $tagstring .= $tagarray[$counter]['name'].$delimiter; } $tagstring = substr($tagstring, 0, strlen($tagstring) - 1); } return $tagstring; } /* This function is used to displat the formatted ouput.Following things will be handled by it - Will split the String to chunks. - Will Strip slashes */ function display_sanitized($body,$length=CHUNK_LENGTH) { $body = stripslashes($body); $body = chunk_split($body, $length); return $body; } //This function checks the mime type of file //purpose e.g. if we change abc.pdf to abc.gif then it will cause GD crash //So we can check it actually if (!function_exists('mime_content_type')) { function mime_content_type($f) { //$output = system ( trim( 'file -bi ' . escapeshellarg ( $f ) ) ) ; $output = exec(trim('file -bi ' . escapeshellarg ($f))); return $output; } } /** * function used to check permissions for user to do an activity * @param $params is array of parameters like $params['action'], $param['uid'].. */ function user_can( $params ) { global $network_info; $action = $params['action']; switch( $action ) { case 'edit_content': case 'delete_content': if( $params['uid'] && $params['cid'] ) { //super admin can edit/ delete any content if( $params['uid'] == SUPER_USER_ID ) { return true; } // network owner can edit / delete any content in a network if( Network::is_admin( $network_info->network_id, $params['uid'] ) ) { return true; } //Loading content $content_obj = Content::load_content((int)$params['cid'], $params['uid'] ); //author of the content can perform the action if( $content_obj->author_id == $params['uid'] ) { return true; } if( $content_obj->parent_collection_id != -1 ) { // content is a part of some collection // Loading collection $collection_obj = ContentCollection::load_collection((int)$content_obj->parent_collection_id, $params['uid'] ); // owner of collection can also edit the content if ( $collection_obj->author_id == $params['uid'] ) { return true; } } } break; case 'delete_comment': //network owner can delete any comment global $login_uid, $network_info; $comment = $params['comment_info'];//array having the comment details if ($login_uid == SUPER_USER_ID) { //Super user can delete any comment return true; } else if ($network_info->owner_id == $login_uid) {//Network owner can delete the comment return true; } else if ($comment['user_id'] == $login_uid) { //Author of comment can delete the comment return true; } $content = Content::load_content((int)$comment['content_id'], $login_uid); if ($content->author_id == $login_uid) { //Author of the content can delete the comment. return true; } else if ($content->parent_collection_id != -1) { // means content belongs to some collection $collection = ContentCollection::load_collection($content->parent_collection_id, $login_id); if ($collection->author_id == $login_uid) {//If content on which comment has been posted belongs to some collection then author of that collection can delete the comment return true; } } return false;// return false in all the other cases break; } return false; } ?>