function lang_update_lang_file($file_path = '') { global $awc_lang, $delete_langs; $out = ''; if (isset($_FILES["new_lang"])) { $lang_Path = $_FILES["new_lang"]["tmp_name"]; } else { $lang_Path = $file_path; } if ($lang_Path == '') { return; } require $lang_Path; $fields = array(); $fields[] = 'lang_update'; $fields[] = 'lang_update_raw'; if (isset($lang_txt_admin_raw)) { $fields[] = 'lang_txt_admin'; $fields[] = 'lang_txt_admin_raw'; } if (isset($lang_txt_mem_raw)) { $fields[] = 'lang_txt_mem'; $fields[] = 'lang_txt_mem_raw'; } if (isset($lang_txt_forum_raw)) { $fields[] = 'lang_txt_forum'; $fields[] = 'lang_txt_forum_raw'; } if (isset($lang_txt_tag_raw)) { $fields[] = 'lang_txt_tag'; $fields[] = 'lang_txt_tag_raw'; } if (isset($lang_txt_search_raw)) { $fields[] = 'lang_txt_search'; $fields[] = 'lang_txt_search_raw'; } if (isset($lang_txt_thread_raw)) { $fields[] = 'lang_txt_thread'; $fields[] = 'lang_txt_thread_raw'; } if (isset($lang_txt_errormsg_raw)) { $fields[] = 'lang_txt_errormsg'; $fields[] = 'lang_txt_errormsg_raw'; } if (isset($lang_txt_redirects_raw)) { $fields[] = 'lang_txt_redirects'; $fields[] = 'lang_txt_redirects_raw'; } $current_lang = array(); $current_lang = lang_getinfo('', $fields); #awc_pdie($current_lang); if (file_exists(awc_dir . 'updates/lang_delete.txt')) { require awc_dir . 'updates/lang_delete.txt'; } else { if (!isset($delete_langs) or empty($delete_langs)) { $delete_langs[] = 'tmp'; } } if (!isset($delete_langs)) { $delete_langs[] = 'tmp'; } foreach ($current_lang as $lang_id => $all_keys) { $working_lang = $all_keys['lang_code']; $working_id = $all_keys['lang_id']; $array_fields = @$current_lang['array_fields']; unset($current_lang[$lang_id]['lang_code'], $current_lang[$lang_id]['lang_id'], $current_lang['array_fields'], $all_keys['lang_code'], $all_keys['lang_id']); #awc_pdie($lang_txt_redirects_raw); foreach ($all_keys as $current_key => $no) { #unset($no); $get_update_key_name = str_replace('_raw', '', $current_key); /** @changeVer 2.5.8 change ($get_update_key_name) to look up with '_raw' to make complient with the import/export */ $get_update_key_name = $current_key; if ($current_key != 'lang_update_raw' and $current_key != 'lang_update' and strstr($current_key, '_raw')) { $current_key_no_raw = str_replace('_raw', '', $current_key); if (empty($current_lang[$lang_id][$current_key]) or !isset($current_lang[$lang_id][$current_key])) { $current_lang[$lang_id][$current_key] = array('tmp' => 'tmp'); } if (empty($current_lang[$lang_id][$current_key_no_raw]) or !isset($current_lang[$lang_id][$current_key_no_raw])) { $current_lang[$lang_id][$current_key_no_raw] = array('tmp' => 'tmp'); } /* return's 'updated', 'dif' and $update_current 'updated' has fully updated the array_raw 'dif' is new array with the new keys and values 'phased' text in array have been wiki_phased $update_current - nothing was different so it just passes the origenal array through */ $update_current = array(); $update_current = arr_CheckIn(${$get_update_key_name}, $current_lang[$lang_id][$current_key], true, true); if (isset($update_current['updated'])) { $current_lang[$lang_id][$current_key] = $update_current['updated']; // add the phased lang text $current_lang[$lang_id][$current_key_no_raw] = arr_AddTo($update_current['phased'], $current_lang[$lang_id][$current_key_no_raw]); // used to print info for update page... $out .= "<b><u>Language</u> definsion added:</b><br /> - Key={$current_key_no_raw}<br /> - Text={$current_lang[$lang_id]}[{$current_key_no_raw}]<br /><br />"; if ($working_lang != 'en') { $check2 = array(); $check2 = arr_CheckIn($update_current['dif'], $current_lang[$lang_id]['lang_update_raw'], true, true); if (isset($check2['updated'])) { $current_lang[$lang_id]['lang_update_raw'] = $check2['updated']; $current_lang[$lang_id]['lang_update'] = arr_AddTo($check2['phased'], $current_lang[$lang_id]['lang_update']); } unset($check2); } } else { // $current_lang[$lang_id][$current_key] = $update_current; } unset($update_current); } if (!empty($current_lang[$lang_id][$current_key])) { foreach ($current_lang[$lang_id][$current_key] as $key => $difi) { if (in_array($key, $delete_langs)) { unset($current_lang[$lang_id][$current_key][$key]); unset($current_lang[$lang_id][$current_key_no_raw][$key]); } } } } // done with one lang-id unset($all_keys); $current_lang[$lang_id]['array_fields'] = $fields; lang_sql_update($current_lang[$lang_id], $working_id); unset($current_lang[$lang_id]); } unset($fields); return $out; }
function arr_CheckIn($chk, $current, $AddTo = false, $wPhase = false) { global $wgOut; if (!isset($chk) || empty($chk)) { return $current; } //if(!isset($current)) return ; //if(empty($current)) $current = array('tmp' => 'tmp') ; if (empty($current) or !isset($current)) { $current = array('tmp' => 'tmp'); } $re_arry = array(); $re_arry = array_diff_key($chk, $current); if (!empty($re_arry)) { if ($AddTo) { $r = array(); $r['updated'] = arr_AddTo($re_arry, $current); $r['dif'] = $re_arry; if ($wPhase) { foreach ($r['dif'] as $k => $v) { $r['dif'][$k] = awc_wikipase($v, $wgOut); } $r['phased'] = $r['dif']; } return $r; } else { return $re_arry; } } unset($re_arry); return $current; }