Esempio n. 1
0
function showsaveeditnews()
{
    global $smcFunc, $context;
    checkSession('post');
    //Clean it
    cleanEditor();
    $id_new = (int) $_POST['id'];
    $autor = CleanAdkStrings($_POST['autore']);
    $title = CleanAdkStrings($_POST['titlepage']);
    $insert = CleanAdkStrings($_REQUEST['descript']);
    $insert = $insert;
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}adk_news
		SET autor = {string:autor},
		titlepage = {string:title},
		new = {string:insert}
		WHERE id = {int:id}', array('autor' => $autor, 'title' => $title, 'insert' => $insert, 'id' => $id_new));
    redirectexit('portal');
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
function EditSaveDownload()
{
    global $modSettings, $sourcedir, $smcFunc, $context, $user_info, $boarddir, $scripturl, $txt, $adkportal, $adkFolder;
    //Need this session
    checkSession('post');
    //Set the initial post
    $id_cat = (int) $_POST['cat'];
    $ex_id_cat = (int) $_POST['ex_id_cat'];
    $id_file = (int) $_POST['id_file'];
    //isAllowedToAdd
    verifyCatPermissions('addfile', $id_cat == $ex_id_cat ? $ex_id_cat : $id_cat);
    //The latest
    if ($context['user']['is_guest']) {
        falta_lang_error('adkfatal_guest_not_add', false);
    }
    cleanEditor();
    if ($user_info['id'] != (int) $_POST['id_member'] && !allowedTo('adk_downloads_manage')) {
        fatal_lang_error('adkfatal_not_permission', false);
    }
    //Set the other strings
    $title = CleanAdkStrings($_POST['title']);
    $description = CleanAdkStrings($_REQUEST['descript']);
    $short_desc = CleanAdkStrings($_POST['short_desc']);
    $image = !empty($_POST['screen2']) ? CleanAdkStrings($_POST['screen2']) : '';
    if (!empty($_FILES['screen']['name']) && $_FILES['screen']['name'] != '') {
        $image = processDownloadImage($_FILES['screen']);
    }
    //Set tdownloads dir
    $DownloadsDir = $boarddir . '/Adk-downloads';
    //Can write on this?
    if (!is_writable($DownloadsDir)) {
        fatal_lang_error('adkfatal_not_writable_dir', false);
    }
    //Your title is empty? error
    if (empty($title)) {
        fatal_lang_error('adkfatal_please_add_a_title', false);
    }
    //Get files
    $files = !empty($_POST['download2']) ? $_POST['download2'] : '';
    $files2 = !empty($_POST['download2']) ? 1 : 0;
    $download = !empty($_FILES['download']) ? 1 : 0;
    if (empty($download) && empty($files2)) {
        fatal_lang_error('adkfatal_empty_attach', false);
    }
    $smcFunc['db_query']('', '
			UPDATE {db_prefix}adk_down_file
			SET title = {string:title}, description = {string:description},
			id_cat = {int:cat}, main_image = {string:image}, short_desc = {string:short}
			WHERE id_file = {int:file}', array('title' => $title, 'description' => $description, 'cat' => $id_cat, 'image' => $image, 'file' => $id_file, 'short' => $short_desc));
    if (!empty($_FILES['download']) && $_FILES['download']['name'] != '') {
        $l = 0;
        foreach ($_FILES['download']['tmp_name'] as $n => $dummy) {
            if ($_FILES['download']['name'][$n] != '') {
                $l++;
            }
            $filesize = $_FILES['download']['size'][$n];
            if (!empty($adkportal['download_max_filesize']) && $filesize > $adkportal['download_max_filesize']) {
                @unlink($_FILES['download']['tmp_name'][$n]);
                fatal_lang_error('adkfatal_big_size', false);
            }
        }
        $i = 0;
        if (!empty($l)) {
            foreach ($_FILES['download']['tmp_name'] as $n => $dummy) {
                $filesize = $_FILES['download']['size'][$n];
                $original = $_FILES['download']['name'][$n];
                //Nosotros usamos el Download System en Smf Personal, entonces... necesitamos el mismo nombre de archivo ;)
                $filename = $user_info['id'] . '_' . date('d_m_y_g_i_s') . $i;
                $i++;
                //Move uploaded file
                move_uploaded_file($_FILES['download']['tmp_name'][$n], $DownloadsDir . '/' . $filename);
                @chmod($DownloadsDir . $filename, 0644);
                //Insert file
                $smcFunc['db_insert']('insert', '{db_prefix}adk_down_attachs', array('id_file' => 'int', 'filename' => 'text', 'filesize' => 'text', 'orginalfilename' => 'text'), array($id_file, $filename, $filesize, $original), array('id_attach'));
            }
        }
    }
    //DELETE files selected
    if (!empty($files)) {
        $delete = $_POST['download2'];
        $t = 0;
        $count = count($delete);
        foreach ($delete as $n => $dummy) {
            $id = $n;
            $sql = $smcFunc['db_query']('', '
				SELECT filename FROM {db_prefix}adk_down_attachs
				WHERE id_attach = {int:attach} LIMIT 1', array('attach' => $id));
            $row = $smcFunc['db_fetch_assoc']($sql);
            $smcFunc['db_free_result']($sql);
            @unlink($adkFolder['eds'] . '/' . $row['filename']);
            $smcFunc['db_query']('', '
				DELETE FROM {db_prefix}adk_down_attachs
				WHERE id_attach = {int:attach} LIMIT 1', array('attach' => $id));
            $t++;
        }
    }
    //Update Category
    if ($id_cat !== $ex_id_cat) {
        TotalCategoryUpdate($id_cat);
        TotalCategoryUpdate($ex_id_cat);
    }
    redirectexit('action=downloads;sa=view;down=' . $id_file);
}
function saveeditpages()
{
    checkSession('post');
    global $context, $smcFunc;
    $titlepage = CleanAdkStrings($_POST['titlepage']);
    $urltext = CleanAdkStrings($_POST['urltext']);
    //Set memberGroups
    $groups_allowed = createArrayFromPost('groups_allowed');
    //Set the editor
    cleanEditor();
    $type = $_POST['type'];
    $body = CleanAdkStrings($_REQUEST['descript']);
    $cattitlebg = $_POST['cattitlebg'];
    $winbg = $_POST['winbg'];
    //$views = 0;
    $id_page = (int) $_POST['id_page'];
    $enable_comments = !empty($_POST['enable_comments']) ? 1 : 0;
    //Check if this page exists
    checkIfPageExists($urltext, $id_page);
    //Empty titlepage?
    if (empty($titlepage)) {
        fatal_lang_error('adkfatal_empty_title', false);
    }
    //Empty body
    if (empty($body)) {
        fatal_lang_error('adkfatal_empty_body', false);
    }
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}adk_pages
		SET titlepage = {string:titlepage}, urltext = {string:urltext},
		grupos_permitidos = {string:grupos}, type = {string:type},
		body = {string:body}, winbg = {string:winbg}, cattitlebg = {string:cat},
		enable_comments = {int:enable_comments}
		WHERE id_page = {int:page}', array('titlepage' => $titlepage, 'urltext' => $urltext, 'grupos' => $groups_allowed, 'type' => $type, 'body' => $body, 'winbg' => $winbg, 'cat' => $cattitlebg, 'page' => $id_page, 'enable_comments' => $enable_comments));
    redirectexit('action=admin;area=modules;sa=viewadminpages;' . $context['session_var'] . '=' . $context['session_id']);
}