تبلیغات اینترنتیclose
getId(), $download_id); $download_rating_module = MK_RecordModuleManager::getFromType('download_rating'); $head_title[] = $download->getTitle(); } catch(Exception $e) { header("Location: $this_filename", true, 302); exit; } if( $user->isAuthorized() ) { $already_rated_search = array( array('field' => 'user', 'value' => $user->getId()), array('field' => 'download', 'value' => $download->getId()) ); $already_rated = (boolean) $download_rating_module->searchRecords($already_rated_search); } if( MK_Request::getQuery('get') && ($download_file = $download->getFile()) && is_file($download_file) ) { $download ->setDownloads( $download->getDownloads() + 1 ) ->save(); $file_name = explode('/', $download_file); $file_name = array_pop($file_name); header("Content-type: application/force-download"); header('Content-Disposition: inline; filename="' . $download_file . '"'); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".$download->getFileSize()); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$file_name.'"'); readfile($download_file); exit; } elseif( ( $rating = MK_Request::getQuery('rating') ) && $user->isAuthorized() ) { $rating = (integer) $rating; $rating = $rating > 5 ? 5 : $rating; $rating = $rating < 1 ? 1 : $rating; if($already_rated === false) { $new_rating = MK_RecordManager::getNewRecord($download_rating_module->getId()); $new_rating ->setUser($user->getId()) ->setDownload($download->getId()) ->setRating($rating) ->save(); } header("Location: ".$this_filename."?download=".$download->getId(), true, 302); exit; } $output = ' Download File '; $output.= ' Downloads / '.$download->getTitle().' '; $output.= ' '; if($download_category = $download->getCategory()) { $download_category = MK_RecordManager::getFromId($download_category_module->getId(), $download_category); $category_list = array(); $parent_categories = array_reverse($download_category->getParentRecords()); $parent_categories[] = $download_category; $category_links = array(); foreach($parent_categories as $parent_category) { $category_links[] = ''.$parent_category->getTitle().''; } $output.= ' Category'; $output.= ' '.implode(' / ', $category_links).''; } $output.= ' Date Submitted'; $output.= ' '.$download->renderDateAdded().''; $download_rating = $download->getRating(); $output.= ' Rating'; $output.= ' isAuthorized() ? ' href="'.$this_filename.'?download='.$download->getId().'&rating=1"' : '').'>★ isAuthorized() ? ' href="'.$this_filename.'?download='.$download->getId().'&rating=2"' : '').'>★ isAuthorized() ? ' href="'.$this_filename.'?download='.$download->getId().'&rating=3"' : '').'>★ isAuthorized() ? ' href="'.$this_filename.'?download='.$download->getId().'&rating=4"' : '').'>★ isAuthorized() ? ' href="'.$this_filename.'?download='.$download->getId().'&rating=5"' : '').'>★ '; if(!$user->isAuthorized()) { $output.= ' You must be logged in to rate '; } elseif($already_rated) { $output.= ' You've already rated this download '; } $output.=''; $output.= ' File Size'; $output.= ' '.$download->renderFileSize().''; $output.= ' Downloads'; $output.= ' '.$download->renderDownloads().''; if($author = $download->getAuthor()) { $output.= ' Author'; $output.= ' '.$author.''; } if($author_website = $download->getAuthorWebsite()) { $output.= ' Author Website'; $output.= ' '.$author_website.''; } if($tags = $download->getTags()) { $tag_list = array(); $tags = explode(',', $tags); $tags = array_filter($tags); foreach($tags as $tag) { $tag = trim($tag); $tag_list[] = ''.MK_Utility::escapeText($tag).''; } $output.= ' Tags'; $output.= ' '.implode(', ', $tag_list).''; } $output.= ' '; if($download_image = $download->getImage()) { $large = 'library/thumb.php?f='.$download_image.'&method=contain&w=800&h=600'; $small = 'library/thumb.php?f='.$download_image.'&method=contain&w=300&h=300'; $output.= ' Preview Image '; $output.= ' Click to enlage / shrink '; } if($description = $download->getDescription()) { $output.= ' Description '; $output.= ' '.nl2br($description).' '; } $output.= ' Comments '; $paginator = new MK_Paginator(); $page = MK_Request::getQuery('page', 1); $paginator ->setPage($page) ->setPerPage(20); $download_comment_module = MK_RecordModuleManager::getFromType('download_comment'); $download_comments_search = array( array('field' => 'download', 'value' => $download_id) ); // Comment form $settings = array( 'attributes' => array( 'class' => 'clear-fix', 'action' => $this_filename.'?download='.$download->getId().'#comments' ) ); $fields = array( 'comment' => array( 'label' => 'Comment', 'type' => 'textarea', 'validation' => array( 'instance' => array() ) ), 'post-comment' => array( 'type' => 'submit', 'attributes' => array( 'value' => 'Post Comment' ) ) ); $form = new MK_Form($fields, $settings); if($form->isSuccessful()) { $new_comment = MK_RecordManager::getNewRecord($download_comment_module->getId()); $new_comment ->setUser($user->getId()) ->setDownload($download_id) ->setComment($form->getField('comment')->getValue()) ->save(); } $download_comments = $download_comment_module->searchRecords($download_comments_search, $paginator); if(count($download_comments) > 0) { $output.= ' '; foreach($download_comments as $download_comment) { $output.= ' Posted by '.$download_comment->renderUser().' - '.$download_comment->renderDateAdded().' '; $output.= ' '.nl2br(MK_Utility::escapeText($download_comment->getComment())).' '; } $output.= ' '; // Show pagination $output.= ' '.$paginator->render($this_filename."?page={page}&download=$download_id#comments").' '; } else { $output.= ' There are no comments, why not be the first to write one! '; } $output.= ' Leave a Comment '; if($user->isAuthorized()) { if($form->isSuccessful()) { $output.= ' Thank you for submitting your comment! '; } else { $output.= $form->render(); } } else { $output.= ' Please log in or register to write a comment! '; } } else { // We don't want ALL of the categories so we create a MK_Paginator $paginator = new MK_Paginator(); // If no page is defined we default to the first page and 10 categories per page $page = MK_Request::getQuery('page', 1); $paginator ->setPage($page) ->setPerPage(10); // Get the current category, if defined $download_categories_search = array( array('field' => 'parent_category', 'value' => $category_id) ); // Get categories, based on $category_id $download_categories = $download_category_module->searchRecords($download_categories_search, $paginator); $breadcrumb = array(); $breadcrumb[] = 'Downloads'; if($download_tag) { $head_title[] = 'Downloads tagged ''.$download_tag.'''; $breadcrumb[] = 'Downloads tagged ''.$download_tag.'''; } if( $category_id ) { $current_category = MK_RecordManager::getFromId($download_category_module->getId(), $category_id); $parent_categories = array_reverse($current_category->getParentRecords()); $parent_categories[] = $current_category; foreach($parent_categories as $parent_category) { $head_title[] = $parent_category->getTitle(); $breadcrumb[] = ''.$parent_category->getTitle().''; } } $output = ' '.implode(' / ', $breadcrumb).' '; if( ( $category_id && count($download_categories) === 0 ) || $download_tag ) { if($download_tag) { $downloads_search = array( array('literal' => "CONCAT(', ', `tags`, ',') LIKE '%, ".mysql_real_escape_string($download_tag, $config->db->con).",%'") ); } else { $downloads_search = array( array('field' => 'category', 'value' => $category_id) ); } $downloads = $download_module->searchRecords($downloads_search, $paginator); if(count($downloads) > 0) { $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; foreach($downloads as $download) { $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; } $output.= ''; $output.= ' Title Date Added Total Downloads '.$download->getTitle().' Posted '.$download->renderDateAdded().' '.$download->renderDateAdded().' '.$download->getDownloads().' '; // Show pagination $output.= ' '.$paginator->render($this_filename."?page={page}".($category_id ? "&category=$category_id" : '').($download_tag ? "&tag=".urlencode($download_tag) : '')).' '; } else { $output.= ' There are no files in this category! '; } } elseif( count($download_categories) > 0 ) { $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; foreach($download_categories as $category) { $output.= ''; $output.= ''; $output.= ''; $output.= ''; } $output.= ''; $output.= ' Category / Description Total Files '.$category->getTitle().' '.( $category->getDescription() ? ' '.nl2br($category->getDescription()).' ' : '').' '.$category->getTotalFiles().' '; // Show pagination $output.= ' '.$paginator->render($this_filename."?page={page}&category=$category_id").' '; } else { $output.= ' There are no files or categories to display! '; } } require_once '_header.php'; print $output; require_once '_footer.php'; ?>