Changeset 2446519
- Timestamp:
- 12/27/2020 09:54:47 PM (5 years ago)
- Location:
- vampire-character/trunk
- Files:
-
- 5 edited
-
inc/adminpages/config.php (modified) (1 diff)
-
inc/chargen.php (modified) (1 diff)
-
inc/functions.php (modified) (2 diffs)
-
inc/install.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vampire-character/trunk/inc/adminpages/config.php
r2392602 r2446519 1334 1334 $upload = wp_upload_dir(); 1335 1335 //print_r($upload); 1336 //phpinfo(); 1336 1337 $link = vtm_export_data($upload['path'], "vtm-export-$vtm_character_version"); 1337 1338 // provide link 1338 $url = $upload['url'] . "/$link"; 1339 echo "<p>Download exported data: <a class='button-primary' href='$url'>$link</a>"; 1340 ?> 1341 <form id='options_form' method='post'> 1342 <input type="submit" name="return_export_data" class="button-primary" value="Done" /> 1343 </form> 1344 <?php 1339 if ($link != "") { 1340 $url = $upload['url'] . "/$link"; 1341 echo "<p>Download exported data: <a class='button-primary' href='$url'>$link</a>"; 1342 ?> 1343 <form id='options_form' method='post'> 1344 <input type="submit" name="return_export_data" class="button-primary" value="Done" /> 1345 </form> 1346 <?php 1347 } 1345 1348 } 1346 1349 elseif (isset($_REQUEST['import_data'])) { -
vampire-character/trunk/inc/chargen.php
r2392602 r2446519 2385 2385 'LEVEL_FROM' => $levelfrom, 2386 2386 2387 'LEVEL_TO' => $ levelto,2387 'LEVEL_TO' => $type == 'MERIT' ? $amount : $levelto, 2388 2388 'AMOUNT' => $amount, 2389 2389 'ITEMTABLE' => $type, -
vampire-character/trunk/inc/functions.php
r2392602 r2446519 1027 1027 global $vtmglobal; 1028 1028 1029 if (!isset($vtmglobal['config'])) $vtmglobal['config'] = new stdClass(); 1030 1031 if (vtm_table_exists('CONFIG')) { 1032 $sql = "SELECT * FROM " . VTM_TABLE_PREFIX . "CONFIG"; 1033 $vtmglobal['config'] = $wpdb->get_row($sql); 1034 } else { 1035 1029 if (!isset($vtmglobal['config'])) { 1030 $vtmglobal['config'] = new stdClass(); 1036 1031 $vtmglobal['config']->PLACEHOLDER_IMAGE = ''; 1037 1032 $vtmglobal['config']->ANDROID_LINK = ''; … … 1042 1037 $vtmglobal['config']->USE_NATURE_DEMEANOUR = 'Y'; 1043 1038 $vtmglobal['config']->DISPLAY_BACKGROUND_IN_PROFILE = 0; 1044 1045 } 1039 $vtmglobal['config']->WEB_COLUMNS = 1; 1040 } 1041 1042 if (vtm_table_exists('CONFIG')) { 1043 // Merge with default settings 1044 $sql = "SELECT * FROM " . VTM_TABLE_PREFIX . "CONFIG"; 1045 $row = $wpdb->get_row($sql); 1046 1047 if (vtm_count($row) > 0) { 1048 foreach($row as $property => $value) { 1049 $vtmglobal['config']->$property = $value; 1050 } 1051 1052 } 1053 1054 } //else { 1055 1056 // $vtmglobal['config']->PLACEHOLDER_IMAGE = ''; 1057 // $vtmglobal['config']->ANDROID_LINK = ''; 1058 // $vtmglobal['config']->HOME_DOMAIN_ID = 1; 1059 // $vtmglobal['config']->HOME_SECT_ID = 1; 1060 // $vtmglobal['config']->DEFAULT_GENERATION_ID = 1; 1061 // $vtmglobal['config']->ASSIGN_XP_BY_PLAYER = 'Y'; 1062 // $vtmglobal['config']->USE_NATURE_DEMEANOUR = 'Y'; 1063 // $vtmglobal['config']->DISPLAY_BACKGROUND_IN_PROFILE = 0; 1064 1065 // } 1066 //print_r($vtmglobal); 1046 1067 1047 1068 switch(get_option('vtm_web_pagewidth', 'wide')) { -
vampire-character/trunk/inc/install.php
r2392602 r2446519 1221 1221 $rows = vtm_count($wpdb->get_results($sql)); 1222 1222 if (!$rows) { 1223 $filehandle = fopen($datafile,"r"); 1224 1225 // Read the data file, line by line 1226 $i=0; 1227 $data = array(); 1228 while(! feof($filehandle)) { 1229 if ($i == 0) { 1230 // first line is the headings 1231 $headings = fgetcsv($filehandle,0,","); 1232 } else { 1233 // remaining lines are data 1234 $line = fgetcsv($filehandle,0,","); 1235 if ($line > 0) { 1236 $j=0; 1237 foreach ($headings as $heading) { 1238 $data[$i-1][$heading] = $line[$j]; 1239 $j++; 1223 if (file_exists($datafile)) { 1224 $filehandle = fopen($datafile,"r"); 1225 1226 // Read the data file, line by line 1227 $i=0; 1228 $data = array(); 1229 while(! feof($filehandle)) { 1230 if ($i == 0) { 1231 // first line is the headings 1232 $headings = fgetcsv($filehandle,0,","); 1233 } else { 1234 // remaining lines are data 1235 $line = fgetcsv($filehandle,0,","); 1236 if ($line > 0) { 1237 $j=0; 1238 foreach ($headings as $heading) { 1239 $data[$i-1][$heading] = $line[$j]; 1240 $j++; 1241 } 1240 1242 } 1241 1243 } 1244 $i++; 1242 1245 } 1243 $i++; 1244 } 1245 fclose($filehandle); 1246 //print_r($headings); 1247 1248 // compare source and target table headings 1249 // If the headings from the csv and db table match then no issues 1250 // If the csv headings are all in the dbtable and the missing ones 1251 // don't have constraints then we should be okay 1252 $tgtinfo = $wpdb->get_results("SHOW COLUMNS FROM " . VTM_TABLE_PREFIX . "$tablename;", ARRAY_A); 1253 //print_r($tgtinfo); 1254 $tgtheadings = array_column($tgtinfo, 'Field'); 1255 $tgttype = array_column($tgtinfo, 'Type'); 1256 $allmatch = 1; 1257 $go = 1; 1258 // All csv headings in dbtable? 1259 foreach ($headings as $heading) { 1260 $check = array_intersect(array($heading), $tgtheadings); 1261 if (empty($check)) { 1262 echo "<p style='color:red'>Table $tablename heading $heading in CSV is not in database: "; 1263 //print_r($tgtheadings); 1264 echo "</p>"; 1265 $allmatch = 0; 1246 fclose($filehandle); 1247 //print_r($headings); 1248 1249 // compare source and target table headings 1250 // If the headings from the csv and db table match then no issues 1251 // If the csv headings are all in the dbtable and the missing ones 1252 // don't have constraints then we should be okay 1253 $tgtinfo = $wpdb->get_results("SHOW COLUMNS FROM " . VTM_TABLE_PREFIX . "$tablename;", ARRAY_A); 1254 //print_r($tgtinfo); 1255 $tgtheadings = array_column($tgtinfo, 'Field'); 1256 $tgttype = array_column($tgtinfo, 'Type'); 1257 $allmatch = 1; 1258 $go = 1; 1259 // All csv headings in dbtable? 1260 foreach ($headings as $heading) { 1261 $check = array_intersect(array($heading), $tgtheadings); 1262 if (empty($check)) { 1263 echo "<p style='color:red'>Table $tablename heading $heading in CSV is not in database: "; 1264 //print_r($tgtheadings); 1265 echo "</p>"; 1266 $allmatch = 0; 1267 } 1266 1268 } 1267 }1268 if ($allmatch == 0) $go = 0;1269 // Add dbtable headings in csv?1270 // If not, we can let the default be null (unless it has a constraint)1271 $allmatch = 1;1272 $index = 0;1273 foreach ($tgtheadings as $tgt) {1274 if ($tgt != "ID") { // It is okay for ID column to be missing in CSV1275 $type = $tgttype[$index];1276 1277 $docheck = 1;1278 if ($tgt != "NAME") {1279 // Tinytext fields are okay to be missing as they are generally descriptions/specialities1280 if ($type == "tinytext")$docheck = 0;1281 if ($type == "text") $docheck = 0;1282 }1283 if ($docheck) {1284 $check = array_intersect(array($tgt), $headings);1285 if (empty($check)) {1286 echo "<p style='color:red'>Table $tablename heading $tgt ($type) in database is not in CSV</p>";1287 $allmatch = 0;1269 if ($allmatch == 0) $go = 0; 1270 // Add dbtable headings in csv? 1271 // If not, we can let the default be null (unless it has a constraint) 1272 $allmatch = 1; 1273 $index = 0; 1274 foreach ($tgtheadings as $tgt) { 1275 if ($tgt != "ID") { // It is okay for ID column to be missing in CSV 1276 $type = $tgttype[$index]; 1277 1278 $docheck = 1; 1279 if ($tgt != "NAME") { 1280 // Tinytext fields are okay to be missing as they are generally descriptions/specialities 1281 if ($type == "tinytext") $docheck = 0; 1282 if ($type == "text") $docheck = 0; 1283 } 1284 if ($docheck) { 1285 $check = array_intersect(array($tgt), $headings); 1286 if (empty($check)) { 1287 echo "<p style='color:red'>Table $tablename heading $tgt ($type) in database is not in CSV</p>"; 1288 $allmatch = 0; 1289 } 1288 1290 } 1289 1291 } 1292 $index++; 1290 1293 } 1291 $index++; 1292 } 1293 if ($allmatch == 0) $go = 0; 1294 1295 if ($go) { 1296 $rowsadded = 0; 1297 foreach ($data as $id => $entry) { 1298 $rowsadded += $wpdb->insert( VTM_TABLE_PREFIX . $tablename, $entry); 1299 } 1294 if ($allmatch == 0) $go = 0; 1300 1295 1301 if ($rowsadded == 0 && $rows > 0) { 1302 echo "<p style='color:red'>No rows added for $tablename but $rows rows in source - check for database errors</p>"; 1296 if ($go) { 1297 $rowsadded = 0; 1298 foreach ($data as $id => $entry) { 1299 $rowsadded += $wpdb->insert( VTM_TABLE_PREFIX . $tablename, $entry); 1300 } 1301 1302 if ($rowsadded == 0 && $rows > 0) { 1303 echo "<p style='color:red'>No rows added for $tablename but $rows rows in source - check for database errors</p>"; 1304 } 1305 } else { 1306 echo "<p style='color:red'>No data added for $tablename - column mismatch</p>"; 1303 1307 } 1304 1308 } else { 1305 echo "<p style='color:red'>No data added for $tablename - column mismatch</p>";1309 //echo "<p style='color:red'>Target table $tablename is not empty</p>"; 1306 1310 } 1307 } else {1308 //echo "<p style='color:red'>Target table $tablename is not empty</p>";1309 1311 } 1310 1312 } … … 2134 2136 //echo "<p>Creating zip: $zipfilename</p>"; 2135 2137 $zip = new ZipArchive(); 2136 $zip->open($zipfilename, ZipArchive::CREATE); 2137 for ($i = 0 ; $i < count($tables) ; $i++) { 2138 $lvl = count($tables) - $i; 2139 $tablelist = $tables[$i]; 2140 for ($id = 0 ; $id < count($tablelist) ; $id++) { 2141 $table = $tablelist[$id]; 2142 $filename = sprintf("%'02s-%'03s.%s.csv", $lvl, $id+1, $table); 2143 //echo "<li>Adding file: $path/$filename, $dirname/$filename</li>"; 2144 $zip->addFile("$path/$filename", "$dirname/$filename"); 2138 chdir($path); 2139 //if ($zip->open($zipfilename, ZipArchive::CREATE)) { 2140 if ($zip->open($zipfilename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) === TRUE && is_writable($filepath)) { 2141 for ($i = 0 ; $i < count($tables) ; $i++) { 2142 $lvl = count($tables) - $i; 2143 $tablelist = $tables[$i]; 2144 for ($id = 0 ; $id < count($tablelist) ; $id++) { 2145 $table = $tablelist[$id]; 2146 $filename = sprintf("%'02s-%'03s.%s.csv", $lvl, $id+1, $table); 2147 if (file_exists("$filename") && is_readable("$filename")) { 2148 //echo "<li>Adding file (" . ($i + 1) .":" . ($id+1) . "): $filename"; 2149 //$ok = $zip->addFile("$filename"); 2150 $contents = file_get_contents($filename); 2151 $ok = $zip->addFromString("$dirname/$filename", $contents); 2152 if (!$ok) { 2153 echo "Failed to add $filename to zip</li>"; 2154 } 2155 } else { 2156 echo "<p>Failed to find file: $path/$filename</p>"; 2157 } 2158 } 2145 2159 } 2160 $zip->close(); 2161 $ret = "$dirname.zip"; 2162 //echo "<li>Completed $ret</li>"; 2163 } else { 2164 echo "<p>Unable to open new zipfile</p>"; 2165 $ret = ""; 2146 2166 } 2147 $zip->close();2148 2149 return "$dirname.zip";2167 2168 return $ret; 2169 2150 2170 } 2151 2171 -
vampire-character/trunk/readme.txt
r2392610 r2446519 3 3 Tags: vampire, character, generation, roleplay, rpg, lrp, larp 4 4 Requires at least: 5.2.4 5 Tested up to: 5. 5.16 Stable tag: 2. 95 Tested up to: 5.6.1 6 Stable tag: 2.10 7 7 Requires PHP: 5.6 8 8 License: GPLv2 or later … … 135 135 136 136 == Changelog == 137 138 = 2.10 = 139 140 * Bug fix: fixed issue where merit & flaw costs were incorrectly set to level 1 when character approved 141 * Bug fix: fixed issue for PHP7.3 where database zip wasn't being created (NB: still fails for PHP7.4) 142 * Bug fix: fixed issue where XP spends could not be approved - database SQL error returned 143 * Bug fix: remove "Creating default object from empty value" warning message when resetting the database to defaults 144 * Bug fix: remove missing file error when reading in init database by checking if file exists first 137 145 138 146 = 2.9 =
Note: See TracChangeset
for help on using the changeset viewer.