View file admin/admin_shop_url.php

File size: 3.35Kb
<?php
/***************************************************************************
 *                                mides.ru
 *                            -------------------
 ***************************************************************************/
define('IN_PHPBB', true);

if( !empty($setmodules) )
{
	$file = basename(__FILE__);
	$module['Магазин']['Заработок на кликах'] = $file;
	return;
}

$phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

if ( isset($HTTP_POST_VARS['start1']) )
{
	$start1 = intval($HTTP_POST_VARS['start1']);
	$start = (($start1 - 1) * $board_config['topics_per_page']);
} else {
	$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
	$start = ($start < 0) ? 0 : $start;
}

$template->set_filenames(array(
	'body' => 'admin/admin_shop_url.tpl')
);

if ( isset($HTTP_GET_VARS['delete']) )
{
	$id = intval($HTTP_GET_VARS['id']);

	$sql = "DELETE FROM ".$table_prefix."shop_url
		WHERE id = '$id'";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_MESSAGE, 'Не удалось удалить ссылку');
	}
	message_die(GENERAL_MESSAGE, 'Ссылка удалена');

} elseif ( isset($HTTP_POST_VARS['add']) ) {

	$url = trim(htmlspecialchars($HTTP_POST_VARS['url1']));
	$nazvanie = trim(htmlspecialchars($HTTP_POST_VARS['nazvanie']));
	$cost = abs(intval($HTTP_POST_VARS['cost']));

	$sql = "INSERT INTO ".$table_prefix."shop_url (url, nazvanie, url_cost) VALUES ('" . str_replace("\'", "''", $url) . "', '" . str_replace("\'", "''", $nazvanie) . "', $cost)";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_MESSAGE, 'Не удалось добавить ссылку');
	}
	message_die(GENERAL_MESSAGE, 'Ссылка добавлена в базу');

} else {

$template->assign_vars(array(
	'S_ACTION' => append_sid("admin_shop_url.$phpEx"))
);

$sql = "SELECT * 
	FROM ".$table_prefix."shop_url
	ORDER BY id ASC LIMIT $start, " . $board_config['topics_per_page'];
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
}

if ( $row = $db->sql_fetchrow($result) )
{
	$i = 0;
	do
	{
		$url = $row['url'];
		$nazvanie = $row['nazvanie'];
		$cost = $row['url_cost'];
		$id = $row['id'];

		$template->assign_block_vars('memberrow', array(
			'URL' => $url,
			'NAZVANIE' => $nazvanie,
			'COST' => $cost,
			'U_DEL' => append_sid("admin_shop_url.$phpEx?delete&amp;id=$id"))
		);

		$i++;
	}
	while ( $row = $db->sql_fetchrow($result) );
	$db->sql_freeresult($result);
} else {
	$template->assign_block_vars('no_pay', array() );
}

$sql = "SELECT count(*) AS total
	FROM ".$table_prefix."shop_url";

if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Error getting total url', '', __LINE__, __FILE__, $sql);
}

if ( $total = $db->sql_fetchrow($result) )
{
	$total_members = $total['total'];
	$pagination = generate_pagination("admin_shop_url.$phpEx?", $total_members, $board_config['topics_per_page'], $start);
}
$db->sql_freeresult($result);

if ( $total_members > $board_config['topics_per_page'] )
{
	$template->assign_vars(array(
		'PAGINATION' => $pagination)
	);
}
$template->pparse('body');
include('./page_footer_admin.'.$phpEx);
}

?>