[Linpha-cvs] SF.net SVN: linpha: [4779] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2007-11-06 16:34:37
|
Revision: 4779 http://linpha.svn.sourceforge.net/linpha/?rev=4779&view=rev Author: bzrudi Date: 2007-11-06 08:34:23 -0800 (Tue, 06 Nov 2007) Log Message: ----------- "fix path for moved sql.data.php" Modified Paths: -------------- trunk/linpha2/admin/maintenance_db.php trunk/linpha2/reset_database.php Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-11-06 11:48:31 UTC (rev 4778) +++ trunk/linpha2/admin/maintenance_db.php 2007-11-06 16:34:23 UTC (rev 4779) @@ -1,307 +1,307 @@ -<?php - -/** - * check if each photo has a parent element - */ - echo '<h2>'.i18n("Checking photos table").'</h2>'; - echo '('.i18n("Checking intern consistency of the photos table. This means every entry must belong to a folder.").')<br /><br />'; - - $query = $GLOBALS['linpha']->db->Execute("SELECT id, parent_id, name FROM ".LIN_PREFIX."photos"); - $i = 0; - $i_tot = 0; - while($data = $query->FetchRow()) - { - if($data['parent_id'] != 0) - { - $query2 = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($data['parent_id'])."'"); - $data2 = $query2->FetchRow(); - if( isset($data2['id'])) - { - $i++; - } - else - { - echo i18n("Warning: This entry doesn't belongs to a folder:").' '.$data['name'].'<br />'; - - /** - * @todo there should be an option where we could really delete any obsolete entries - */ - echo i18n("Should delete it").'<br />'; - } - } - else - { - $i++; - } - - $i_tot++; - } - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - -/** - * check cached photos exists in filesystem and vice versa - */ - echo '<br /><h2>'.i18n("Checking image cache").'</h2>'; - - echo '<h3>'.i18n("Do all cache entries exists in the photos table?").'</h3>'; - - $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."photos_cache.id, ".LIN_PREFIX."photos_cache.photo_id" . - " FROM ".LIN_PREFIX."photos_cache". - " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.id = ".LIN_PREFIX."photos_cache.photo_id". - " WHERE ".LIN_PREFIX."photos.id IS NULL"); - - if( $query->EOF ) - { - echo '<font color="green">ok</font> '.i18n("There is no broken association.").'<br />'; - } - else - { - echo '<font color="red">failed</font><br />'; - while($data = $query->FetchRow() ) - { - echo i18n("Missing entry of:").' '.$data['photo_id'].' ('.i18n("Cache Id").': '.$data['id'].')<br />'; - } - echo '<br />'; - } - - - echo '<h3>'.i18n("Do all cache entries exists in the filesystem?").'</h3>'; - $query = $GLOBALS['linpha']->db->Execute("SELECT id, photo_id FROM ".LIN_PREFIX."photos_cache"); - $i = 0; - $i_tot = 0; - while($data = $query->FetchRow() ) - { - $filename = LinImage::getCachePath('img',$data['id'],'2'); - if( !file_exists($filename)) - { - echo i18n("Cached file doesn't exists:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; - - /** - * @todo there should be an option where we could really delete any obsolete entries - */ - echo i18n("Should delete it").'<br />'; - } - else - { - if(filesize($filename) == 0) - { - echo i18n("Filesize is zero of:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; - } - else - { - $i++; - } - } - - $i_tot++; - } - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - - - echo '<br /><h3>'.i18n("Are there obsolete cached images lying around?").'</h3>'; - $path = LinSql::getPath('cache'); - $i = 0; - $i_tot = 0; - $sub_dir_handle = opendir($path.'/img'); - while( ($sub_dir = readdir($sub_dir_handle)) !== false ) - { - if($sub_dir != "." && $sub_dir != "..") - { - $sub_file_handle = opendir($path.'/img/'.$sub_dir); - while( ($sub_file = readdir($sub_file_handle)) !== false ) - { - if($sub_file != "." && $sub_file != "..") - { - $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); - - /** - * need this pre check because mysql returns a result even if id is '107.' - * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" - */ - if(! preg_match('/^[0-9]*$/', $filename_without_ext)) - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - else - { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . - "id = '".LinSql::linAddslashes( LinFilesys::getFilenameWithoutFileExt($sub_file) )."'"); - $data = $query->FetchRow(); - - if( isset($data['id'])) - { - $i++; - } - else - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - } - - $i_tot++; - } - } - - closedir($sub_file_handle); - } - } - closedir($sub_dir_handle); - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - - - echo '<br /><h3>'.i18n("Are there obsolete cached thumbnails lying around?").'</h3>'; - $path = LinSql::getPath('cache'); - $i = 0; - $i_tot = 0; - $sub_dir_handle = opendir($path.'/thumb'); - while( ($sub_dir = readdir($sub_dir_handle)) !== false ) - { - if($sub_dir != "." && $sub_dir != "..") - { - $sub_file_handle = opendir($path.'/thumb/'.$sub_dir); - while( ($sub_file = readdir($sub_file_handle)) !== false ) - { - if($sub_file != "." && $sub_file != "..") - { - $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); - - /** - * need this pre check because mysql returns a result even if id is '107.' - * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" - */ - if(! preg_match('/^[0-9]*$/', $filename_without_ext)) - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - else - { - $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".LIN_PREFIX."photos WHERE " . - "id = '".LinSql::linAddslashes( $filename_without_ext )."'"); - $data = $query->FetchRow(); - - if( isset($data['name'])) - { - $i++; - } - else - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - } - - $i_tot++; - } - } - - closedir($sub_file_handle); - } - } - closedir($sub_dir_handle); - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - -/** - * check comment/exif/iptc/xmp to photo association - */ - echo '<br /><h2>'.i18n("Checking MetaData").'</h2>'; - $array_meta = array('comments','data','exif','iptc'/*,'xmp'*/); - foreach($array_meta AS $value) - { - echo i18n("Checking table").' '.LIN_PREFIX."meta_".$value.' '; - $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."meta_".$value.".md5sum FROM ".LIN_PREFIX."meta_".$value. - " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.md5sum = ".LIN_PREFIX."meta_".$value.".md5sum". - " WHERE ".LIN_PREFIX."photos.id IS NULL"); - - if( $query->EOF ) - { - echo '<font color="green">ok</font>'.'<br />'; - } - else - { - echo '<font color="red">failed</font><br />'; - while($data = $query->FetchRow() ) - { - echo i18n("Missing entry with md5sum:").' '.$data['md5sum'].'<br />'; - } - echo '<br />'; - } - } - - -/** - * check permission entries - */ - $array_perms = array( - 'read', - 'write', - 'basket_print', - 'basket_mail', - 'basket_download', - 'metadata_comments', - 'metadata_deletecomments', - 'metadata_edit', - 'watermark', - 'stats', - 'download', - ); - - echo '<br /><h2>'.i18n("Checking permission entries").'</h2>'; - - foreach($array_perms AS $value) - { - $query = $GLOBALS['linpha']->db->Execute("SELECT permission FROM ".LIN_PREFIX."permissions " . - "WHERE photos_id = '0' AND perm_type = '".$value."'"); - $data = $query->FetchRow(); - - echo i18n("Checking").' "'.$value.'" '; - if( isset($data['permission']) ) - { - echo '<font color="green">'.i18n("ok").'</font>'; - } - else - { - echo '<font color="red">'.i18n("failed").'</font><br />'; - echo i18n("Please check the database, these entry is missing!").'<br />'; - } - echo '<br />'; - } - -/** - * checking config entries - */ - echo '<br /><h2>'.i18n("Checking config entries").'</h2>'; - - /** - * prevent some php notices - */ - $options = array(); - $_SESSION['sys_im_bracket_support'] = ''; - $_SESSION['sys_im_use_convert'] = ''; - $_SESSION['sys_im_convert_path'] = ''; - $_SESSION['language'] = ''; - $_SESSION['album_dir'] = ''; - $_SESSION['cache_dir'] = ''; - $_SESSION['tmp_dir'] = ''; - - include(LINPHA_DIR.'/install/sql/sql.data.php'); - foreach($options AS $key=>$value) - { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . - "WHERE option_name = '".$key."'"); - $data = $query->FetchRow(); - - echo i18n("Checking").' "'.$key.'" '; - if( isset($data['id']) ) - { - echo '<font color="green">'.i18n("ok").'</font>'; - } - else - { - echo '<font color="red">'.i18n("failed").'</font><br />'; - echo i18n("Please check the database, these entry is missing!").'<br />'; - } - echo '<br />'; - } - - +<?php + +/** + * check if each photo has a parent element + */ + echo '<h2>'.i18n("Checking photos table").'</h2>'; + echo '('.i18n("Checking intern consistency of the photos table. This means every entry must belong to a folder.").')<br /><br />'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, parent_id, name FROM ".LIN_PREFIX."photos"); + $i = 0; + $i_tot = 0; + while($data = $query->FetchRow()) + { + if($data['parent_id'] != 0) + { + $query2 = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($data['parent_id'])."'"); + $data2 = $query2->FetchRow(); + if( isset($data2['id'])) + { + $i++; + } + else + { + echo i18n("Warning: This entry doesn't belongs to a folder:").' '.$data['name'].'<br />'; + + /** + * @todo there should be an option where we could really delete any obsolete entries + */ + echo i18n("Should delete it").'<br />'; + } + } + else + { + $i++; + } + + $i_tot++; + } + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + +/** + * check cached photos exists in filesystem and vice versa + */ + echo '<br /><h2>'.i18n("Checking image cache").'</h2>'; + + echo '<h3>'.i18n("Do all cache entries exists in the photos table?").'</h3>'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."photos_cache.id, ".LIN_PREFIX."photos_cache.photo_id" . + " FROM ".LIN_PREFIX."photos_cache". + " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.id = ".LIN_PREFIX."photos_cache.photo_id". + " WHERE ".LIN_PREFIX."photos.id IS NULL"); + + if( $query->EOF ) + { + echo '<font color="green">ok</font> '.i18n("There is no broken association.").'<br />'; + } + else + { + echo '<font color="red">failed</font><br />'; + while($data = $query->FetchRow() ) + { + echo i18n("Missing entry of:").' '.$data['photo_id'].' ('.i18n("Cache Id").': '.$data['id'].')<br />'; + } + echo '<br />'; + } + + + echo '<h3>'.i18n("Do all cache entries exists in the filesystem?").'</h3>'; + $query = $GLOBALS['linpha']->db->Execute("SELECT id, photo_id FROM ".LIN_PREFIX."photos_cache"); + $i = 0; + $i_tot = 0; + while($data = $query->FetchRow() ) + { + $filename = LinImage::getCachePath('img',$data['id'],'2'); + if( !file_exists($filename)) + { + echo i18n("Cached file doesn't exists:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; + + /** + * @todo there should be an option where we could really delete any obsolete entries + */ + echo i18n("Should delete it").'<br />'; + } + else + { + if(filesize($filename) == 0) + { + echo i18n("Filesize is zero of:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; + } + else + { + $i++; + } + } + + $i_tot++; + } + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + + + echo '<br /><h3>'.i18n("Are there obsolete cached images lying around?").'</h3>'; + $path = LinSql::getPath('cache'); + $i = 0; + $i_tot = 0; + $sub_dir_handle = opendir($path.'/img'); + while( ($sub_dir = readdir($sub_dir_handle)) !== false ) + { + if($sub_dir != "." && $sub_dir != "..") + { + $sub_file_handle = opendir($path.'/img/'.$sub_dir); + while( ($sub_file = readdir($sub_file_handle)) !== false ) + { + if($sub_file != "." && $sub_file != "..") + { + $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); + + /** + * need this pre check because mysql returns a result even if id is '107.' + * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" + */ + if(! preg_match('/^[0-9]*$/', $filename_without_ext)) + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + else + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . + "id = '".LinSql::linAddslashes( LinFilesys::getFilenameWithoutFileExt($sub_file) )."'"); + $data = $query->FetchRow(); + + if( isset($data['id'])) + { + $i++; + } + else + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + } + + $i_tot++; + } + } + + closedir($sub_file_handle); + } + } + closedir($sub_dir_handle); + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + + + echo '<br /><h3>'.i18n("Are there obsolete cached thumbnails lying around?").'</h3>'; + $path = LinSql::getPath('cache'); + $i = 0; + $i_tot = 0; + $sub_dir_handle = opendir($path.'/thumb'); + while( ($sub_dir = readdir($sub_dir_handle)) !== false ) + { + if($sub_dir != "." && $sub_dir != "..") + { + $sub_file_handle = opendir($path.'/thumb/'.$sub_dir); + while( ($sub_file = readdir($sub_file_handle)) !== false ) + { + if($sub_file != "." && $sub_file != "..") + { + $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); + + /** + * need this pre check because mysql returns a result even if id is '107.' + * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" + */ + if(! preg_match('/^[0-9]*$/', $filename_without_ext)) + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + else + { + $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".LIN_PREFIX."photos WHERE " . + "id = '".LinSql::linAddslashes( $filename_without_ext )."'"); + $data = $query->FetchRow(); + + if( isset($data['name'])) + { + $i++; + } + else + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + } + + $i_tot++; + } + } + + closedir($sub_file_handle); + } + } + closedir($sub_dir_handle); + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + +/** + * check comment/exif/iptc/xmp to photo association + */ + echo '<br /><h2>'.i18n("Checking MetaData").'</h2>'; + $array_meta = array('comments','data','exif','iptc'/*,'xmp'*/); + foreach($array_meta AS $value) + { + echo i18n("Checking table").' '.LIN_PREFIX."meta_".$value.' '; + $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."meta_".$value.".md5sum FROM ".LIN_PREFIX."meta_".$value. + " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.md5sum = ".LIN_PREFIX."meta_".$value.".md5sum". + " WHERE ".LIN_PREFIX."photos.id IS NULL"); + + if( $query->EOF ) + { + echo '<font color="green">ok</font>'.'<br />'; + } + else + { + echo '<font color="red">failed</font><br />'; + while($data = $query->FetchRow() ) + { + echo i18n("Missing entry with md5sum:").' '.$data['md5sum'].'<br />'; + } + echo '<br />'; + } + } + + +/** + * check permission entries + */ + $array_perms = array( + 'read', + 'write', + 'basket_print', + 'basket_mail', + 'basket_download', + 'metadata_comments', + 'metadata_deletecomments', + 'metadata_edit', + 'watermark', + 'stats', + 'download', + ); + + echo '<br /><h2>'.i18n("Checking permission entries").'</h2>'; + + foreach($array_perms AS $value) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT permission FROM ".LIN_PREFIX."permissions " . + "WHERE photos_id = '0' AND perm_type = '".$value."'"); + $data = $query->FetchRow(); + + echo i18n("Checking").' "'.$value.'" '; + if( isset($data['permission']) ) + { + echo '<font color="green">'.i18n("ok").'</font>'; + } + else + { + echo '<font color="red">'.i18n("failed").'</font><br />'; + echo i18n("Please check the database, these entry is missing!").'<br />'; + } + echo '<br />'; + } + +/** + * checking config entries + */ + echo '<br /><h2>'.i18n("Checking config entries").'</h2>'; + + /** + * prevent some php notices + */ + $options = array(); + $_SESSION['sys_im_bracket_support'] = ''; + $_SESSION['sys_im_use_convert'] = ''; + $_SESSION['sys_im_convert_path'] = ''; + $_SESSION['language'] = ''; + $_SESSION['album_dir'] = ''; + $_SESSION['cache_dir'] = ''; + $_SESSION['tmp_dir'] = ''; + + include(LINPHA_DIR.'/lib/include/sql.data.php'); + foreach($options AS $key=>$value) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . + "WHERE option_name = '".$key."'"); + $data = $query->FetchRow(); + + echo i18n("Checking").' "'.$key.'" '; + if( isset($data['id']) ) + { + echo '<font color="green">'.i18n("ok").'</font>'; + } + else + { + echo '<font color="red">'.i18n("failed").'</font><br />'; + echo i18n("Please check the database, these entry is missing!").'<br />'; + } + echo '<br />'; + } + + ?> \ No newline at end of file Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2007-11-06 11:48:31 UTC (rev 4778) +++ trunk/linpha2/reset_database.php 2007-11-06 16:34:23 UTC (rev 4779) @@ -81,7 +81,7 @@ * insert data */ echo "<br /><br />".tr("Inserting Table Data")."... "; - include_once(LINPHA_DIR.'/install/sql/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |