Location: PHPKode > projects > PHPSiteStats > phpsitestats/configure.php
<?php include("inc.header.php"); ?>


<?php

        // set vars
        $msg = '<b>PhpSiteStats configuration page.<img src=gfx/ico_info.gif align=absmiddle
        alt="On this page you can add the logs PHPSiteStats will handle"
        title="On this page you can add the logs PHPSiteStats will handle"></b>';

        // check if form is submitted
        if (isset($_POST['submit_f'])) {
            if ($_POST['fl_name'] != "" && $_POST['fl_path'] != ""){

                //get the post data
                $fl_name = $_POST['fl_name'];
                $fl_path = $_POST['fl_path'];

                //make sure file is writable if not chmod it
                fl_chmod("inc.conf.php");

                //do our work
                conf_insert("inc.conf.php","\$cfg_flogs['$fl_name']='$fl_path';");
                $msg = "<img src=gfx/ico_yes.gif> Log entry was successfully added.";

             }else{$msg = "<img src=gfx/ico_warn.gif> Please fill the field of the form.";}
        }

        // check if form is submitted
        if (isset($_POST['submit_d'])) {
            if ($_POST['db_name'] != "" && $_POST['db_table'] != ""){

                //get the post data
                $db_name = $_POST['db_name'];
                $db_table = $_POST['db_table'];

                //make sure file is writable if not chmod it
                fl_chmod("inc.conf.php");

                //do our work
                conf_insert("inc.conf.php","\$cfg_dlogs['$db_name']='$db_table';");
                $msg = "<img src=gfx/ico_yes.gif> Log entry was successfully added.";

             }else{$msg = "<img src=gfx/ico_warn.gif> Please fill the field of the form.";}
        }

        // check if form is submitted
        if (isset($_POST['submit_d_c'])) {
            if ($_POST['tname'] != ""){

                //get the post data
                $tname = $_POST['tname'];

                //make table
                $cache = $tname."_cache";
                db_table_make($tname);
                db_table_make($cache);
                $query = "INSERT INTO `$cache` (Id, Date, Ip, Referrer, Agent) VALUES ('', '', '', '', '')";
                $result = mysql_query($query) or die ("Failed to log to $tname<br>Debug info: $query". mysql_error());
                $msg = "<img src=gfx/ico_yes.gif> Table $tname was successfully created.";

             }else{$msg = "<img src=gfx/ico_warn.gif> Please fill the field of the form.";}
        }

        // check if form is submitted
        if (isset($_POST['submit_f_c'])) {
            if (isset($_POST['fname'])){

                //get the data
                $fname = $_POST['fname'];
                $path = get_path("configure.php")."logs/";

                //make file
                if (touch($path.$fname)) {
                   $msg = "<img src=gfx/ico_yes.gif> $fname was created in $path";
                } else {
                   $msg = "<img src=gfx/ico_no.gif> $fname could not be created under $path";
                }
             }else{$msg = "<img src=gfx/ico_warn.gif> Please fill the fields of the form.";}
        }

?>

