File: fix_image_data.php

package info (click to toggle)
gforge 3.1-31sarge5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,148 kB
  • ctags: 11,865
  • sloc: sql: 27,860; php: 25,574; perl: 7,124; xml: 3,152; sh: 2,586; ansic: 315; makefile: 143
file content (36 lines) | stat: -rw-r--r-- 707 bytes parent folder | download | duplicates (3)
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
<?php

/*

	A simple fix script

	We had some problem of unknown origin
	where a bunch of accounts had unix_uids of 1

*/
exit;
require('squal_pre.php');

if (!strstr($REMOTE_ADDR,$sys_internal_network)) {
        exit_permission_denied();
}

$res=db_query("SELECT id,bin_data FROM db_images ORDER BY id ASC",50,$offset);

$rows=db_numrows($res);

echo "<br />affect users: $rows<br />";

for ($i=0; $i<$rows; $i++) {

	echo "<br />fixing: ".db_result($res,$i,'id');

	$data=addslashes(base64_encode(db_result($res,$i,'bin_data')));
	$res2=db_query("UPDATE db_images SET bin_data='$data' WHERE id='". db_result($res,$i,'id') ."'");
	if (!$res2 || db_affected_rows($res2) < 1) {
		echo db_error();
	}

}

?>