- Timestamp:
- Sep 30, 2011, 10:49:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserAdvManager/branches/2.30/include/functions.inc.php
r12272 r12276 2840 2840 for ($i=0; $i<$nb_fields; $i++) 2841 2841 { 2842 $insertions .= '\'' . mysql_real_escape_string($line[$i]) . '\', ';2842 $insertions .= '\'' . pwg_db_real_escape_string($line[$i]) . '\', '; 2843 2843 } 2844 2844 $insertions = substr($insertions, 0, -2); … … 2869 2869 for ($i=0; $i<$nb_fields; $i++) 2870 2870 { 2871 $insertions .= '\'' . mysql_real_escape_string($line[$i]) . '\', ';2871 $insertions .= '\'' . pwg_db_real_escape_string($line[$i]) . '\', '; 2872 2872 } 2873 2873 $insertions = substr($insertions, 0, -2); … … 2904 2904 return true; 2905 2905 } 2906 2907 2908 /** 2909 * UAM_Restore_backup_file 2910 * Restore backup database file 2911 * 2912 * @returns : Boolean 2913 */ 2914 function UAM_Restore_backup_file() 2915 { 2916 global $prefixeTable, $dblayer, $conf; 2917 2918 define('DEFAULT_PREFIX_TABLE', 'piwigo_'); 2919 2920 $Backup_File = UAM_PATH.'/include/backup/UAM_dbbackup.sql'; 2921 2922 // Cleanup database before restoring 2923 // --------------------------------- 2924 2925 // Delete UserAdvManager global config in #_config table 2926 $q = ' 2927 DELETE FROM '.CONFIG_TABLE.' 2928 WHERE param="UserAdvManager" 2929 ;'; 2930 2931 pwg_query($q); 2932 2933 // Delete UserAdvManager_ConfirmMail global config in #_config table 2934 $q = ' 2935 DELETE FROM '.CONFIG_TABLE.' 2936 WHERE param="UserAdvManager_ConfirmMail" 2937 ;'; 2938 2939 pwg_query($q); 2940 2941 // Delete UserAdvManager_Redir config in #_config table 2942 $q = ' 2943 DELETE FROM '.CONFIG_TABLE.' 2944 WHERE param="UserAdvManager_Redir" 2945 ;'; 2946 2947 pwg_query($q); 2948 2949 // Delete UserAdvManager_Version config in #_config table 2950 $q = ' 2951 DELETE FROM '.CONFIG_TABLE.' 2952 WHERE param="UserAdvManager_Version" 2953 ;'; 2954 2955 pwg_query($q); 2956 2957 // Restore sql backup file - DROP TABLE queries are executed 2958 // --------------------------------------------------------- 2959 UAM_execute_sqlfile( 2960 $Backup_File, 2961 DEFAULT_PREFIX_TABLE, 2962 $prefixeTable, 2963 $dblayer 2964 ); 2965 } 2966 2967 2968 /** 2969 * loads an sql file and executes all queries / Based on Piwigo's original install file 2970 * 2971 * Before executing a query, $replaced is... replaced by $replacing. This is 2972 * useful when the SQL file contains generic words. 2973 * 2974 * @param string filepath 2975 * @param string replaced 2976 * @param string replacing 2977 * @return void 2978 */ 2979 function UAM_execute_sqlfile($filepath, $replaced, $replacing, $dblayer) 2980 { 2981 $sql_lines = file($filepath); 2982 $query = ''; 2983 foreach ($sql_lines as $sql_line) 2984 { 2985 $sql_line = trim($sql_line); 2986 if (preg_match('/(^--|^$)/', $sql_line)) 2987 { 2988 continue; 2989 } 2990 2991 $query.= ' '.$sql_line; 2992 2993 // if we reached the end of query, we execute it and reinitialize the 2994 // variable "query" 2995 if (preg_match('/;$/', $sql_line)) 2996 { 2997 $query = trim($query); 2998 $query = str_replace($replaced, $replacing, $query); 2999 if ('mysql' == $dblayer) 3000 { 3001 if (preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches)) 3002 { 3003 $query = $matches[1].' DEFAULT CHARACTER SET utf8'.';'; 3004 } 3005 } 3006 pwg_query($query); 3007 $query = ''; 3008 } 3009 } 3010 } 3011 2906 3012 2907 3013
Note: See TracChangeset
for help on using the changeset viewer.