Beispiel #1
0
    $ret .= "<status>ok</status>";
    $ret .= "<id>" . $id . "</id></result>";
    echo $ret;
    exit;
}
//TODO: V4
if ($action == "delete_account") {
    $id = POSTGET("account_id");
    $full_delete = false;
    if (POSTGET("full") == "1") {
        $full_delete = true;
    }
    $debug_msg = "";
    $db = db_connect($config, "", "", "");
    if ($db) {
        $stmt = new db_stmt_update("accounts");
        $stmt->addColumnValue("deleted", "1");
        $stmt->addColumnValue("deletedtime", "", NOW);
        $stmt->setWhereClause("id = '" . $id . "'");
        $s = $stmt->getStatement();
        $rs = $db->Execute($s);
        if (!$rs) {
            $ret = "<?xml version=\"1.0\" encoding=\"utf-8\"?><result>";
            $ret .= "<status>ko</status></result>";
            echo $ret;
            $debug_msg .= "Error deleting account id [" . $s . "]";
            if ($debug) {
                print "</br>" . $debug_msg;
            }
            exit;
        }
 public function getSqlStmt($mode)
 {
     //TODO: V4
     $mode = strtolower($mode);
     if ($mode != 'insert' && $mode != 'update') {
         return "";
     }
     if ($mode == 'insert') {
         $stmt = new db_stmt_insert("sources");
     }
     if ($mode == 'update') {
         $stmt = new db_stmt_update("sources");
         $stmt->setWhereClause("id = '" . $this->getValue('id', '') . "'");
     }
     $xml = new SimpleXMLElement('<params/>');
     foreach ($this->data as $key => $value) {
         $key = strtolower($key);
         if ($key == 'params') {
             continue;
         }
         if (!in_array($key, $this->commons)) {
             if (!empty($value) && substr($value, 0, 1) == '<') {
                 $child = $xml->addChild($key);
                 $schedules = new SimpleXMLElement($value);
                 $domschedule = dom_import_simplexml($child);
                 $domschedules = dom_import_simplexml($schedules);
                 $domschedules = $domschedule->ownerDocument->importNode($domschedules, TRUE);
                 $domschedule->appendChild($domschedules);
             } else {
                 $xml->addChild($key, $value);
             }
         } else {
             $stmt->addColumnValue($key, $value);
         }
     }
     $stmt->addColumnValue("params", $xml->asXML());
     return $stmt->getStatement();
 }
 function login($config, $name, $password, $password_crypted, $prefix = '')
 {
     $db = db_connect($config, "", "", "", $prefix);
     if ($db) {
         $stmt = new db_stmt_select("users");
         $stmt->addColumn("*");
         $whereclause = "user_name='" . $name . "'";
         $whereclause .= " and (user_password = '******' or user_password = '******')";
         $stmt->setWhereClause($whereclause);
         $s = $stmt->getStatement();
         if (!is_null($this->cLog)) {
             $this->cLog->log_debug("User.inc.php - login - " . $s);
         }
         $rs = $db->Execute($s);
         if ($rs) {
             if ($rs->RecordCount() == 1) {
                 $this->id = $rs->fields["id"];
                 $this->name = $rs->fields["user_name"];
                 $this->password = $password;
                 $this->email = $rs->fields["user_email"];
                 $this->level = $rs->fields["user_level"];
                 $this->uuid = $rs->fields["uuid"];
                 $this->expiry = $rs->fields["subscription_date_end"];
                 $this->plan = $rs->fields["subscription_type"];
                 $this->postal_address = $rs->fields["invoice_address"];
                 $this->country_code = $rs->fields["invoice_country_code"];
                 $this->enabled = $rs->fields["enabled"];
                 $this->paiment_status = $rs->fields["paiment_status"];
                 $this->paiment_price_due = $rs->fields["paiment_price_due"];
                 $this->renew_plan = $rs->fields["renew_type"];
                 $this->renew_date_end = $rs->fields["renew_date_end"];
                 $this->tva_intra = $rs->fields["invoice_tva_intra"];
                 // mise a jour login_lasttime
                 $stmt = new db_stmt_update("users");
                 $stmt->addColumnValue("login_lasttime", "", "now");
                 $stmt->setWhereClause("id = '" . $this->id . "'");
                 $s = $stmt->getStatement();
                 $rs = $db->Execute($s);
                 return true;
             }
         }
     }
     return false;
 }