Esempio n. 1
0
 function receivePayment()
 {
     global $CFG;
     if (empty($_REQUEST['tx'])) {
         return false;
     }
     $auth_info = Link::executeScript($CFG->paypal_submit_url, array('tx' => $_REQUEST['tx'], 'at' => $CFG->paypal_tocken, 'cmd' => '_notify-synch'));
     $is_approved = stristr($auth_info, 'SUCCESS');
     if ($is_approved) {
         $auth_info = str_ireplace('SUCCESS', '', $auth_info);
         Messages::add($CFG->paypal_success_message);
         self::$item_count = mb_substr_count($auth_info, 'item_number');
         return self::parseInfo($auth_info);
     } else {
         Errors::add($CFG->paypal_failure_message);
         return false;
     }
 }
Esempio n. 2
0
 public static function logIn($user = false, $pass = false, $table = false, $session_name = false)
 {
     global $CFG;
     $user = strip_tags(mysql_real_escape_string($user));
     $pass = strip_tags(mysql_real_escape_string($pass));
     $table = $table ? $table : 'admin';
     $session_name = $session_name ? $session_name : 'user_info';
     self::$session_name = $session_name;
     if (empty($user) && empty($pass) && !$_SESSION[$session_name]['user']) {
         return false;
     }
     if (!empty($user) || !empty($pass)) {
         if (empty($user)) {
             Errors::add($CFG->login_empty_user);
             return false;
         }
         if (empty($pass)) {
             Errors::add($CFG->login_empty_pass);
             return false;
         }
     }
     if (empty($CFG->dbname)) {
         Errors::add($CFG->no_database_error);
         return false;
     }
     $user = $user ? trim($user) : $_SESSION[$session_name]['user'];
     $pass = $pass ? trim($pass) : $_SESSION[$session_name]['pass'];
     if (empty($user) || empty($pass)) {
         return false;
     }
     if (!User::verify($user, $pass, $table)) {
         Errors::add($CFG->login_invalid);
         User::logOut(1);
         return false;
     }
     $_SESSION[$session_name] = User::getInfo($user, $table);
     self::$logged_in = true;
     self::$info = $_SESSION[$session_name];
     return true;
 }
Esempio n. 3
0
 function get($p_id = 0, $count = false)
 {
     global $CFG;
     if (empty($this->url) && !$this->show_all) {
         Errors::add($CFG->comments_no_url_error);
         return false;
     }
     if (!($this->record_id > 0) && !$this->show_all) {
         Errors::add($CFG->comments_no_record_error);
         return false;
     }
     $sql_filter = $this->sql_filter;
     $sql = "SELECT comments.* FROM {$this->table} ";
     if ($sql_filter) {
         $matches = String::getSubstring($sql_filter, '[', ']');
         foreach ($matches as $match) {
             if (strstr($match, ',')) {
                 $join_path = explode(',', $match);
                 if (is_array($join_path)) {
                     foreach ($join_path as $join_field) {
                         $join_field_parts = explode('.', $join_field);
                         $join_table = $join_field_parts[0];
                         $j_field = $join_field_parts[1];
                         $join_tables[$join_table][] = $j_field;
                     }
                     $sql_filter = str_ireplace('[' . $match . ']', $join_field, $sql_filter);
                 }
             } elseif (strstr($match, '.')) {
                 $join_field_parts = explode('.', $match);
                 $join_table = $join_field_parts[0];
                 $j_field = $join_field_parts[1];
                 $join_tables[$join_table][] = $j_field;
                 $sql_filter = str_replace('[', '', str_replace(']', '', $sql_filter));
             }
         }
     }
     if ($join_tables) {
         foreach ($join_tables as $r_table => $r_field) {
             $j_field = $prev_field == 'id' ? $r_field[0] : 'id';
             $j_field = $r_table == $prev_table ? $prev_field : $r_field[0];
             if ($r_table != $this->table) {
                 $sql .= " LEFT JOIN {$r_table} ON ({$prev_table}.{$prev_field} = {$r_table}.{$j_field}) ";
             }
             $prev_table = $r_table;
             $prev_field = count($r_field) > 1 ? $r_field[1] : $r_field[0];
         }
     }
     $sql .= " WHERE 1 ";
     if ($sql_filter) {
         $sql_filter = String::doFormulaReplacements($sql_filter);
         $sql .= " AND (" . $sql_filter . ') ';
     }
     $sql .= (!$this->show_all ? "AND {$this->table}.url = '{$this->url}' AND {$this->table}.record_id = {$this->record_id}" : "") . " " . (!$count ? "AND {$this->table}.p_id = {$p_id}" : '') . " \n\t\tORDER BY {$this->table}.date DESC ";
     if ($this->max_comments) {
         $sql .= " LIMIT 0,{$this->max_comments}";
     }
     $result = db_query_array($sql);
     if ($result) {
         foreach ($result as $row) {
             $this->count++;
             $id = $row['id'];
             $comments[$id] = $row;
             $comments[$id]['children'] = Comments::get($id);
         }
     }
     return $comments;
 }
    $_SESSION['ba_c_currency'] = $_REQUEST['c_currency'];
} else {
    if (empty($_SESSION['ba_c_currency'])) {
        $_SESSION['ba_c_currency'] = $_SESSION['c_currency'];
    }
}
$c_currency = $_SESSION['ba_c_currency'];
API::add('BitcoinAddresses', 'get', array(false, $c_currency, false, 30, 1));
API::add('Content', 'getRecord', array('bitcoin-addresses'));
$query = API::send();
$bitcoin_addresses = $query['BitcoinAddresses']['get']['results'][0];
$content = $query['Content']['getRecord']['results'][0];
$page_title = Lang::string('bitcoin-addresses');
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'add' && $_SESSION["btc_uniq"] == $_REQUEST['uniq']) {
    if (strtotime($bitcoin_addresses[0]['date']) >= strtotime('-1 day')) {
        Errors::add(Lang::string('bitcoin-addresses-too-soon'));
    }
    if (!is_array(Errors::$errors)) {
        API::add('BitcoinAddresses', 'getNew', array($c_currency));
        API::add('BitcoinAddresses', 'get', array(false, $c_currency, false, 30, 1));
        $query = API::send();
        $bitcoin_addresses = $query['BitcoinAddresses']['get']['results'][0];
        Messages::add(Lang::string('bitcoin-addresses-added'));
    }
}
$_SESSION["btc_uniq"] = md5(uniqid(mt_rand(), true));
include 'includes/head.php';
?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
Esempio n. 5
0
 public static function deleteRecursive($table, $id)
 {
     global $CFG;
     if (!$table || !($id > 0)) {
         return false;
     }
     if (!db_delete($table, $id)) {
         Errors::add($CFG->ajax_delete_error);
         return false;
     }
     $sql = "SELECT id FROM {$table} WHERE p_id = {$id}";
     $result = db_query_array($sql);
     if ($result) {
         foreach ($result as $row1) {
             $id1 = $row1['id'];
             self::deleteRecursive($table, $id1);
         }
     }
 }
