Contact_AddressBook
[ class tree: Contact_AddressBook ] [ index: Contact_AddressBook ] [ all elements ]

Source for file action-import.php

Documentation is available at action-import.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */
  3.  
  4. // Ignore this line.
  5. include_once 'include/head.php';
  6.  
  7. if (isset($_POST['submit'])) {
  8.     $error = false;
  9.     if ($_POST['mode'== 'sim'{
  10.         include_once 'include/simulations.php';
  11.         if (!isset($GLOBALS['_Contact_AddressBook_simulations'][$_POST['simId']])) {
  12.             print 'Error: no simulation file selected';
  13.             $error = true;
  14.         else {
  15.             $file dirname(__FILE__'/files/' .
  16.                     $GLOBALS['_Contact_AddressBook_simulations'][$_POST['simId']]['file'];
  17.             $format $GLOBALS['_Contact_AddressBook_simulations'][$_POST['simId']]['format'];
  18.         }
  19.     else {
  20.         if (isset($_FILES['file'])) {
  21.             if ($_FILES['file']['error'!== 0{
  22.                 print 'An error occurs when uploading file';
  23.                 $error = true;
  24.             else {
  25.                 $file $_FILES['file']['tmp_name'];
  26.                 $format $_POST['format'];
  27.             }
  28.         }
  29.     }
  30.  
  31.     if (!$error{
  32.         // Load the Contact_AddressBook.
  33.         require_once 'Contact/AddressBook.php';
  34.  
  35.         // Create a new instance of Contact_AddressBook object.
  36.         $cab = new Contact_AddressBook;
  37.  
  38.         // Call the import method.
  39.         $res $cab->importFromFile($file$format);
  40.  
  41.         // Done!
  42.         print '<h3>File contents</h3>' "\n";
  43.         print '<pre>';
  44.         print htmlspecialchars(file_get_contents($file));
  45.         print '</pre>';
  46.  
  47.         print '<h3>Converted data</h3>' "\n";
  48.         print '<pre>';
  49.         var_export($res);
  50.         print '</pre>';
  51.     }
  52. }
  53.  
  54. // Ignore this line.
  55. include_once 'include/footer.php';
  56.  
  57. /*
  58.  * Local variables:
  59.  * mode: php
  60.  * tab-width: 4
  61.  * c-basic-offset: 4
  62.  * c-hanging-comment-ender-p: nil
  63.  * End:
  64.  */
  65. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.