Esempio n. 1
0
 public function errorMessages()
 {
     if (errorSending()) {
         if (empty($_POST['number'])) {
             $this->info['number'] = 'Numéro vide ! ';
         }
         if (empty($_POST['message'])) {
             $this->info['message'] = 'Message vide !';
         }
         formSetSessionValues();
     } else {
         if (errorContact()) {
             if (empty($_POST['number'])) {
                 $this->warn['number'] = 'Numéro vide ! ';
             }
             if (empty($_POST['name'])) {
                 $this->warn['name'] = 'Nom de la personne vide !';
             }
         } else {
             if (errorList()) {
                 if (empty($_POST['list'])) {
                     $this->listoff['list'] = 'Nom de la list vide ! ';
                 }
                 if (empty($_POST['number1'])) {
                     $this->listoff['number'] = 'Vous devez renseigner 1 numéro minimum !';
                 }
             }
         }
     }
 }
function form(&$err)
{
    if (isset($_POST)) {
        global $_POST;
    } else {
        return;
    }
    global $db;
    if (sending()) {
        $_SESSION = array();
        if (isset($_POST['flash'])) {
            $flash = ' -flash';
        } else {
            $flash = '';
        }
        if ($list = getlist($_POST['number'])) {
            foreach ($list->numbers as $no) {
                $err->out = Gammu::infiniteSend($_POST['message'], $no, $flash);
                if ($err->out != 0) {
                    $err->numberInError[] = getNameOf($no);
                }
            }
        } else {
            $users = $db->table('directory')->find();
            foreach ($users as $user) {
                if (isset($user->name) and $user->name == $_POST['number']) {
                    $_POST['number'] = $user->number;
                }
            }
            $_POST['number'] = str_replace(' ', '', $_POST['number']);
            $err->out = Gammu::send($_POST['message'], $_POST['number'], $flash);
            if ($err->out != 0) {
                formSetSessionValues();
            }
        }
    } else {
        if (saveContact()) {
            $_POST['number'] = str_replace(' ', '', $_POST['number']);
            $err->in = $db->table('directory')->insert($_POST);
        } else {
            if (saveList()) {
                $list = array("list" => $_POST['list']);
                $i = 1;
                while (isset($_POST['number' . $i])) {
                    if (!empty($_POST['number' . $i])) {
                        if ($number = getNumberOfName($_POST['number' . $i])) {
                            $list['numbers'][] = $number;
                        } else {
                            $list['numbers'][] = $_POST['number' . $i];
                        }
                    }
                    $i++;
                }
                $err->listin = $db->table('lists')->insert($list);
            } else {
                $err->errorMessages();
            }
        }
    }
}