Esempio n. 6
0
            exit;
        }
    }
}
if ($sell && !is_array(Errors::$errors)) {
    $sell_market_price1 = !empty($_REQUEST['sell_market_price']);
    $sell_stop = !empty($_REQUEST['sell_stop']);
    $sell_stop_price1 = $sell_stop ? $sell_stop_price1 : false;
    $sell_limit = !empty($_REQUEST['sell_limit']);
    $sell_limit = !$sell_stop && !$sell_market_price1 ? 1 : $sell_limit;
    $sell_price1 = $sell_market_price1 ? $current_bid : $sell_price1;
    API::add('Orders', 'executeOrder', array(0, $sell_stop && !$sell_limit ? $sell_stop_price1 : $sell_price1, $sell_amount1, $c_currency1, $currency1, $user_fee_ask, $sell_market_price1, $order_info['id'], false, false, $sell_stop_price1));
    $query = API::send();
    $operations = $query['Orders']['executeOrder']['results'][0];
    if (!empty($operations['error'])) {
        Errors::add($operations['error']['message']);
    } else {
        if ($operations['edit_order'] > 0) {
            $uniq_time = time();
            $_SESSION["editorder_uniq"][$uniq_time] = md5(uniqid(mt_rand(), true));
            if (count($_SESSION["editorder_uniq"]) > 3) {
                unset($_SESSION["editorder_uniq"][min(array_keys($_SESSION["editorder_uniq"]))]);
            }
            Link::redirect('open-orders.php', array('transactions' => $operations['transactions'], 'edit_order' => 1));
            exit;
        } else {
            $uniq_time = time();
            $_SESSION["editorder_uniq"][$uniq_time] = md5(uniqid(mt_rand(), true));
            if (count($_SESSION["editorder_uniq"]) > 3) {
                unset($_SESSION["editorder_uniq"][min(array_keys($_SESSION["editorder_uniq"]))]);
            }
Esempio n. 7
0
        $step1 = true;
    }
} elseif (!empty($_REQUEST['step']) && $_REQUEST['step'] == 3) {
    if (!($token1 > 0)) {
        Errors::add(Lang::string('security-no-token'));
    }
    if (!is_array(Errors::$errors)) {
        API::settingsChangeId($authcode1);
        API::token($token1);
        API::add('User', 'verifiedGoogle');
        $query = API::send();
        if ($query['error'] == 'security-incorrect-token') {
            Errors::add(Lang::string('security-incorrect-token'));
        }
        if ($query['error'] == 'request-expired') {
            Errors::add(Lang::string('settings-request-expired'));
        }
        if (!is_array(Errors::$errors)) {
            Messages::add(Lang::string('security-success-message'));
            $step4 = true;
        } else {
            $step3 = true;
        }
    } else {
        $step3 = true;
    }
}
if (!empty($_REQUEST['notice']) && $_REQUEST['notice'] == 'email') {
    $notice = Lang::string('settings-change-notice');
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'security-disabled-message') {
    Messages::add(Lang::string('security-disabled-message'));
Esempio n. 8
0
 static function sendSMS($authy_id = false)
 {
     global $CFG;
     API::add('User', 'sendSMS', array($authy_id));
     $query = API::send();
     $response = $query['User']['sendSMS']['results'][0];
     if (!$response || !is_array($response)) {
         Errors::add(Lang::string('security-com-error'));
     } elseif ($response['success'] == false) {
         Errors::merge($response['errors']);
     } else {
         return true;
     }
 }
Esempio n. 9
0
define('NO_LOGIN_REQUIRE', TRUE);
include 'conf/conf.php';
$action = !empty($_REQUEST['ajax']) ? $_REQUEST['ajax'] : exit;
switch ($action) {
    case "addPanier":
        if (isset($_POST)) {
            $panier = new Panier();
            $panier->addItem($_POST['code-produit'], $_POST['nb-produit']);
            Utils::json(array('result' => 'success'));
        }
        break;
    case "inscription":
        $controle = new Errors();
        if (empty($_POST['codeClientSignIn'])) {
            $controle->add('Veuillez saisir votre code client', 'codeClientSignIn');
        }
        if (empty($_POST['emailSignIn'])) {
            $controle->add('Veuillez saisir votre adresse email', 'emailSignIn');
        }
        if (empty($_POST['emailSignIn2'])) {
            $controle->add('Veuillez confirmez votre adresse email', 'emailSignIn2');
        }
        if ($_POST['emailSignIn'] != $_POST['emailSignIn2']) {
            $controle->add('Les adresses email ne sont pas identiques', 'emailNotSame');
        }
        if ($controle->isEmpty()) {
            $codeClientSignIn = $_POST['codeClientSignIn'];
            $emailSignIn = $_POST['emailSignIn'];
            $customer = UtilisateursManager::getUtilisateurByCodeClientAndEmail($codeClientSignIn, $emailSignIn);
            if ($customer) {
Esempio n. 10
0
 /**
  * Add validation error
  *
  * @param string $error_msg
  * @param string|null $attribute
  */
 public function addError($error_msg, $attribute = 'base')
 {
     $this->errors->add($attribute, $error_msg);
 }
Esempio n. 11
0
        $query = API::send();
        Messages::add(Lang::string('bank-accounts-added-message'));
        $bank_accounts = $query['BankAccounts']['get']['results'][0];
    }
}
if ($remove_id1 > 0) {
    $found = false;
    if (!empty($bank_accounts) && is_array($bank_accounts)) {
        foreach ($bank_accounts as $account) {
            if ($account['id'] == $remove_id1) {
                $found = true;
            }
        }
    }
    if (!$found) {
        Errors::add(Lang::string('bank-accounts-remove-error'));
    }
    if (!is_array(Errors::$errors)) {
        API::add('BankAccounts', 'delete', array($remove_id1));
        API::add('BankAccounts', 'get');
        $query = API::send();
        Messages::add(Lang::string('bank-accounts-removed-message'));
        $bank_accounts = $query['BankAccounts']['get']['results'][0];
    }
}
$_SESSION["bankaccount_uniq"] = md5(uniqid(mt_rand(), true));
include 'includes/head.php';
?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
Esempio n. 12
0
         if ($row['month']) {
             if ($month != date('n') && $month != date('m')) {
                 continue;
             }
         }
         if ($row['year']) {
             if ($year != date('Y') && $year != date('y')) {
                 continue;
             }
         }
     }
     if ($method['method'] == 'emailNotify') {
         if (Email::send($CFG->form_email, $row1[$email_field], $message['title'], $CFG->form_email_from, false, $message['content'], $row1)) {
             Messages::add($CFG->email_sent_message);
         } else {
             Errors::add($CFG->email_send_error);
         }
     } elseif ($method['method'] == 'createRecord') {
         $CFG->save_called = 1;
         $form = new Form('cron', false, false, false, $control_args['table'], false, 1);
         $form->get($row1['id']);
         $form->createRecord($method_args['table'], $method_args['insert_array'], $method_args['trigger_field'], $method_args['trigger_value'], $method_args['day'], $method_args['month'], $method_args['year'], $method_args['send_condition'], $method_args['any_modification'], $method_args['register_changes'], $method_args['on_new_record_only'], $method_args['store_row'], $method_args['if_not_exists'], $method_args['run_in_cron']);
         unset($form);
     } elseif ($method['method'] == 'editRecord') {
         $CFG->save_called = 1;
         $form = new Form('cron', false, false, false, $control_args['table'], false, 1);
         $form->get($row1['id']);
         $form->editRecord($method_args['table'], $method_args['insert_array'], $method_args['trigger_field'], $method_args['trigger_value'], $method_args['day'], $method_args['month'], $method_args['year'], $method_args['send_condition'], $method_args['any_modification'], $method_args['register_changes'], $method_args['on_new_record_only'], $method_args['store_row'], $method_args['edit_record_field_id'], $method_args['run_in_cron']);
         unset($form);
     }
 }
Esempio n. 13
0
                        Utils::writeAPhpManager($chemin . '/' . 'managers/', ucfirst($table[$bddName]) . 'Manager', $describes, $table[$bddName]);
                    }
                    break;
                case '0':
                    exit;
                    break;
            }
        }
    }
}
// section backoffice
if (isset($_POST['submit-backoffice'])) {
    if (isset($_POST)) {
        $error = new Errors();
        if (empty($_POST['PATH_CLASS'])) {
            $error->add('Veuilliez sassir le nom de la base de donnés. ', 'DBNAME');
        }
        if (empty($_POST['PATH'])) {
            $error->add('Veuilliez sassir le chemi des fichers ', 'PATH');
        }
        if ($error->isEmpty()) {
            $dir = $_POST['PATH_CLASS'];
            $files = scandir($dir);
            $menu = array();
            foreach ($files as $file) {
                if (count(explode('.php', $file)) > 1) {
                    $name = explode('.php', $file);
                    array_push($menu, $name[0]);
                    $content = file_get_contents($dir . $file);
                    explode($content);
                    // creation controller ;
Esempio n. 14
0
<?php

require 'conf/conf.php';
define('PAGE', 'CONTACT');
require 'conf/conf_page.php';
$sentMail = 'sentmail';
if (!empty($_POST)) {
    if (isset($_POST['submit'])) {
        $controle = new Errors();
        if (empty($_POST['email'])) {
            $controle->add('Veuillez saisir votre e-mail', 'email');
        }
        if (empty($_POST['name'])) {
            $controle->add('Veuillez saisir votre nom', 'name');
        }
        if (empty($_POST['message'])) {
            $controle->add('Veuillez saisir votre message', 'message');
        }
        if ($controle->isEmpty()) {
            $sentMessage = new Mail();
            $customer = UtilisateursManager::getUtilisateursById($_SESSION['customer']['idClient']);
            $sentMail = $sentMessage->Contact($customer);
            if ($sentMail) {
                $sentMail = 'send';
            }
        }
    }
}
echo $twig->render('contact.twig', array('PAGE' => $_PAGE, 'controle' => isset($controle) && !empty($controle) ? $controle : null, 'POST' => isset($_POST) && !empty($_POST) ? $_POST : '', 'send' => $sentMail));
Esempio n. 15
0
 function grid($name, $caption = false, $link_url = false, $link_is_tab = false, $concat_char = false)
 {
     global $CFG;
     $form = Control::getControls($CFG->editor_page_id, 'form', $CFG->editor_is_tab);
     if (!$form) {
         Errors::add('No form action created yet.');
         return false;
     }
     foreach ($form as $id => $control) {
         if (is_array($control['methods'])) {
             foreach ($control['methods'] as $method) {
                 $args = unserialize($method['arguments']);
                 if ($method['method'] == 'grid' && $args['name'] == $name) {
                     $grid_id = $id;
                     $grid_method = $method;
                     $grid_control = $control;
                     break 2;
                 }
             }
         }
     }
     if (!($grid_id > 0)) {
         Errors::add('No grid input called ' . $name . ' exists. Create it on the form action first.');
         return false;
     }
     if ($CFG->pm_editor) {
         $method_name = Form::peLabel($CFG->method_id, 'grid');
     }
     $this->in_grid = true;
     $this->grid_table = $this->table . '_grid_' . $name;
     $inputs_array = Control::getSubMethods($method['id'], $control['params']['class']);
     $HTML .= '<div class="record_grid"><div class="caption">' . $caption . $method_name . '</div><table>';
     if ($inputs_array) {
         $HTML .= '<tr>';
         foreach ($inputs_array as $args) {
             $HTML .= '<th>' . $args['caption'] . '</th>';
         }
         $HTML .= '</tr>';
         $values = DB::getGridValues($this->table . '_grid_' . $name, $subtable_fields, $this->record_id);
         if ($values) {
             foreach ($values as $row) {
                 $num_empty = 0;
                 $c1 = count($inputs_array);
                 if (is_array($inputs_array)) {
                     foreach ($inputs_array as $k => $v) {
                         if (stristr($k, 'checkBox')) {
                             $c1--;
                         }
                     }
                 }
                 foreach ($row as $key => $row1) {
                     if ($key != 'id' && empty($row1)) {
                         $num_empty++;
                     }
                 }
                 if ($num_empty >= $c1) {
                     continue;
                 }
                 $this->grid_values = $row;
                 $HTML .= '<tr>';
                 foreach ($inputs_array as $args) {
                     $HTML .= '<td>' . self::field($args['name'], $args['caption'], $args['subtable'], $args['subtable_fields'], $link_url, $concat_char, true, $args['f_id_field'], false, false, false, $link_is_tab) . '</td>';
                 }
                 $HTML .= '</tr>';
             }
         }
     }
     $HTML .= '</table></div>';
     $this->in_grid = false;
     $this->grid_table = false;
     $this->HTML[] = $HTML;
 }
Esempio n. 16
0
    $header->jsFile('js/jquery.swfupload.js');
    $header->jsFile('ckeditor/ckeditor.js');
    $header->jsFile('js/Ops.js');
    $header->js('CKEDITOR.dtd.$removeEmpty[\'span\'] = false;');
    $header->display();
    $header->getJsGlobals();
}
if ($_REQUEST['authy_form']) {
    $token1 = preg_replace("/[^0-9]/", "", $_REQUEST['authy_form']['token']);
    if (!($token1 > 0)) {
        Errors::add('Invalid token.');
    }
    if (!is_array(Errors::$errors)) {
        $response = Google2FA::verify_key(User::$info['authy_id'], $token1);
        if (!$response) {
            Errors::add('Invalid token.');
        }
        if (!is_array(Errors::$errors)) {
            $_SESSION['token_verified'] = 1;
            Errors::$errors = false;
        }
    }
}
if (User::isLoggedIn() && !(User::$info['verified_authy'] == 'Y' && !($_SESSION['token_verified'] > 0))) {
    $CFG->user_id = User::$info['id'];
    $CFG->group_id = User::$info['f_id'];
    if (!$CFG->bypass || $CFG->url == 'edit_page' && !$_REQUEST['tab_bypass']) {
        include_once 'includes/popups.php';
        ?>
<div id="head">
	<?php 
Esempio n. 17
0
<?php

include '../lib/common.php';
if (User::isLoggedIn()) {
    Link::redirect('account.php');
} elseif (!User::$awaiting_token) {
    Link::redirect('login.php');
}
$token1 = !empty($_REQUEST['token']) ? preg_replace("/[^0-9]/", "", $_REQUEST['token']) : false;
$dont_ask1 = !empty($_REQUEST['dont_ask']);
$authcode1 = !empty($_REQUEST['authcode']) ? urldecode($_REQUEST['authcode']) : false;
if (!empty($_REQUEST['step']) && $_REQUEST['step'] == 1) {
    if (!($token1 > 0)) {
        Errors::add(Lang::string('security-no-token'));
    }
    if (!is_array(Errors::$errors)) {
        $verify = User::verifyToken($token1, $dont_ask1);
        if ($verify) {
            if (!empty($_REQUEST['email_auth'])) {
                Link::redirect('change-password.php?authcode=' . urlencode($_REQUEST['authcode']));
            } else {
                Link::redirect('account.php');
            }
            exit;
        }
    }
}
API::add('Content', 'getRecord', array('security-token-login'));
$query = API::send();
$content = $query['Content']['getRecord']['results'][0];
$page_title = Lang::string('verify-token');
Esempio n. 18
0
    }
} elseif ($action == 'method') {
    if (!db_query("INSERT INTO admin_controls_methods (method,arguments,admin_controls_methods.order,control_id,p_id) SELECT method,arguments,admin_controls_methods.order," . $_REQUEST['control_id'] . ",p_id FROM admin_controls_methods WHERE id = {$old_id}")) {
        if (!Errors::$errors) {
            Errors::add($CFG->ajax_insert_error);
        }
    } else {
        $method_id = mysql_insert_id();
        $return_values[] = 'method_' . $old_id . '=' . $method_id;
        if ($method_id > 0) {
            $submethods = db_query_array("SELECT id FROM admin_controls_methods WHERE p_id = {$method_id} ");
            if ($submethods) {
                foreach ($submethods as $submethod) {
                    if (!db_query("INSERT INTO admin_controls_methods (method,arguments,admin_controls_methods.order,control_id,p_id) SELECT method,arguments,admin_controls_methods.order,control_id," . $method_id . " FROM admin_controls_methods WHERE id = {$submethod['id']}")) {
                        if (!Errors::$errors) {
                            Errors::add($CFG->ajax_insert_error);
                        }
                    } else {
                        $return_values[] = 'method_' . $submethod['id'] . '=' . mysql_insert_id();
                    }
                }
            }
        }
    }
}
if (is_array(Errors::$errors)) {
    Errors::display();
} else {
    echo '[Return values:' . implode('|', $return_values) . ']';
    Messages::add($CFG->ajax_save_message);
    Messages::display();
Esempio n. 19
0
    public static function send($from, $recipients, $subject, $from_name = false, $text_version = false, $html_version = false, $variables = false)
    {
        global $CFG;
        $reply_to = $from;
        //$from = ($from_name) ? '"'.$from_name.'" <'.$from.'>' : $from;
        /*
        if (is_array($recipients)) {
        	foreach ($recipients as $name => $email) {
        		if (!self::verifyAddress($email)) {
        			$errors[$email] = $CFG->invalid_email_error;
        			unset($recipients[$name]);
        			continue;
        		}
        		if (!is_numeric($name)) 
        			$recipients[$name] = "\"{$name}\" <{$email}>";
        	}
        	if (!empty($recipients))
        		$to = implode(',',$recipients);
        }
        else {
        	if (self::verifyAddress($recipients)) {
        		$to = $recipients;
        	}
        	else {
        		$errors[$recipients] = $recipients;
        	}
        }
        */
        if (is_array($variables)) {
            foreach ($variables as $name => $value) {
                $var_string .= '
					' . ucfirst(str_ireplace('_', ' ', $name)) . ': ' . $value . '<br/>';
            }
        }
        $html_version = str_ireplace('[variables]', $var_string, $html_version);
        $text_version = str_ireplace('[variables]', $var_string, $text_version);
        if (is_array($variables)) {
            if (!$CFG->backstage_mode) {
                foreach ($variables as $key => $val) {
                    $html_version = str_ireplace('[' . $key . ']', $val, $html_version);
                    $text_version = str_ireplace('[' . $key . ']', $val, $text_version);
                    $subject = str_ireplace('[' . $key . ']', $val, $subject);
                }
            } else {
                $matches = String::getSubstring($html_version, '[', ']');
                if (is_array($matches)) {
                    foreach ($matches as $match) {
                        $f_id = $variables['id'];
                        if (strstr($match, ',')) {
                            $value = DB::getForeignValue($match, $f_id);
                        } elseif (array_key_exists($match, $variables)) {
                            $value = $variables[$match];
                        } elseif (strstr($match, '.')) {
                            $parts = explode('.', $match);
                            $sql = "SELECT {$match[1]} FROM {$match[0]} WHERE f_id = {$f_id}";
                            $result = db_query_array($sql);
                            if ($result) {
                                $m1 = $match[1];
                                $value = $result[0][$m1];
                            }
                        } elseif (stristr($match, 'curdate')) {
                            $operation = str_ireplace('curdate', '', $match);
                            if (empty($operation)) {
                                $value = date($CFG->default_date_format);
                            } else {
                                $value = date($CFG->default_date_format, strtotime($operation));
                            }
                        }
                        $html_version = str_ireplace('[' . $match . ']', $value, $html_version);
                        $text_version = str_ireplace('[' . $match . ']', $value, $text_version);
                        $subject = str_ireplace('[' . $match . ']', $value, $subject);
                    }
                }
            }
        }
        $html_version = str_ireplace('[curdate]', date($CFG->default_date_format), $html_version);
        $text_version = str_ireplace('[curdate]', date($CFG->default_date_format), $text_version);
        $subject = str_ireplace('[curdate]', date($CFG->default_date_format), $subject);
        if (!$text_version) {
            include_once 'html2text.php';
            $h2t =& new html2text($html);
            $h2t->set_base_url($CFG->baseurl);
            $text_version = $h2t->get_text();
        }
        if (!$html_version) {
            $html_version = nl2br($text_version);
        }
        /*
        $message = '
        
        ------=_Part_40832071_1556867510.1259294982273
        Content-Type: text/plain; charset=iso-8859-1
        Content-Transfer-Encoding: 7bit
        
        ';
        $message .= $text_version;
        
        $message .= '
        
        ------=_Part_40832071_1556867510.1259294982273
        Content-Type: text/html; charset=iso-8859-1
        Content-Transfer-Encoding: quoted-printable
        
        ';
        $message .= $html_version;
        
        $message .= '
        
        ------=_Part_40832071_1556867510.1259294982273--
        ';
        
        if ($errors) {
        	Errors::merge($errors);
        	return false;
        }
        if(mail($to, $subject, $message, $headers)) {
        	Messages::add($CFG->email_sent_message);
        	return true;
        }
        else {
        	Errors::add($CFG->email_send_error);
        	return false;
        }
        */
        include_once 'phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        $mail->isSMTP();
        $mail->CharSet = 'UTF-8';
        $mail->SMTPDebug = 0;
        $mail->Debugoutput = 'html';
        $mail->Host = $CFG->email_smtp_host;
        $mail->Port = $CFG->email_smtp_port;
        $mail->SMTPSecure = $CFG->email_smtp_security;
        $mail->SMTPAuth = true;
        $mail->Username = $CFG->email_smtp_username;
        $mail->Password = $CFG->email_smtp_password;
        $mail->setFrom($from, $from_name);
        $mail->addReplyTo($from);
        if (is_array($recipients)) {
            foreach ($recipients as $name => $email) {
                if (!self::verifyAddress($email)) {
                    $errors[$email] = $CFG->invalid_email_error;
                    unset($recipients[$name]);
                    continue;
                }
                $mail->addAddress($email, $name);
            }
        } else {
            if (self::verifyAddress($recipients)) {
                $mail->addAddress($recipients);
            } else {
                $errors[$recipients] = $recipients;
            }
        }
        $mail->Subject = $subject;
        $mail->msgHTML($html_version);
        $mail->AltBody = $text_version;
        if ($mail->send()) {
            Messages::add($CFG->email_sent_message);
            return true;
        } else {
            Errors::add($mail->ErrorInfo);
            return false;
        }
    }
Esempio n. 20
0
        //API::token($token1);
        API::settingsChangeId($authcode1);
        API::add('User', 'changePassword', array($personal->info['pass']));
        $query = API::send();
        if (!empty($query['error'])) {
            if ($query['error'] == 'security-com-error') {
                Errors::add(Lang::string('security-com-error'));
            }
            if ($query['error'] == 'authy-errors') {
                Errors::merge($query['authy_errors']);
            }
            if ($query['error'] == 'request-expired') {
                Errors::add(Lang::string('settings-request-expired'));
            }
            if ($query['error'] == 'security-incorrect-token') {
                Errors::add(Lang::string('security-incorrect-token'));
            }
        }
        if (!is_array(Errors::$errors)) {
            $_SESSION["cp_uniq"] = md5(uniqid(mt_rand(), true));
            Link::redirect('account.php?message=settings-personal-message');
        } else {
            $request_2fa = true;
        }
    }
} else {
    $personal->info['pass'] = false;
}
$_SESSION["cp_uniq"] = md5(uniqid(mt_rand(), true));
$page_title = Lang::string('change-password');
include 'includes/head.php';
Esempio n. 21
0
    }
    if (!is_array(Errors::$errors)) {
        $login = User::logIn($user1, $pass1);
        if ($login && empty($login['error'])) {
            if (!empty($login['message']) && $login['message'] == 'awaiting-token') {
                $_SESSION["register_uniq"] = md5(uniqid(mt_rand(), true));
                Link::redirect('verify-token.php');
            } elseif (!empty($login['message']) && $login['message'] == 'logged-in' && $login['no_logins'] == 'Y') {
                $_SESSION["register_uniq"] = md5(uniqid(mt_rand(), true));
                Link::redirect('first_login.php');
            } elseif (!empty($login['message']) && $login['message'] == 'logged-in') {
                $_SESSION["register_uniq"] = md5(uniqid(mt_rand(), true));
                Link::redirect('account.php');
            }
        } elseif (!$login || !empty($login['error'])) {
            Errors::add(Lang::string('login-invalid-login-error'));
        }
    }
}
if (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'registered') {
    Messages::add(Lang::string('register-success'));
}
$_SESSION["register_uniq"] = md5(uniqid(mt_rand(), true));
include 'includes/head.php';
?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
echo Lang::string('home-login');
?>
</h1></div>
Esempio n. 22
0
                $query = API::send();
                $api_keys = $query['APIKeys']['get']['results'][0];
            } elseif ($_REQUEST['action'] == 'delete') {
                Link::redirect('api-access.php?message=delete');
            }
        } else {
            $request_2fa = true;
        }
    }
}
if (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'edit') {
    Messages::add(Lang::string('api-edit-message'));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'delete') {
    Messages::add(Lang::string('api-delete-message'));
} elseif (!empty($_REQUEST['error']) && $_REQUEST['error'] == 'delete') {
    Errors::add(Lang::string('api-delete-error'));
}
$page_title = Lang::string('api-access-setup');
include 'includes/head.php';
?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
echo $page_title;
?>
</h1></div>
        <div class="pagenation">&nbsp;<a href="index.php"><?php 
