09 Coders Edit Log

Started by Mindless, July 21, 2012, 05:49:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

whocares

did you add the user id you want to be able to access it?

$allowed_ids = array(1); //== 1 Is Sysop - add userids you want access
Unless stated otherwise code is untested

Jctheboss


ZajferX

thank you very much :D

Quote from: denede on May 02, 2014, 11:03:14 PM
Quote from: ZajferX on May 02, 2014, 10:51:27 PM
after applying the mod i get an error on this code

<span class='btn'><a href='admin.php?action=editlog'>{$lang['index_coder_editlog']}</a></span>

Notice: Undefined index: index_coder_editlog in C:\xampp\htdocs\admin\index.php on line 50

go to lang_ad_index.php and add 'index_coder_editlog' => "Editlog",

denede

#3
Quote from: ZajferX on May 02, 2014, 10:51:27 PM
after applying the mod i get an error on this code

<span class='btn'><a href='admin.php?action=editlog'>{$lang['index_coder_editlog']}</a></span>

Notice: Undefined index: index_coder_editlog in C:\xampp\htdocs\admin\index.php on line 50

go to lang_ad_index.php and add 'index_coder_editlog' => "Editlog",

ZajferX

after applying the mod i get an error on this code

<span class='btn'><a href='admin.php?action=editlog'>{$lang['index_coder_editlog']}</a></span>

Notice: Undefined index: index_coder_editlog in C:\xampp\htdocs\admin\index.php on line 50

Mindless

Credits to Retro, awesome script this one.

Save and upload editlog.php to /admin :

Code (php) Select
<?php
if ( ! defined'IN_TBDEV_ADMIN' ) )
{
print "<h1>{$lang['text_incorrect']}</h1>{$lang['text_cannot']}";
exit();
}
require_once(
INCL_DIR.'user_functions.php');
$lang array_merge$langload_language('editlog') );
$HTMLOUT='';
// ID list - Add individual user IDs to this list for access to this script

$allowed_ids = array(1); //== 1 Is Sysop - add userids you want access
if (!in_array($CURUSER['id'], $allowed_ids))
    
stderr('Error''Access Denied!');
// Written by RetroKill to allow scripters to see what scripts have changed since
// they last updated their own list.
//
// This script will create a unique list for each member allowed to access this
// script. It allows them to see what scripts have been updated since they last
// updated their own list, allowing scripters to work together better.
//
// The first run will produce no results, as it will initialise the list for the
// member running the script. Further runs will show the scripter when a script
// has been updated from their original list (someone else, or they, have modified
// a script). When a member updates a script, they should run this script, which
// will show the update, then update their list using the update button, to bring
// their list up to date. If an update appears when the scripter hasn't made any
// changes, then they know that another scripter has modified a script.
function unsafeChar($var)
{
    return 
str_replace(array("&gt;""&lt;""&quot;""&amp;"), array(">""<""\"""&"), $var);
}
function 
safeChar($var)
{
    return 
htmlspecialchars(unsafeChar($var));
}
function 
makeSafeText($arr)
{
    foreach (
$arr as $k => $v) {
        if (
is_array($v))
            
$arr[$k] = makeSafeText($v);
        else
            
$arr[$k] = safeChar($v);
    }
    return 
$arr;
}
// Makes the data safe
if (!empty($_GET)) $_GET makeSafeText($_GET);
if (!empty(
$_POST)) $_POST makeSafeText($_POST);
if (!empty(
$_COOKIE)) $_COOKIE makeSafeText($_COOKIE);
loggedinorreturn();

$file_data './dir_list/data_'.$CURUSER['username'].'.txt';

if (
file_exists($file_data))
{
// Fetch existing data
$data unserialize(file_get_contents($file_data));
$exist TRUE;
}
else
{
// Initialise File
$exist FALSE;
}

$fetch_set = array();
$i=0;
$directories = array();

//== Enter directories to log... if you dont have them - comment them out or edit them
$directories[] = './'// Webroot
$directories[] = './include/';
$directories[] = './bitbucket/';
$directories[] = './avatars/';
//$directories[] = './templates/';  //==09 template system - do you use it ??
$directories[] = './include/settings/';
$directories[] = './cache/';
//$directories[] = './dictbreaker/'; //==09 Failed logins - do you use it ??
$directories[] = './logs/';
//$directories[] = './torrents/';  //== watch this fella if you have 1000's of torrents it will timeout
$directories[] = './admin/';

foreach (
$directories AS $x)
{
if (
$handle opendir($x)) {
while (
false !== ($file readdir($handle))) {
if (
$file != "." && $file != "..") {
if (!
is_dir($x.'/'.$file)) {
$fetch_set[$i]['modify'] = filemtime($x.$file);
$fetch_set[$i]['size'] = filesize($x.$file);
$fetch_set[$i]['name'] = $x.$file;
$fetch_set[$i]['key'] = $i;
$i++;
}
}
}
closedir($handle);
}
}

if (!
$exist OR (isset($_POST['update']) AND ($_POST['update'] == 'Update')))
{
// Create first disk image of files
// OR update existing data...
$data serialize($fetch_set);
$handle fopen($file_data,"w");
fputs($handle$data);
fclose($handle);
$data unserialize($data);
}

// We now need to link current contents with stored contents.

