-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodebase.php
85 lines (70 loc) · 2.8 KB
/
codebase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**************************************************
SQL_Mode Plugin for Coppermine Photo Gallery
*************************************************
SQL_Mode version 1.0
Copyright (c) 2005-2006 Donovan Bray <donnoman@donovanbray.com>
*************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*************************************************
Coppermine version: 1.4.9
$Source: /cvsroot/cpg-contrib/sql_mode/codebase.php,v $
$Revision: 1.1 $
$Author: donnoman $
$Date: 2006/11/01 05:43:31 $
***************************************************/
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
$thisplugin->add_action('plugin_install','sqlmode_install');
$thisplugin->add_action('plugin_wakeup','sqlmode_wakeup');
$thisplugin->add_action('plugin_configure','sqlmode_configure');
$thisplugin->add_action('plugin_uninstall','sqlmode_uninstall');
function sqlmode_wakeup() {
global $CONFIG;
$query = "SET sql_mode = '{$CONFIG['sqlmode']}';";
$result = cpg_db_query($query);
return true;
}
function sqlmode_install() {
global $CONFIG;
sqlmode_uninstall();
$query = "SELECT @@global.sql_mode;";
$result = cpg_db_query($query);
$global_sql_mode = cpg_db_fetch_rowset($result);
$global_sql_mode=empty($global_sql_mode[0][0]) ? '' : $global_sql_mode[0][0];
$query = "INSERT INTO {$CONFIG['TABLE_CONFIG']} (name,value) VALUES ('sqlmode','$global_sql_mode') ;";
$result = cpg_db_query($query);
$query = "UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '1' WHERE name = 'debug_mode';";
$result = cpg_db_query($query);
$query = "UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '1' WHERE name = 'debug_notice';";
$result = cpg_db_query($query);
// Install
if ($_POST['submit']=="Go!") {
return true;
// Loop again
} else {
return 1;
}
}
function sqlmode_configure() {
$query = "SELECT @@global.sql_mode;";
$result = cpg_db_query($query);
$global_sql_mode = cpg_db_fetch_rowset($result);
$global_sql_mode=empty($global_sql_mode[0][0]) ? 'NULL' : $global_sql_mode[0][0];
echo <<< EOT
<p>Current GLOBAL SQL MODE: $global_sql_mode</p>
<p>Coppermine Debug modes automatically turned on during install.</p>
<form action="{$_SERVER['REQUEST_URI']}" method="post">
<input type="submit" name="submit" value="Go!" />
</form>
EOT;
}
function sqlmode_uninstall() {
global $CONFIG;
$query = "DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'sqlmode';";
$result = cpg_db_query($query);
return true;
}
?>