<?php
/*
 * @ PHP 5.3
 * @ Decoder version : 1.0.0.1
 * @ Release on : 24.03.2018
 * @ Website    : http://EasyToYou.eu
 */

if (basename($_SERVER["SCRIPT_FILENAME"]) == basename(__FILE__)) {
    echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!<meta http-equiv=\"refresh\" content=\"2; url=./index.php\">";
    exit;
}
$server = $_SERVER["SERVER_NAME"];
/*$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://www.primadesain.com/verifydomains.php");
curl_setopt($c, CURLOPT_TIMEOUT, 30);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$postfields = "svr=" . $server;
curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
$result = curl_exec($c);*/
$result = 'valid';
if ($result == "fail") {
    echo "<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>You not have a license to use this script on this domain,<br>Please contact us to purchase a license.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - " . date("Y") . " www.primadesain.com</p>";
    exit;
}
class db_layout
{
    public $classname = "db_layout";
    public $db_name = NULL;
    public $db_user = NULL;
    public $db_password = NULL;
    public $db_host = NULL;
    public $db_link_ptr = NULL;
    public $tables = NULL;
    public $fields = NULL;
}
class db_mysql extends db_layout
{
    public $classname = "db_mysql";
    public $db_result = NULL;
    public $db_affected_rows = NULL;
    public $saved_results = array();
    public $results_saved = 0;
    public function error($where = "", $error, $errno)
    {
        echo "" . $where . "<br>";
        exit($error . "<br>" . $errno);
    }
    public function error_msg()
    {
        return mysql_error();
    }
    public function PushResults()
    {
        $this->saved_results[$this->results_saved] = array($this->db_result, $this->db_affected_rows);
        $this->results_saved++;
    }
    public function PopResults()
    {
        $this->results_saved--;
        $this->db_result = $this->saved_results[$this->results_saved][0];
        $this->db_affected_rows = $this->saved_results[$this->results_saved][1];
    }
    public function db_mysql($host, $user, $passwd, $db, $create = "")
    {
        $this->db_name = $db;
        $this->db_user = $user;
        $this->db_passwd = $passwd;
        $this->db_host = $host;
        $this->db_link_ptr = @mysql_connect($host, $user, $passwd) or $this->error("", mysql_error(), mysql_errno());
        $this->dbhandler = @mysql_select_db($db);
        if (!$this->dbhandler && $create == "1") {
            @mysql_create_db($db, $this->db_link_ptr) or $this->error("imposible crear la base de datos.", mysql_error(), mysql_errno());
            $this->dbhandler = @mysql_select_db($db);
        }
    }
    public function reselect_db($db)
    {
        $this->dbhandler = @mysql_select_db($db);
    }
    public function closeDB()
    {
        @mysql_close($this->db_link_ptr);
    }
    public function create_table($tblName, $tblStruct)
    {
        if (is_array($tblStruct)) {
            $theStruct = implode(",", $tblStruct);
        } else {
            $theStruct = $tblStruct;
        }
        @mysql_query("" . "create table " . $tblName . " (" . $theStruct . ")") or $this->error("" . "create table " . $tblName . " (" . $theStruct . ")", mysql_error(), mysql_errno());
    }
    public function drop_table($tblName)
    {
        @mysql_query("" . "drop table if exists " . $tblName) or $this->error("" . "drop table " . $tblName, mysql_error(), mysql_errno());
    }
    public function raw_query($sql_stat)
    {
        $this->db_result = @mysql_query($sql_stat) or $this->error($sql_stat, mysql_error(), mysql_errno());
        $this->db_affected_rows = @mysql_num_rows($this->db_result);
    }
    public function count_records($table, $filter = "")
    {
        $this->db_result = @mysql_query("" . "select count(*) as num from " . $table . ($filter != "" ? "" . " where " . $filter : ""));
        $xx = @mysql_result($this->db_result, 0, "num");
        return $xx;
    }
    public function select($fields, $tables, $where = "", $order_by = "", $group_by = "", $having = "", $limit = "")
    {
        $sql_stat = "" . " select " . $fields . " from " . $tables . " ";
        if (!empty($where)) {
            $sql_stat .= "" . "where " . $where . " ";
        }
        if (!empty($group_by)) {
            $sql_stat .= "" . "group by " . $group_by . " ";
        }
        if (!empty($order_by)) {
            $sql_stat .= "" . "order by " . $order_by . " ";
        }
        if (!empty($having)) {
            $sql_stat .= "" . "having " . $having . " ";
        }
        if (!empty($limit)) {
            $sql_stat .= "" . "limit " . $limit . " ";
        }
        $this->db_result = @mysql_query($sql_stat) or $this->error($sql_stat, mysql_error(), mysql_errno());
        $this->db_affected_rows = @mysql_num_rows($this->db_result);
        return $sql_stat;
    }
    public function list_tables()
    {
        $this->db_result = @mysql_list_tables($this->db_name);
        $this->db_affected_rows = @mysql_num_rows($this->db_result);
        return $this->db_result;
    }
    public function describe($tablename)
    {
        $this->result = @mysql_query("" . "describe " . $tablename);
    }
    public function table_exists($tablename)
    {
        $this->pushresults();
        $description = $this->describe($tablename);
        $this->popresults();
        if ($description) {
            $exists = true;
        } else {
            $exists = false;
        }
        return $exists;
    }
    public function tablename($tables, $tbl)
    {
        return mysql_tablename($tables, $tbl);
    }
    public function insert_id()
    {
        return mysql_insert_id();
    }
    public function insert($table, $fields = "", $values = "")
    {
        $sql_stat = "" . "insert into " . $table . " ";
        if (is_array($fields)) {
            $theFields = implode(",", $fields);
        } else {
            $theFields = $fields;
        }
        if (is_array($values)) {
            $theValues = "'" . implode("','", $values) . "'";
        } else {
            $theValues = $values;
        }
        $theValues = str_replace("'now()'", "now()", $theValues);
        if (!empty($theFields)) {
            $sql_stat .= "" . "(" . $theFields . ") ";
        }
        $sql_stat .= "" . "values (" . $theValues . ")";
        @mysql_query($sql_stat) or $this->error($sql_stat, mysql_error(), mysql_errno());
    }
    public function update($table, $newvals, $where = "")
    {
        if (is_array($newvals)) {
            $theValues = implode(",", $newvals);
        } else {
            $theValues = $newvals;
        }
        $sql_stat = "" . "update " . $table . " set " . $theValues;
        if (!empty($where)) {
            $sql_stat .= "" . " where " . $where;
        }
        @mysql_query($sql_stat) or $this->error($sql_stat, mysql_error(), mysql_errno());
    }
    public function delete($table, $where = "")
    {
        $sql_stat = "" . "delete from " . $table . " ";
        if (!empty($where)) {
            $sql_stat .= "" . "where " . $where . " ";
        }
        $db_result2 = @mysql_query($sql_stat) or $this->error($sql_stat, mysql_error(), mysql_errno());
        $this->db_affected_rows = @mysql_affected_rows($this->db_result2);
    }
    public function free()
    {
        @mysql_free_result($this->db_result) or $this->error("", mysql_error(), mysql_errno());
    }
    public function fetch_row()
    {
        $row = mysql_fetch_row($this->db_result);
        return $row;
    }
    public function num_fields()
    {
        return mysql_num_fields($this->db_result);
    }
    public function fetch_array()
    {
        $row = mysql_fetch_array($this->db_result);
        return $row;
    }
    public function fetch_field()
    {
        $row = mysql_fetch_field($this->db_result);
        return $row;
    }
    public function num_rows()
    {
        $row = mysql_num_rows($this->db_result);
        return $row;
    }
    public function result($recno, $field)
    {
        if (0 < $this->num_rows()) {
            return mysql_result($this->db_result, $recno, $field);
        }
    }
    public function dataku($field, $username)
    {
        $this->select($field, "member", "" . "username='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datane($field, $username)
    {
        $this->select($field, "member", "" . "accid='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datapaket($field, $username)
    {
        $this->select($field, "dataewalet3", "" . "username='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datawalet($field, $username)
    {
        $this->select($field, "ewalet", "" . "accid='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datawalete($field, $username)
    {
        $this->select($field, "ewalet", "" . "username='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datamngr($field, $username)
    {
        $this->select($field, "manager", "" . "username='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function datasto($field, $username)
    {
        $this->select($field, "stockist", "" . "username='" . $username . "'");
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function subkat($kat, $sub)
    {
        $this->select($kat, "katagori", "" . "sub='" . $sub . "'");
        $dt = $this->result(0, $kat);
        return $dt;
    }
    public function data($field, $table, $cond)
    {
        $this->select($field, $table, $cond);
        $dt = $this->result(0, $field);
        return $dt;
    }
    public function iklan_lama($username)
    {
        $this->select("no, judul", "iklan", "" . "userid='" . $username . "' and status=0");
        $j = $this->num_rows();
        if (0 < $j) {
            $ada = $j;
        } else {
            $ada = 0;
        }
        return $ada;
    }
    public function publikasi($username)
    {
        $this->select("no, judul", "berita", "" . "username='" . $username . "'");
        $j = $this->num_rows();
        if (0 < $j) {
            $ada = $j;
        } else {
            $ada = 0;
        }
        return $ada;
    }
    public function katiklan($no)
    {
        $this->select("id, title", "categories", "" . "id='" . $no . "'");
        $kat = $this->fetch_row();
        return $kat[1];
    }
    public function config($field)
    {
        $sql = mysql_query("" . "select " . $field . " from configuration where id=1");
        if ($sql === FALSE) {
            exit(mysql_error());
        }
        $row = mysql_fetch_row($sql);
        $kat = $row[0];
        return $kat;
    }
    public function config2($field)
    {
        $sql = mysql_query("" . "select " . $field . " from admin where id=1");
        if ($sql === FALSE) {
            exit(mysql_error());
        }
        $row = mysql_fetch_row($sql);
        $kat = $row[0];
        return $kat;
    }
    public function configs($field)
    {
        $sql = mysql_query("" . "select options_value from udb_options where options_key='" . $field . "'");
        if ($sql === FALSE) {
            exit(mysql_error());
        }
        $row = mysql_fetch_row($sql);
        $kat = $row[0];
        return $kat;
    }
    public function downline($level, $st, $username)
    {
        $jdl = 0;
        $sql = mysql_query("" . "select * from member where " . $level . "='" . $username . "' and status=" . $st);
        $jdl = mysql_num_rows($sql);
        return $jdl;
    }
    public function klik($username)
    {
        $cl = 0;
        $this->select("*", "click", "" . "refid='" . $username . "'");
        $cl = $this->num_rows();
        return $cl;
    }
    public function totbonus($username, $st, $sp)
    {
        $tb = 0;
        $sql = mysql_query("" . "select rp1, rp2 from member where " . $sp . "='" . $username . "' and status=" . $st);
        while ($row = mysql_fetch_row($sql)) {
            if ($sp == "sponsor") {
                $tb = $tb + $row[0];
            } else {
                $tb = $tb + $row[1];
            }
        }
        return $tb;
    }
    public function topmenu()
    {
        $sql = $this->select("id, name, alias, link", "menu", "published=1", "ordering");
        $n = $this->num_rows();
        echo "<ul>";
        for ($i = 0; $i < $n; $i++) {
            $mx = explode("=", $this->result($i, "link"));
            $ma = $mx[2];
            $mb = explode("&", $mx[1]);
            $catid = $mb[1];
            if ($m == "contact") {
                $cl = "class=current";
            } else {
                $cl = "";
            }
            echo "<li><a href='" . $this->result($i, "link") . "" . "' " . $cl . "><span>" . $this->result($i, "name") . "" . "</span>" . $m . "</a></li>";
        }
        echo "</ul>";
    }
    public function delete_html($form_name)
    {
        $form_name = str_replace("[", "", "" . $form_name);
        $form_name = str_replace("]", "", "" . $form_name);
        $not = "" . "\"'*\\abcdefghijklmnopqrstuvwxyz1234567890&#225;&#233;&#237;&#243;&#250;&#253;&#226;&#234;&#238;&#244;&#251;&#224;&#232;&#236;&#242;&#249;&#231;&#228;&#235;&#239;&#246;&#252;&#255;=~`@#\$%^&*()_{}\n\t\r\\ /;:.!?,+-";
        $form_name = eregi_replace("" . "(</)+[" . $not . "]+(>)", "", "" . $form_name);
        $form_name = eregi_replace("" . "(<)+[" . $not . "]+(>)", "", "" . $form_name);
        $form_name = str_replace("<", "", $form_name);
        $form_name = str_replace(">", "", $form_name);
        $form_name = htmlspecialchars($form_name);
        return $form_name;
    }
    public function crops($teks, $jh)
    {
        $ISIBERITA = $teks;
        $b_bagianberita = $jh;
        $TMPBAGIANBERITA = array();
        $TMP = explode(" ", $ISIBERITA);
        for ($i = 0; $i <= $b_bagianberita; $i++) {
            $TMPBAGIANBERITA[$i] = $TMP[$i];
        }
        $BAGIANBERITA = implode(" ", $TMPBAGIANBERITA);
        $dt = $BAGIANBERITA;
        return $dt;
    }
    public function news($ref)
    {
        $this->select("id_berita, judul, isi_berita, tanggal, published", "berita", "published=1", "id_berita", "", "", "1");
        $ada = $this->num_rows();
        for ($i = 0; $i < $ada; $i++) {
            $text = $this->result($i, "isi_berita");
            $tgcr = $this->result($i, "tanggal");
            echo "<h4><a href='?m=detailberita&nid=" . $this->result($i, "id_berita") . "" . "&id=" . $ref . "'>" . $this->result($i, "judul") . "</a></h4>";
            echo "<div class='author'>" . formatgl($tgcr) . "</div>";
            echo "<br>";
            $text0 = $this->crops($this->delete_html($text), 8);
            echo "" . $text0 . "...";
            echo "<br><br><br>";
        }
    }
    public function dataupline($field, $username)
    {
        $dup = "";
        $this->select("" . $field, "upline", "" . "username='" . $username . "'");
        $dup = $this->result(0, $field);
        return $dup;
    }
    public function tree($username)
    {
        $tr = "";
        $this->select("id", "tree", "" . "username='" . $username . "'");
        $tr = $this->result(0, "id");
        return $tr;
    }
    public function levelmbr($username, $posisine)
    {
        $jlv = 0;
        $slv = "select * from upline order by level desc";
        $rlv = mysql_query($slv);
        $slev = mysql_fetch_array($rlv);
        if ($slev["level"] <= 20) {
            $jmlev = $slev["level"];
        } else {
            $jmlev = 20;
        }
        $sqlki = "" . "select a.username, b.status from upline as a inner join member as b on a.username=b.username where a.upline0='" . $username . "' and a.posisi='" . $posisine . "' and b.status=1";
        $rki = mysql_query($sqlki);
        $kir = mysql_fetch_array($rki);
        $adaki = mysql_num_rows($rki);
        $user = $kir[0];
        if (0 < $adaki) {
            for ($i = 0; $i < $jmlev; $i++) {
                $sql2 = "" . "select a.username, b.status from upline as a inner join member as b on a.username=b.username where upline" . $i . "='" . $user . "' and b.status=1";
                $res = mysql_query($sql2);
                $jml = array();
                $jml[$i] = mysql_num_rows($res);
                $lv = 1 + $i;
                if (0 < $jml[$i]) {
                    $jl = $lv;
                }
            }
            $tb = 1;
        } else {
            $jl = 0;
            $tb = 0;
        }
        $jlv = $jl + $tb;
        return $jlv;
    }
    public function match($username)
    {
        $mt = "";
        $kia = memberL1($username, "and b.status=1");
        $kaa = memberL2($username, "and b.status=1");
        if ($kaa < $kia) {
            $match = $kaa;
            $ki_unmatch = $kia - $kaa;
            $ka_unmatch = $kaa - $kia;
        } else {
            $match = $kia;
            $ki_unmatch = $kaa - $kia;
            $ka_unmatch = $kia - $kaa;
        }
        $mt = $match;
        return $mt;
    }
    public function jumlahdl($username, $status)
    {
        $lev = mysql_query("select level from upline order by level desc");
        $lv = mysql_fetch_row($lev);
        if (100 < $lv[0]) {
            $jmlev = 100;
        } else {
            $jmlev = $lv[0];
        }
        for ($i = 0; $i < $jmlev; $i++) {
            $sql = mysql_query("" . "SELECT a.username, b.status FROM upline as a INNER JOIN member as b on a.username=b.username WHERE a.upline" . $i . "='" . $username . "' AND b.status='" . $status . "'");
            $ada = mysql_num_rows($sql);
            $td = $td + $ada;
        }
        $jdl = $td;
        return $jdl;
    }
    public function jumlahsp($username)
    {
        $j = 0;
        $sql = mysql_query("" . "select username from member where sponsor='" . $username . "' and status=1");
        $j = mysql_num_rows($sql);
        return $j;
    }
    public function aktivasi($username)
    {
        $clientdate = date("Y-m-d H:i:s");
        $tgl_skr = date("Y-m-d");
        $dtfrom = "" . $tgl_skr . " 00:00:00";
        $dtto = "" . $tgl_skr . " 23:59:59";
        $sql = mysql_query("select username, id_aktivasi from member where status=1 order by id_aktivasi DESC");
        if (0 < mysql_num_rows($sql)) {
            $mbr = mysql_fetch_row($sql);
            $last_id = (int) $mbr[1];
        } else {
            $last_id = 0;
        }
        $new_id = (int) $last_id + 1;
        $id_aktivasi = $new_id;
        $this->update("member", "" . "status=1, tglaktif='" . $clientdate . "',id_aktivasi='" . $id_aktivasi . "'", "" . "username='" . $username . "'");
        $this->select("username", "komisi", "" . "dari='" . $username . "'");
        if ($this->num_rows() == 0) {
            $jsp = $this->jumlahsp($sponsore);
            $this->update("upline", "" . "sp='" . $jsp . "'", "" . "username='" . $sponsore . "'");
            $level = $this->dataupline("level", $username);
            if (100 < $level) {
                $levelx = 100;
                return NULL;
            }
            $levelx = $level;
        }
    }
    public function myawalet($username)
    {
        $te = 0;
        $te = $this->myawaletdone($username);
        return $te;
    }
    public function myawaletpending($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from dataawalet where tujuan='" . $username . "' and status=0");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from dataawalet where username='" . $username . "' and status=0");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted + $tek;
        return $te;
    }
    public function myawaletdone($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from dataawalet where tujuan='" . $username . "' and status=1");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from dataawalet where username='" . $username . "' and status=1");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted - $tek;
        return $te;
    }
    public function mycwalet($username)
    {
        $te = 0;
        $te = $this->mycwaletdone($username);
        return $te;
    }
    public function mycwaletpending($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from datacwalet where tujuan='" . $username . "' and status=0");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from datacwalet where username='" . $username . "' and status=0");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted + $tek;
        return $te;
    }
    public function mycwaletdone($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from datacwalet where tujuan='" . $username . "' and status=1");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from datacwalet where username='" . $username . "' and status=1");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted - $tek;
        return $te;
    }
    public function mybwalet($username)
    {
        $te = 0;
        $te = $this->mybwaletdone($username);
        return $te;
    }
    public function mybwaletpending($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from databwalet where tujuan='" . $username . "' and status=0");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from databwalet where username='" . $username . "' and status=0");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted + $tek;
        return $te;
    }
    public function mybwaletdone($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from databwalet where tujuan='" . $username . "' and status=1");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from databwalet where username='" . $username . "' and status=1");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted - $tek;
        return $te;
    }
    public function myvwalet($username)
    {
        $te = 0;
        $te = $this->myvwaletdone($username);
        return $te;
    }
    public function myvwaletpending($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from datadwalet where tujuan='" . $username . "' and status=0");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from datadwalet where username='" . $username . "' and status=0");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted + $tek;
        return $te;
    }
    public function myvwaletdone($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from datadwalet where tujuan='" . $username . "' and status=1");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from datadwalet where username='" . $username . "' and status=1");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted - $tek;
        return $te;
    }
    public function myewalet($username)
    {
        $te = 0;
        $te = $this->myewaletdone($username);
        return $te;
    }
    public function myewaletpending($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from dataewalet where tujuan='" . $username . "' and status=0");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from dataewalet where username='" . $username . "' and status=0");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted + $tek;
        return $te;
    }
    public function myewaletdone($username)
    {
        $te = 0;
        $sql = mysql_query("" . "select username, jumlah, tujuan from dataewalet where tujuan='" . $username . "' and status=1");
        $a = mysql_num_rows($sql);
        $ted = 0;
        while ($row = mysql_fetch_row($sql)) {
            $ted = $ted + $row[1];
        }
        $sqla = mysql_query("" . "select username, jumlah, tujuan from dataewalet where username='" . $username . "' and status=1");
        $tek = 0;
        while ($rowa = mysql_fetch_row($sqla)) {
            $tek = $tek + $rowa[1];
        }
        $te = $ted - $tek;
        return $te;
    }
    public function jmlmember($username, $field)
    {
        $jm = 0;
        $this->select("a.username, a.status, a.blokir, b.sponsor", "member as a inner join upline as b on a.username=b.username", $field);
        $jm = $this->num_rows();
        return $jm;
    }
    public function saldoadmin($dtgl)
    {
        $this->select("jumlah, status", "transaksi", $dtgl);
        $sa = 0;
        while ($row = $this->fetch_row()) {
            if (0 < $row[1]) {
                $ja = $row[0];
            } else {
                $ja = 0 - $row[0];
            }
            $sa = $sa + $ja;
        }
        return $sa;
    }
    public function banner()
    {
        $this->select("id, nama, banner, url", "banner", "published=1", "RAND() LIMIT 5");
        while ($row = $this->fetch_row()) {
            echo "" . "<a href='./adsku.php?bid=" . $row["0"] . "' target='_blank'><img src='images/banner/" . $row["2"] . "' alt='" . $row["1"] . "' title='" . $row["1"] . "' border=0 /></a><br><br>";
        }
    }
    public function bannerb()
    {
        $this->select("id, nama, banner, url", "banner", "published=1", "RAND() LIMIT 5");
        while ($row = $this->fetch_row()) {
            echo "" . "<a href='../adsku/" . $row["0"] . "' target='_blank'><img src='../images/banner/" . $row["2"] . "' alt='" . $row["1"] . "' title='" . $row["1"] . "' border=0/></a><br><br>";
        }
    }
    public function banner2()
    {
        $this->select("id, nama, banner, url", "banner_kanan", "published=1", "RAND() LIMIT 2");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "images/banner/" . $row["2"];
            } else {
                $potoe = "images/image-not-available.jpg";
            }
            echo "" . "<a href='./ads.php?bid=" . $row["0"] . "' target='_blank'><img src='" . $potoe . "' alt='" . $row["1"] . "' title='" . $row["1"] . "' border=0 height='125'/></a>&nbsp;&nbsp;";
        }
    }
    public function banner2b()
    {
        $this->select("id, nama, banner, url", "banner_kanan", "published=1", "RAND() LIMIT 2");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "../images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "../images/banner/" . $row["2"];
            } else {
                $potoe = "../images/image-not-available.jpg";
            }
            echo "" . "<a href='../ads.php?bid=" . $row["0"] . "' target='_blank'><img src='" . $potoe . "' alt='" . $row["1"] . "' title='" . $row["1"] . "' border=0 height='125'/></a>&nbsp;&nbsp;";
        }
    }
    public function bannerlogo()
    {
        $this->select("id, nama, banner, url", "banner_logo", "published=1 and id=1", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "images/banner/" . $row["2"];
            } else {
                $potoe = "images/banner/your-logo-here.png";
            }
            echo "" . $potoe . "\r\n\t\t\t\t";
        }
    }
    public function bannerlogo2()
    {
        $this->select("id, nama, banner, url", "banner_logo", "published=1 and id=2", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "../images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "../images/banner/" . $row["2"];
            } else {
                $potoe = "../images/banner/your-logo-here.png";
            }
            echo "" . "<img src='" . $potoe . "' border=0 alt='" . $row["1"] . "'/>\r\n\t\t\t\t";
        }
    }
    public function bannerlogo3()
    {
        $this->select("id, nama, banner, url", "banner_logo", "published=1 and id=3", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "./images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "./images/banner/" . $row["2"];
            } else {
                $potoe = "./images/banner/your-logo-here.png";
            }
            echo "" . "<img src='" . $potoe . "' border=0 alt='" . $row["1"] . "' title='" . $row["1"] . "'/>\r\n\t\t\t\t";
        }
    }
    public function bannerlogo3b()
    {
        $this->select("id, nama, banner, url", "banner_logo", "published=1 and id=3", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "../images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "../images/banner/" . $row["2"];
            } else {
                $potoe = "../images/banner/your-logo-here.png";
            }
            echo "" . "<img src='" . $potoe . "' border=0 alt='" . $row["1"] . "' title='" . $row["1"] . "'/>\r\n\t\t\t\t";
        }
    }
    public function bannerrek()
    {
        $this->select("id, nama, banner, url, namabank, norek, pemilik", "banner_rek", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "<a href='images/banner/" . $row["2"] . "' class='highslide' onclick='return hs.expand(this)'><img src='images/banner/" . $row["2"] . "' width='135' title='" . $row["1"] . "' class='imgFloatCenter'/></a><br><div class='highslide-caption'><center><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $row["4"] . "</strong></font><br><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font><br><br></center></div>";
            } else {
                $potoe = "" . "<a href='images/banner/bank.png' class='highslide' onclick='return hs.expand(this)'><img src='images/banner/bank.png' width='135' title='" . $row["1"] . "' class='imgFloatCenter' /></a><br><div class='highslide-caption'><center><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $row["4"] . "</strong></font><br><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font><br><br></center></div>";
            }
            echo "" . "<div>" . $potoe . "</div>";
        }
    }
    public function bannerreka()
    {
        $this->select("id, nama, banner, url, namabank, norek, pemilik", "banner_rek", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            $adafoto = $row[2];
            $dirfoto = "" . "../images/banner/" . $row["2"];
            if (!empty($adafoto) && file_exists($dirfoto)) {
                $potoe = "" . "<a href='../images/banner/" . $row["2"] . "' class='highslide' onclick='return hs.expand(this)'><img src='../images/banner/" . $row["2"] . "' width='135' title='" . $row["1"] . "' class='imgFloatCenter'/></a><br><div class='highslide-caption'><center><font style='font-size:12pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $row["4"] . "</strong></font><br><font style='font-size:12pt;color:#444444;line-height:150%;font-family:Arial'>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font><br><br></center></div>";
            } else {
                $potoe = "" . "<a href='../images/banner/bank.png' class='highslide' onclick='return hs.expand(this)'><img src='../images/banner/bank.png' width='135' title='" . $row["1"] . "' class='imgFloatCenter' /></a><br><div class='highslide-caption'><center><font style='font-size:12pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $row["4"] . "</strong></font><br><font style='font-size:13pt;color:#444444;line-height:150%;font-family:Arial'>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font><br><br></center></div>";
            }
            echo "" . "<div>" . $potoe . "</div>";
        }
    }
    public function bannerrek2()
    {
        $uw = mysql_query("select id, nama, banner, url, namabank, norek, pemilik from banner_rek where published=1 Order by ordering");
        $ttlex = mysql_num_rows($uw);
        if (0 < $ttlex) {
            echo "<table class='table' style='width:100%;'>";
            while ($row = mysql_fetch_array($uw)) {
                $adafoto = $row[2];
                $dirfoto = "" . "./images/banner/" . $row["2"];
                if (!empty($adafoto) && file_exists($dirfoto)) {
                    $potoe = "" . "./images/banner/" . $row["2"];
                } else {
                    $potoe = "./images/banner/bank.png";
                }
                echo "<tr>";
                echo "" . "<td data-title='Payment'><img src='" . $potoe . "' width='100' title='" . $row["1"] . "' class='imgOpacity' border='1' style='border-color:#CCCCCC' /></td>";
                echo "" . "<td data-title='Acc'>" . $row["4"] . "<br>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font></td>";
                echo "</tr>";
            }
            echo "</table>";
        } else {
            echo "";
        }
    }
    public function bannerrek2a()
    {
        $uw = mysql_query("select id, nama, banner, url, namabank, norek, pemilik from banner_rek where published=1 Order by ordering");
        $ttlex = mysql_num_rows($uw);
        if (0 < $ttlex) {
            echo "<table class='table' style='width:100%;'>";
            while ($row = mysql_fetch_array($uw)) {
                $adafoto = $row[2];
                $dirfoto = "" . "../images/banner/" . $row["2"];
                if (!empty($adafoto) && file_exists($dirfoto)) {
                    $potoe = "" . "../images/banner/" . $row["2"];
                } else {
                    $potoe = "../images/banner/bank.png";
                }
                echo "<tr>";
                echo "" . "<td data-title='Payment'><img src='" . $potoe . "' width='100' title='" . $row["1"] . "' class='imgOpacity' border='1' style='border-color:#CCCCCC' /></td>";
                echo "" . "<td data-title='Acc'>" . $row["4"] . "<br>Acc : " . $row["5"] . "<br>" . $row["6"] . "</font></td>";
                echo "</tr>";
            }
            echo "</table>";
        } else {
            echo "";
        }
    }
    public function bannerhome()
    {
        $this->select("id, nama, banner, url", "bannerhome", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<a href='http://" . $row["1"] . "' target='_blank'><img src='images/banner/" . $row["2"] . "' title='" . $row["1"] . "' border=0 /></a>\r\n                <br>\r\n                " . $row["3"] . "\r\n                <br><br>";
        }
    }
    public function bannerkiri()
    {
        $this->select("id, nama, banner, url", "banner_kiri", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<a href='http://" . $row["3"] . "' target='_blank'><img src='images/banner/" . $row["2"] . "' title='" . $row["1"] . "' width='175' border=0 /></a>\r\n\t\t\t\t<br><br>";
        }
    }
    public function bannerbawah()
    {
        $this->select("id, nama, banner, url", "banner_bawah", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<a href='http://" . $row["3"] . "' target='_blank'><img src='images/banner/" . $row["2"] . "' title='" . $row["1"] . "' border=0 /></a>&nbsp";
        }
    }
    public function banneratas()
    {
        $this->select("id, nama, banner, url", "banner_atas", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<img src='../images/banner/" . $row["2"] . "' title='" . $row["1"] . "' border=0 /></a>";
        }
    }
    public function bannerkanan()
    {
        $this->select("id, nama, banner, url", "banner_kanan", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<img src='images/banner/" . $row["2"] . "' />\r\n\t\t\t\t";
        }
    }
    public function bannerkanan2()
    {
        $this->select("id, nama, banner, url", "banner_kanan", "published=1", "ordering");
        while ($row = $this->fetch_row()) {
            echo "" . "<img src='../images/banner/" . $row["2"] . "' />\r\n\t\t\t\t";
        }
    }
    public function updatejaringan($username)
    {
        $upline = $this->dataku("upline", $username);
        $posisi = $this->dataupline("posisi", $username);
        $sql = mysql_query("" . "select kiri, kanan from jaringan where username='" . $upline . "'");
        $data = mysql_fetch_row($sql);
        if ($posisi == "L1") {
            $nk = $data[0] + 1;
            $pos = "kiri";
        } else {
            $nk = $data[1] + 1;
            $pos = "kanan";
        }
        $this->update("jaringan", "" . $pos . "='" . $nk . "'", "" . "username='" . $upline . "'");
    }
    public function Menunggu($username, $posisi, $dtgl)
    {
        $n = 0;
        $kiri = $this->kirikanan($username, "L1", "1", $dtgl);
        $kanan = $this->kirikanan($username, "L2", "1", $dtgl);
        if ($kanan <= $kiri && $posisi == "L1") {
            $mp = $kiri - $kanan;
        } else {
            if ($kanan <= $kiri && $posisi == "L2") {
                $mp = 0;
            } else {
                if ($kiri < $kanan && $posisi == "L2") {
                    $mp = $kanan - $kiri;
                } else {
                    $mp = 0;
                }
            }
        }
        $n = $mp;
        return $n;
    }
    public function NetGrowth($username, $jenis, $dtgl)
    {
        $n = 0;
        if ($jenis == "komlev") {
            $sql = mysql_query("" . "select * from komisi where jenis like '%komlev%' and username='" . $username . "' " . $dtgl);
            $n = mysql_num_rows($sql);
        } else {
            if ($jenis == "fo") {
                $sqle = mysql_query("" . "select * from komisi where jenis='kompasangan' and username='" . $username . "' " . $dtgl);
                $fo = $this->config("flushout");
                $afo = mysql_num_rows($sqle);
                if ($fo < $afo) {
                    $n = 1;
                }
            } else {
                $sql = mysql_query("" . "select * from komisi where jenis='" . $jenis . "' and username='" . $username . "' " . $dtgl);
                $n = mysql_num_rows($sql);
            }
        }
        return $n;
    }
    public function kirikanan($username, $posisi, $status, $dtgl)
    {
        $n = 0;
        $rep = str_replace("tglbayar", "b.tglaktif", $dtgl);
        $level = $this->dataupline("level", $username);
        $sqlu = mysql_query("" . "select a." . $posisi . ", b.tgl from upline as a inner join member as b on a.username=b.username where  a.username='" . $username . "' and b.status='" . $status . "'");
        $data = mysql_fetch_row($sqlu);
        $user = $data[0];
        if ($user) {
            $t = 1;
        }
        $sql_lev = mysql_query("select level from upline order by level desc");
        $rowlev = mysql_fetch_row($sql_lev);
        $loop = $rowlev[0] - $level;
        for ($i = 0; $i < $loop; $i++) {
            if ($i == 0) {
                $sql = mysql_query("" . "select a.username, b.tgl from upline as a inner join member as b on a.username=b.username where  a.upline" . $i . "='" . $username . "' and a.posisi='" . $posisi . "' and b.status='" . $status . "' " . $rep);
                $ada0 = mysql_num_rows($sql);
            } else {
                $o = $i - 1;
                $sql = mysql_query("" . "select a.username, b.tgl from upline as a inner join member as b on a.username=b.username where  a.upline" . $i . "='" . $username . "' and a.upline" . $o . "='" . $user . "' and b.status='" . $status . "' " . $rep);
            }
            $ada = mysql_num_rows($sql);
            $n0 = $n0 + $ada;
        }
        $n = $n0;
        return $n;
    }
    public function ym($i, $n)
    {
        $ym = "";
        $ymn = explode("|", $this->config("ym"));
        $cn = count($ymn);
        echo "" . "<a href='ymsgr:sendIM?" . $ymn[$i] . "'><img src='http://opi.yahoo.com/online?u=" . $ymn[$i] . "&m=g&t=1' border='0' title='" . $n . "'></a>";
    }
    public function newmember()
    {
        $this->select("username, nama, kota, foto, sponsor, tgl", "member", "", "tgl desc", "", "", "5");
        while ($data = $this->fetch_row()) {
            $tgljn = formatglxy($data[5]);
            $adafotos = $data[3];
            $dirfotos = "" . "./member/images/" . $adafotos;
            if (!empty($adafotos) && file_exists($dirfotos)) {
                $foto = "" . "<a href='./member/images/" . $adafotos . "' class='highslide' onclick='return hs.expand(this)'><img src='./member/images/" . $adafotos . "' title='" . $data["1"] . "'/></a>";
            } else {
                $foto = "" . "<a href='./images/nopic.png' class='highslide' onclick='return hs.expand(this)'><img src='./images/nopic.png' title='" . $data["1"] . "' /></a>";
            }
            echo "<li><div class='img'>" . $foto . "<span class='title'>" . $data[0] . "</span></div><div class='desc'><h4><a href='#' class='tooltip' title='Username : " . $data[0] . "'>" . $data[1] . "</a></h4><p>" . $data[2] . "<br><i>" . $tgljn . "</i></p></div></li>";
        }
    }
    public function newmemberc($status)
    {
        $this->select("username, nama, kota, foto, sponsor, tgl", "member", "" . "status=" . $status, "tglaktif desc", "", "", "5");
        while ($data = $this->fetch_row()) {
            $tgljn = formatgl($data[5]);
            $adafotos = $data[3];
            $dirfotos = "" . "../member/images/" . $adafotos;
            if (!empty($adafotos) && file_exists($dirfotos)) {
                $foto = "" . "<div><a href='../member/images/" . $adafotos . "' class='highslide' onclick='return hs.expand(this)'><img src='../member/images/" . $adafotos . "' title='" . $data["1"] . "' width='50' height='50' class='imgku2xx' style='margin-right:15px;'/></a><div class='highslide-caption'><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $data["0"] . "</strong><br>Nama : " . $data["1"] . "<br>Kota : " . $data["2"] . "<br>Sponsor : " . $data["4"] . "<br>Tanggal Join : " . $tgljn . "</font></div></div>";
            } else {
                $foto = "" . "<div><a href='../images/nopic.png' class='highslide' onclick='return hs.expand(this)'><img src='../images/nopic.png' title='" . $data["1"] . "' width='50' height='50' class='imgku2xx' style='margin-right:15px;'/></a><div class='highslide-caption'><font style='font-size:10pt;color:#444444;line-height:150%;font-family:Arial'><strong>" . $data["0"] . "</strong><br>Nama : " . $data["1"] . "<br>Kota : " . $data["2"] . "<br>Sponsor : " . $data["4"] . "<br>Tanggal Join : " . $tgljn . "</font></div></div>";
            }
            echo "" . "<table cellpadding=\"0\" cellspacing=\"0\" width=\"50px\" height=\"50px\" border=\"0\" align=\"left\" background=\"\"><tr><td width=\"100%\" align=\"left\">" . $foto . "</td></tr></table><font style='font-size:10pt;color:#999999;line-height:110%;font-family:Arial'><strong>" . $data["0"] . "</strong><br /> " . $data["1"] . " <br />(" . $data["2"] . ")<br /><br /><br /></font>";
        }
    }
    public function freemember($status, $from)
    {
        $this->select("username, nama, hp, kota, foto", "member", "" . "status=" . $status . " and paket=1", "tgl desc", "", "", "5");
        if ($from == "home") {
            $folder = "images/";
            $folder2 = "user-area-non-public/images/";
        } else {
            $folder = "../images/";
            $folder2 = "images/";
        }
        while ($data = $this->fetch_row()) {
            if (!$data[4]) {
                $foto = $folder . "no_avatar.gif";
            } else {
                $foto = $folder2 . $data[4];
            }
            echo "" . "<center><table cellpadding=\"0\" cellspacing=\"0\" width=\"50px\" height=\"50px\" border=\"0\" align=\"left\" bgcolor=\"#F9F9F9\"><tr><td width=\"100%\" align=\"center\"><img src=\"" . $foto . "\" width=\"50px\" height=\"50px\"></td></tr></table>" . $data["0"] . "<br /> " . $data["1"] . " <br />(" . $data["3"] . ")<br /><br /><br /></center>";
        }
    }
}

?>