Menu

[2eb2a2]: / get_diffs_changelog.php  Maximize  Restore  History

Download this file

212 lines (177 with data), 6.6 kB

  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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php session_start(); ?>
<html>
<head>
<title>deltasql - Show differences between revisions</title>
<link rel="stylesheet" type="text/css" href="deltasql.css">
<link rel="shortcut icon" href="pictures/favicon.ico" />
</head>
<body>
<br>
<?php
// to disable warning messages
ERROR_REPORTING(0);
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer/unified.php';
include("head.inc.php");
include("utils/diffutils.inc.php");
include("utils/utils.inc.php");
include("utils/constants.inc.php");
include("utils/timing.inc.php");
$startwatch = start_watch();
$scriptid = $_POST['scriptid'];
$version = $_POST['version'];
$fromdiff = $_POST['fromdiff'];
$todiff = $_POST['todiff'];
$differences = 0;
if ($scriptid=="") exit;
if ($fromdiff=="") die("<b>No source revision specified</b>");
if ($todiff=="") die("<b>No target revision specified</b>");
echo "<h2>Differences for Script $version between Revisions</h2>";
if ($fromdiff==$todiff) die("<b>There is no difference, both scripts are the same!</b>");
include("conf/config.inc.php");
mysql_connect($dbserver, $username, $password);
@mysql_select_db($database) or die("Unable to select database");
if ($todiff!="latest") {
$queryto="SELECT * from tbscriptchangelog where id=$todiff";
$querytargetbranch="SELECT * from tbscriptbranchchangelog where script_id=$todiff";
} else {
$queryto="SELECT * from tbscript where id=$scriptid";
$querytargetbranch="SELECT * from tbscriptbranch where script_id=$scriptid";
}
// 1. differences in branches assigned to the script
$branchesdifferences=0;
$branchesstring="";
// 1.1 branches which are in source but not in target
$querysourcebranch="SELECT * from tbscriptbranchchangelog where script_id=$fromdiff;";
$resultsb=mysql_query($querysourcebranch);
if ($resultsb=="") $numsb=0; else $numsb=mysql_num_rows($resultsb);
$i=0;
while ($i<$numsb) {
$branchid=mysql_result($resultsb,$i,"branch_id");
// check if the branch is in target
$checktarget="$querytargetbranch AND branch_id=$branchid;";
$resulttarget=mysql_query($checktarget);
if ($resulttarget=="") $checknum=0; else $checknum=mysql_num_rows($resulttarget);
if ($checknum==0) {
$branchesdifferences++;
$queryname="SELECT * FROM tbbranch where id=$branchid";
$resultname=mysql_query($queryname);
$branchname=mysql_result($resultname,0,"name");
$branchesstring = "$branchesstring\n-$branchname";
}
$i++;
}
// 1.2 branches which are in target but not in source
$resultsb=mysql_query($querytargetbranch);
if ($resultsb=="") $numsb=0; else $numsb=mysql_num_rows($resultsb);
$i=0;
while ($i<$numsb) {
$branchid=mysql_result($resultsb,$i,"branch_id");
// check if the branch is in source
$checksource="SELECT * from tbscriptbranchchangelog where script_id=$fromdiff AND branch_id=$branchid;";
$resultsource=mysql_query($checksource);
if ($resultsource=="") $checknum=0; else $checknum=mysql_num_rows($resultsource);
if ($checknum==0) {
$branchesdifferences++;
$queryname="SELECT * FROM tbbranch where id=$branchid";
$resultname=mysql_query($queryname);
$branchname=mysql_result($resultname,0,"name");
$branchesstring = "$branchesstring\n+$branchname";
}
$i++;
}
if ($branchesdifferences>0) {
echo "<h3>Branches:</h3>";
color_diff("$branchesstring\n");
echo "<hr>";
}
// 2. differences in script itself
$queryfrom="SELECT * from tbscriptchangelog where id=$fromdiff";
$resultfrom=mysql_query($queryfrom);
$scriptfrom =mysql_result($resultfrom,0,"code");
$commentsfrom=mysql_result($resultfrom,0,"comments");
$moduleidfrom=mysql_result($resultfrom, 0, "module_id");
$titlefrom=mysql_result($resultfrom, 0, "title");
$versionfrom=mysql_result($resultfrom, 0, "versionnr");
$resultto=mysql_query($queryto);
$scriptto =mysql_result($resultto,0,"code");
$commentsto=mysql_result($resultto,0,"comments");
$moduleidto=mysql_result($resultto, 0, "module_id");
$titleto=mysql_result($resultto, 0, "title");
$versionto=mysql_result($resultto, 0, "versionnr");
// generating sessionid
$c = uniqid (rand (),true);
$sessionid = md5($c);
$scriptfromfilename="output/diffs/script_from_$sessionid.txt";
$scripttofilename="output/diffs/script_to_$sessionid.txt";
$commentsfromfilename="output/diffs/comments_from_$sessionid.txt";
$commentstofilename="output/diffs/comments_to_$sessionid.txt";
$fh = fopen($scriptfromfilename, 'w');
fwrite($fh, "$scriptfrom");
fclose($fh);
$fh = fopen($scripttofilename, 'w');
fwrite($fh, "$scriptto");
fclose($fh);
$fh = fopen($commentsfromfilename, 'w');
fwrite($fh, "$commentsfrom");
fclose($fh);
$fh = fopen($commentstofilename, 'w');
fwrite($fh, "$commentsto");
fclose($fh);
if ($versionfrom!=$versionto) {
echo "<h3>Version number:</h3>";
color_diff("-$versionfrom\n+$versionto");
echo "<hr>";
$differences++;
}
if ($titlefrom!=$titleto) {
echo "<h3>Title:</h3>";
color_diff("-$titlefrom\n+$titleto");
echo "<hr>";
$differences++;
}
if ($moduleidfrom!=$moduleidto) {
$querymod ="SELECT * from tbmodule WHERE id=$moduleidfrom";
$resultmod=mysql_query($querymod);
$modulefrom=mysql_result($resultmod,0,"name");
$querymod ="SELECT * from tbmodule WHERE id=$moduleidto";
$resultmod =mysql_query($querymod);
$moduleto=mysql_result($resultmod,0,"name");
echo "<h3>Modules:</h3>";
color_diff("-$modulefrom\n+$moduleto");
echo "<hr>";
$differences++;
}
$lines1 = file($scriptfromfilename);
$lines2 = file($scripttofilename);
$diff = new Text_Diff('auto', array($lines1, $lines2));
$renderer = new Text_Diff_Renderer_unified();
$difftext = $renderer->render($diff);
if ($difftext!="") {
echo "<h3>Script:</h3>";
color_diff($difftext);
echo "<hr>";
$differences++;
}
$lines1 = file($commentsfromfilename);
$lines2 = file($commentstofilename);
$diff = new Text_Diff('auto', array($lines1, $lines2));
$difftext = $renderer->render($diff);
if ($difftext!="") {
echo "<h3>Comments:</h3>";
color_diff($difftext);
echo "<hr>";
$differences++;
}
if (($differences==0) && ($branchesdifferences==0)) echo "<br><b>No differences found.</b><br>";
unlink($scriptfromfilename);
unlink($scripttofilename);
unlink($commentsfromfilename);
unlink($commentstofilename);
mysql_close();
echo "<h6>"; stop_watch($startwatch); echo "</h6>";
?>
</td></tr></table>
</body>
</html>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.