1<?php 2 3use phpweb\UserPreferences; 4 5$_SERVER['BASE_PAGE'] = 'my.php'; 6include_once __DIR__ . '/include/prepend.inc'; 7 8// Try to make this page non-cached 9header_nocache(); 10 11// Languages array copy and options to list 12$langs = $ACTIVE_ONLINE_LANGUAGES; 13$options = []; 14 15// We have post data, and it is an available language 16if (isset($_POST['my_lang'], $langs[$_POST['my_lang']])) { 17 18 // Set the language preference 19 UserPreferences::$languageCode = $_POST['my_lang']; 20 21 // Add this as first option, selected 22 $options[] = '<option value="' . $_POST['my_lang'] . '" selected>' . 23 $langs[$_POST['my_lang']] . "</option>\n"; 24 25 // Remove, so it is not listed two times 26 unset($langs[$_POST['my_lang']]); 27} 28 29// We have received a cookie and it is an available language 30elseif (isset($langs[myphpnet_language()])) { 31 32 // Add this as first option, selected 33 $options[] = '<option value="' . myphpnet_language() . '" selected>' . 34 $langs[myphpnet_language()] . "</option>\n"; 35 36 // Remove, so it is not listed two times 37 unset($langs[myphpnet_language()]); 38} 39 40// We have no cookie and no form submitted 41else { 42 // Add this as first option, selected 43 $options[] = "<option value=\"not_set\" selected=\"selected\">Not Set</option>\n"; 44} 45 46// Add all other languages 47foreach ($langs as $code => $name) { 48 $options[] = '<option value="' . $code . '">' . $name . "</option>\n"; 49} 50 51// Assemble form from collected data 52$langpref = "<select id=\"form-my_lang\" name=\"my_lang\">\n" . 53 implode("", $options) . "</select>\n"; 54 55// Save URL shortcut fallback setting 56if (isset($_POST['urlsearch'])) { 57 myphpnet_urlsearch($_POST['urlsearch']); 58} 59 60if (isset($_POST["showug"])) { 61 myphpnet_showug($_POST["showug"] === "enable"); 62} 63 64// Prepare mirror array 65$mirror_sites = $MIRRORS; 66$mirror_sites["NONE"] = [7 => MIRROR_OK]; 67 68myphpnet_save(); 69 70site_header("My PHP.net", ["current" => "community"]); 71?> 72 73<form action="/my.php" method="post"> 74<h1>My PHP.net</h1> 75 76<p> 77 This page allows you to customize the PHP.net site. 78</p> 79 80<?php if (!is_official_mirror()) { ?> 81<p class="warn"> 82 This is not an official PHP.net mirror site, and therefore the settings 83 you set and see here will <strong>not</strong> be effective on any 84 official PHP.net mirror site. The settings you specify here are only 85 going to be active for this URL, and only if you have cookies enabled. 86</p> 87<?php } else { ?> 88<p> 89 These settings are cookie-based and will work on all official PHP.net 90 mirror sites. 91</p> 92<?php } ?> 93 94<h2>Preferred language</h2> 95 96<p> 97 If you use a shortcut or search for a function, the language used 98 is determined by checking for the following settings. The list is 99 in priority order, the first is the most important. Normally you don't 100 need to set your preferred language, as your browser's language preferences 101 are detected automatically using the Accept-Language header. 102</p> 103 104<div class="indent"> 105<table border="0" cellpadding="3" cellspacing="2" class="standard"> 106<?php 107 108// Data for the language settings table 109$langinfo = [ 110 111 "<label for=\"form-my_lang\">Your preferred language</label>" => 112 $langpref, 113 114 "Your Accept-Language browser setting" => 115 (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? htmlentities($_SERVER['HTTP_ACCEPT_LANGUAGE'], ENT_QUOTES | ENT_IGNORE, 'UTF-8') : "None"), 116 117 "The mirror's default language" => 118 default_language(), 119 120 "Default" => "en", 121]; 122 123// Write a row for all settings 124foreach ($langinfo as $lin => $lid) { 125 echo " <tr>\n <td class=\"sub\">" . $lin . "</td>\n"; 126 echo " <td>" . $lid . "</td>\n </tr>\n"; 127} 128 129?> 130</table> 131</div> 132 133<p> 134 These settings are only overridden in case you have passed a language 135 setting URL parameter or POST data to a page or you are viewing a manual 136 page in a particular language. In these cases, the explicit specification 137 overrides the language selected from the above list. 138</p> 139 140<p> 141 The language setting is honored when you use a 142 <a href="/urlhowto.php">URL shortcut</a>, when you start 143 a function list search on a non-manual page, when you visit 144 the <a href="/download-docs.php">manual download</a> or 145 <a href="/docs.php">language selection</a> pages, etc. 146</p> 147 148<h2>Your country</h2> 149 150<p> 151 The PHP.net site tries to detect your country 152 using the <a href="http://www.directi.com/?site=ip-to-country">Directi 153 Ip-to-Country Database</a>. This information is used to mark 154 the events in your country specially. 155</p> 156 157<div class="indent"> 158<?php 159if (i2c_valid_country()) { 160 echo "We detected that you are from <b>" . $COUNTRIES[$COUNTRY] . "</b>"; 161} else { 162 echo "We were unable to detect your country"; 163} 164?> 165</div> 166 167<h2>URL search fallback</h2> 168 169<p> 170 When you try to access a PHP.net page via a URL shortcut, and 171 the site is unable to find that particular page, it falls back 172 to a documentation search, or a function list lookup, depending on 173 your choice. The default is a function list lookup, as most of 174 the URL shortcut users try to access function documentation pages. 175</p> 176 177<div class="indent"> 178 Your setting: <input id="form-urlsearch-quickref" type="radio" name="urlsearch" value="quickref" 179<?php 180$type = myphpnet_urlsearch(); 181if ($type === UserPreferences::URL_NONE || $type === UserPreferences::URL_FUNC) { 182 echo ' checked="checked"'; 183} 184echo '> <label for="form-urlsearch-quickref">Function list search</label> <input id="form-urlsearch-manual" type="radio" name="urlsearch" value="manual"'; 185if ($type === UserPreferences::URL_MANUAL) { 186 echo ' checked="checked"'; 187} 188?> 189> <label for="form-urlsearch-manual">PHP Documentation search</label> 190</div> 191 192<br> 193<h2>User Group tips</h2> 194 195<p> 196We are experimenting with listing nearby user groups. This feature is highly experimental 197and will very likely change a lot and be broken at times. 198</p> 199<label for="showugenable">Enable UG tips</label> <input type="radio" name="showug" id="showugenable" value="enable" <?php echo myphpnet_showug() ? "checked=checked" : "" ?>><br> 200<label for="showugdisable">Disable UG tips</label> <input type="radio" name="showug" id="showugdisable" value="disable" <?php echo myphpnet_showug() ? "" : "checked=checked" ?>> 201 202<p class="center"> 203 <input type="submit" value="Set All Preferences"> 204</p> 205</form> 206 207<?php site_footer(); ?> 208