reset($fetch_set);
reset($data);
$current $fetch_set;
$last $data;
foreach(
$current as $x)
{
// Search the data sets for differences
foreach ($last AS $y)
{
if (
$x['name'] == $y['name'])
{
if ((
$x['size'] == $y['size']) AND ($x['modify'] == $y['modify']))
{
unset (
$current[$x['key']]);
unset (
$last[$y['key']]);
}
else
$current[$x['key']]['status'] = 'modified';
}
if (isset(
$last[$y['key']])) $last[$y['key']]['status'] = 'deleted';
}
if (isset(
$current[$x['key']]['name']) AND
!isset(
$current[$x['key']]['status'])) $current[$x['key']]['status'] = 'new';
}

$current += $last// Add deleted entries to current list
unset ($last);

// $fetch_data contains a current list of directory
// $data contains the last snapshot of the directory
// $current contains a current list of files in the directory that are
// new, modified or deleted...
// Remove lists from current code...
unset ($data);
unset (
$fetch_set);
$HTMLOUT .="<table width='750' border='1' cellspacing='2' cellpadding='5' align='center'>
<tr>
<td align='center' width='70%' bgcolor='orange'><strong>
{$lang['editlog_new']}</strong></td>
<td align='center' bgcolor='orange'><strong>
{$lang['editlog_added']}</strong></td>
</tr>"
;
reset($current);
$count 0;
foreach (
$current AS $x)
{
if (
$x['status'] == 'new')
{
$HTMLOUT .="
<tr>
<td align='center'>"
;
$HTMLOUT .= safeChar(substr($x['name'],2));
$HTMLOUT .="</td>
<td align='center'>"
;
$HTMLOUT .= get_date($x['modify'], 'LONG',0,1);
$HTMLOUT .="</td>
</tr>"
;
$count++;
}
}
if (!
$count)
{
$HTMLOUT .="
<tr>
<td align='center' colspan='2'><b>
{$lang['editlog_no_new']}</b></td>
</tr>"
;
}

$HTMLOUT .="
</table>
<br /><br /><br />
<table width='750' border='1' cellspacing='2' cellpadding='5' align='center'>
<tr>
<td align='center' width='70%' bgcolor='orange'><strong>
{$lang['editlog_modified']}</strong></td>
<td align='center' bgcolor='orange'><strong>
{$lang['editlog_modified1']}</strong></td>
</tr>"
;
reset($current);
$count 0;
foreach (
$current AS $x)
{
if (
$x['status'] == 'modified')
{
$HTMLOUT .="
<tr>
<td align='center'>"
;
$HTMLOUT .= safeChar(substr($x['name'],2));
$HTMLOUT .="</td>
<td align='center'>"
;
$HTMLOUT .= get_date($x['modify'], 'long',0,1);
$HTMLOUT .="</td>
</tr>"
;
$count++;
}
}
if (!
$count)
{
$HTMLOUT .="
<tr>
<td align='center' colspan='2'><b>
{$lang['editlog_no_modified']}</b></td>
</tr>"
;
}
$HTMLOUT .="
</table>
<br /><br /><br />
<table width='750' border='1' cellspacing='2' cellpadding='5' align='center'>
<tr>
<td align='center' width='70%' bgcolor='orange'><strong>
{$lang['editlog_deleted']}</strong></td>
<td align='center' bgcolor='orange'><strong>
{$lang['editlog_deleted1']}</strong></td>
</tr>"
;
reset($current);
$count 0;
foreach (
$current AS $x)
{
if (
$x['status'] == 'deleted')
{
$HTMLOUT .="
<tr>
<td align='center'>"
;
$HTMLOUT .= safeChar(substr($x['name'],2));
$HTMLOUT .="</td>
<td align='center'>"
;
$HTMLOUT .= get_date($x['modify'], 'LONG',0,1);
$HTMLOUT .="</td>
</tr>"
;
$count++;
}
}
if (!
$count)
{
$HTMLOUT .="
<tr>
<td align='center' colspan='2'><b>
{$lang['editlog_no_deleted']}</b></td>
</tr>"
;
}
$HTMLOUT .="
</table>
<br /><br /><br />
<form method='post' action='?'>
<table width='750' border='1' cellspacing='2' cellpadding='5' align='center'>
<tr>
<td align='center' bgcolor='orange'>
<input name='update' type='submit' value='
{$lang['editlog_update']}' />
</td>
</tr>
</table>
</form>"
;
print 
stdhead('Php File Edit Log') . $HTMLOUT stdfoot();
?>


Add this to /admin/index.php :

Code (php) Select
<span class='btn'><a href='admin.php?action=editlog'>{$lang['index_coder_editlog']}</a></span>

Add this to the array on admin.php :

Code (php) Select
'editlog' => 'editlog',

Save and upload lang_editlog.php to /lang/en

Code (php) Select
<?php

$lang 
= array(

#editlog
'editlog_new' => "New files added since last check.",
'editlog_added' => "Added.",
'editlog_no_new' => "No new files added since last check.",
'editlog_modified' => "Modified files since last check.",
'editlog_modified1' => "Modified.",
'editlog_no_modified' => "No files modified since last check.",
'editlog_deleted' => "Files deleted since last check.",
'editlog_deleted1' => "Deleted.",
'editlog_no_deleted' => "No files deleted since last check.",
'editlog_update' => "Update"
);

?>


Last create a directory in root named dir_list - make sure you chmod it to 777 and add a .htaccess or index.html minimum.
On first visit you want see anything - Press the update button then on next visit you'll start seeing modified files since last check if there is any.