Esempio n. 1
0
 function array_rename_key(array $array, $old, $new)
 {
     $changed = array();
     foreach ($array as $key => $value) {
         if ((string) $key == (string) $old) {
             $key = $new;
         }
         $changed[$key] = is_array($value) ? array_rename_key($value, $old, $new) : $value;
     }
     return $changed;
 }
Esempio n. 2
0
            if (isset($_POST['delete'][$grouping]) && in_array($timestamp, $_POST['delete'][$grouping])) {
                # Delete this timestamp!
                unset($visits[$grouping][$timestamp]);
                continue;
            }
            // Update counts
            $diffTotal = $hits['total'] - $control[$grouping][$timestamp]['total'];
            $visits[$grouping][$timestamp]['total'] += $diffTotal;
            $diffUnique = $hits['unique'] - $control[$grouping][$timestamp]['unique'];
            $visits[$grouping][$timestamp]['unique'] += $diffUnique;
            // Update timestamps
            if (isset($_POST['timestamps'][$grouping][$timestamp])) {
                $ts = $_POST['timestamps'][$grouping][$timestamp];
                $newTimestamp = $Mint->offsetMakeGMT($ts['hour'], 0, 0, $ts['month'], $ts['day'], $ts['year']);
                if ($timestamp != $newTimestamp) {
                    $visits[$grouping] = array_rename_key($visits[$grouping], $timestamp, $newTimestamp);
                }
            }
        }
    }
    $pepper->data['visits'] = $visits;
    $Mint->_save();
    $html .= '<tr><th colspan="4" id="notice">Saved.</th></tr>';
}
// Comes after editing
echo '<input type="hidden" name="control" value=\'' . serialize($visits) . '\' />';
$groupings = array('Since Install', 'Past Day (by hour)', 'Past Week (by day)', 'Past Month (by week)', 'Past Year (by month)');
foreach ($visits as $grouping => $existing) {
    $html .= '<tr>
	<th colspan="4" class="sub">' . $groupings[$grouping] . '</th>
</tr>';