Example #1
0
 /**
  * Insert a new comment into the database
  *
  * @param	array
  */
 function new_comment($comment)
 {
     $created = date("Y-m-d H:i:s", utc_time());
     $sql = "INSERT\n\t\t\t\tINTO comments (\n\t\t\t\t\tthread_id,\n\t\t\t\t\tuser_id,\n\t\t\t\t\tcontent,\n\t\t\t\t\toriginal_content,\n\t\t\t\t\tcreated\n\t\t\t\t) VALUES (?, ?, ?, ?, ?)";
     $this->db->query($sql, array($comment->thread_id, $comment->user_id, $comment->content, $comment->original_content, $created));
     $sql = "UPDATE\n\t\t\t\tthreads\n\t\t\tSET\n\t\t\t\tlast_comment_id = ?,\n\t\t\t\tlast_comment_created = ?\n\t\t\tWHERE thread_id = ?";
     $this->db->query($sql, array($this->db->insert_id(), $created, $comment->thread_id));
     $sql = "UPDATE\n\t\t\t\tcategories \n\t\t\tSET\n\t\t\t\tlast_comment_created = ?\n\t\t\tWHERE category_id = (\n\t\t\t\tSELECT category\n\t\t\t\tFROM threads\n\t\t\t\tWHERE thread_id = ?)";
     $this->db->query($sql, array($created, $comment->thread_id));
 }