echo Lang::string('home');
?>
</a> <i>/</i> <a href="account.php"><?php 
echo Lang::string('account');
Esempio n. 23
0
        $captcha_error = empty($_REQUEST['forgot']['captcha']) || !$securimage->check($_REQUEST['forgot']['captcha']);
    } else {
        $captcha = new Form('captcha');
        $captcha->reCaptchaCheck(1);
        if (!empty($captcha->errors) && is_array($captcha->errors)) {
            $captcha_error = true;
            Errors::add($captcha->errors['recaptcha']);
        }
    }
    if (!$captcha_error) {
        API::add('User', 'resetUser', array($email1));
        $query = API::send();
        Messages::$messages = array();
        Messages::add(Lang::string('login-password-sent-message'));
    } else {
        Errors::add(Lang::string('login-capcha-error'));
    }
}
$_SESSION["forgot_uniq"] = md5(uniqid(mt_rand(), true));
include 'includes/head.php';
?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
echo Lang::string('login-forgot');
?>
</h1></div>
        <div class="pagenation">&nbsp;<a href="index.php"><?php 
echo Lang::string('home');
?>
</a> <i>/</i> <a href="forgot.php"><?php 
Esempio n. 24
0
    Messages::add(Lang::string('transactions-orders-new-message'));
}
if (!empty($_REQUEST['edit_order']) && !$trans_realized1) {
    Messages::add(Lang::string('transactions-orders-edit-message'));
} elseif (!empty($_REQUEST['new_order']) && $trans_realized1 > 0) {
    Messages::add(str_replace('[transactions]', $trans_realized1, Lang::string('transactions-orders-done-message')));
} elseif (!empty($_REQUEST['edit_order']) && $trans_realized1 > 0) {
    Messages::add(str_replace('[transactions]', $trans_realized1, Lang::string('transactions-orders-done-edit-message')));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'order-doesnt-exist') {
    Errors::add(Lang::string('orders-order-doesnt-exist'));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'not-your-order') {
    Errors::add(Lang::string('orders-not-yours'));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'order-cancelled') {
    Messages::add(Lang::string('orders-order-cancelled'));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'deleteall-error') {
    Errors::add(Lang::string('orders-order-cancelled-error'));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'deleteall-success') {
    Messages::add(Lang::string('orders-order-cancelled-all'));
}
$page_title = Lang::string('open-orders');
$_SESSION["openorders_uniq"] = md5(uniqid(mt_rand(), true));
if (!$bypass) {
    include 'includes/head.php';
    ?>
<div class="page_title">
	<div class="container">
		<div class="title"><h1><?php 
    echo $page_title;
    ?>
</h1></div>
        <div class="pagenation">&nbsp;<a href="<?php 
Esempio n. 25
0
<?php

define('NO_LOGIN_REQUIRE', TRUE);
require 'conf/conf.php';
if (isset($_GET['action']) && !empty($_GET['action']) && $_GET['action'] == 'logOut') {
    $_SESSION = array();
    Utils::redirect('connexion');
}
if (!empty($_SESSION['customer']['utilisateur']) && !empty($_SESSION['customer']['motDePasse'])) {
    Utils::redirect('home');
}
if (!empty($_POST)) {
    if (isset($_POST['submit'])) {
        $controle = new Errors();
        if (empty($_POST['codeClient'])) {
            $controle->add('Veuillez saisir votre code client', 'codeClient');
        }
        if (empty($_POST['motDePasse'])) {
            $controle->add('Veuillez saisir votre mot de passe', 'motDePasse');
        }
        if ($controle->isEmpty()) {
            $utilisateur = $_POST['codeClient'];
            $motDePasse = $_POST['motDePasse'];
            $customer = UtilisateursManager::getUtilisateurByCodeClientAndPassword($utilisateur, $motDePasse);
            if ($customer) {
                $_SESSION['customer']['idClient'] = $customer->getIdUtilisateur();
                $_SESSION['customer']['codeClient'] = $customer->getCodeClient();
                $_SESSION['customer']['codeClient'] = $customer->getCodeClient();
                $_SESSION['customer']['motDePasse'] = $customer->getMotDePasse();
                $_SESSION['customer']['nom'] = $customer->getNom();
                $_SESSION['customer']['prenom'] = $customer->getPrenom();