Exemple #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);
    }
}
Exemple #2
1
 public function processQuery($sql, $type = NULL)
 {
     $result = mysqli_query($this->db, $sql);
     $this->checkForError();
     $data = array();
     if ($result instanceof mysqli_result) {
         $resultType = MYSQLI_NUM;
         if ($type == 'assoc') {
             $resultType = MYSQLI_ASSOC;
         }
         while ($row = mysqli_fetch_array($result, $resultType)) {
             if (mysqli_affected_rows($this->db) > 1) {
                 array_push($data, $row);
             } else {
                 $data = $row;
             }
         }
         mysqli_free_result($result);
     } else {
         if ($result) {
             $data = mysqli_insert_id($this->db);
         }
     }
     return $data;
 }
function mysql_compat_affected_rows($link = NULL)
{
    if (!isset($link)) {
        $link = $GLOBALS['mysql_compat_last_link'];
    }
    return mysqli_affected_rows($link);
}
Exemple #4
0
 public function affectedRow()
 {
     if ($this->con) {
         return mysqli_affected_rows($this->con);
     }
     return 0;
 }
 /**
  * Return the number of rows affected by a query.
  *
  * @return integer
  */
 public static function affectedRows()
 {
     if (is_null(self::$conn_id)) {
         self::init();
     }
     return mysqli_affected_rows(self::$conn_id);
 }
Exemple #6
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);
    }
}
Exemple #7
0
 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO category VALUES (?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $name = $item->getName();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sss', $code, $name, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
Exemple #8
0
function insertDepartment($name, $manager_id)
{
    checkConnectivity2();
    $query = sprintf("insert into department(name,manager_id\t) values('%s',%s)", $name, $manager_id);
    mysqli_query($GLOBALS['connection_link'], $query);
    return mysqli_affected_rows($GLOBALS['connection_link']) > 0;
}
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);
    }
}
 /**
  * Native function for executing mysql query
  */
 private function executeQuery($q)
 {
     if (empty($q)) {
         throw new DBException('Empty query submitted!');
     }
     if (DB_DEBUG) {
         $start = microtime(true);
     }
     $this->_res_resource = mysqli_query($this->_con, $q);
     if (DB_DEBUG) {
         $end = microtime(true);
         $this->_executedQueries[] = array('q' => $q, 'time' => $end - $start);
     }
     if (!$this->_res_resource) {
         throw new DBException(mysqli_error($this->_con));
     }
     if (preg_match('/^SELECT.+/', strtoupper($q))) {
         $this->_res_num = @mysqli_num_rows($this->_res_resource);
     } elseif (preg_match('/^INSERT.+/', strtoupper($q))) {
         $this->_last_inserted_id = mysqli_insert_id($this->_con);
         $this->_affected_rows = @mysqli_affected_rows($this->_con);
     } else {
         $this->_affected_rows = @mysqli_affected_rows($this->_con);
     }
     return true;
 }
 public function ejecutar($sql, $conexion)
 {
     $n = 0;
     $resultado = mysqli_query($conexion, $sql);
     $n = mysqli_affected_rows($conexion);
     return $n;
 }
Exemple #12
0
 public function insertItems(Items $items)
 {
     $con = self::openConnection();
     $affected = 0;
     mysqli_begin_transaction($con);
     $stm = mysqli_stmt_init($con);
     $sql = "INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
     mysqli_stmt_prepare($stm, $sql);
     foreach ($items->getItems() as $item) {
         $code = $item->getCode();
         $articul = $item->getArticul();
         $name = $item->getName();
         $bmuID = $item->getBasicMeasurementUnit() == null ? null : $item->getBasicMeasurementUnit()->getId();
         $price = $item->getPrice();
         $curID = $item->getCurrency() == null ? null : $item->getCurrency()->getId();
         $muID = $item->getMeasurementUnit() == null ? null : $item->getMeasurementUnit()->getId();
         $parent = $item->getParent() == null ? null : $item->getParent()->getCode();
         mysqli_stmt_bind_param($stm, 'sssdddds', $code, $articul, $name, $bmuID, $price, $curID, $muID, $parent);
         mysqli_stmt_execute($stm);
         if (mysqli_affected_rows($con) == 1) {
             $affected++;
         }
     }
     if ($affected > 0) {
         mysqli_commit($con);
     } else {
         mysqli_rollback($con);
     }
     return $affected;
 }
