$ref_test) { $field_name = 'id'; $tpl_var = array( 'ID' => 'test-'.$table, 'LABEL' => '#'.$table.'.'.$field_name, 'CHECKED' => isset($_POST['test-'.$table]) ? 'checked="checked"' : $default_checked, 'COUNT' => count($ref_test), ); if ( isset($_POST['test-'.$table]) ) { $failed = 0; foreach ($ref_test as $test) { $err = check_table_ref($table, $field_name, $test[0], $test[1] ); if ($err) { $failed++; $tpl_var['errors'][]= $err.' error references; #'.$test[0].'.'.$test[1].' referring to #'.$table.'.'.$field_name; } } $tpl_var['result'] = $failed; } $template->append('reference_tests', $tpl_var); } // Permalinks test ------------------------------------------------------------ $tpl_var = array( 'ID' => 'permalinks', 'LABEL' => l10n('Pemalinks'), 'CHECKED' => isset($_POST['permalinks']) ? 'checked="checked"' : $default_checked, 'COUNT' => 1, ); if (isset($_POST['permalinks'])) { $query = ' SELECT c.permalink, c.id, op.cat_id FROM '.CATEGORIES_TABLE.' c INNER JOIN '.OLD_PERMALINKS_TABLE.' op ON c.permalink=op.permalink'; $result = pwg_query($query); $tpl_var['result'] = pwg_db_num_rows($result); while ($row=pwg_db_fetch_assoc($result)) { $tpl_var['errors'][] = $row['permalink'].' matches categories '.$row['id'].' and '.$row['cat_id']; } } $template->append('reference_tests', $tpl_var); // #images(id,storage_category_id) vs. #image_category(image_id,category_id) --- $tpl_var = array( 'ID' => 'id_storage_category_id', 'LABEL' => l10n('#images(id,storage_category_id) in #image_category'), 'CHECKED' => isset($_POST['id_storage_category_id']) ? 'checked="checked"' : $default_checked, 'COUNT' => 1, ); if (isset($_POST['id_storage_category_id'])) { $query = ' SELECT i.id, i.storage_category_id, i.path FROM '.IMAGES_TABLE.' i LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ic ON ic.image_id=i.id AND ic.category_id=i.storage_category_id WHERE (ic.category_id IS NULL OR ic.image_id IS NULL) AND i.storage_category_id IS NOT NULL'; $result = pwg_query($query); $tpl_var['result'] = pwg_db_num_rows($result); $i=0; while ($row=pwg_db_fetch_assoc($result) and $i<=50 ) { $tpl_var['errors'][] = $row['path'].' missing entry ('.$row['id'].','.$row['storage_category_id']. ') in #'.IMAGE_CATEGORY_TABLE; $i++; } } $template->append('reference_tests', $tpl_var); $template->set_filename('check', dirname(__FILE__).'/check_db.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'check'); ?>