} if (!empty($sub_cats)) { $string = $i . ', ' . implode(", ", $sub_cats); } else { $string = $i; } $where .= " AND (document_category_id IN ({$string}))"; //if the category has a main category $main_cat = $database->database_fetch_assoc($database->database_query("SELECT t2.category_id, t2.category_name FROM se_document_categories as t1 INNER JOIN se_document_categories t2 ON t1.cat_dependency = t2.category_id WHERE t1.category_id = '{$i}'")); if (!empty($main_cat)) { $smarty->assign("main_cat_id", $main_cat['category_id']); } } //GETTING FIVE RECENTLY UPLOADED DOCUMENTS AND UPDATED THEIR STATUS $where_temp .= $where . " AND (document_status = 0)"; $doc_forUpdate = $document->documents_list(0, 5, 'document_datecreated DESC', $where_temp, 1); $scribd_api_key = $params['api_key']; $scribd_secret = $params['secret_key']; foreach ($doc_forUpdate as $value) { $scribd = new Document($scribd_api_key, $scribd_secret, $value->document_info['document_user_id']); $scribd->my_user_id = $value->document_info['document_user_id']; try { $stat = trim($scribd->getConversionStatus($value->document_info['document_doc_id'])); } catch (Exception $e) { $message = $e->getMessage(); $excep_error = 1; $smarty->assign('excep_message', $message); } if ($stat == 'DONE') { try { //GETTING DOCUMENT'S FULL TEXT
$p = $_GET['p']; } else { $p = 1; } $documents = new Document(null, null, $owner->user_info['user_id']); // SET PRIVACY LEVEL AND WHERE CLAUSE $privacy_max = $owner->user_privacy_max($user); $where = "(document_privacy & {$privacy_max}) AND (document_approved = '1') AND (document_publish = '1') AND (document_status = 1) AND (document_user_id = '{$owner->user_info['user_id']}') "; $sort = "document_datecreated DESC"; $total_docs = $documents->documents_total($where); if ($total_docs > 0) { //SHOWING A PROFILE TAB if ($params['document_block'] == 1) { $entries_per_page = 5; $page_vars = make_page($total_docs, $entries_per_page, $p); $tab_documents = $documents->documents_list($page_vars[0], $entries_per_page, $sort, $where, 1); $smarty->assign('documents', $tab_documents); $smarty->assign('total_docs', $total_docs); $smarty->assign('p', $page_vars[1]); $smarty->assign('maxpage', $page_vars[2]); $smarty->assign('p_start', $page_vars[0] + 1); $smarty->assign('p_end', $page_vars[0] + count($tab_documents)); $plugin_vars['menu_profile_tab'] = array('file' => 'profile_document_tab.tpl', 'title' => 650003010, 'name' => 'document'); } else { //SHOWING A SIDE BLOCK ON PROFILE PAGE //GETTING TWO MOST RECENT DOCUMENTS OF THE USER $side_documents = $documents->documents_list(0, 2, $sort, $where, 1); $plugin_vars['menu_profile_side'] = array('file' => 'profile_document_side.tpl', 'title' => 650003010, 'name' => 'document'); $smarty->assign('total_docs', $total_docs); $smarty->assign('documents', $side_documents); }
$start = ($p - 1) * $entries_per_page; // GET TOTAL DOCUMNETS $total_entries = $scribd->documents_total($where); // MAKE DOCUMENT PAGES $page_vars = make_page($total_entries, $entries_per_page, $p); $page_array = array(); for ($x = 0; $x <= $page_vars[2] - 1; $x++) { if ($x + 1 == $page_vars[1]) { $link = "1"; } else { $link = "0"; } $page_array[$x] = array('page' => $x + 1, 'link' => $link); } // GET DOCMENTS ARRAY $documents = $scribd->documents_list($page_vars[0], $entries_per_page, $sort, $where, 1); // ASSIGN SMARTY VARIABLES AND SHOW VIEW DOCUMENTS PAGE $smarty->assign('total_documents', $total_entries); $smarty->assign('pages', $page_array); $smarty->assign('documents', $documents); $smarty->assign('f_title', $f_title); $smarty->assign('f_owner', $f_owner); $smarty->assign('i', $i); $smarty->assign('t', $t); $smarty->assign('o', $o); $smarty->assign('v', $v); $smarty->assign('d', $d); $smarty->assign('a', $a); $smarty->assign('f', $f); $smarty->assign('p', $page_vars[1]); $smarty->assign('s', $s);
} if (isset($_POST['s'])) { $s = $_POST['s']; } elseif (isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "created DESC"; } // ENSURE SORT/VIEW ARE VALID if ($s != "document_datecreated DESC" && $s != "document_views DESC" && $s != "document_dateupdated DESC" && $s != 'total_comments DESC') { $s = "document_datecreated DESC"; } // CREATE SCRIBD OBJECT $document = new Document(null, null); // SET PRIVACY LEVEL AND WHERE CLAUSE $privacy_max = $owner->user_privacy_max($user); $where = "(document_privacy & {$privacy_max}) AND (document_approved = '1') AND (document_publish = '1') AND (document_status = 1) AND (document_user_id = '{$owner->user_info['user_id']}') "; $entries_per_page = 10; // GET TOTAL DOCUMNETS $total_entries = $document->documents_total($where); $page_vars = make_page($total_entries, $entries_per_page, $p); // GET DOCMENTS ARRAY $documents = $document->documents_list($page_vars[0], $entries_per_page, $s, $where, 1); // ASSIGN SMARTY VARIABLES AND SHOW VIEW DOCUMENTS PAGE $smarty->assign('documents', $documents); $smarty->assign('total_entries', $total_entries); $smarty->assign('p', $page_vars[1]); $smarty->assign('maxpage', $page_vars[2]); $smarty->assign('p_start', $page_vars[0] + 1); $smarty->assign('p_end', $page_vars[0] + count($documents)); include "footer.php";
if ($user->user_info['user_id'] == $owner->user_info['user_id']) { $database->database_query("\r\n DELETE FROM\r\n se_notifys\r\n USING\r\n se_notifys\r\n LEFT JOIN\r\n se_notifytypes\r\n ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id\r\n WHERE\r\n se_notifys.notify_user_id='{$owner->user_info[user_id]}' AND\r\n se_notifytypes.notifytype_name='documentcomment' AND\r\n notify_object_id='{$document->document_info['document_id']}'\r\n "); } //SETTING PARAMETERS FOR SECURE DOCUMENT if ($user->user_info['user_id'] == 0) { $uid = mt_rand(1000, 100000); } else { $uid = $user->user_info['user_id']; } $sessionId = session_id(); $signature = md5($scribd_secret . 'document_id' . $document->document_info['document_doc_id'] . 'session_id' . $sessionId . 'user_identifier' . $uid); $smarty->assign('uid', $uid); $smarty->assign('sessionId', $sessionId); $smarty->assign('signature', $signature); // FOR SHOWING THE USER'S DOCUMENT ON THE RIGHT SIDE BLOCK. WE ARE USING BELOW CODE. //GETTING USER'S DOCUMENTS AND SELECTING TWO RANDOM DOCUMENTS AMONG THEM // SET PRIVACY LEVEL AND WHERE CLAUSE $privacy_max = $owner->user_privacy_max($user); $where_tmp = "(document_privacy & {$privacy_max}) AND (document_approved = '1') AND (document_publish = '1') AND (document_status = 1) AND (document_user_id = '{$owner->user_info['user_id']}') AND (se_documents.document_id NOT IN('{$document->document_info['document_id']}')) "; $total_entries = $document->documents_total($where_tmp); $documents = $document->documents_list(0, 3, "RAND()", $where_tmp, 1); // GET TOTAL DOCUMNETS $smarty->assign('total_comments', $total_comments); $smarty->assign('allowed_to_comment', $allowed_to_comment); $smarty->assign("document", $document); $smarty->assign("documents", $documents); $smarty->assign("total_entries", $total_entries); $smarty->assign("excep_error", $excep_error); $smarty->assign("excep_message", $excep_message); $smarty->assign("params", $params); include "footer.php";
$smarty->assign('excep_message', $message); } $smarty->assign('msg', 'Document has been deleted'); } } if ($task == 'publish') { $doc_id = $_GET['document_id']; $result = $database->database_fetch_assoc($database->database_query("SELECT document_id FROM se_documents WHERE document_id = '{$doc_id}' AND document_user_id = '" . $user->user_info['user_id'] . "' AND document_publish = 0")); if (!empty($result)) { $database->database_query("UPDATE se_documents SET document_publish = 1 WHERE document_id = '{$doc_id}'"); $smarty->assign('msg', 'Document has been published successfully.'); } } //BLOCK FOR UPDATING CONVERSION STATUS OF THE DOCUMENT $where_tmp = " se_documents.document_user_id=" . $user->user_info[user_id] . " AND se_documents.document_status = 0"; $doc_forUpdate = $scribd->documents_list(0, 5, 'document_datecreated DESC', $where_tmp, 1); foreach ($doc_forUpdate as $value) { $scribd_tmp = new Document($scribd_api_key, $scribd_secret, $value->document_info['document_user_id']); $scribd_tmp->my_user_id = $value->document_info['document_user_id']; try { $stat = trim($scribd_tmp->getConversionStatus($value->document_info['document_doc_id'])); } catch (Exception $e) { $message = $e->getMessage(); $excep_error = 1; $smarty->assign('excep_message', $message); } if ($stat == 'DONE') { try { //GETTING DOCUMENT'S FULL TEXT $texturl = $scribd_tmp->getDownloadUrl($value->document_info['document_doc_id'], 'txt'); //for some reason, the URL comes back with leading and trailing spaces