Ejemplo n.º 1
0
 // Large files are likely to take their time and memory. Let PHP know
 // that we'll take longer, and that the process should be recycled soon
 // to free up memory.
 @set_time_limit(0);
 @raise_memory_limit("192M");
 if (function_exists('apache_child_terminate')) {
     @apache_child_terminate();
 }
 // Create a unique temporary directory, to process the zip file
 // contents.
 $zipdir = my_mktempdir($CFG->dataroot . '/temp/', 'usrpic');
 if (!$mform->save_files($zipdir)) {
     notify(get_string('uploadpicture_cannotmovezip', 'admin'));
     @remove_dir($zipdir);
 } else {
     $dstfile = $zipdir . '/' . $mform->get_new_filename();
     if (!unzip_file($dstfile, $zipdir, false)) {
         notify(get_string('uploadpicture_cannotunzip', 'admin'));
         @remove_dir($zipdir);
     } else {
         // We don't need the zip file any longer, so delete it to make
         // it easier to process the rest of the files inside the directory.
         @unlink($dstfile);
         $results = array('errors' => 0, 'updated' => 0);
         process_directory($zipdir, $userfields[$userfield], $overwritepicture, $results);
         // Finally remove the temporary directory with all the user images and print some stats.
         remove_dir($zipdir);
         notify(get_string('usersupdated', 'admin') . ": " . $results['updated']);
         notify(get_string('errors', 'admin') . ": " . $results['errors']);
         echo '<hr />';
     }