<form action='configure.php' method='post'>
<?php echo "<p>$msg</p>"; ?>
        <table>
        <th width='100' align="left"><img src=gfx/ico_file.gif align=absmiddle> File</th>
        <th width='250' align="left"><img src=gfx/ico_create.gif align=absmiddle> create</th>
        <th width='100' align="left"><img src=gfx/ico_check.gif align=absmiddle> existing</th>
                <tr>
                        <td class=tdd align="center">
                        Logs
                            <a href="javascript:alert('Files will be created under phpsitestats/logs , so make sure that directory is writeable');">
                            <img src=gfx/ico_help.gif align=absmiddle border=0
                            alt="Files will be created under phpsitestats/logs , so make sure that directory is writeable"
                            title="Files will be created under phpsitestats/logs , so make sure that directory is writeable"></a>
                        </td>
                        <td class=tdd align=right>
                            <input class=input type='text' name='fname' size='46' maxvalue='50'  value='file name' onfocus="this.value=''">
                            <input class=input type='submit' name='submit_f_c' value='Create FileLog File'>
                        </td>
                        <td class=tdd>
                        <?php
                        $path = get_path("configure.php");
                        $files = get_files ($path."logs/");
                        if (count($files) != 0){
                            echo "<select>";
                            foreach($files as $name) {
                                    echo "<option>".$path."logs/".$name."</option>";
                            }
                            echo "</select>";
                        }else{
                            echo "<img src=gfx/ico_notice.gif align=absmiddle> No filelogs files\n";
                        }
                        ?>
                        </td>
                </tr>
                <tr>
                        <td class=tdd colspan=3>
                         &nbsp;
                        </td>
                </tr>
                <tr>
                        <td class=tdd align="center">
                        Records
                        </td>
                        <td class=tdd align=right>
                            <input class=input type='text' name='fl_path' size='25' maxvalue='40' value='file path/name' onfocus="this.value=''">
                            <input class=input type='text' name='fl_name' size='15' maxvalue='20' value='record name' onfocus="this.value=''">
                            <input class=input type='submit' name='submit_f' value='Add FileLog Record'>
                        </td>
                        <td class=tdd>
                        <?php
                        if (isset($cfg_flogs)){
                            echo "<select>";
                            foreach($cfg_flogs as $logs_name => $logs_path) {
                                    echo "<option>$logs_name ($logs_path)</option>";
                            }
                            echo "</select>";
                        }else{
                            echo "<img src=gfx/ico_notice.gif align=absmiddle> No filelogs records\n";
                        }
                        ?>
                        </td>
                </tr>
        </table>

<p>&nbsp;</p>


        <table>
        <th width='100' align="left"><img src=gfx/ico_dbase.gif align=absmiddle> Database</th>
        <th width='250' align="left"><img src=gfx/ico_create.gif align=absmiddle> create</th>
        <th width='100' align="left"><img src=gfx/ico_check.gif align=absmiddle> existing</th>
                <tr>
                        <td class=tdd align="center">
                        Logs
                            <a href="javascript:alert('Make sure you have entered the database details and enabled it on the setup page');">
                            <img src=gfx/ico_help.gif align=absmiddle border=0
                            alt="Make sure you have entered the database details and enabled it on the setup page"
                            title="Make sure you have entered the database details and enabled it on the setup page"></a>
                        </td>
                        <td class=tdd align=right>
                            <input class=input type='text' name='tname' size='42' maxvalue='50'  value='table name' onfocus="this.value=''">
                            <input class=input type='submit' name='submit_d_c' value='Create DbLog Table'>
                        </td>
                        <td class=tdd>
                        <?php
                        $tables = get_tables();
                        if (is_array($tables)){
                            echo "<select>";
                            foreach($tables as $name) {
                                    echo "<option>$name</option>";
                            }
                            echo "</select>";
                        }else{
                            echo "<img src=gfx/ico_notice.gif align=absmiddle> No dblogs tables\n";
                        }
                        ?>
                        </td>
                </tr>
                <tr>
                        <td class=tdd colspan=3>
                         &nbsp;
                        </td>
                </tr>
                <tr>
                        <td class=tdd align="center">
                        Records
                        </td>
                        <td class=tdd align=right>
                            <input class=input type='text' name='db_table' size='25' maxvalue='40' value='table name' onfocus="this.value=''">
                            <input class=input type='text' name='db_name' size='15' maxvalue='20' value='record name' onfocus="this.value=''">
                            <input class=input type='submit' name='submit_d' value='Add DbLog Record'>
                        </td>
                        <td class=tdd>
                        <?php
                        if (isset($cfg_dlogs)){
                            echo "<select>";
                            foreach($cfg_dlogs as $logs_name => $logs_path) {
                                    echo "<option>$logs_name ($logs_path)</option>";
                            }
                            echo "</select>";
                        }else{
                            echo "<img src=gfx/ico_notice.gif align=absmiddle> No dblogs records\n";
                        }
                        ?>
                        </td>
                </tr>
        </table>

</form>

</center>
</body>
</html>
Return current item: PHPSiteStats