Exemple #13
0
 public function query($sql)
 {
     $pos = stripos($sql, 'select');
     if (is_numeric($pos)) {
         //是select 语句
         $rs = mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         if ($rs === false) {
             return mysqli_affected_rows($this->conn);
         }
         //什么时候返回是false呢...哦子查询是select
         $columns = array();
         while ($property = @mysqli_fetch_field($rs)) {
             $columns[] = $property->name;
         }
         $arr = array();
         while ($result = @mysqli_fetch_row($rs)) {
             $arr[] = array_combine($columns, $result);
         }
         return $arr;
     } else {
         mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         return mysqli_affected_rows($this->conn);
     }
 }
/**
|--------------------------------------------------------------------------|
|   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);
    }
}
Exemple #15
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;
}
/**
* добавление комментария
**/
function add_comment()
{
    global $connection;
    $comment_author = trim(mysqli_real_escape_string($connection, $_POST['commentAuthor']));
    $comment_text = trim(mysqli_real_escape_string($connection, $_POST['commentText']));
    $parent = (int) $_POST['parent'];
    $comment_product = (int) $_POST['productId'];
    $is_admin = isset($_SESSION['auth']['is_admin']) ? $_SESSION['auth']['is_admin'] : 0;
    // если нет ID товара
    if (!$comment_product) {
        $res = array('answer' => 'Неизвестный продукт!');
        return json_encode($res);
    }
    // если не заполнены поля
    if (empty($comment_author) or empty($comment_text)) {
        $res = array('answer' => 'Все поля обязательны к заполнению');
        return json_encode($res);
    }
    $query = "INSERT INTO comments (comment_author, comment_text, parent, comment_product, is_admin)\n\t\t\t\tVALUES ('{$comment_author}', '{$comment_text}', {$parent}, {$comment_product}, {$is_admin})";
    $res = mysqli_query($connection, $query);
    if (mysqli_affected_rows($connection) > 0) {
        $comment_id = mysqli_insert_id($connection);
        $comment_html = get_last_comment($comment_id);
        return $comment_html;
    } else {
        $res = array('answer' => 'Ошибка добавления комментария');
        return json_encode($res);
    }
}
/**
|--------------------------------------------------------------------------|
|   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);
    }
}
Exemple #18
0
function checkInstall($lang)
{
    global $install_message;
    //1. check if config file exist
    if (!file_exists('db.tematres.php')) {
        return message("<span class=\"error\">{$install_message['201']}</span>");
    } else {
        message("<span class=\"success\">{$install_message['202']}</span>");
        include 'db.tematres.php';
    }
    //2. check connection to server
    if (!($linkDB = @mysqli_connect($DBCFG["Server"], $DBCFG["DBLogin"], $DBCFG["DBPass"]))) {
        return message('<span class="error">' . sprintf($install_message[203], $DBCFG[Server], $DBCFG[DBLogin]) . '</span>');
    } else {
        message('<span class="success">' . sprintf($install_message[204], $DBCFG[Server]) . '</span>');
    }
    //3. check connection to database
    if (!mysqli_select_db($linkDB, $DBCFG["DBName"])) {
        return message('<span class="error">' . sprintf($install_message[205], $DBCFG[DBName], $DBCFG[Server]) . '</span>');
    } else {
        message('<span class="success">' . sprintf($install_message[206], $DBCFG[DBName], $DBCFG[Server]) . '</span>');
    }
    //4. check tables
    $sql = mysqli_query($linkDB, "SHOW TABLES from {$DBCFG['DBName']} where Tables_in_{$DBCFG['DBName']} in ('{$DBCFG['DBprefix']}config','{$DBCFG['DBprefix']}indice','{$DBCFG['DBprefix']}notas','{$DBCFG['DBprefix']}tabla_rel','{$DBCFG['DBprefix']}tema','{$DBCFG['DBprefix']}usuario','{$DBCFG['DBprefix']}values')");
    if (mysqli_affected_rows($linkDB) == '7') {
        return message("<span class=\"error\">{$install_message['301']}</span>");
    } else {
        //Final step: dump or form
        if (isset($_POST['send'])) {
            $sqlInstall = SQLtematres($DBCFG, $linkDB);
        } else {
            echo HTMLformInstall($lang);
        }
    }
}
 function mysql_affected_rows(&$c = null)
 {
     if (($c = mysql_global_resource($c, 1 - func_num_args())) == null) {
         return;
     }
     return mysqli_affected_rows($c);
 }
Exemple #20
0
 function setNuevoUsuario($nombreCompleto, $nombre, $correo, $contrasena, $confirmar)
 {
     require_once 'dbm.php';
     if ($nombreCompleto == "" or $nombre == "" or $correo == "" or $contrasena == "" or $confirmar == "") {
         return false;
     }
     if ($contrasena != $confirmar) {
         return false;
     }
     $datab = new DataBase();
     $datab->open();
     $connect = $datab->get_connect();
     $query = "INSERT INTO usuario (nombre_completo, nombre, correo, contrasena, valoracion, rol) \r\n                        SELECT * FROM ( SELECT '" . $nombreCompleto . "','" . $nombre . "','" . $correo . "','" . $contrasena . "',0,'autor') AS tmp\r\n                        WHERE NOT EXISTS (\r\n                        SELECT nombre FROM usuario WHERE nombre = '" . $nombre . "') LIMIT 1;";
     if (mysqli_query($connect, $query) == false) {
         mysqli_close($connect);
         return false;
     }
     $col_afectadas = mysqli_affected_rows($connect);
     if ($col_afectadas == 0) {
         mysqli_close($connect);
         $this->nombre_completo = $nombreCompleto;
         $this->nombre = $nombre;
         $this->correo = $correo;
         $this->contrasena = $contrasena;
         return false;
     }
     mysqli_close($connect);
     return true;
 }
Exemple #21
0
/**
* начало восстановления пароля
**/
function forgot()
{
    global $connection;
    $email = trim(mysqli_real_escape_string($connection, $_POST['email']));
    if (empty($email)) {
        $_SESSION['auth']['errors'] = 'Поле email не заполнено';
    } else {
        $query = "SELECT id FROM users WHERE email = '{$email}' LIMIT 1";
        $res = mysqli_query($connection, $query);
        if (mysqli_num_rows($res) == 1) {
            $expire = time() + 3600;
            $hash = md5($expire . $email);
            $query = "INSERT INTO forgot (hash, expire, email)\n\t\t\t\t\t\tVALUES ('{$hash}', {$expire}, '{$email}')";
            $res = mysqli_query($connection, $query);
            if (mysqli_affected_rows($connection) > 0) {
                // если добавлена запись в таблицу forgot
                $link = PATH . "forgot/?forgot={$hash}";
                $subject = "Запрос на восстановление пароля на сайте " . PATH;
                $body = "По ссылке <a href='{$link}'>{$link}</a> вы найдете страницу с формой, где сможете ввести новый пароль. Ссылка активна в течение 1 часа.";
                $headers = "FROM: " . strtoupper($_SERVER['SERVER_NAME']) . "\r\n";
                $headers .= "Content-type:text/html; charset=utf-8";
                mail($email, $subject, $body, $headers);
                $_SESSION['auth']['ok'] = 'На ваш email выслана инструкция по восстановлению пароля';
            } else {
                $_SESSION['auth']['errors'] = 'Ошибка!';
            }
        } else {
            $_SESSION['auth']['errors'] = 'Пользователь с таким email не найден';
        }
    }
}
 public function __construct($query, $parameters, $resource, $link)
 {
     $this->resource = $resource;
     $this->affected_rows = mysqli_affected_rows($link);
     $this->last_inserted_id = mysqli_insert_id($link);
     parent::__construct($query, $parameters);
 }
