deeemm-cms /admin/includes/language_admin.php

Language PHP Lines 230
MD5 Hash cd1c227dfaeab008da41eebf3f56e2c8 Estimated Cost $2,738 (why?)
Repository https://bitbucket.org/mpercy/deeemm-cms View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );

/*===========================================================================
Check user priviledges
===========================================================================*/
require VALIDATE;
if ($user != 'ADMIN') header("Location: " . $default_url . "index.php");


/*===========================================================================
admin page
===========================================================================*/
function language_admin() {

//[FIXME] 
	global $lang_conf;
	global $conf;
	global $lan;
	global $var;
	global $language_textbox_temp;
	global $language_textboxes;
	global $language_admin;
	global $language_description;
	global $language_id;
	global $language_flag;
	global $language_tag;
	global $language_flag_tag;

	get_languages();

	//Get page details
	$var[page_title] .= ' :: ' . $lan[edit_language_settings];
	$var[cookie_trial] .= ' :: ' . $lan[edit_language_settings];
	$var[admin_title] = $lan[edit_language_settings];
	
	$language_admin = read_file('templates/edit_language.tpl');
	
	if ($conf[multi_language]) $main = str_replace('[conf]multi_language[/conf]', 'checked="true"', $main);
	
	//count number of languages in lang_conf table
	$num_langs = count($lang_conf);
		
	//auto create language text boxes
	$language_textbox_temp = read_file('templates/edit_language_textbox.tpl');
	
	//generate and propogate textboxes
	foreach ($lang_conf as $value){
	
		if ($value[id] > 0){
		
			$language_description = $value[description];
			$language_flag = $value[iso_code];

			$language_tag = 'language_' . $value[id];
			$language_flag_tag = 'language_' . $value[id] . '_flag';
		
			$language_id = $value[id];

			$language_textboxes .= replace_variables($language_textbox_temp);
		}
	
	}
	
	
}


/*===========================================================================
get_languages
===========================================================================*/
function get_languages(){
	global $conf;
	global $lang_conf;
	global $db_table_prefix;
	
	$lang_conf = array();
	
	//get language info from database
	$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "lang_conf`");
	while($row = mysql_fetch_assoc( $sql_query )){
		$lang_conf[] = $row;
	}

	mysql_free_result($sql_query);
	
	//count number of languages in lang_conf table
	$num_langs = count($lang_conf);
		
	//populate language vars
	foreach ($lang_conf as $value){
	
		global ${'language_'.$value[id]};
		global ${'language_'.$value[id].'_flag'};
		
		//create language variables
		${'language_'.$value[id]} = $value[description];
		${'language_'.$value[id].'_flag'} = $value[iso_code];		
		
	}
	
}

/*===========================================================================
add_language
===========================================================================*/
function add_language(){

	global $lang_conf;
	global $all_tables;
	global $db_table_prefix;

	//get post vars from form submission
	$language_description = htmlspecialchars($_POST["language_description"], ENT_QUOTES);
	$language_iso = htmlspecialchars($_POST["language_iso"], ENT_QUOTES);

	$num_langs = count($lang_conf);

	//add to lang_conf TABLE
	mysql_query("INSERT INTO `dmcms_077`.`" . $db_table_prefix . "lang_conf` SET
	`id` = '$num_langs',
	`description` = '$language_description',
	`iso_code` = '$language_iso',
	`enabled` = '',
	`default` = '' ") or die (header("Location: " . $default_url . $admin_dir . "index.php?action=edit_language_settings&popmess=add_language_failed"));
	
	
	//add additional columns to content tables
	foreach ($all_tables as $ud_table) {
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` ADD `title_lan_$num_langs` varchar(60) NOT NULL");	
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` ADD `tool_tip_lan_$num_langs` varchar(60) NOT NULL");	
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` ADD `description_lan_$num_langs` varchar(60) NOT NULL");	
	}
	
	//add tables to orphan pages
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` ADD `title_lan_$num_langs` varchar(60) NOT NULL");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` ADD `tool_tip_lan_$num_langs` varchar(60) NOT NULL");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` ADD `description_lan_$num_langs` varchar(60) NOT NULL");	
		
	//add tables to static content
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` ADD `title_lan_$num_langs` varchar(60) NOT NULL");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` ADD `tool_tip_lan_$num_langs` varchar(60) NOT NULL");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` ADD `description_lan_$num_langs` varchar(60) NOT NULL");	

	
	get_languages();

}

/*===========================================================================
delete_language
===========================================================================*/
function delete_language($language_id){

	global $lang_conf;
	global $all_tables;
	global $db_table_prefix;

	//remove language from lang_conf
	mysql_query("DELETE FROM `" . $db_table_prefix . "lang_conf` WHERE id='$language_id'");	
	 
	//remove tables from content
	foreach ($all_tables as $ud_table) {
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` DROP COLUMN `title_lan_$language_id` ");	
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` DROP COLUMN `tool_tip_lan_$language_id`");	
		mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_" . $ud_table . "` DROP COLUMN `description_lan_$language_id`");	
	}
	
	//remove tables from orphan pages
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` DROP COLUMN `title_lan_$language_id`");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` DROP COLUMN `tool_tip_lan_$language_id`");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "cat_orphan` DROP COLUMN `description_lan_$language_id`");	
		
	//remove tables from static content
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` DROP COLUMN `title_lan_$language_id`");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` DROP COLUMN `tool_tip_lan_$language_id`");	
	mysql_query("ALTER TABLE `" . $db_table_prefix . "static_content` DROP COLUMN `description_lan_$language_id`");	
	
	get_languages();


}

/*===========================================================================
Save_language_settings
===========================================================================*/
function save_language_settings(){
	global $db_table_prefix;
	global $conf;
	global $db_table_prefix;
	
	//Get user input
	$conf[multi_language] = $_REQUEST['multi_language'];

	//Update values
	foreach ($conf as $key => $value){
		mysql_query("UPDATE `" . $db_table_prefix . "core_conf` SET `value` = '$value' WHERE `name` = '$key'");
	}
	
	//count number of languages in lang_conf table
	$num_langs = count($lang_conf);
	
	//read new values in from form
	foreach ($lang_conf as $value){
	
		if ($value[id] > 0){
			//$conf[language_1] = $_REQUEST['language_1'];
			//$conf[language_1_flag] = $_REQUEST['language_1_flag'];
		}
	}	
	

	//form vars as array
	foreach($_POST['education'] as $key=>$value)
 		echo $key.' '.$value;




	//Save to database
	
	
}






?>
Back to Top