- Timestamp:
- Sep 11, 2003, 11:54:04 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r81 r88 22 22 function insert_local_category( $cat_id ) 23 23 { 24 global $conf, $page, $user ;24 global $conf, $page, $user, $lang; 25 25 26 26 $site_id = 1; … … 71 71 } 72 72 // 4. retrieving the sub-directories 73 $sub_rep = array(); 74 $i = 0; 73 $subdirs = array(); 75 74 $dirs = ''; 76 if ( $opendir = opendir 77 { 78 while ( $file = readdir 75 if ( $opendir = opendir( $cat_directory ) ) 76 { 77 while ( $file = readdir( $opendir ) ) 79 78 { 80 79 if ( $file != '.' … … 83 82 and $file != 'thumbnail' ) 84 83 { 85 $sub_rep[$i++] = $file; 84 if ( preg_match( '/^[a-zA-Z0-9-_.]+$/', $file ) ) 85 array_push( $subdirs, $file ); 86 else 87 { 88 $output.= '<span style="color:red;">"'.$file.'" : '; 89 $output.= $lang['update_wrong_dirname'].'</span><br />'; 90 } 86 91 } 87 92 } 88 93 } 89 for ( $i = 0; $i < sizeof( $sub_rep ); $i++ ) 90 { 94 foreach ( $subdirs as $subdir ) { 91 95 // 5. Is the category already existing ? we create a subcat if not 92 96 // existing … … 95 99 $query.= ' FROM '.PREFIX_TABLE.'categories'; 96 100 $query.= ' WHERE site_id = '.$site_id; 97 $query.= " AND dir = '".$sub_rep[$i]."'"; 98 if ( !is_numeric( $cat_id ) ) 99 { 100 $query.= ' AND id_uppercat IS NULL'; 101 } 102 else 103 { 104 $query.= ' AND id_uppercat = '.$cat_id; 105 } 101 $query.= " AND dir = '".$subdir."'"; 102 $query.= ' AND id_uppercat'; 103 if ( !is_numeric( $cat_id ) ) $query.= ' IS NULL'; 104 else $query.= ' = '.$cat_id; 106 105 $query.= ';'; 107 106 $result = mysql_query( $query ); 108 107 if ( mysql_num_rows( $result ) == 0 ) 109 108 { 109 $name = str_replace( '_', ' ', $subdir ); 110 110 // we have to create the category 111 111 $query = 'INSERT INTO '.PREFIX_TABLE.'categories'; 112 $query.= ' (dir, site_id,id_uppercat) VALUES';113 $query.= " ('".$sub _rep[$i]."','".$site_id."'";112 $query.= ' (dir,name,site_id,id_uppercat) VALUES'; 113 $query.= " ('".$subdir."','".$name."','".$site_id."'"; 114 114 if ( !is_numeric( $cat_id ) ) $query.= ',NULL'; 115 115 else $query.= ",'".$cat_id."'"; … … 117 117 mysql_query( $query ); 118 118 $category_id = mysql_insert_id(); 119 // regeneration of the plain_structure to integrate the new category 120 $page['plain_structure'] = get_plain_structure(); 119 121 } 120 122 else
Note: See TracChangeset
for help on using the changeset viewer.