Exemple #23
0
 /**
  * @inheritdocs
  */
 function Execute($connection, $sql)
 {
     if (!($result = @mysqli_query($connection, $sql))) {
         throw new Exception(mysqli_error($connection));
     }
     return mysqli_affected_rows($connection);
 }
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);
    }
}
Exemple #25
0
function deleteAdminByID($id)
{
    checkConnectivity4();
    $query = sprintf("delete  from admin where ID = %s", $id);
    mysqli_query($GLOBALS['connection_link'], $query);
    return mysqli_affected_rows($GLOBALS['connection_link']) > 0;
}
 public function numAffectedRows()
 {
     if ($this->_result) {
         return mysqli_affected_rows($this->_result);
     }
     return 0;
 }
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);
    }
}
function importHoldingsData($host, $db, $user, $pass, $data)
{
    // Create connection
    $con = mysqli_connect($host, $user, $pass, $db);
    // Check connection
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        return;
    }
    //create table if it doesn't exist yet
    $tableExists = tableExists($con, "current_holdings");
    if (!$tableExists) {
        $createTable = "CREATE TABLE `pse_data`.`current_holdings` (\n\t\t\t\t\t\t\t  `quote` VARCHAR(16) NOT NULL,\n\t\t\t\t\t\t\t  `datebuy` DATE NOT NULL,\n\t\t\t\t\t\t\t  `pricebuy` FLOAT NULL,\n\t\t\t\t\t\t\t  `volume` INT NULL,\n\t\t\t\t\t\t\t  `pricestoploss` FLOAT NULL,\n\t\t\t\t\t\t\t  PRIMARY KEY (`quote`))\n\t\t\t\t\t\t\tCOMMENT = 'contains the current stocks being held and the stop loss selling price'";
        $result = mysqli_query($con, $createTable);
        echo "importHoldingsData: Created table 'current_holdings' <Br><Br>";
    }
    $sql = "REPLACE INTO current_holdings (datebuy, quote, pricebuy, volume)";
    $holdingValues = " VALUES";
    $dataSize = count($data);
    $ctr = 0;
    foreach ($data as $holdings) {
        $holdingValues = $holdingValues . "('" . $holdings['date'] . "','" . $holdings['company'] . "','" . $holdings['pricebuy'] . "','" . $holdings['volume'] . "')";
        $ctr++;
        if ($ctr < $dataSize) {
            $holdingValues = $holdingValues . ", ";
        }
    }
    $sql = $sql . $holdingValues;
    echo "{$sql}";
    $result = mysqli_query($con, $sql);
    if (mysqli_affected_rows($con) < 1) {
        echo "importHoldingsData: Failed Value Insertion!<Br>";
    }
    mysqli_close($con);
}
Exemple #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);
    }
}
Exemple #30
0
function update_poll()
{
    global $INSTALLER09, $CURUSER, $mc1;
    $total_votes = 0;
    if (!isset($_POST['pid']) or !is_valid_id($_POST['pid'])) {
        stderr('USER ERROR', 'There is no poll with that ID!');
    }
    $pid = intval($_POST['pid']);
    if (!isset($_POST['poll_question']) or empty($_POST['poll_question'])) {
        stderr('USER ERROR', 'There is no title defined!');
    }
    $poll_title = sqlesc(htmlsafechars(strip_tags($_POST['poll_question']), ENT_QUOTES));
    //get the main crux of the poll data
    $poll_data = makepoll();
    $total_votes = isset($poll_data['total_votes']) ? intval($poll_data['total_votes']) : 0;
    unset($poll_data['total_votes']);
    if (!is_array($poll_data) or !count($poll_data)) {
        stderr('SYSTEM ERROR', 'There was no data sent');
    }
    //all ok, serialize
    $poll_data = sqlesc(serialize($poll_data));
    $username = sqlesc($CURUSER['username']);
    sql_query("UPDATE polls SET choices={$poll_data}, starter_id={$CURUSER['id']}, starter_name={$username}, votes={$total_votes}, poll_question={$poll_title} WHERE pid={$pid}") or sqlerr(__FILE__, __LINE__);
    $mc1->delete_value('poll_data_' . $CURUSER['id']);
    if (-1 == mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $msg = "<h2>An Error Occured!</h2>\r\n      <a href='javascript:history.back()' title='Go back and fix the error' style='color:green;font-weight:bold'><span class='btn' style='padding:3px;'><img style='vertical-align:middle;' src='{$INSTALLER09['pic_base_url']}/polls/p_delete.gif' alt='Go Back' />Go Back</span></a>";
    } else {
        $msg = "<h2>Groovy, everything went hunky dory!</h2>\r\n      <a href='staffpanel.php?tool=polls_manager&amp;action=polls_manager' title='Return to Polls Manager' style='color:green;font-weight:bold'><span class='btn' style='padding:3px;'><img style='vertical-align:middle;' src='{$INSTALLER09['pic_base_url']}/polls/p_tick.gif' alt='Success' />Success</span></a>";
    }
    echo stdhead('Poll Manager::Add New Poll') . $msg . stdfoot();
}