Location: PHPKode > scripts > CsCP WapSite > cscp-wapsite/admin/ad_functions.php
<?php

/*********************************************************************
 *
 * WapSite powered by CsC Portal. WapSite[tm] is module of CsC Portal.
 *
 * (C) 2004. CsC Portal. All rights reserved.
 *
 * http://cscp.cs-centar.net | http://www.cs-centar.net
 *
 ********************************************************************/

// File: admin/ad_functions.php
// Desc: Use to define functions which will be used by the admin panel
// Written on: 22.04.2004

function display_table_edit() {

include("../db_connect.php");

$display_page = mysql_query("SELECT * from cscp_wap_page ORDER BY page_name", $db);

$count_pages = mysql_num_rows($display_page);

echo "<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lang_display_ed[display_from]:</b> cscp_wap_page </td><td><B>$lang_display_ed[display_order]:</b> page_name </td><td> <b>$lang_display_ed[display_page]:</b> $count_pages
</td></tr>
</table>";

echo "<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td width=\"30%\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_ed[table_page_name]</b> </font>
</td>
<td width=\"70%\" colspan=\"3\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_ed[table_options]</b> </font>
</td></tr>";


while($display_page_name = mysql_fetch_row($display_page)) {


	echo "<tr align=\"center\"><td width=\"25%\" bgcolor=\"efefef\">
	<u>$display_page_name[0]</u>
	</td>
	<td width=\"25%\" bgcolor=\"eeeeee\">
	[ <a href=\"javascript:display_preview('preview.php?substr=edit_delete&page=$display_page_name[0]')\">$lang_display_ed[preview]</a> ]
	</td>
	<td width=\"25%\" bgcolor=\"efefef\">
	[ <a href=\"javascript:display_edit('edit.php?page=$display_page_name[0]')\">$lang_display_ed[edit]</a> ]
	</td>
	<td width=\"25%\" bgcolor=\"eeeeee\">
	[ <a href=\"del.php?substr=edit_delete&page=$display_page_name[0]\">$lang_display_ed[delete]</a> ]
	</td></tr>";


	}

echo "</table>";

}

function display_table_edit_add() {

include("../wap_db.php");

echo "<form method=\"post\" action=\"add.php?substr=edit_delete&act=add\">
<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lanq_display_ed[page_add]</b> - $SiteUrl
</td></tr>
</table>
<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td bgcolor=\"cccccc\" width=\"40%\">
<u>$lang_display_ed[url_name]</u>:
</td>
<td bgcolor=\"efefef\"><input type=\"text\" name=\"page_name\"> [ <a href=\"javascript:help('help.php?substr=edit&faq=url_name')\" title=\"$lang_display_help[menu_title]\">$lang_display_help[title]</a> ]
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"40%\">
<u>$lang_display_p[page_id]</u>: <br>[$lang_display_p[page_id_more]]
</td>
<td bgcolor=\"efefef\"><input type=\"text\" name=\"page_id\"> [ <a href=\"javascript:help('help.php?substr=edit&faq=page_id')\" title=\"$lang_display_help[menu_title]\">$lang_display_help[title]</a> ]
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"40%\">
<u>$lang_display_p[page_subject]</u>:
</td>
<td bgcolor=\"efefef\"><input type=\"text\" name=\"page_subject\"> [ <a href=\"javascript:help('help.php?substr=edit&faq=page_subject')\" title=\"$lang_display_help[menu_title]\">$lang_display_help[title]</a> ]
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"42%\">
<u>$lang_display_p[page_text]</u>:
<br><br>
[$lang_display[html]]
</td>
<td bgcolor=\"efefef\"><textarea name=\"page_text\" rows=\"10\" cols=\"40\"></textarea>
</td></td>
</table>
<p align=\"right\"><input type=\"submit\" value=\" $lang_btn_ed[add_page] \">&nbsp;&nbsp;
</form>";

}

function display_preview($page) {

include("../db_connect.php");

$display_preview = mysql_query("SELECT * from cscp_wap_page WHERE page_name = '$page'", $db);

$display_preview_f = mysql_fetch_row($display_preview);

echo "<table width=\"95%\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\" class=\"table_display\"><tr><td bgcolor=\"efefef\">
<b><u>$lang_display_ed[url_name]</u>:</b> $display_preview_f[0]
<br>
<b><u>$lang_display_p[page_subject]</u>:</b> $display_preview_f[1]
<br>
<b><u>$lang_display_p[page_text]</u>:</b>
<br>
$display_preview_f[2]
</td></tr>
</table><br><center>[ <a href=\"javascript:window.close()\">$lang_display[window_close]</a> ]</center>";

}

function display_preview_news($page) {

include("../db_connect.php");

$display_preview_news = mysql_query("SELECT * from cscp_wap_news WHERE news_name = '$page'", $db);

$display_preview_news_f = mysql_fetch_row($display_preview_news);


echo "<table width=\"95%\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\" class=\"table_display\"><tr><td bgcolor=\"efefef\">
<b><u>$lang_display_news[table_news_name]</u>:</b> $display_preview_news_f[0]
<br>
<b><u>$lang_display_news[news_date]</u>:</b> $display_preview_news_f[2]
<br>
<b><u>$lang_display_news[news_text]</u>:</b>
<br>
$display_preview_news_f[1]
</td></tr>
</table><br><center>[ <a href=\"javascript:window.close()\">$lang_display[window_close]</a> ]</center>";


}

function display_preview_files() {

global $file, $file_id;

include("../db_connect.php");
include("../wap_db.php");

$file_url = mysql_query("SELECT * from cscp_wap_options WHERE id = 'panel'", $db);

$file_url_f = mysql_fetch_row($file_url);

$display_preview_files = mysql_query("SELECT * from cscp_wap_files WHERE file_id = '$file_id'", $db);

$display_preview_files_f = mysql_fetch_row($display_preview_files);

echo "<table width=\"95%\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\" class=\"table_display\"><tr bgcolor=\"efefef\"><td width=\"30%\">
<b>$lang_display_fp[file_id]:</b></td><td align=\"center\">$display_preview_files_f[0]
</td></tr><tr bgcolor=\"efefef\"><td>
<b>$lang_display_fp[file_name]:</b></td><td align=\"center\">$display_preview_files_f[1]
</td></tr><tr bgcolor=\"efefef\"><td>
<b>$lang_display_fp[file_size]:</b></td><td align=\"center\">$display_preview_files_f[2]
</td></tr>
<tr bgcolor=\"efefef\"><td>
<b>$lang_display_fp[file_url]:</b></td><td align=\"center\"><a href=\"$SiteUrl/$PortalDir/$AdminPanel/$file_url_f[2]/$display_preview_files_f[1]\" target=_blank>$SiteUrl/$PortalDir/<br>$AdminPanel/$file_url_f[2]/$display_preview_files_f[1]</a>
<tr bgcolor=\"efefef\"><td>
<b>$lang_display_fp[file_code]:</b></td><td align=\"center\"><textarea rows=\"4\" cols=\"30\">$SiteUrl/$PortalDir/$AdminPanel/$file_url_f[2]/$display_preview_files_f[1]</textarea>
</td></tr>
</table><br><center>[ <a href=\"javascript:window.close()\">$lang_display[window_close]</a> ]</center>";

}

function display_edit($page) {

include("../db_connect.php");

$display_edit = mysql_query("SELECT * from cscp_wap_page WHERE page_name = '$page'", $db);

$display_edit_f = mysql_fetch_row($display_edit);

echo "<table align=\"center\" width=\"100%\">
<tr><td>
<b>$lang_display_ed[url_name]:</b> </td><td><input type=\"text\" name=\"p_name\" value=\"$display_edit_f[0]\" readonly></td></tr>
<tr><td>
<b>$lang_display_p[page_subject]:</b> </td><td><input type=\"text\" name=\"p_subject\" value=\"$display_edit_f[1]\"></td></tr>
<tr><td>
<b>$lang_display_p[page_text]:</b> </td><td><textarea name=\"p_text\" rows=\"10\" cols=\"40\">$display_edit_f[2]</textarea></tr></td>
<tr><td>
<br><br>
</td></tr>
<tr><td>
<p align=\"right\"><input type=\"submit\" value=\" $lang_btn_ed[save] \"></td><td> | <input type=\"reset\" value=\" $lang_btn_ed[default] \">
</tr></td>
</table>";

}

function display_edit_news($page) {

include("../db_connect.php");

$display_edit_news = mysql_query("SELECT * from cscp_wap_news WHERE news_name = '$page'", $db);

$display_edit_news_f = mysql_fetch_row($display_edit_news);

echo "<table align=\"center\" width=\"100%\">
<tr><td>
<b>$lang_display_news[table_news_name]:</b> </td><td><input type=\"text\" name=\"n_name\" value=\"$display_edit_news_f[0]\"></td></tr>
<tr><td>
<b>$lang_display_news[news_date]:</b> </td><td><input type=\"text\" name=\"n_date\" value=\"$display_edit_news_f[2]\"></td></tr>
<tr><td>
<b>$lang_display_news[news_text]:</b> </td><td><textarea name=\"n_text\" rows=\"10\" cols=\"40\">$display_edit_news_f[1]</textarea></tr></td>
<tr><td>
<br><br>
</td></tr>
<tr><td>
<p align=\"right\"><input type=\"submit\" value=\" $lang_btn_ed[save] \"></td><td> | <input type=\"reset\" value=\" $lang_btn_ed[default] \">
</tr></td>
</table>";

}

function display_table_news() {

include("../db_connect.php");

$display_news = mysql_query("SELECT * from cscp_wap_news ORDER BY news_name", $db);

$count_news = mysql_num_rows($display_news);

echo "<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lang_display_ed[display_from]:</b> cscp_wap_news </td><td><B>$lang_display_ed[display_order]:</b> news_name </td><td> <b>$lang_display_news[display_page]:</b> $count_news
</td></tr>
</table>";

echo "<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td width=\"30%\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_news[table_news_name]</b> </font>
</td>
<td width=\"70%\" colspan=\"3\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_ed[table_options]</b> </font>
</td></tr>";

while($display_page_news = mysql_fetch_row($display_news)) {


	echo "<tr align=\"center\"><td width=\"25%\" bgcolor=\"efefef\">
	<u>$display_page_news[0]</u>
	</td>
	<td width=\"25%\" bgcolor=\"eeeeee\">
	[ <a href=\"javascript:display_preview('preview.php?substr=news&page=$display_page_news[0]')\">$lang_display_ed[preview]</a> ]
	</td>
	<td width=\"25%\" bgcolor=\"efefef\">
	[ <a href=\"javascript:display_edit('edit.php?substr=news&page=$display_page_news[0]')\">$lang_display_ed[edit]</a> ]
	</td>
	<td width=\"25%\" bgcolor=\"eeeeee\">
	[ <a href=\"del.php?substr=news&page=$display_page_news[0]\">$lang_display_ed[delete]</a> ]
	</td></tr>";

	}

echo "</table>";

}

function display_table_news_add() {

include("../wap_db.php");

echo "<form method=\"post\" action=\"add.php?substr=news&act=add\">
<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lanq_display_news[news_add]</b> - $SiteUrl
</td></tr>
</table>
<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td bgcolor=\"cccccc\" width=\"40%\">
<u>$lang_display_news[table_news_name]</u>:
</td>
<td bgcolor=\"efefef\"><input type=\"text\" name=\"news_name\"> [ <a href=\"javascript:help('help.php?substr=news&faq=news_name')\" title=\"$lang_display_help[menu_title]\">$lang_display_help[title]</a> ]
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"40%\">
<u>$lang_display_news[news_date]</u>: [$lang_display_news[news_date_more]]
</td>
<td bgcolor=\"efefef\"><input type=\"text\" name=\"news_date\"> [ <a href=\"javascript:help('help.php?substr=news&faq=news_date')\" title=\"$lang_display_help[menu_title]\">$lang_display_help[title]</a> ]
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"42%\">
<u>$lang_display_news[news_text]</u>:
<br><br>
[$lang_display[html]]
</td>
<td bgcolor=\"efefef\"><textarea name=\"news_text\" rows=\"10\" cols=\"40\"></textarea>
</td></td>
</table>
<p align=\"right\"><input type=\"submit\" value=\" $lang_btn_news[add_news] \">&nbsp;&nbsp;
</form>";

}

function display_table_files() {

include("../db_connect.php");
include("../wap_db.php");

$display_files = mysql_query("SELECT * from cscp_wap_files ORDER BY file_name", $db);

$count_files = mysql_num_rows($display_files);

echo "<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lang_display_ed[display_from]:</b> cscp_wap_files </td><td><B>$lang_display_ed[display_order]:</b> file_name </td><td> <b>$lang_display_files[display_page]:</b> $count_files
</td></tr>
</table>";

echo "<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td width=\"30%\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_files[table_news_name]</b> </font>
</td>
<td width=\"70%\" colspan=\"3\" bgcolor=\"cccccc\">
<p align=\"center\"><font color=\"ff0000\"><b>$lang_display_ed[table_options]</b> </font>
</td></tr>";

while($display_files_n = mysql_fetch_row($display_files)) {

echo "<tr align=\"center\"><td width=\"33%\" bgcolor=\"efefef\">
	<u>$display_files_n[1]</u> [ID: <b>$display_files_n[0]</b>]
	</td>
	<td width=\"33%\" bgcolor=\"eeeeee\">
	[ <a href=\"javascript:display_preview('preview.php?substr=files&file=$display_files_n[1]&file_id=$display_files_n[0]')\">$lang_display_files[view_file]</a> ]
	</td>
	<td width=\"33%\" bgcolor=\"eeeeee\">
	[ <a href=\"del.php?substr=files&file=$display_files_n[1]\">$lang_display_ed[delete]</a> ]</td></tr>";

	}

echo "</table>";

}

function display_table_files_upload() {

include("../wap_db.php");

echo "<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lang_display_ul[upload]</b> - $SiteUrl
</td></tr>
</table>
<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td bgcolor=\"cccccc\" width=\"10%\">
<br>
<form method=\"post\" action=\"add.php?substr=file&act=upload\" enctype=\"multipart/form-data\">
<input type=\"hidden\" name=\"action\" value=\"upload\">
$lang_display_ul[upload] ::
<input type=\"file\" name=\"userfile\">
<input type=\"submit\" name=\"submit\" value=\"$lang_btn[upload]\">
</form>
</td></tr>
</table>";

}

function upload_file() {

global $userfile, $userfile_name, $userfile_size, $userfile_type, $archive_dir, $WINDIR;

include("../db_connect.php");

$file_upload_dir = mysql_query("SELECT * from cscp_wap_options WHERE id = 'panel'", $db);

$fud_f = mysql_fetch_row($file_upload_dir);

$archive_dir = $fud_f[2];

  if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);

  $filename = basename($userfile_name);

  if($userfile_size <= 0) die ("$lang_display_ul[err_empty]");

  if(!@copy($userfile, "$archive_dir/$filename"))
    die ("$lang_display_ul[err_copy]");

  if(!isset($WINDIR) && !@unlink($userfile))
    die ("$lang_display_ul[err_delete]");


}

function display_table_options() {

include("../db_connect.php");
include("../wap_db.php");


$set_panel = mysql_query("SELECT * from cscp_wap_options WHERE id = 'panel'", $db);

$set_panel_d = mysql_fetch_row($set_panel);

$set_page = mysql_query("SELECT * from cscp_wap_options WHERE id = 'page'", $db);

$set_page_d = mysql_fetch_row($set_page);

$set_news = mysql_query("SELECT * from cscp_wap_options WHERE id = 'news'", $db);

$set_news_d = mysql_fetch_row($set_news);

$set_file = mysql_query("SELECT * from cscp_wap_options WHERE id = 'file'", $db);

$set_file_d = mysql_fetch_row($set_file);

echo "<form method=\"post\" action=\"ad_menu.php?act=options&substr=save\">
<table align=\"center\" width=\"98%\" class=\"table_info\"><tr><td>
<b>$lang_display_opt[title]</b> - $SiteUrl
</td></tr>
</table>
<table align=\"center\" width=\"98%\" class=\"table_display\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"gray\"><tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[language]</u>:</td>
<td bgcolor=\"efefef\" align=\"center\"><select name=\"lang_set\"><option>$set_panel_d[1]</option><option>----</option>$LangFiles[1]$LangFiles[2]$LangFiles[3]$LangFiles[4]$LangFiles[5]$LangFiles[6]</select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[file_upload_dir]</u>:
</td>
<td bgcolor=\"efefef\" align=\"center\" colspan=\"2\">
<input type=\"text\" name=\"file_upload_dir\" value=\"$set_panel_d[2]\" size=\"20\">
</td></tr>
<tr><td bgcolor=\"efefef\" colspan=\"3\">
&nbsp;
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[p_que1]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\"><select name=\"m_add_p\"><option>$set_page_d[3]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[p_que2]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\"><select name=\"m_edit_p\"><option>$set_page_d[4]</option><option>----</option><option>yes</option><option>no</opion></select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[p_que3]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_delete_p\"><option>$set_page_d[5]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"efefef\" colspan=\"3\">
&nbsp;
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[n_que1]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_add_n\"><option>$set_news_d[3]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[n_que2]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_edit_n\"><option>$set_news_d[4]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[n_que3]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_delete_n\"><option>$set_news_d[5]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"efefef\" colspan=\"3\">
&nbsp;
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[f_que1]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_upload\"><option>$set_file_d[6]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
<tr><td bgcolor=\"cccccc\" width=\"60%\">
<u>$lang_display_opt[f_que2]</u>?</td>
<td bgcolor=\"efefef\" align=\"center\">
<select name=\"m_delete_f\"><option>$set_file_d[5]</option><option>----</option><option>yes</option><option>no</option></select>
</td></tr>
</table>
<p align=\"right\"><input type=\"submit\" value=\" $lang_btn[save_changes] \">&nbsp;&nbsp;
</form>";

}


?>
Return current item: CsCP WapSite