Example #2
0
 /**
  * Insert a new comment into the database
  *
  * @param	array
  * @return	void
  */
 function new_comment($data)
 {
     $whattime = date("Y-m-d H:i:s", utc_time());
     $sql = "INSERT INTO comments (thread_id, user_id, content, original_content, " . "created) VALUES (?, ?, ?, ?, ?)";
     $this->db->query($sql, array($data['thread_id'], $data['user_id'], $data['content'], $data['original_content'], $whattime));
     $sql = "UPDATE threads SET last_comment_id = ?,last_comment_created = ? " . "WHERE thread_id = ?";
     $this->db->query($sql, array($this->db->insert_id(), $whattime, $data['thread_id']));
     $sql = "UPDATE categories SET last_comment_created = ? WHERE " . "category_id = (SELECT category FROM threads WHERE thread_id = ?)";
     $this->db->query($sql, array($whattime, $data['thread_id']));
 }
    exit;
}
if ($argv[1] == "--delete") {
    delete_mysql($argv[2]);
    exit;
}
if ($argv[1] == "--run-mysql") {
    run_mysql();
    exit;
}
if ($argv[1] == "--test") {
    tests_import();
    exit;
}
if ($argv[1] == "--utctime") {
    utc_time();
    exit;
}
if ($argv[1] == "--deleteall") {
    delete_mysql_all();
    exit;
}
$GLOBALS["PROGRESS"] = true;
Scan($argv[1]);
function delete_mysql($md5file)
{
    $q = new mysql_squid_builder();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM import_srclogs WHERE md5file='{$md5file}'"));
    $path = $ligne["path"];
    @unlink($path);
    $q->QUERY_SQL("DELETE FROM import_srclogs WHERE  md5file='{$md5file}'");
Example #4
0
 /**
  * Update user login info, such as IP-address or login time, and
  * clear previously generated (but not activated) passwords.
  *
  * @param	int
  * @return	void
  */
 function update_login_info($user_id)
 {
     $sql = "\n\t\t\tUPDATE users\n\t\t\tSET\n\t\t\t\tlast_ip = ?,\n\t\t\t\tlast_login = ?\n\t\t\tWHERE id = ?";
     $this->db->query($sql, array($this->input->ip_address(), date("Y-m-d H:i:s", utc_time()), $user_id));
 }
     $available_languages = available_languages();
 }
 $available_languages = array_merge(array('' => $strDefault), $available_languages);
 if (!empty($user->i18n)) {
     $selectedlang = $user->i18n;
 } else {
     $selectedlang = $_SESSION['lang'];
 }
 echo array_drop_down($available_languages, 'vari18n', $selectedlang, '', TRUE);
 echo "</td></tr>\n";
 if ($user->utc_offset == '') {
     $user->utc_offset = 0;
 }
 echo "<tr><th>{$strUTCOffset}</th><td>";
 foreach ($availabletimezones as $offset => $tz) {
     $tz = $tz . '  (' . ldate('H:i', utc_time($now) + $offset * 60) . ')';
     $availtz[$offset] = $tz;
 }
 echo array_drop_down($availtz, 'utcoffset', $user->utc_offset, '', TRUE) . "</td></tr>\n";
 echo "<tr><th>{$strInterfaceStyle}</th><td>" . interfacestyle_drop_down('style', $user->style) . "</td></tr>\n";
 echo "<tr><th>{$strIncidentRefresh}</th>";
 echo "<td><input maxlength='10' name='incidentrefresh' size='3' type='text' value=\"{$user->incident_refresh}\" /> {$strSeconds}</td></tr>\n";
 echo "<tr><th>{$strIncidentLogOrder}</th><td>";
 echo "<select name='updateorder'>";
 echo "<option ";
 if ($user->update_order == "desc") {
     echo "selected='selected'";
 }
 echo " value='desc'>{$strNewestAtTop}</option>\n";
 echo "<option ";
 if ($user->update_order == "asc") {
/**
* Returns a localised and translated date
* @author Ivan Lucas
* @param string $format. date() format
* @param int $date.  UNIX timestamp.  Uses 'now' if ommitted
* @param bool $utc bool. Is the timestamp being passed as UTC or system time
TRUE = passed as UTC
FALSE = passed as system time
* @returns string. An internationised date/time string
* @todo  th/st and am/pm maybe?
*/
function ldate($format, $date = '', $utc = TRUE)
{
    if ($date == '') {
        $date = $GLOBALS['now'];
    }
    if ($_SESSION['utcoffset'] != '') {
        if (!$utc) {
            // Adjust the date back to UTC
            $date = utc_time($date);
        }
        // Adjust the display time to the users local timezone
        $useroffsetsec = $_SESSION['utcoffset'] * 60;
        $date += $useroffsetsec;
    }
    $datestring = gmdate($format, $date);
    // Internationalise date endings (e.g. st)
    if (strpos($format, 'S') !== FALSE) {
        $endings = array('st', 'nd', 'rd', 'th');
        $i18nendings = array($GLOBALS['strst'], $GLOBALS['strnd'], $GLOBALS['strrd'], $GLOBALS['strth']);
        $datestring = str_replace($endings, $i18nendings, $datestring);
    }
    // Internationalise full day names
    if (strpos($format, 'l') !== FALSE) {
        $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
        $i18ndays = array($GLOBALS['strMonday'], $GLOBALS['strTuesday'], $GLOBALS['strWednesday'], $GLOBALS['strThursday'], $GLOBALS['strFriday'], $GLOBALS['strSaturday'], $GLOBALS['strSunday']);
        $datestring = str_replace($days, $i18ndays, $datestring);
    }
    // Internationalise abbreviated day names
    if (strpos($format, 'D') !== FALSE) {
        $days = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
        $i18ndays = array($GLOBALS['strMon'], $GLOBALS['strTue'], $GLOBALS['strWed'], $GLOBALS['strThu'], $GLOBALS['strFri'], $GLOBALS['strSat'], $GLOBALS['strSun']);
        $datestring = str_replace($days, $i18ndays, $datestring);
    }
    // Internationalise full month names
    if (strpos($format, 'F') !== FALSE) {
        $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
        $i18nmonths = array($GLOBALS['strJanuary'], $GLOBALS['strFebruary'], $GLOBALS['strMarch'], $GLOBALS['strApril'], $GLOBALS['strMay'], $GLOBALS['strJune'], $GLOBALS['strJuly'], $GLOBALS['strAugust'], $GLOBALS['strSeptember'], $GLOBALS['strOctober'], $GLOBALS['strNovember'], $GLOBALS['strDecember']);
        $datestring = str_replace($months, $i18nmonths, $datestring);
    }
    // Internationalise short month names
    if (strpos($format, 'M') !== FALSE) {
        $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        $i18nmonths = array($GLOBALS['strJanAbbr'], $GLOBALS['strFebAbbr'], $GLOBALS['strMarAbbr'], $GLOBALS['strAprAbbr'], $GLOBALS['strMayAbbr'], $GLOBALS['strJunAbbr'], $GLOBALS['strJulAbbr'], $GLOBALS['strAugAbbr'], $GLOBALS['strSepAbbr'], $GLOBALS['strOctAbbr'], $GLOBALS['strNovAbbr'], $GLOBALS['strDecAbbr']);
        $datestring = str_replace($months, $i18nmonths, $datestring);
    }
    // Internationalise am/pm
    if (strpos($format, 'a') !== FALSE) {
        $months = array('am', 'pm');
        $i18nmonths = array($GLOBALS['strAM'], $GLOBALS['strPM']);
        $datestring = str_replace($months, $i18nmonths, $datestring);
    }
    return $datestring;
}
Example #7
0
 function new_message($data)
 {
     $sql = "\n\t\t\tINSERT INTO pm_content\n\t\t\t\t(subject, content, created)\n\t\t\tVALUES\n\t\t\t(?, ?, ?)";
     $this->db->query($sql, array($data['subject'], $data['content'], date("Y-m-d H:i:s", utc_time())));
     return $this->db->insert_id();
 }