Location: PHPKode > scripts > GigKalender > functions/import/12/gigs.php
<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
        $daten = fgetcsv($datei, 10000, ';');
        while ($daten)
        {
         if ($daten[0]!='ID')
         {
          $amountDaten = count($daten);
          for ($i=0; $i<$amountDaten;$i++)
          {
            $daten[$i] = str_replace("'","\'",$daten[$i]);
          }
          if ( $daten[20]=='' ) { echo 'ERROR: GigStatus is empty! ('.$daten[0].')<br />'; }
          // Import Venues
            $VenueArray = array ( '', $daten[8], $daten[9], $daten[2], $daten[3], $daten[4], $daten[5]);
            if ( $VenueArray[1]=='' )
                $VenueArray[1] = getLocationString($VenueArray[3], $VenueArray[4], $VenueArray[5], $VenueArray[6]);
            if (!isVenueInDatabase($VenueArray[1]))
            {
              if ( !addVenue ( $VenueArray, 'add' ) )
              {
                $ImportFehler++;
                echo '<span class="ERROR">ERROR: Importing Venue! ('.$daten[0].')</span><br />';
              }
              $GigVenueID = mysql_insert_id();
            }
            else $GigVenueID = getVenueVarFromVenueVar ( 'VenueName', $daten[8], 'VenueID');
          // Import Organizer
            $OrganizerArray = array ( '', $daten[11], $daten[12]);
            if ( $OrganizerArray[1]=='' AND $OrganizerArray[1]!='')
              $OrganizerArray[1] = 'unknown';
            if (!isOrganizerInDatabase($OrganizerArray[1]) AND $OrganizerArray[1]!='')
            {
              if ( !addOrganizer ( $OrganizerArray, 'add' ) )
              {
                $ImportFehler++;
                echo '<span class="ERROR">ERROR: Importing Organizer! ('.$daten[0].')</span><br />';
              }
              $GigOrganizerID = mysql_insert_id();
            }
            else $GigOrganizerID = getOrganizerVarFromOrganizerVar ( 'OrganizerName', $OrganizerArray[1], 'OrganizerID');

          // Import Artist
            $ArtistArray = array ( '', $daten[23], $daten[24]);
            // optimize String
              $amountGigArrayItems = count($ArtistArray);
              for ($i=0; $i<$amountGigArrayItems; $i++)
                $ArtistArray[$i] = optimizeImportString ($ArtistArray[$i]);
            if ( $ArtistArray[1]=='' AND $ArtistArray[1]!='')
              $ArtistArray[1] = 'unknown';
            if (!isArtistInDatabase($ArtistArray[1]) AND $ArtistArray[1]!='')
            {
              if ( !addArtist ( $ArtistArray, 'add' ) )
              {
                $ImportFehler++;
                echo '<span class="ERROR">ERROR: Importing Artist! ('.$daten[0].')</span><br />';
              }
              $GigArtistID = mysql_insert_id();
            }
            else $GigArtistID = getArtistVarFromArtistVar ( 'ArtistName', $ArtistArray[1], 'ArtistID');
          // Import Gigs
            $GigDate = convertISO8601ToTimestamp ( $daten[1]);
            $GigDateDay = date('d', $GigDate);
            $GigDateMonth = date('m', $GigDate);
            $GigDateYear = date('Y', $GigDate);
            $GigArray = array ( $daten[0], $GigDateDay, $GigDateMonth, $GigDateYear, $daten[6], $daten[7], $daten[10],
                            $daten[13], $daten[14], $daten[15], $daten[16], $daten[17], $daten[18], $daten[19],
                            $daten[20], $daten[21], $daten[22], convertISO8601ToTimestamp($daten[25]),
                            $daten[26], $daten[27], convertISO8601ToTimestamp($daten[28]),
                            $GigVenueID, $GigOrganizerID, $GigArtistID );
            // optimize String
              $amountGigArrayItems = count($GigArray);
              for ($i=0; $i<$amountGigArrayItems; $i++)
                $GigArray[$i] = optimizeImportString ($GigArray[$i]);
            if ( !addGig ( $GigArray, 'add' ) )
            {
              $ImportFehler++;
              echo '<span class="ERROR">ERROR: Importing Gig! ('.$daten[0].')</span><br />';
            }
        }
        $daten = fgetcsv($datei, 10000, ';');
      }
?>
Return current item: GigKalender