function AddSMFPersonalBlock() { global $boarddir, $context, $adkFolder; checkSession('get'); //Set error if empty id if (empty($_REQUEST['id']) || empty($_REQUEST['name']) || empty($_REQUEST['real'])) { fatal_lang_error('adkfatal_smf_p_blocks_not', false); } $id = CleanAdkStrings($_REQUEST['id']); $name = cleanAdkStrings($_REQUEST['name']); $real = CleanAdkStrings($_REQUEST['real']); //Set the dir blocks $blocks_dir = $adkFolder['blocks'] . '/' . $real; //Get the file :D $block_portal = getFile('http://www.smfpersonal.net/Adk-downloads/' . $id); //die($block_portal); fopen($blocks_dir, 'a'); //die(); //Does not exists? if (empty($block_portal)) { fatal_lang_error('adkfatal_smf_p_blocks_not', false); } //Create a block file_put_contents($blocks_dir, $block_portal); //Expand variable to create a simple block $_POST += array('titulo' => $name, 'empty_title' => 0, 'empty_body' => 0, 'empty_collapse' => 0, 'img' => ''); createBlock('include', $real); redirectexit('action=admin;area=blocks;sa=viewblocks;' . $context['session_var'] . '=' . $context['session_id']); }
function template_download_new_block() { global $scripturl, $context, $txt, $boardurl, $adkFolder; echo ' <form method="post" action=""> <div class="cat_bar"> <h3 class="catbg"> <img alt="" class="adk_vertical_align" src="' . $adkFolder['images'] . '/drive_key.png" /> ', $txt['adkmod_block_download'], ' </h3> </div> <table style="width: 100%;"> <tr>'; $i = 0; if (!empty($context['smf_personal_blocks'])) { foreach ($context['smf_personal_blocks']->bloque as $bloque) { if ($i == 2) { echo '</tr><tr style="padding:; 8px;">'; $i = 0; } $desc = CleanAdkStrings(utf8_decode($bloque->description)); $name = CleanAdkStrings(utf8_decode($bloque->name)); echo ' <td> <span class="clear upperframe"> <span> </span> </span> <div class="roundframe"> <div> <span style="cursor: pointer;" title="', $desc, '"> ', $name, ' </span> <div style="float: right;"> <a href="', $scripturl, '?action=admin;area=blocks;sa=add_smf_block;id=', $bloque->filename, ';name=', $bloque->name, ';real=', $bloque->original, ';', $context['session_var'], '=', $context['session_id'], '"><img alt="', $txt['adkblock_install'], '" title="', $txt['adkblock_install'], '" src="' . $adkFolder['images'] . '/add.png" /></a> <a href="http://www.smfpersonal.net/index.php?action=downloads;sa=view;down=', $bloque->file_id, '"><img alt="', $txt['adkblock_go_to_personal'], '" title="', $txt['adkblock_go_to_personal'], '" src="' . $adkFolder['images'] . '/xmag.png" /></a> </div> <br class="clear" /> </div> </div> <span class="clear lowerframe"> <span> </span> </span> </td>'; $i++; } } else { echo ' <td> <span class="clear upperframe"> <span> </span> </span> <div class="roundframe"> <div style="text-align: center; font-weight: bold; font-family: georgia;"> ' . $txt['adkblock_no_blocks'] . ' </div> </div> <span class="clear lowerframe"> <span> </span> </span> </td>'; } echo ' </tr> </table> </form>'; }
function SaveSettingsStandAlone() { checkSession('post'); $adk_stand_alone_url = !empty($_POST['adk_stand_alone_url']) ? CleanAdkStrings($_POST['adk_stand_alone_url']) : ''; updateSettingsAdkPortal(array('adk_stand_alone_url' => $adk_stand_alone_url)); global $context; redirectexit('action=admin;area=adkadmin;sa=standalone;' . $context['session_var'] . '=' . $context['session_id']); }
function notasparacambiar() { global $user_info, $smcFunc, $txt, $adkFolder; $notes = ''; if (isset($_POST['notes_save']) && isset($_POST['notes_txt'])) { $notes = CleanAdkStrings($_POST['notes_txt']); if ($user_info['is_guest']) { $_SESSION['adk_notes'] = $notes; } else { updateMemberData($user_info['id'], array('adk_notes' => $notes)); } } else { $notes = $user_info['adk_notes']; //If this user is guest, He can add notes too ;) if (isset($_SESSION['adk_notes']) && $user_info['is_guest']) { $notes = $_SESSION['adk_notes']; } } echo ' <script type="text/javascript"> function ChangeContent(id, id2) { if(document.getElementById(id).style.display == "none"){ document.getElementById(id).style.display = "block"; } else{ document.getElementById(id).style.display = "none"; } if(document.getElementById(id2).style.display == "none"){ document.getElementById(id2).style.display = "block"; } else{ document.getElementById(id2).style.display = "none"; } } </script>'; echo ' <div class="smalltext" align="center" id="note" style="display: none;"> <form action="" method="post"> <textarea rows="3" cols="15" name="notes_txt">', $notes, '</textarea> <br /> <br /><input class="button_submit" type="submit" name="notes_save" value="' . $txt['save'] . '" /> </form> </div>'; echo ' <div id="note2" align="center" class="smalltext" style="display: block;"> ', empty($notes) ? $txt['adkmod_block_reminder'] : parse_bbc($notes), ' </div> <div align="right"> <a href="javascript:ChangeContent(\'note\',\'note2\')" title="' . $txt['adkmod_block_editar'] . '"> <img alt="" src="' . $adkFolder['images'] . '/email_edit.png" /> </a> </div> '; /* rows="10" cols="10" onkeyup="if(this.value.length > 140){this.value=this.value.substring(0,140);alert(\'no puede poner más de 140 caracteres\')}"*/ }
function createBlock($type = 'php', $echo) { global $smcFunc; $name = CleanAdkStrings($_POST['titulo']); $empty_body = !empty($_POST['empty_body']) ? 1 : 0; $empty_title = !empty($_POST['empty_title']) ? 1 : 0; $empty_collapse = !empty($_POST['empty_collapse']) ? 1 : 0; $img = !empty($_POST['img']) ? CleanAdkStrings($_POST['img']) : ''; if (empty($name)) { fatal_lang_error('adkfatal_empty_title', false); } $the_array_info = array('name' => 'text', 'echo' => 'text', 'img' => 'text', 'type' => 'text', 'empty_body' => 'int', 'empty_title' => 'int', 'empty_collapse' => 'int'); $the_array_insert = array($name, $echo, $img, $type, $empty_body, $empty_title, $empty_collapse); $smcFunc['db_insert']('insert', '{db_prefix}adk_blocks', $the_array_info, $the_array_insert, array('id')); }
function AdkSearchDownloads2() { global $smcFunc, $txt, $context, $scripturl, $user_info, $adkportal; checkSession('post'); setLinktree('downloads', 'adkdown_downloads'); setLinktree('downloads;sa=search', 'adkdown_search'); $body = CleanAdkStrings($_POST['search']); //Set the permissions $allowed_to_manage = allowedTo('adk_downloads_manage') ? 1 : 0; $sql = $smcFunc['db_query']('', ' SELECT d.id_file, d.title, d.id_member, m.id_member, m.real_name, d.lastdownload, d.totaldownloads, d.date, d.views FROM {db_prefix}adk_down_file AS d LEFT JOIN {db_prefix}members AS m ON (m.id_member = d.id_member) LEFT JOIN {db_prefix}adk_down_cat AS c ON (c.id_cat = d.id_cat) WHERE (d.title LIKE "%' . $body . '%" OR d.description LIKE "%' . $body . '%") AND ' . $adkportal['query_downloads'], array('a' => 1, 'member' => $user_info['id'])); $context['downloads'] = array(); while ($row = $smcFunc['db_fetch_assoc']($sql)) { $context['downloads'][] = array('id' => $row['id_file'], 'title' => $row['title'], 'id_member' => $row['id_member'], 'name' => $row['real_name'], 'date' => timeformat($row['date'], '%d/%m/%Y (%I:%M:%S %p)'), 'lastd' => !empty($row['lastdownload']) ? timeformat($row['lastdownload'], '%d/%m/%Y (%I:%M:%S %p)') : $txt['adkdown_never'], 'totald' => $row['totaldownloads'], 'viewsd' => $row['views']); } $smcFunc['db_free_result']($sql); if (count($context['downloads']) == 1) { foreach ($context['downloads'] as $id2) { $id = $id2['id']; } //redirect to the only download avaiable redirectexit('action=downloads;sa=view;down=' . $id); } elseif (count($context['downloads']) == 0) { $context['sub_template'] = 'adk_search_not'; $context['page_title'] = $txt['adkdown_search']; } else { $context['sub_template'] = 'adk_search_results'; $context['page_title'] = $txt['adkdown_search'] . ': ' . $body; } }
function AdkPagesAddComment() { global $smcFunc, $context, $user_info; checkSession('post'); cleanEditor(); $comment = CleanAdkStrings($_POST['descript']); $id_page = (int) $_POST['id_page']; $idUser = $user_info['id']; $date = time(); //Check if this user is allowed to view this page $page = getPage($id_page, true, true); if (empty($page)) { fatal_lang_error('adkfatal_page_not_exist', false); } $the_array_info = array('body' => 'text', 'date' => 'int', 'id_member' => 'int', 'id_page' => 'int'); $the_array_insert = array($comment, $date, $idUser, $id_page); $smcFunc['db_insert']('insert', '{db_prefix}adk_pages_comments', $the_array_info, $the_array_insert, array('id_new')); $last_id = 0; $last_id = $smcFunc['db_insert_id']("{db_prefix}adk_pages_comments"); //Add notifications to members $members_id = array(); $query = $smcFunc['db_query']('', ' SELECT id_member, adk_pages_notifications FROM {db_prefix}members WHERE id_group = {int:id_group}', array('id_group' => 1)); while ($row = $smcFunc['db_fetch_assoc']($query)) { $members_id[$row['id_member']] = $row['adk_pages_notifications']; } $smcFunc['db_free_result']($query); //Load comments user $sql = $smcFunc['db_query']('', ' SELECT c.id_member, m.adk_pages_notifications FROM {db_prefix}adk_pages_comments AS c LEFT JOIN {db_prefix}members AS m on (m.id_member = c.id_member) WHERE id_page = {int:id_page} AND c.id_member', array('id_page' => $id_page)); while ($row = $smcFunc['db_fetch_assoc']($sql)) { $members_id[$row['id_member']] = $row['adk_pages_notifications']; } $smcFunc['db_free_result']($sql); unset($members_id[$user_info['id']]); //Add notification if (!empty($members_id)) { foreach ($members_id as $id => $notifications) { $n = array(); if (!empty($notifications)) { $n = explode(',', $notifications); } $n[] = $last_id; $smcFunc['db_query']('', ' UPDATE {db_prefix}members SET adk_pages_notifications = {text:notifications} WHERE id_member = {int:id_member}', array('notifications' => implode(',', $n), 'id_member' => $id)); } } redirectexit('page=' . $page['urltext'] . ';comment=' . $last_id . '#' . $last_id); }
function DeleteImagesAdk() { checkSession('get'); global $smcFunc, $context, $boarddir, $boardurl; $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; if (!empty($_REQUEST['url2'])) { $url = CleanAdkStrings($_REQUEST['url2']); } else { fatal_lang_error('adkfatal_require_url', false); } $url = str_replace($boardurl, $boarddir, $url); @chmod($url, 0755); @unlink($url); //Delete this entry deleteEntry('adk_advanced_images', 'id = {int:id}', array('id' => $id)); redirectexit('action=admin;area=modules;sa=manageimagesadk;' . $context['session_var'] . '=' . $context['session_id']); }
function AdkDownloadSaveEditCategory() { global $context, $modSettings, $sourcedir, $txt, $boarddir, $smcFunc; checkSession('post'); $title = CleanAdkStrings($_POST['title']); $parent = (int) $_POST['parent']; $description = CleanAdkStrings($_POST['description']); $boardselect = (int) $_POST['boardselect']; $locktopic = (int) $_POST['locktopic']; $id_cat = !empty($_POST['id_cat']) ? (int) $_POST['id_cat'] : 0; $filename = $_POST['picture2']; $cant_view = createArrayFromPost('view'); $cant_add = createArrayFromPost('add'); $roworder = (int) $_POST['roworder']; if (empty($title)) { fatal_lang_error('adkfatal_cat_title_false', false); } $sortby = ''; $orderby = ''; if (!empty($_POST['sortby'])) { switch ($_POST['sortby']) { case 'date': $sortby = 'id_file'; break; case 'title': $sortby = 'title'; break; case 'mostview': $sortby = 'views'; break; case 'mostdowns': $sortby = 'totaldownloads'; break; } } else { $sortby = 'id_file'; } if (!empty($_POST['orderby'])) { switch ($_POST['orderby']) { case 'asc': $orderby = 'ASC'; break; case 'desc': $orderby = 'DESC'; break; } } else { $orderby = 'DESC'; } $context['download_file_name'] = ''; if (!empty($_FILES['picture']['name']) && $_FILES['picture']['name'] != '') { processIconDownload($_FILES['picture'], 'size'); processIconDownload($_FILES['picture'], 'update', $id_cat); } $smcFunc['db_query']('', ' UPDATE {db_prefix}adk_down_cat SET title = {string:title}, description = {string:description}, image = {string:filename}, id_board = {int:idb}, id_parent = {int:idp}, locktopic = {int:locktopic}, sortby = {string:sortby}, orderby = {string:orderby}, groups_can_add = {string:cant_add}, groups_can_view = {string:cant_view}, error = {int:error}, roworder = {int:roworder} WHERE id_cat = {int:id_cat}', array('title' => $title, 'description' => $description, 'filename' => $context['download_file_name'], 'idb' => $boardselect, 'idp' => $parent, 'locktopic' => $locktopic, 'sortby' => $sortby, 'orderby' => $orderby, 'id_cat' => $id_cat, 'cant_add' => $cant_add, 'cant_view' => $cant_view, 'error' => 0, 'roworder' => $roworder)); redirectexit('action=admin;area=adkdownloads;sa=allcategories;' . $context['session_var'] . '=' . $context['session_id']); }