Ejemplo n.º 1
0
     }
     break;
 case '/delete':
     echo "\nEnter the nickname you want to remove > ";
     $nickname = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));
         if ($check != 'yes') {
             echo "\nEnter the nickname you want to remove > ";
             $nickname = trim(fgets(STDIN));
         }
     } while ($check != 'yes');
     $numberToRemove = findPhoneByNickname($nickname);
     $w->sendSync([], [$numberToRemove], 3);
     $w->sendPresenceUnsubscription($numberToRemove);
     $contactsDB = __DIR__ . DIRECTORY_SEPARATOR . 'contacts.db';
     $cDB = new \PDO('sqlite:' . $contactsDB, null, null, [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
     $sql = 'DELETE FROM contacts WHERE nickname = :nickname';
     $query = $cDB->prepare($sql);
     $query->execute([':nickname' => $nickname]);
     break;
 case '/contacts':
     $show = true;
     break;
 case '/status':
     echo "\nEnter your status > ";
     $status = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));