예제 #1
1
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                			    |
|--------------------------------------------------------------------------|
|   Licence Info: GPL			                                    |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V5					    |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless, Autotron, whocares, Swizzles.					    |
|--------------------------------------------------------------------------|
 _   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    //== Delete inactive user accounts
    $secs = 350 * 86400;
    $dt = TIME_NOW - $secs;
    $maxclass = UC_STAFF;
    sql_query("SELECT FROM users WHERE parked='no' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
    //== Delete parked user accounts
    $secs = 675 * 86400;
    // change the time to fit your needs
    $dt = TIME_NOW - $secs;
    $maxclass = UC_STAFF;
    sql_query("SELECT FROM users WHERE parked='yes' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
    if ($queries > 0) {
        write_log("Inactive Clean -------------------- Inactive Clean Complete using {$queries} queries--------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #2
0
/**
 * Update server traffic settings.
 *
 * @param int $trafficLimit Monthly traffic limit
 * @param int $trafficWarning Traffic warning
 * @return bool TRUE on success FALSE otherwise
 */
function admin_updateServerTrafficSettings($trafficLimit, $trafficWarning)
{
    $retVal = true;
    if (!is_numeric($trafficLimit)) {
        set_page_message(tr('Monthly traffic limit must be a number.'), 'error');
        $retVal = false;
    }
    if (!is_numeric($trafficWarning)) {
        set_page_message(tr('Monthly traffic warning must be a number.'), 'error');
        $retVal = false;
    }
    if ($retVal && $trafficWarning > $trafficLimit) {
        set_page_message(tr('Monthly traffic warning cannot be bigger than monthly traffic limit.'), 'error');
        $retVal = false;
    }
    if ($retVal) {
        /** @var $db_cfg iMSCP_Config_Handler_Db */
        $dbConfig = iMSCP_Registry::get('dbConfig');
        $dbConfig->SERVER_TRAFFIC_LIMIT = $trafficLimit;
        $dbConfig->SERVER_TRAFFIC_WARN = $trafficWarning;
        // gets the number of queries that were been executed
        $updtCount = $dbConfig->countQueries('update');
        $newCount = $dbConfig->countQueries('insert');
        // An Update was been made in the database ?
        if ($updtCount || $newCount) {
            set_page_message(tr('Server traffic settings successfully updated.', $updtCount), 'success');
            write_log("{$_SESSION['user_logged']} updated server  traffic settings.", E_USER_NOTICE);
        } else {
            set_page_message(tr("Nothing has been changed."), 'info');
        }
    }
    return $retVal;
}
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    //== delete torrents - ????
    $days = 30;
    $dt = TIME_NOW - $days * 86400;
    sql_query("UPDATE torrents SET flags='1' WHERE added < {$dt} AND seeders='0' AND leechers='0'") or sqlerr(__FILE__, __LINE__);
    $res = sql_query("SELECT id, name FROM torrents WHERE mtime < {$dt} AND seeders='0' AND leechers='0' AND flags='1'") or sqlerr(__FILE__, __LINE__);
    while ($arr = mysqli_fetch_assoc($res)) {
        sql_query("DELETE files.*, comments.*, thankyou.*, thanks.*, thumbsup.*, bookmarks.*, coins.*, rating.*, xbt_files_users.* FROM xbt_files_users\n                                 LEFT JOIN files ON files.torrent = xbt_files_users.fid\n                                 LEFT JOIN comments ON comments.torrent = xbt_files_users.fid\n                                 LEFT JOIN thankyou ON thankyou.torid = xbt_files_users.fid\n                                 LEFT JOIN thanks ON thanks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN bookmarks ON bookmarks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN coins ON coins.torrentid = xbt_files_users.fid\n                                 LEFT JOIN rating ON rating.torrent = xbt_files_users.fid\n                                 LEFT JOIN thumbsup ON thumbsup.torrentid = xbt_files_users.fid\n                                 WHERE xbt_files_users.fid =" . sqlesc($arr['id'])) or sqlerr(__FILE__, __LINE__);
        @unlink("{$INSTALLER09['torrent_dir']}/{$arr['id']}.torrent");
        write_log("Torrent " . (int) $arr['id'] . " (" . htmlsafechars($arr['name']) . ") was deleted by system (older than {$days} days and no seeders)");
    }
    if ($queries > 0) {
        write_log("Delete Old Torrents XBT Clean -------------------- Delete Old XBT Torrents cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #4
0
 public function view_forgetPost()
 {
     $act = A('Login');
     $sendEmail = A('Public')->act_sendEmail("checkPassword");
     if ($sendEmail) {
         $email = isset($_REQUEST['email']) ? trim($_REQUEST['email']) : '';
         $mailType = explode("@", $email);
         $emailAddrs = C('EMAILADDRESS');
         //替换特殊邮箱edu
         $splitArray = explode(".", $mailType[1]);
         if (in_array("edu", $splitArray)) {
             $mailType[1] = str_replace($splitArray[0], "**", $mailType[1]);
             $emailAddrs[$mailType[1]] = str_replace("**", $splitArray[0], $emailAddrs[$mailType[1]]);
         }
         if (!empty($emailAddrs[$mailType[1]])) {
             $this->smarty->assign('emailAddress', $emailAddrs[$mailType[1]]);
             $this->smarty->assign('email', $email);
         } else {
             write_log(WEB_PATH . "log/noCachedEmail.log", $mailType[1]);
             $this->smarty->assign('emailAddress', "unknown");
             $this->smarty->assign('email', $email);
         }
         $this->smarty->assign('flag', "sendEmailOk");
     } else {
         $this->smarty->assign('flag', "checkEmailNo");
     }
     $this->smarty->display('forgotPassword.html');
 }
예제 #5
0
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    sql_query("UPDATE `freeslots` SET `addedup` = 0 WHERE `addedup` != 0 AND `addedup` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `freeslots` SET `addedfree` = 0 WHERE `addedfree` != 0 AND `addedfree` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("DELETE FROM `freeslots` WHERE `addedup` = 0 AND `addedfree` = 0") or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `free_switch` = 0 WHERE `free_switch` > 1 AND `free_switch` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `torrents` SET `free` = 0 WHERE `free` > 1 AND `free` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `downloadpos` = 1 WHERE `downloadpos` > 1 AND `downloadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `uploadpos` = 1 WHERE `uploadpos` > 1 AND `uploadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `chatpost` = 1 WHERE `chatpost` > 1 AND `chatpost` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `avatarpos` = 1 WHERE `avatarpos` > 1 AND `avatarpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `immunity` = 0 WHERE `immunity` > 1 AND `immunity` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `warned` = 0 WHERE `warned` > 1 AND `warned` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `pirate` = 0 WHERE `pirate` > 1 AND `pirate` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `king` = 0 WHERE `king` > 1 AND `king` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    if ($queries > 0) {
        write_log("User Clean -------------------- User Clean Complete using {$queries} queries--------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #6
0
function padd_group($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'warning');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($groupname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $change_status = $cfg->ITEM_ADD_STATUS;
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups`\n\t\t\t\t\t\t(`dmn_id`, `ugroup`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $groupname, $change_status));
                send_request();
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add group (protected areas): {$groupname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('Group already exists!'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid group name!'), 'error');
            return;
        }
    } else {
        return;
    }
}
예제 #7
0
function add_ip(&$tpl, &$sql)
{
    global $ip_number_1, $ip_number_2, $ip_number_3, $ip_number_4;
    global $domain, $alias;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_ip') {
        if (check_user_data()) {
            //add ip
            global $ip_number_1, $ip_number_2, $ip_number_3, $ip_number_4;
            $ip_number = trim($ip_number_1) . '.' . trim($ip_number_2) . '.' . trim($ip_number_3) . '.' . trim($ip_number_4);
            $query = <<<SQL_QUERY
                insert into server_ips
                    (ip_number,ip_domain,ip_alias)
                values
                    (?,?,?)
SQL_QUERY;
            $rs = exec_query($sql, $query, array($ip_number, htmlspecialchars($domain, ENT_QUOTES, "UTF-8"), htmlspecialchars($alias, ENT_QUOTES, "UTF-8")));
            set_page_message(tr('New IP was added!'));
            $user_logged = $_SESSION['user_logged'];
            write_log("{$user_logged}: add new IP4 address: {$ip_number}");
        }
        $tpl->assign(array('VALUE_IP1' => $_POST['ip_number_1'], 'VALUE_IP2' => $_POST['ip_number_2'], 'VALUE_IP3' => $_POST['ip_number_3'], 'VALUE_IP4' => $_POST['ip_number_4'], 'VALUE_DOMAIN' => $_POST['domain'], 'VALUE_ALIAS' => $_POST['alias']));
    } else {
        $tpl->assign(array('VALUE_IP1' => '', 'VALUE_IP2' => '', 'VALUE_IP3' => '', 'VALUE_IP4' => '', 'VALUE_DOMAIN' => '', 'VALUE_ALIAS' => ''));
    }
}
예제 #8
0
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                			    |
|--------------------------------------------------------------------------|
|   Licence Info: GPL			                                    |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V5					    |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless, Autotron, whocares, Swizzles.					    |
|--------------------------------------------------------------------------|
 _   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //=== Clean silver
    $res = sql_query("SELECT id, silver FROM torrents WHERE silver > 1 AND silver < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    $Silver_buffer = array();
    if (mysqli_num_rows($res) > 0) {
        while ($arr = mysqli_fetch_assoc($res)) {
            $Silver_buffer[] = '(' . $arr['id'] . ', \'0\')';
            $mc1->begin_transaction('torrent_details_' . $arr['id']);
            $mc1->update_row(false, array('silver' => 0));
            $mc1->commit_transaction($INSTALLER09['expires']['torrent_details']);
        }
        $count = count($Silver_buffer);
        if ($count > 0) {
            sql_query("INSERT INTO torrents (id, silver) VALUES " . implode(', ', $Silver_buffer) . " ON DUPLICATE key UPDATE silver=values(silver)") or sqlerr(__FILE__, __LINE__);
            write_log("Cleanup - Removed Silver from " . $count . " torrents");
        }
        unset($Silver_buffer, $count);
    }
    //==End
    if ($queries > 0) {
        write_log("Free clean-------------------- Silver Torrents cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #9
0
function scrape($url, $infohash = '')
{
    global $TABLE_PREFIX, $BASEDIR;
    if (isset($url)) {
        $url_c = parse_url($url);
        if (!isset($url_c["port"]) || empty($url_c["port"])) {
            $url_c["port"] = 80;
        }
        require_once $BASEDIR . "/phpscraper/" . $url_c["scheme"] . "tscraper.php";
        try {
            $timeout = 5;
            if ($url_c["scheme"] == "udp") {
                $scraper = new udptscraper($timeout);
            } else {
                $scraper = new httptscraper($timeout);
            }
            $ret = $scraper->scrape($url_c["scheme"] . "://" . $url_c["host"] . ":" . $url_c["port"] . ($url_c["scheme"] == "udp" ? "" : "/announce"), array($infohash));
            do_sqlquery("UPDATE `{$TABLE_PREFIX}files` SET `lastupdate`=NOW(), `lastsuccess`=NOW(), `seeds`=" . $ret[$infohash]["seeders"] . ", `leechers`=" . $ret[$infohash]["leechers"] . ", `finished`=" . $ret[$infohash]["completed"] . " WHERE `announce_url` = '" . $url . "'" . ($infohash == "" ? "" : " AND `info_hash`='" . $infohash . "'"), true);
            if (mysqli_affected_rows($GLOBALS["___mysqli_ston"]) == 1) {
                write_log('SUCCESS update external torrent from ' . $url . ' tracker (infohash: ' . $infohash . ')', '');
            }
        } catch (ScraperException $e) {
            write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (" . $e->getMessage() . "))", "");
        }
        return;
    }
    return;
}
예제 #10
0
/**
 * Adds Htaccess group.
 *
 * @param int $domainId Domain unique identifier
 * @return
 */
function client_addHtaccessGroup($domainId)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'error');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($query, array($groupname, $domainId));
            if ($rs->rowCount() == 0) {
                $change_status = 'toadd';
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups` (\n\t\t\t\t\t    `dmn_id`, `ugroup`, `status`\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t    ?, ?, ?\n\t\t\t\t\t)\n\t\t\t\t";
                exec_query($query, array($domainId, $groupname, $change_status));
                send_request();
                set_page_message(tr('Htaccess group successfully scheduled for addition.'), 'success');
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: added htaccess group: {$groupname}", E_USER_NOTICE);
                redirectTo('protected_user_manage.php');
            } else {
                set_page_message(tr('This htaccess group already exists.'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid htaccess group name.'), 'error');
            return;
        }
    } else {
        return;
    }
}
예제 #11
0
 private function log_result($text, $res)
 {
     if ($res != true) {
         write_log('errors', "{$text}:");
         write_log('errors', $res);
     }
 }
예제 #12
0
function get_images($url, $image_dir, $image_name)
{
    //    echo $image_name . '<br/>';
    $savefile = $image_dir . "/" . $image_name;
    try {
        $ch = curl_init($url);
        $fp = fopen($savefile, "wb");
        if (!$fp) {
            write_log('Не удалось открыть файл для сохранения изображения ' . $url);
        }
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
        $filesize = filesize($savefile);
        if ($filesize > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    } catch (Exception $exc) {
        //        echo $exc->getTraceAsString();
        return FALSE;
    }
}
예제 #13
0
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                			    |
|--------------------------------------------------------------------------|
|   Licence Info: GPL			                                    |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V5					    |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless, Autotron, whocares, Swizzles.					    |
|--------------------------------------------------------------------------|
 _   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    require_once INCL_DIR . 'function_happyhour.php';
    //==Putyns HappyHour
    $f = $INSTALLER09['happyhour'];
    $happy = unserialize(file_get_contents($f));
    $happyHour = strtotime($happy["time"]);
    $curDate = TIME_NOW;
    $happyEnd = $happyHour + 3600;
    if ($happy["status"] == 0 && $INSTALLER09['happy_hour'] == true) {
        write_log("Happy hour was @ " . get_date($happyHour, 'LONG', 1, 0) . " and Catid " . $happy["catid"] . " ");
        happyFile("set");
    } elseif ($curDate > $happyEnd && $happy["status"] == 1) {
        happyFile("reset");
    }
    //== End
    if ($queries > 0) {
        write_log("Happyhour Clean -------------------- Happyhour cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #14
0
/**
 * Update autoresponder of the given mail account
 *
 * @param int $mailAccountId Mail account id
 * @param string $autoresponderMessage Auto-responder message
 * @return void
 */
function client_updateAutoresponder($mailAccountId, $autoresponderMessage)
{
    $autoresponderMessage = clean_input($autoresponderMessage);
    if ($autoresponderMessage == '') {
        set_page_message(tr('Auto-responder message cannot be empty.'), 'error');
        redirectTo("mail_autoresponder_enable.php?mail_account_id={$mailAccountId}");
    } else {
        $db = iMSCP_Database::getInstance();
        try {
            $db->beginTransaction();
            $query = "SELECT `mail_addr` FROM `mail_users` WHERE `mail_id` = ?";
            $stmt = exec_query($query, $mailAccountId);
            $query = "UPDATE `mail_users` SET `status` = ?, `mail_auto_respond_text` = ? WHERE `mail_id` = ?";
            exec_query($query, array('tochange', $autoresponderMessage, $mailAccountId));
            // Purge autoreplies log entries
            delete_autoreplies_log_entries();
            $db->commit();
            // Ask iMSCP daemon to trigger engine dispatcher
            send_request();
            write_log(sprintf("%s: Updated auto-responder for the '%s' mail account", $_SESSION['user_logged'], $stmt->fields['mail_addr']), E_USER_NOTICE);
            set_page_message(tr('Auto-responder successfully scheduled for update.'), 'success');
        } catch (iMSCP_Exception_Database $e) {
            $db->rollBack();
            throw $e;
        }
    }
}
예제 #15
0
function gen_page_dynamic_data(&$tpl, &$sql, $mail_id)
{
    global $cfg;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'enable_arsp') {
        if ($_POST['arsp_message'] === '') {
            $tpl->assign('ARSP_MESSAGE', '');
            set_page_message(tr('Please type your mail autorespond message!'));
            return;
        }
        $arsp_message = $_POST['arsp_message'];
        $item_change_status = $cfg['ITEM_CHANGE_STATUS'];
        check_for_lock_file();
        $query = <<<SQL_QUERY
            update
                mail_users
            set
                status = ?,
                mail_auto_respond = ?
            where
                mail_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($item_change_status, $arsp_message, $mail_id));
        send_request();
        write_log($_SESSION['user_logged'] . " : add mail autorsponder");
        set_page_message(tr('Mail account scheduler for modification!'));
        header("Location: email_accounts.php");
        exit(0);
    } else {
        $tpl->assign('ARSP_MESSAGE', '');
    }
}
예제 #16
0
function my_query($str_query, $conex)
{
    global $conf_db_type, $conf_is_prod;
    $queries2log = array('UPD', 'DEL', 'DRO', 'ALT', 'TRU');
    if (in_array(strtoupper(substr($str_query, 0, 3)), $queries2log) && !$conf_is_prod) {
        @write_log('db_trans', $str_query);
    }
    switch ($conf_db_type) {
        case 'mysql':
            $res = @mysql_query($str_query, $conex);
            if ($res) {
                return $res;
            } else {
                write_log('db_error', mysql_error() . " ----> " . $str_query);
            }
            break;
        case 'mssql':
            $res = @mssql_query($str_query, $conex);
            if ($res) {
                return $res;
            } else {
                write_log('db_error', mssql_get_last_message() . " ----> " . $str_query);
            }
            break;
    }
}
예제 #17
0
/**
 * Schedule backup restoration.
 *
 * @param int $userId Customer unique identifier
 * @return void
 */
function scheduleBackupRestoration($userId)
{
    exec_query("UPDATE `domain` SET `domain_status` = ? WHERE `domain_admin_id` = ?", array('torestore', $userId));
    send_request();
    write_log($_SESSION['user_logged'] . ": scheduled backup restoration.", E_USER_NOTICE);
    set_page_message(tr('Backup has been successfully scheduled for restoration.'), 'success');
}
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                                |
|--------------------------------------------------------------------------|
|   Licence Info: GPL                                                |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V4                        |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless,putyn.                        |
|--------------------------------------------------------------------------|
_   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    $deadtime = TIME_NOW - $INSTALLER09['signup_timeout'];
    $res = sql_query("SELECT id, username, added, downloaded, uploaded, last_access, class, donor, warned, enabled, status FROM users WHERE status = 'pending' AND added < {$deadtime} AND last_login < {$deadtime} AND last_access < {$deadtime} ORDER BY username DESC");
    if (mysqli_num_rows($res) != 0) {
        while ($arr = mysqli_fetch_assoc($res)) {
            $userid = $arr['id'];
            $res_del = sql_query("DELETE FROM users WHERE id=" . sqlesc($userid)) or sqlerr(__FILE__, __LINE__);
            $mc1->delete_value('MyUser_' . $userid);
            $mc1->delete_value('user' . $userid);
            write_log("User: {$arr['username']} Was deleted by Expired Signup clean");
        }
    }
    if ($queries > 0) {
        write_log("Expired Signup clean-------------------- Expired Signup cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #19
0
 public function view_registerLocation()
 {
     $flag = $_REQUEST['flag'];
     $email = trim($_REQUEST['email']);
     if ($flag == "resend") {
         $sendStatus = A('Public')->act_sendEmail("checkRegister");
         if ($sendStatus) {
             $flag = 'resendOk';
         } else {
             $flag = 'resendError';
         }
     }
     $mailType = explode("@", $email);
     $emailAddrs = C('EMAILADDRESS');
     //替换特殊邮箱edu
     $splitArray = explode(".", $mailType[1]);
     if (in_array("edu", $splitArray)) {
         $mailType[1] = str_replace($splitArray[0], "**", $mailType[1]);
         $emailAddrs[$mailType[1]] = str_replace("**", $splitArray[0], $emailAddrs[$mailType[1]]);
     }
     if (!empty($emailAddrs[$mailType[1]])) {
         $this->smarty->assign('emailAddress', $emailAddrs[$mailType[1]]);
     } else {
         write_log(WEB_PATH . "log/noCachedEmail.log", $mailType[1]);
         $this->smarty->assign('emailAddress', "unknown");
     }
     $this->smarty->assign("flag", $flag);
     $this->smarty->assign("email", $email);
     $this->smarty->display('registerLocation.html');
 }
예제 #20
0
/**
 * Updates htaccess user.
 *
 * @param int $dmn_id Domain unique identifier
 * @param int $uuser_id Htaccess user unique identifier
 * @return
 */
function client_updateHtaccessUser(&$dmn_id, &$uuser_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify_user') {
        // we have to add the user
        if (isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if (!checkPasswordSyntax($_POST['pass'])) {
                return;
            }
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr("Passwords do not match."), 'error');
                return;
            }
            $nadmin_password = cryptPasswordWithSalt($_POST['pass'], generateRandomSalt(true));
            $change_status = 'tochange';
            $query = "\n\t\t\t\tUPDATE\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tSET\n\t\t\t\t\t`upass` = ?, `status` = ?\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
            exec_query($query, array($nadmin_password, $change_status, $dmn_id, $uuser_id));
            send_request();
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`uname`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
            $rs = exec_query($query, array($dmn_id, $uuser_id));
            $uname = $rs->fields['uname'];
            $admin_login = $_SESSION['user_logged'];
            write_log("{$admin_login}: updated htaccess user ID: {$uname}", E_USER_NOTICE);
            redirectTo('protected_user_manage.php');
        }
    } else {
        return;
    }
}
예제 #21
0
파일: iusers.php 프로젝트: klldll/tbdev
function iUsers($iname, $ipass, $imail)
{
    global $admin_file, $CURUSER;
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        list($iclass) = mysql_fetch_row(sql_query('SELECT class FROM users WHERE username = '******'Администратор ' . $CURUSER['username'] . ' пробовал изменить учетные данные пользователя ' . $iname . ' классом выше!', 'red', 'error');
        } else {
            $updateset = array();
            if (!empty($ipass)) {
                $secret = mksecret();
                $hash = md5($secret . $ipass . $secret);
                $updateset[] = "secret = " . sqlesc($secret);
                $updateset[] = "passhash = " . sqlesc($hash);
            }
            if (!empty($imail) && validemail($imail)) {
                $updateset[] = "email = " . sqlesc($imail);
            }
            if (count($updateset)) {
                $res = sql_query("UPDATE users SET " . implode(", ", $updateset) . " WHERE username = "******"Ошибка", "Смена пароля завершилась неудачей! Возможно указано несуществующее имя пользователя.", "error");
            } else {
                stdmsg("Изменения пользователя прошло успешно", "Имя пользователя: " . $iname . (!empty($hash) ? "<br />Новый пароль: " . $ipass : "") . (!empty($imail) ? "<br />Новая почта: " . $imail : ""));
            }
        }
    } else {
        echo "<form method=\"post\" action=\"" . $admin_file . ".php?op=iUsers\">" . "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">" . "<tr><td class=\"colhead\" colspan=\"2\">Смена пароля</td></tr>" . "<tr>" . "<td><b>Пользователь</b></td>" . "<td><input name=\"iname\" type=\"text\"></td>" . "</tr>" . "<tr>" . "<td><b>Новый пароль</b></td>" . "<td><input name=\"ipass\" type=\"password\"></td>" . "</tr>" . "<tr>" . "<td><b>Новая почта</b></td>" . "<td><input name=\"imail\" type=\"text\"></td>" . "</tr>" . "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"isub\" value=\"Сделать\"></td></tr>" . "</table>" . "<input type=\"hidden\" name=\"op\" value=\"iUsers\" />" . "</form>";
    }
}
예제 #22
0
 private function read_from_db()
 {
     if (!is_resource($this->db_conn)) {
         if (!$this->init_db()) {
             return false;
         }
     }
     // Get query for user and policy config
     $query = "SELECT users.id as user_id, users.priority, users.email, users.fullname, policy.*\n            FROM users, policy\n            WHERE users.policy_id = policy.id \n            AND users.email = ? ";
     $res = $this->db_conn->query($query, $this->user_email);
     // Error check
     if ($error = $this->db_conn->is_error()) {
         $this->rc->amacube->errors[] = 'db_query_error';
         write_log('errors', 'AMACUBE: Database query error: ' . $error);
     }
     // Get record for user and map policy config
     if ($res && ($res_array = $this->db_conn->fetch_assoc($res))) {
         foreach ($this->policy_setting as $key => $value) {
             $this->policy_setting[$key] = $this->map_from_db($key, $res_array[$key]);
         }
         $this->user_pk = $res_array['user_id'];
         $this->priority = $res_array['priority'];
         $this->fullname = $res_array['fullname'];
         $this->policy_pk = $res_array['id'];
         $this->policy_name = $res_array['policy_name'];
         return true;
     }
     return false;
 }
예제 #23
0
function docleanup($data)
{
    global $INSTALLER09, $queries;
    set_time_limit(1200);
    ignore_user_abort(1);
    $sql = sql_query("SHOW TABLE STATUS FROM {$INSTALLER09['mysql_db']}");
    $oht = '';
    while ($row = mysqli_fetch_assoc($sql)) {
        if ($row['Data_free'] > 100) {
            $oht .= $row['Data_free'] . ',';
        }
    }
    $oht = rtrim($oht, ',');
    if ($oht != '') {
        $sql = sql_query("OPTIMIZE TABLE {$oht}");
    }
    if ($queries > 0) {
        write_log("Auto-optimizedb--------------------Auto Optimization Complete using {$queries} queries --------------------");
    }
    if ($oht != '') {
        $data['clean_desc'] = "MySQLCleanup optimized {$oht} table(s)";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //== Delete old backup's
    $days = 3;
    $res = sql_query("SELECT id, name FROM dbbackup WHERE added < " . sqlesc(TIME_NOW - $days * 86400)) or sqlerr(__FILE__, __LINE__);
    if (mysqli_num_rows($res) > 0) {
        $ids = array();
        while ($arr = mysqli_fetch_assoc($res)) {
            $ids[] = (int) $arr['id'];
            $filename = $INSTALLER09['backup_dir'] . '/' . $arr['name'];
            if (is_file($filename)) {
                unlink($filename);
            }
        }
        sql_query('DELETE FROM dbbackup WHERE id IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__);
    }
    //== end
    if ($queries > 0) {
        write_log("Backup Clean -------------------- Backup Clean Complete using {$queries} queries--------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #25
0
/**
 * Register custom fields using Advanced Custom Fields (ACF). For example
 * 'Illustrator' field on posts.
 */
function my_acf_add_local_field_groups()
{
    write_log("my_acf_add_local_field_groups() called.");
    if (function_exists("register_field_group")) {
        register_field_group(array('id' => 'acf_skin-deep-article', 'title' => 'Skin Deep Article', 'fields' => array(array('key' => 'field_5833fcdadee6a', 'label' => 'Author', 'name' => 'author', 'type' => 'text', 'instructions' => 'The person who wrote the piece', 'required' => 1, 'default_value' => '', 'placeholder' => '', 'prepend' => ' ', 'append' => '', 'formatting' => 'none', 'maxlength' => ''), array('key' => 'field_5833fd0edee6b', 'label' => 'Illustrator', 'name' => 'illustrator', 'type' => 'text', 'instructions' => 'The person who created the illustrations', 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'formatting' => 'none', 'maxlength' => '')), 'location' => array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'post', 'order_no' => 0, 'group_no' => 0))), 'options' => array('position' => 'acf_after_title', 'layout' => 'no_box', 'hide_on_screen' => array(0 => 'author')), 'menu_order' => 0));
    }
}
예제 #26
0
function docleanup($data)
{
    global $INSTALLER09, $queries, $bdir;
    set_time_limit(0);
    ignore_user_abort(1);
    $mysql_host = $INSTALLER09['mysql_host'];
    $mysql_user = $INSTALLER09['mysql_user'];
    $mysql_pass = $INSTALLER09['mysql_pass'];
    $mysql_db = $INSTALLER09['mysql_db'];
    $bdir = $_SERVER["DOCUMENT_ROOT"] . "/include/backup";
    $c1 = "mysqldump -h " . $mysql_host . " -u " . $mysql_user . " -p" . $mysql_pass . " " . $mysql_db . " -d > " . $bdir . "/db_structure.sql";
    $c = "mysqldump -h " . $mysql_host . " -u " . $mysql_user . " -p" . $mysql_pass . " " . $mysql_db . " " . tables("peers|messages|sitelog") . " | bzip2 -cq9 > " . $bdir . "/db_" . date("m_d_y", TIME_NOW) . ".sql.bz2";
    system($c1);
    system($c);
    $files = glob($bdir . "/db_*");
    foreach ($files as $file) {
        if (TIME_NOW - filemtime($file) > 3 * 86400) {
            unlink($file);
        }
    }
    $ext = "db_" . date("m_d_y", TIME_NOW) . ".sql.bz2";
    sql_query("INSERT INTO dbbackup (name, added, userid) VALUES (" . sqlesc($ext) . ", " . TIME_NOW . ", " . $INSTALLER09['site']['owner'] . ")") or sqlerr(__FILE__, __LINE__);
    if ($queries > 0) {
        write_log("Auto-dbbackup----------------------Auto Back Up Complete using {$queries} queries---------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #27
0
/**
 * Kill user session.
 *
 * @return void
 */
function kill_session()
{
    if (isset($_GET['kill']) && $_GET['kill'] !== '' && isset($_GET['username'])) {
        $username = clean_input($_GET['username']);
        $sessionId = clean_input($_GET['kill']);
        // Getting current session id
        $currentSessionId = session_id();
        // Closing current session
        session_write_close();
        // Switch to session to handle
        session_id($sessionId);
        session_start();
        if (isset($_GET['logout_only'])) {
            iMSCP_Authentication::getInstance()->unsetIdentity();
            session_write_close();
            $message = tr('User successfully disconnected.');
        } else {
            iMSCP_Authentication::getInstance()->unsetIdentity();
            session_destroy();
            $message = tr('User session successfully destroyed.');
        }
        // Restore session
        session_id($currentSessionId);
        session_start();
        set_page_message($message, 'success');
        write_log($_SESSION['user_logged'] . ": has disconnected {$username} or destroyed its session", E_USER_NOTICE);
    } elseif (isset($_GET['own'])) {
        set_page_message(tr("You are not allowed to act on your own session."), 'warning');
    }
}
예제 #28
0
function import_voter_guide()
{
    $voter_data = json_decode(file_get_contents('php://input'), TRUE);
    write_log($voter_data);
    if (!$voter_data) {
        return false;
    }
    $args = array('post_type' => 'voter-guide', 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'), 'posts_per_page' => 1);
    $item = get_posts($args);
    $voter_id = '';
    if ($item) {
        $voter_id = $item[0]->ID;
    }
    $voter_post = array('ID' => $voter_id, 'post_title' => $voter_data["post_title"], 'post_content' => $voter_data["post_content"], 'post_type' => 'voter-guide', 'post_status' => $item ? $item[0]->post_status : 'draft');
    //  $voter_id = wp_insert_post( $voter_post );
    //
    ////  if ( $voter_id ) {
    ////    update_post_meta( $voter_id, 'voter_id', $voter_data->id );
    ////
    ////    update_post_meta( $voter_id, 'json', addslashes( file_get_contents( 'php://input' ) ) );
    ////
    ////    wp_set_object_terms( $voter_id, $developer_data->tags, 'post_tag' );
    ////  }
    //
    write_log($voter_post);
}
예제 #29
0
/**
 *   https://github.com/Bigjoos/
 *   Licence Info: GPL
 *   Copyright (C) 2010 U-232 v.3
 *   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *   Project Leaders: Mindless, putyn.
 *
 */
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //=== delete from now viewing after 15 minutes
    sql_query('DELETE FROM now_viewing WHERE added < ' . (TIME_NOW - 900));
    //=== fix any messed up counts
    $forums = sql_query('SELECT f.id, count( DISTINCT t.id ) AS topics, count(p.id) AS posts
                          FROM forums f
                          LEFT JOIN topics t ON f.id = t.forum_id
                          LEFT JOIN posts p ON t.id = p.topic_id
                          GROUP BY f.id');
    while ($forum = mysqli_fetch_assoc($forums)) {
        $forum['posts'] = $forum['topics'] > 0 ? $forum['posts'] : 0;
        sql_query('update forums set post_count = ' . sqlesc($forum['posts']) . ', topic_count = ' . sqlesc($forum['topics']) . ' where id=' . sqlesc($forum['id']));
    }
    if ($queries > 0) {
        write_log("Forum clean-------------------- Forum cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
예제 #30
0
파일: cmd_learn.php 프로젝트: ehmedov/www
function do_salearn($uids, $spam)
{
    $rcmail = rcmail::get_instance();
    $temp_dir = realpath($rcmail->config->get('temp_dir'));
    if ($spam) {
        $command = $rcmail->config->get('markasjunk2_spam_cmd');
    } else {
        $command = $rcmail->config->get('markasjunk2_ham_cmd');
    }
    if (!$command) {
        return;
    }
    $command = str_replace('%u', $_SESSION['username'], $command);
    if (strpos($_SESSION['username'], '@') !== false) {
        $parts = explode("@", $_SESSION['username'], 2);
        $command = str_replace(array('%l', '%d'), array($parts[0], $parts[1]), $command);
    }
    foreach (explode(",", $uids) as $uid) {
        $tmpfname = tempnam($temp_dir, 'rcmSALearn');
        file_put_contents($tmpfname, $rcmail->imap->get_raw_body($uid));
        $tmp_command = str_replace('%f', $tmpfname, $command);
        exec($tmp_command, $output);
        if ($rcmail->config->get('markasjunk2_debug')) {
            write_log('markasjunk2', $tmp_command);
            write_log('markasjunk2', $output);
        }
        unlink($tmpfname);
        $output = '';
    }
}