function generatePDFReport($report, $results)
 {
     $types = self::get_report_column_types($report->getId());
     eval('$managerInstance = ' . $report->getObjectType() . "::instance();");
     $externalCols = $managerInstance->getExternalColumns();
     $filename = str_replace(' ', '_', $report->getName()) . date('_YmdHis');
     $pageLayout = $_POST['pdfPageLayout'];
     $fontSize = $_POST['pdfFontSize'];
     include_once LIBRARY_PATH . '/pdf/fpdf.php';
     $pdf = new FPDF($pageLayout);
     $pdf->setTitle($report->getName());
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', $fontSize);
     $pdf->Cell(80);
     $report_title = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($report->getName(), ENT_COMPAT));
     $pdf->Cell(30, 10, $report_title);
     $pdf->Ln(20);
     $colSizes = array();
     $maxValue = array();
     $fixed_col_sizes = array();
     foreach ($results['rows'] as $row) {
         $i = 0;
         foreach ($row as $k => $value) {
             if (!isset($maxValue[$i])) {
                 $maxValue[$i] = '';
             }
             if (strlen(strip_tags($value)) > strlen($maxValue[$i])) {
                 $maxValue[$i] = strip_tags($value);
             }
             $i++;
         }
     }
     $k = 0;
     foreach ($maxValue as $str) {
         $col_title_len = $pdf->GetStringWidth($results['columns'][$k]);
         $colMaxTextSize = max($pdf->GetStringWidth($str), $col_title_len);
         $db_col = $results['columns'][$k];
         $colType = array_var($types, array_var($results['db_columns'], $db_col, ''), '');
         if ($colType == DATA_TYPE_DATETIME && !($report->getObjectType() == 'ProjectEvents' && $results['db_columns'][$db_col] == 'start')) {
             $colMaxTextSize = $colMaxTextSize / 2;
             if ($colMaxTextSize < $col_title_len) {
                 $colMaxTextSize = $col_title_len;
             }
         }
         $fixed_col_sizes[$k] = $colMaxTextSize;
         $k++;
     }
     $fixed_col_sizes = self::fix_column_widths($pageLayout == 'P' ? 172 : 260, $fixed_col_sizes);
     $max_char_len = array();
     $i = 0;
     foreach ($results['columns'] as $col) {
         $colMaxTextSize = $fixed_col_sizes[$i];
         $colFontSize = $colMaxTextSize + 5;
         $colSizes[$i] = $colFontSize;
         $col_name = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($col, ENT_COMPAT));
         $pdf->Cell($colFontSize, 7, $col_name);
         $max_char_len[$i] = self::get_max_length_from_pdfsize($pdf, $colFontSize);
         $i++;
     }
     $lastColX = $pdf->GetX();
     $pdf->Ln();
     $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
     foreach ($results['rows'] as $row) {
         $i = 0;
         $more_lines = array();
         $col_offsets = array();
         foreach ($row as $k => $value) {
             if ($k == 'link') {
                 $value = strip_tags($value);
                 $cell = $value;
             } else {
                 $cell = $this->format_value_to_print($k, $value, $types[$k], $report->getObjectType());
             }
             $cell = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($cell, ENT_COMPAT));
             $splitted = self::split_column_value($cell, $max_char_len[$i]);
             $cell = $splitted[0];
             if (count($splitted) > 1) {
                 array_shift($splitted);
                 $ml = 0;
                 foreach ($splitted as $sp_val) {
                     if (!isset($more_lines[$ml]) || !is_array($more_lines[$ml])) {
                         $more_lines[$ml] = array();
                     }
                     $more_lines[$ml][$i] = $sp_val;
                     $ml++;
                 }
                 $col_offsets[$i] = $pdf->x;
             }
             $pdf->Cell($colSizes[$i], 7, $cell);
             $i++;
         }
         foreach ($more_lines as $ml_values) {
             $pdf->Ln();
             foreach ($ml_values as $col_idx => $col_val) {
                 $pdf->SetX($col_offsets[$col_idx]);
                 $pdf->Cell($colSizes[$col_idx], 7, $col_val);
             }
         }
         $pdf->Ln();
         $pdf->SetDrawColor(220, 220, 220);
         $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
         $pdf->SetDrawColor(0, 0, 0);
     }
     $filename = ROOT . "/tmp/" . gen_id() . ".pdf";
     $pdf->Output($filename, "F");
     download_file($filename, "application/pdf", $report->getName(), true);
     unlink($filename);
     die;
 }
示例#2
0
/**
 * Process a pull request creation or update event.
 *
 * @param object $payload
 *   The received data.
 */
function handle_pull_request($payload)
{
    $issue_number = get_issue_number($payload->pull_request);
    if (!$issue_number) {
        exit;
    }
    $pull_request_url = $payload->pull_request->html_url;
    switch ($payload->action) {
        case 'synchronize':
            $comment = '<a href="' . $payload->sender->html_url . '">' . $payload->sender->login . '</a> pushed some commits to the <a href="' . $pull_request_url . '">pull request</a>.' . "\n\nFor an interdiff please see the <a href=\"" . $pull_request_url . "/commits\">list of recent commits</a>.";
            break;
        case 'opened':
            $comment = '<a href="' . $payload->pull_request->user->html_url . '">' . $payload->pull_request->user->login . '</a> opened a <a href="' . $pull_request_url . '">new pull request</a> for this issue.';
            break;
        default:
            // Unknown action, so we just exit.
            exit;
    }
    // Get node metadata to append comment number to patch file name.
    $issue_meta = get_issue_meta($issue_number);
    if (!empty($issue_meta['comment_count'])) {
        $file_name = $issue_number . '-' . ($issue_meta['comment_count'] + 1) . '.patch';
    } else {
        $file_name = "{$issue_number}.patch";
    }
    $diff_url = $payload->pull_request->diff_url;
    // Download the patch.
    $file = download_file($diff_url, $file_name);
    post_comment($issue_number, $comment, $file);
    // Cleanup: remove the downloaded file and the temporary directory it is in.
    unlink($file);
    rmdir(dirname($file));
}
示例#3
0
function get_result($id)
{
    $result = Resources::get_result($id);
    if ($result["success"] == false) {
        show_message("Operation failed with status code " . $result['status-code']);
        return;
    }
    download_file($result['data'], $id . ".zip", "application/zip");
}
function download_fonts($pack)
{
    if (!isset($pack['fonts'])) {
        return;
    }
    foreach ($pack['fonts'] as $font) {
        download_file(github_or_network_for($font, $pack), get_libs_dir() . $pack['name'] . '/fonts/' . basename($font));
    }
}
示例#5
0
 public function pre_process($person)
 {
     parent::pre_process($person);
     $res = false;
     if ($this->person->isAuth()) {
         if (isset($_GET['file_cert'])) {
             $authKey = Input::sanitizeCertKey($_GET['file_cert']);
             try {
                 $cert = $this->ca->getCert($authKey);
                 if (isset($cert) && $cert->isValid()) {
                     include 'file_download.php';
                     download_file($cert->getPEMContent(), 'usercert.pem');
                     exit(0);
                 }
             } catch (ConfusaGenException $cge) {
                 Framework::error_output($this->translateMessageTag('downl_err_nodownload') . " " . htmlentities($cge->getMessage()));
             }
         } else {
             if (isset($_GET['cert_status'])) {
                 $this->pollCertStatusAJAX(Input::sanitizeCertKey($_GET['cert_status']));
             } else {
                 if (isset($_GET['certlist_all'])) {
                     $this->showAll = $_GET['certlist_all'] == "true";
                 } else {
                     if (isset($_GET['revoke']) && $_GET['revoke'] == 'revoke_single') {
                         $order_number = Input::sanitizeCertKey($_GET['order_number']);
                         /* sanitized by checking inclusion in the REVOCATION_REASONS
                          * array
                          */
                         if (!array_key_exists('reason', $_GET)) {
                             Framework::error_output($this->translateMessageTag('rev_err_singlenoreason'));
                             return;
                         }
                         $reason = Input::sanitizeText(trim($_GET['reason']));
                         try {
                             if (!isset($order_number) || !isset($reason)) {
                                 Framework::error_output("Revoke Certificate: Errors with parameters, not set properly");
                             } elseif (!$this->checkRevocationPermissions($order_number)) {
                                 Framework::error_output($this->translateMessageTag('rev_err_singlenoperm'));
                             } elseif (!$this->ca->revokeCert($order_number, $reason)) {
                                 Framework::error_output($this->translateMessageTag('rev_err_notyet1') . htmlentities($order_number) . $this->translateMessageTag('rev_err_notyet2') . htmlentities($reason));
                             } else {
                                 Framework::message_output($this->translateMessageTag('rev_suc_single1') . htmlentities($order_number) . $this->translateMessageTag('rev_suc_single2'));
                                 if (Config::get_config('ca_mode') === CA_COMODO && Config::get_config('capi_test') === true) {
                                     Framework::message_output($this->translateTag('l10n_msg_revsim1', 'revocation'));
                                 }
                             }
                         } catch (ConfusaGenException $cge) {
                             Framework::error_output($this->translateMessageTag('rev_err_singleunspec') . " " . htmlentities($cge->getMessage()));
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
示例#6
0
文件: Backup.php 项目: rodino25/tsv2
 public function download($type = '')
 {
     requireadmin();
     $q = $this->input->get('q');
     if ($type == 'files') {
         if (is_file('backup/files/' . $q)) {
             download_file('backup/files/' . $q, $q);
         }
     } else {
         if (is_file('backup/database/' . $q)) {
             download_file('backup/database/' . $q, $q);
         }
     }
 }
示例#7
0
文件: download.php 项目: philum/cms
function plug_download($p, $o)
{
    $dir = 'plug/_data/' . ses('qb') . '_';
    $f = base64_decode($p);
    if ($f != "../" && strpos($f, "params") === false && is_file($f)) {
        //nb_of_dwnl
        $nm = rednm($f);
        $nmf = $nm . '.txt';
        if (is_file($dir . $nmf)) {
            $nb = read_file($dir . $nmf);
        }
        write_file($dir . $nmf, $nb = $nb ? $nb + 1 : 1);
        //clients
        $arr = array($f, hostname());
        $dy = date('ymd-hi', time());
        download_eye($arr, $dy);
        download_file($f, $nm);
    }
}
示例#8
0
 public function file($id = 0)
 {
     $myID = getUserID();
     $query = $this->mdb->get_attachment($id);
     if ($query->num_rows()) {
         $row = $query->row();
         if (validate_access('valid_member', array('project_id' => $row->project_id, 'user_id' => $myID)) || $row->uploader == $myID) {
             $filepath = 'uploads/files/' . $row->uploader . '/' . $row->filepath;
             if (is_file($filepath)) {
                 download_file($filepath, $row->filename);
             } else {
                 echo 'File does not exists in server.';
             }
         } else {
             echo 'You are not allowed to download this file.';
         }
     } else {
         echo 'file does not exists.';
     }
 }
 /**
  * View single attachment (basically, load it and forward it to the user)
  *
  * @param void
  * @return null
  */
 function view()
 {
     if ($this->active_attachment->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_attachment->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     // Fix problem with non-ASCII characters in IE
     $filename = $this->active_attachment->getName();
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
         $filename = urlencode($filename);
     }
     // if
     $as_attachment = $this->request->get('disposition', 'attachment') == 'attachment';
     download_file($this->active_attachment->getFilePath(), $this->active_attachment->getMimeType(), $filename, $as_attachment);
     die;
 }
示例#10
0
function process_job(&$jobData)
{
    $data = json_decode($jobData->getData());
    if (!is_array($data)) {
        echo "Found bad job:\n";
        print_r($data);
        echo "\n";
        bs()->delete($jobData);
        continue;
    }
    echo "===============================================\n";
    echo "# Beginning job\n";
    print_r($data);
    foreach ($data as $job) {
        // Get the instagram access token for this user ID
        $user = ORM::for_table('users')->where('instagram_user_id', $job->object_id)->find_one();
        if ($user) {
            if ($user->micropub_success) {
                // Retrieve recent photos for the user after the time specified in the post
                // https://api.instagram.com/v1/users/self/media/recent?min_timestamp=1394295266
                $timestamp = $job->time;
                $media_id = $job->data->media_id;
                if ($photo = IG\get_photo($user, $media_id)) {
                    $entry = h_entry_from_photo($user, $photo);
                    $photo_url = $photo->images->standard_resolution->url;
                    // Download the photo to a temp folder
                    echo "Downloading photo...\n";
                    $filename = download_file($photo_url);
                    if (property_exists($photo, 'videos')) {
                        $video_url = $photo->videos->standard_resolution->url;
                        echo "Downloading video...\n";
                        $video_filename = download_file($video_url, 'mp4');
                    } else {
                        $video_filename = false;
                    }
                    // Send the photo to the micropub endpoint
                    echo "Sending photo" . ($video_filename ? " and video" : "") . " to micropub endpoint: " . $user->micropub_endpoint . "\n";
                    // Collapse category to a comma-separated list if they haven't upgraded yet
                    if ($user->send_category_as_array != 1) {
                        if ($entry['category'] && is_array($entry['category']) && count($entry['category'])) {
                            $entry['category'] = implode(',', $entry['category']);
                        }
                    }
                    print_r($entry);
                    echo "\n";
                    $response = micropub_post($user->micropub_endpoint, $user->micropub_access_token, $entry, $filename, $video_filename);
                    print_r($response);
                    echo "\n";
                    unlink($filename);
                    if ($video_filename) {
                        unlink($video_filename);
                    }
                    // Store the request and response from the micropub endpoint in the DB so it can be displayed to the user
                    $user->last_micropub_response = json_encode($response);
                    $user->last_instagram_photo = $photo->id;
                    $user->last_photo_date = date('Y-m-d H:i:s');
                    $user->save();
                    /*
                    // Add the link to the photo caption
                    
                    $comment_text = '';
                    
                    if($photo->caption && $photo->caption->id) {
                      $comment_id = $photo->caption->id;
                      $comment_text = $photo->caption->text;
                    
                      // Now delete the comment (caption) if there is one
                      $result = IG\delete_comment($user, $media_id, $comment_id);
                      print_r($result);
                    }
                    
                    // Re-add the caption with the citation 
                    $canonical = 'http://aaron.pk/xxxxx';
                    $comment_text .= ' ('.$canonical.')';
                    $result = IG\add_comment($user, $media_id, $comment_text);
                    print_r($result);
                    */
                }
            } else {
                echo "This user has not successfully completed a test micropub post yet\n";
            }
        } else {
            echo "No user account found for Instagram user " . $job->object_id . "\n";
        }
    }
    echo "# Job Complete\n-----------------------------------------------\n\n";
    bs()->delete($jobData);
}
	function download_exported_file() {
		$filename = array_var($_SESSION, 'contact_export_filename', '');
		if ($filename != '') {
			$path = ROOT.'/tmp/'.$filename;
			$size = filesize($path);
                        
			if (isset($_SESSION['fname'])) {
				$name = $_SESSION['fname'];
				unset($_SESSION['fname']);
			}
			else $name = (array_var($_SESSION, 'import_type', 'contact') == 'contact' ? 'contacts.csv' : 'companies.csv');
			
			unset($_SESSION['contact_export_filename']);
			unset($_SESSION['import_type']);
			download_file($path, 'text/csv', $name, $size, true);
			unlink($path);
			die();			
		} else $this->setTemplate('csv_export');
	}
示例#12
0
 function downloadFromHttp()
 {
     $file = basename($this->main->download_url_f);
     if (!$file) {
         throw new lxexception('please_type_the_full_url_including_file_name', '');
     }
     $fullpath = $this->main->getFullPath() . "/" . $file;
     check_file_if_owned_by_and_throw($fullpath, $this->main->__username_o);
     if (lxfile_exists($fullpath) && !$this->main->isOn('download_overwrite_f')) {
         throw new lxexception('file_exists', '', $file);
     }
     download_file($this->main->download_url_f, $fullpath);
     return $fullpath;
 }
示例#13
0
									        <td>' . $row['dia'] . '</td>
									        <td>' . $row['total'] . '</td>
									        <td>' . $row['hr'] . '</td>
									        <td>' . $row['descueto'] . '</td>
									      </tr>';
        }
        $codigoHTML .= '
									</table>
									</div>
									</body>
									</html>';
        $dompdf = new DOMPDF();
        $dompdf->load_html($codigoHTML);
        $dompdf->render();
        file_put_contents('./reportes/reporte.pdf', $dompdf->output());
        download_file("reportes/reporte.pdf", "reporte4.pdf");
    } else {
        echo "<script>\r\n\t\t\t\t\t\t\t    swal(\"!Vacio¡\", \"No hay datos\", \"warning\");\r\n\t\t\t\t\t\t\t    </script>";
    }
    $conn->close();
}
?>
				<hr>
				<center>
				<table id="tabla1" border="1" width="100%">
				<tr>
				<th>Nombre</th>
				<th>Dias laborados</th>
				<th>Total (Q)</th>
				<th>Total (hr)</th>
				<th>Total descuentos(Q)</th>
示例#14
0
copy(__DIR__ . "/launcher.cpp", "{$bundle_file}.app/Contents/MacOS/launcher.cpp");
copy(__DIR__ . "/launcher.sh", "{$bundle_file}.app/Contents/MacOS/launcher.sh");
copy(__DIR__ . "/shell_header.txt", "{$bundle_file}.app/Contents/MacOS/shell_header.txt");
chdir(__DIR__);
chdir("../../");
copy("artwork/icon.icns", $cwd . "/{$bundle_file}.app/Contents/Resources/icon.icns");
chdir("{$cwd}/{$bundle_file}.app/Contents/MacOS");
// Compile the bundle launcher
exec("g++ -mmacosx-version-min=10.5 launcher.cpp -o launcher");
chdir(__DIR__);
// Download and compile php if not already compiled
if (!is_dir("php")) {
    $php_src_dir = str_replace(".tar.bz2", "", $php_file);
    if (!file_exists($php_src_dir)) {
        print "Downloading php source from {$php_mirror_provider}...\n\n";
        download_file($php_mirror, $php_file);
        print "Uncompressing {$php_file}...\n\n";
        exec("tar -xjf {$php_file}");
        unlink($php_file);
    }
    chdir($php_src_dir);
    $php_prefix = str_replace($php_src_dir, "php", getcwd());
    $php_configure = 'CFLAGS="-mmacosx-version-min=10.5" ' . 'CXXFLAGS="-mmacosx-version-min=10.5" ' . './configure ' . '--prefix="' . $php_prefix . '" ' . '--disable-cgi ' . '--enable-maintainer-zts ' . '--enable-ftp ' . '--enable-zip ' . '--enable-pcntl ' . '--enable-shmop ' . '--enable-sockets ' . '--enable-sysvmsg ' . '--enable-sysvsem ' . '--enable-sysvshm ' . '--enable-mysqlnd ' . '--enable-mbstring ' . '--with-pdo-mysql ' . '--with-zlib ' . '--with-bz2 ' . '--with-curl ';
    print "Starting configure script with:\n";
    print $php_configure . "\n\n";
    exec($php_configure);
    print "Modifying main/build-defs.h paths to be relative...\n\n";
    $build_defs = file_get_contents("main/build-defs.h");
    $build_defs = str_replace($php_prefix, "./php", $build_defs);
    file_put_contents("main/build-defs.h", $build_defs);
    print "Compiling php...\n\n";
示例#15
0
    if ($user = require_login($app)) {
        $user->send_category_as_array = 1;
        $user->save();
        $app->response()->body(json_encode(array('result' => 'ok')));
    }
});
$app->post('/micropub/test', function () use($app) {
    if ($user = require_login($app)) {
        $params = $app->request()->params();
        if ($user->send_category_as_array != 1) {
            if (is_array($params['category'])) {
                $params['category'] = implode(',', $params['category']);
            }
        }
        // Download the file to a temp folder
        $filename = download_file($params['url']);
        // Now send to the micropub endpoint
        $r = micropub_post($user->micropub_endpoint, $user->micropub_access_token, $params, $filename);
        $response = $r['response'];
        #unlink($filename);
        $user->last_micropub_response = json_encode($r);
        // Check the response and look for a "Location" header containing the URL
        if ($response && preg_match('/Location: (.+)/', $response, $match)) {
            $location = $match[1];
            $user->micropub_success = 1;
        } else {
            $location = false;
        }
        $user->save();
        $app->response()->body(json_encode(array('response' => htmlspecialchars($response), 'location' => $location, 'error' => $r['error'], 'curlinfo' => $r['curlinfo'], 'filename' => $filename)));
    }
示例#16
0
function install_playtomic($gameid)
{
    $table = '';
    $pre = 'ptomic';
    global $mysqli;
    $categories = array('Action' => 2, 'Adventure' => 3, 'Strategy' => 10, 'Multiplayer' => 2, 'Puzzle' => 1, 'Rhythm' => 7, 'Shooter' => 5, 'Sports' => 4, 'Other' => 7, 'RPG' => 3, 'Arcade' => 9, 'Driving' => 4, 'Defense' => 10, 'Rhythm' => 7, 'Education' => 7, 'Gadgets' => 1, 'Fighting' => 2, 'Dress Up' => 8, 'Board Game' => 7, 'Pimp & Customize' => 8, 'Pimp &amp; Customize' => 8);
    $query = yasDB_select("SELECT * FROM `playtomicfeed` WHERE `id` = '{$gameid}'", false);
    $result = $query->fetch_array(MYSQLI_ASSOC);
    $gamename = $result['name'];
    $thumburl = $result['thumburl'];
    $thumburl_200 = $result['thumbnail_200x200'];
    $screen1_thumb = '';
    $screen2_thumb = '';
    $screen3_thumb = '';
    $screen4_thumb = '';
    $gameurl = $result['gameurl'];
    $c = explode(",", $result['categories']);
    // Remove comma delimiter and seperate categories into array in order to insert single category.
    $category = $categories[$c[0]];
    $slug = str_replace(array('-', '_'), '', $result['slug']);
    // Download and save game file
    $game_file = $pre . "_" . $slug . "." . GetFileExtension($result['gameurl']);
    $game_url = '../swf/' . $game_file;
    download_file($gameurl, $game_url);
    $gamefile = 'swf/' . $game_file;
    // Download and save 100x100 thumbnail pic
    $smallthumb = $pre . "_" . $slug . "." . GetFileExtension($result['thumburl']);
    $sm_thumb = '../img/' . $smallthumb;
    download_file($thumburl, $sm_thumb);
    $gamethumb = 'img/' . $smallthumb;
    // Download and save 200x200 thumbnail pic
    $gamethumb200 = '';
    /*if(!empty($result['thumbnail_200x200']) || $type == 0) {
    		$t_url = str_replace("..", "", $result['thumbnail_200x200']);
    		$mediumthumb = $pre."_200_" . $slug . "." . GetFileExtension($result['thumbnail_200x200']);
    		$med_thumb = '../img/' . $mediumthumb;			
    		download_file($t_url, $med_thumb);
    		$gamethumb200 = 'img/' . $mediumthumb; 
    	} else {
    		$gamethumb200 = '';
    	}*/
    /////////////////////////////////////////////////////////////////////////////////////////////////
    // Remove code comment to download the game screen images - depends on availabilty in the feed //
    /////////////////////////////////////////////////////////////////////////////////////////////////
    /*
    // Download and save screen 1 pic
    if($result['screenthumburl1']) {
    	$t_url = str_replace("..", "", $result['screenthumburl1']);
    	$largethumb = $pre."_screen1_" . $slug . "." . GetFileExtension($result['screenthumburl1']);
    	$screen1_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen1_thumb);
    }	
    // Download and save screen 2 pic
    if($result['screenthumburl2']) {
    	$t_url = str_replace("..", "", $result['screenthumburl2']);
    	$largethumb = $pre."_screen2_" . $slug . "." . GetFileExtension($result['screenthumburl2']);
    	$screen2_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen2_thumb);
    }	
    // Download and save screen 3 pic
    if($result['screenthumburl3']) {
    	$t_url = str_replace("..", "", $result['screenthumburl3']);
    	$largethumb = $pre."_screen3_" . $slug . "." . GetFileExtension($result['screenthumburl3']);
    	$screen3_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen3_thumb);
    }	
    // Download and save screen 4 pic
    if($result['screenthumburl2']) {
    	$t_url = str_replace("..", "", $result['screenthumburl4']);
    	$largethumb = $pre."_screen4_" . $slug . "." . GetFileExtension($result['screenthumburl4']);
    	$screen4_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen4_thumb);
    }	
    */
    $desc = yasDB_clean($result['description']);
    // Prep for DB insert
    $instructions = yasDB_clean($result['instructions']);
    $keywords = $result['keywords'];
    $keywords = yasDB_clean($keywords);
    $gamename = yasDB_clean($gamename);
    $gamefile = yasDB_clean($gamefile);
    $gamethumb = yasDB_clean($gamethumb);
    $height = $result['height'];
    $width = $result['width'];
    $query->close();
    $query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`) VALUES (NULL, '{$gamename}', '{$desc}', '{$instructions}', '{$keywords}', '{$gamefile}', '{$height}', '{$width}', {$category}, 0, '', 'SWF', 'PLAYTOMIC', {$gameid}, '{$gamethumb}', '{$gamethumb200}', '{$screen1_thumb}', '{$screen2_thumb}','{$screen3_thumb}','{$screen4_thumb}')", false);
    if (!$query) {
        echo 'Error updating Games database';
        return false;
    }
    $query = yasDB_update("UPDATE `playtomicfeed` SET isinstalled = 1 WHERE id = '{$result['id']}'", false);
    if (!query) {
        echo 'Error updating $table database';
        return false;
    }
    return true;
}
示例#17
0
        $tn = $data['thumbnail'];
        $title = yasDB_clean($data['title']);
        $desc = yasDB_clean($data['description']);
        $keywords = yasDB_clean($data['keywords']);
        if (isset($_POST['name'])) {
            $name = yasDB_clean($_POST['name']);
        } else {
            if (isset($_SESSION['user'])) {
                $name = $_SESSION['user'];
            } else {
                $name = '';
            }
        }
        if (remoteFileExists($tn) === true) {
            $thumb = 'img/' . preg_replace('#\\W#', '', $title) . rand(0, pow(10, 5)) . '.' . get_file_extension($tn);
            download_file($tn, $setting['sitepath'] . '/' . $thumb);
        } else {
            $thumb = '';
        }
    }
    yasDB_insert("INSERT INTO games (title, description, category, thumbnail, keywords, file, height, width, type, active) values ('{$title}', '{$desc}', " . intval($_POST['category']) . ", '{$thumb}', '{$keywords}', '{$file}', {$height}, {$width}, '" . yasDB_clean($_POST['type']) . "', 1)", false);
    if (isset($_SESSION['user'])) {
        $user = yasDB_clean($_SESSION['user']);
        //yasDB_update("UPDATE `user` set videos = videos +1 WHERE username = '******'"); // add a video to users profile
    }
    echo '<center>Media successfully added!</font><br/>';
    echo '<a href="index.php?">Click here to proceed</a></center>';
} else {
    ?>
<div class="table">
        <form enctype="multipart/form-data" action="" method="post">
示例#18
0
 /**
  * @method download
  *
  * @author 云小印[yunyin.org]
  *
  * @param  $pid,$fid
  * @return $download_url
  */
 public function download()
 {
     $pid = pri_id(U('Index/index'));
     $fid = I('fid', null, 'intval');
     $map['pri_id'] = $pid;
     $map['id'] = $fid;
     $map['status'] = array('gt', 0);
     $File = M('File');
     $info = $File->where($map)->field('url,status,copies,ppt_layout,color,double_side,name')->find();
     if ($info) {
         if ($info['copies']) {
             $file_name = $info['copies'] . '份_' . ($info['double_side'] ? '双面_' : '单面_') . ($info['color'] ? '彩印_' : '黑白_');
             if ($ppt_layout = $info['ppt_layout']) {
                 $layouts = C('PPT_LAYOUT');
                 $file_name .= $layouts[$ppt_layout] . '版_';
             }
         } else {
             $file_name = '到店打印_';
         }
         $file_name = $file_name . "[{$fid}]" . $info['name'];
         redirect(download_file($info['url'], 'attname=' . urlencode($file_name)));
     } else {
         $this->error('文件已删除,不能再下载!');
     }
 }
示例#19
0
}
$message = "";
//set action to delete if delete was pressed instead of submit
if ($var['submit'] == _('Download') && $var['action'] == 'backup_list') {
    $var['action'] = 'download';
}
//set action to view if only id is set
if ($var['action'] == '' && $var['id']) {
    $var['action'] = 'browseserver';
}
//action actions
switch ($var['action']) {
    case 'download':
        $var['restore_path'] = backup_restore_locate_file($var['id'], $var['restore_path']);
        $_SESSION['backup_restore_path'] = $var['restore_path'];
        download_file($var['restore_path']);
        break;
    case 'upload':
        //make sure our file was uploaded
        if (!is_uploaded_file($_FILES['upload']['tmp_name'])) {
            $message = _('Error uploading file!');
            $var['action'] = '';
            break;
        }
        //ensure uploaded file is a valid tar file
        exec(fpbx_which('tar') . ' -tf ' . $_FILES['upload']['tmp_name'], $array, $ret_code);
        if ($ret_code !== 0) {
            $message = _('Error verifying uploaded file!');
            $var['action'] = '';
            break;
        }
示例#20
0
function install_mgfgame($gameid)
{
    global $mysqli;
    $query = yasDB_select("SELECT * FROM `mgffeed` WHERE `id` = '{$gameid}'", false);
    $result = $query->fetch_array(MYSQLI_ASSOC);
    // Download and save game file
    if ($result['file']) {
        $g_url = str_replace("..", "", $result['file']);
        $game_file = basename($g_url);
        $game_file = "mgf_" . $result['title'] . "." . GetFileExtension($result['file']);
        $game_url = '../swf/' . $game_file;
        download_file($g_url, $game_url);
    } else {
        return false;
    }
    // Download and save thumbnail pic
    if ($result['thumbnail']) {
        $t_url = str_replace("..", "", $result['thumbnail']);
        $smallthumb = "mgf_" . $result['title'] . "." . GetFileExtension($result['thumbnail']);
        $sm_thumb = '../img/' . $smallthumb;
        download_file($t_url, $sm_thumb);
    }
    $desc = yasDB_clean($result['description']);
    // Prep for DB insert
    $gamename = yasDB_clean($result['title']);
    $keywords = yasDB_clean($result['keywords']);
    $gamefile = yasDB_clean(str_replace("../", "", $game_url));
    $gamethumb = yasDB_clean(str_replace("../", "", $sm_thumb));
    $gamethumb200 = yasDB_clean(str_replace("../", "", $med_thumb));
    $height = intval($result['height']);
    $width = intval($result['width']);
    $instructions = yasDB_clean($result['instructions']);
    $keywords = yasDB_clean($result['keywords']);
    $category = $result['category'];
    $review = yasDB_clean($result['review']);
    $query->close();
    $query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `ismochi`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`, `review`, `active`) VALUES (NULL, '{$gamename}', '{$desc}', '{$instructions}', '{$keywords}', '{$gamefile}', {$height}, {$width}, {$category}, 0, '', 'SWF', 'OTHER', {$gameid}, '{$gamethumb}', 0, '{$gamethumb200}', '', '','','', '{$review}', 1)", false);
    if (!$query) {
        echo 'Error updating Games database';
        return false;
    }
    $query = yasDB_update("UPDATE mgffeed SET installed = '1' WHERE id = {$result['id']}", false);
    if (!$query) {
        echo 'Error updating mgffeed database';
        return false;
    }
    return true;
}
示例#21
0
    } else {
        $filename = BACKUP_PATH . clean_file_name(get_post('backups'));
        if (in_ajax()) {
            $Ajax->popup($filename);
        } else {
            header('Content-type: text/plain');
            header('Content-Length: ' . filesize($filename));
            header("Content-Disposition: inline");
            readfile($filename);
            exit;
        }
    }
}
if (get_post('download')) {
    if (get_post('backups')) {
        download_file(BACKUP_PATH . clean_file_name(get_post('backups')));
        exit;
    } else {
        display_error(_("Select backup file first."));
    }
}
page(_($help_context = "Backup and Restore Database"), false, false, '', '');
check_paths();
function check_paths()
{
    if (!file_exists(BACKUP_PATH)) {
        display_error(_("Backup paths have not been set correctly.") . _("Please contact System Administrator.") . "<br>" . _("cannot find backup directory") . " - " . BACKUP_PATH . "<br>");
        end_page();
        exit;
    }
}
             $final_address_details[] = sprintf(gettext("Entry added %s"), date('r'));
         }
     }
 } else {
     if ($_POST['type'] == "url" || $_POST['type'] == "url_ports") {
         $desc_fmt_err_found = false;
         /* item is a url type */
         for ($x = 0; $x < $max_alias_addresses - 1; $x++) {
             $_POST['address' . $x] = trim($_POST['address' . $x]);
             if ($_POST['address' . $x]) {
                 /* fetch down and add in */
                 $temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
                 unlink_if_exists($temp_filename);
                 $verify_ssl = isset($config['system']['checkaliasesurlcert']);
                 mkdir($temp_filename);
                 download_file($_POST['address' . $x], $temp_filename . "/aliases", $verify_ssl);
                 /* if the item is tar gzipped then extract */
                 if (stristr($_POST['address' . $x], ".tgz")) {
                     process_alias_tgz($temp_filename);
                 } else {
                     if (stristr($_POST['address' . $x], ".zip")) {
                         process_alias_unzip($temp_filename);
                     }
                 }
                 if (!isset($alias['aliasurl'])) {
                     $alias['aliasurl'] = array();
                 }
                 $alias['aliasurl'][] = $_POST['address' . $x];
                 if ($_POST["detail{$x}"] != "") {
                     if (strpos($_POST["detail{$x}"], "||") === false && substr($_POST["detail{$x}"], 0, 1) != "|" && substr($_POST["detail{$x}"], -1, 1) != "|") {
                         $final_address_details[] = $_POST["detail{$x}"];
示例#23
0
    case 'cdr_audio':
        include_once "{$action}.php";
        exit;
        break;
    case 'download_audio':
        $file = $dbcdr->getOne('SELECT recordingfile FROM ' . $db_name . '.' . $db_table_name . ' WHERE uniqueid = ?', array($_REQUEST['cdr_file']));
        db_e($file);
        if ($file) {
            $rec_parts = explode('-', $file);
            $fyear = substr($rec_parts[3], 0, 4);
            $fmonth = substr($rec_parts[3], 4, 2);
            $fday = substr($rec_parts[3], 6, 2);
            $monitor_base = $amp_conf['MIXMON_DIR'] ? $amp_conf['MIXMON_DIR'] : $amp_conf['ASTSPOOLDIR'] . '/monitor';
            $file = pathinfo($file, PATHINFO_EXTENSION) == 'wav49' ? pathinfo($file, PATHINFO_FILENAME) . '.WAV' : $file;
            $file = "{$monitor_base}/{$fyear}/{$fmonth}/{$fday}/" . $file;
            download_file($file, '', '', true);
        }
        exit;
        break;
    default:
        break;
}
// FREEPBX-8845
foreach ($_POST as $k => $v) {
    $_POST[$k] = preg_replace('/;/', ' ', $dbcdr->escapeSimple($v));
}
$h_step = 30;
if (!isset($_POST['need_csv'])) {
    ?>
	<h3><?php 
    echo _('CDR Reports');
示例#24
0
 function update()
 {
     if (!PRODUCTION) {
         // Don't want to ever run this in development
         die('good');
     }
     App::import('Vendor', 'bradleyboy/updater');
     $old_mask = umask(0);
     // Move these to off position in case we need to rollback
     $movers = array('app', 'm', 'cron.php', 'images.php', 'index.php', 'p.php', 'popup.php');
     foreach ($movers as $m) {
         $path = ROOT . DS . $m;
         $to = $path . '.off';
         if (is_dir($path)) {
             $f = new Folder($path);
             $f->move($to);
             if (is_dir($path)) {
                 umask($old_mask);
                 rollback($movers);
                 die('permfail');
             }
         } else {
             if (file_exists($path)) {
                 rename($path, $to);
                 if (file_exists($path)) {
                     umask($old_mask);
                     rollback($movers);
                     die('permfail');
                 }
             }
         }
     }
     $version = trim($this->Pigeon->version(true));
     if ((strpos($version, 'b') !== false || strpos($version, 'a') !== false) && BETA_TEST) {
         $core = 'http://www.sspdirector.com/zips/upgrade_beta.zip';
     } else {
         $core = 'http://www.sspdirector.com/zips/upgrade.zip';
     }
     $zip_helper = 'http://www.sspdirector.com/zips/pclzip.lib.txt';
     $local_core = ROOT . DS . 'core.zip';
     $local_helper = ROOT . DS . 'pclzip.lib.php';
     if (download_file($core, $local_core) && download_file($zip_helper, $local_helper)) {
         require $local_helper;
         $archive = new PclZip('core.zip');
         $archive->extract(PCLZIP_CB_POST_EXTRACT, 'extract_callback');
     } else {
         umask($old_mask);
         rollback($movers);
         die('permfail');
     }
     foreach ($movers as $m) {
         $path = ROOT . DS . $m;
         $to = $path . '.off';
         if (is_dir($to)) {
             $f = new Folder($path);
             $f->delete($to);
         } else {
             if (file_exists($to)) {
                 unlink($to);
             }
         }
     }
     unlink($local_core);
     unlink($local_helper);
     umask($old_mask);
     die('good');
 }
示例#25
0
    if ($dlinfo[2] == "this") {
        $mr = $MYSITE;
    } else {
        $mr = "http://{$dlinfo[2]}/";
    }
    // Check if that mirror really exists if not, bail out
    if (!isset($MIRRORS[$mr])) {
        error_nomirror($mr);
        exit;
    }
    // Start the download process
    include $_SERVER['DOCUMENT_ROOT'] . "/include/do-download.inc";
    $filename = get_actual_download_file($df);
    if ($filename) {
        status_header(200);
        download_file($mr, $filename);
    } else {
        status_header(404);
        /* The file didn't exist on this server.. ask the user to pick another mirror */
        include $_SERVER['DOCUMENT_ROOT'] . "/include/get-download.inc";
    }
    exit;
}
// php.net/42 --> likely a bug number
if (is_numeric($URI)) {
    mirror_redirect("http://bugs.php.net/bug.php?id={$URI}");
}
// ============================================================================
// Redirect if the entered URI was a PHP page name (except some pages,
// which we display in the mirror's language or the explicitly specified
// language [see below])
示例#26
0
function process_content($article)
{
    $image_types = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp');
    if (!empty($article->content)) {
        $md5 = md5($article->url);
        $article->md5 = $md5;
        $content = $article->content;
        unset($article->content);
        $json = json_encode($article);
        $domain = str_replace('www.', '', $article->domain);
        $domain = "<a href=\"{$article->url}\">{$domain}</a>";
        $meta = $article->author ? "By {$article->author}<span class=\"short-url\"> / {$domain}</span><div class=\"full-url\">{$article->url}</div>" : "<div class=\"short-url\">{$domain}</div><div class=\"full-url\">{$article->url}</div>";
        $content = <<<END
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{$article->title}</title>
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <style>
    
    body {
      text-align: center;
      margin: 0;
    }
    
    #article-{$md5} {
      font: 16px/24px serif;
      width: 100%;
      text-align: left;
      margin: 0 auto;
      padding-bottom: 25px;
    }
    
    #article-{$md5} a {
      color: #03C;
    }
    
    #article-{$md5} img {
      display: block;
      max-width: 100%;
      width: auto;
      height: auto;
    }
    
    #article-{$md5} > h1 {
      font: bold 24px/24px helvetica neue, helvetica, sans-serif;
      margin: 25px 0 10px 0;
    }
    
    #article-{$md5} > .meta {
      color: #666;
      font: 11px verdana, sans-serif;
      text-transform: uppercase;
      border-top: 1px solid #ccc;
      padding-top: 10px;
      padding-bottom: 10px;
    }
    
    #article-{$md5} > .meta .full-url {
      display: none;
    }
    
    #article-{$md5} > .meta a {
      color: #666;
    }
    
    #article-{$md5} > h1,
    #article-{$md5} > .meta,
    #article-{$md5} p {
      padding-left: 15px;
      padding-right: 15px;
    }
    
    #article-{$md5}-links {
      display: none;
      font-size: 9px;
      text-align: left;
      padding-left: 0;
      list-style-position: inside;
      border-top: 1px dotted #ccc;
      padding-top: 10px;
      margin-top: 20px;
    }
    
    #article-{$md5}-links li {
      margin-top: 5px;
      margin-left: 5px;
      padding-left: 0;
    }
    
    @media only screen and (min-width: 580px) {
      
      #article-{$md5} {
        width: 550px;
        padding-bottom: 50px;
      }
      
      #article-{$md5} > h1 {
        font: bold 30px/30px helvetica neue, helvetica, sans-serif;
        margin: 50px 0 10px 0;
      }
      
      #article-{$md5} {
        font: 16px/24px serif;
      }
      
      #article-{$md5} > h1,
      #article-{$md5} > .meta,
      #article-{$md5} p {
        padding-left: 0;
        padding-right: 0;
      }
      
    }
    
    @media print {
    
      #article-{$md5} {
        font: 12px/18px serif;
        padding-top: 0;
        padding-bottom: 0;
        column-count: 2;
        column-gap: 20px;
        -moz-column-count: 2;
        -moz-column-gap: 20px;
        -webkit-column-count: 2;
        -webkit-column-gap: 20px;
       counter-reset: link;
      }
      
      #article-{$md5}-links {
        display: block;
      }
      
      #article-{$md5} a[href] {
        color: #000;
        text-decoration: none;
        border-bottom: 1px dotted #ccc;
      }
      
      #article-{$md5} a[href]:after {
        counter-increment: link;
        content: counter(link);
        vertical-align: super;
        font-size: 50%;
        line-height: 0;
      }
      
      #article-{$md5} > h1 {
        font: bold 18px/18px helvetica neue, helvetica, sans-serif;
        margin-top: 0;
      }
      
      #article-{$md5} > .meta {
        font-size: 9px;
        text-transform: none;
      }
      
      #article-{$md5} > .meta .short-url {
        display: none;
      }
      
      #article-{$md5} > .meta .full-url {
        display: block;
      }
      
      #article-{$md5} > h1,
      #article-{$md5} > .meta,
      #article-{$md5} p {
        padding-left: 0;
        padding-right: 0;
      }
      
    }
    
    </style>
  </head>
  <body>
    <!-- occupy.here meta start -->
    <script id="meta">
    var meta = {$json};
    </script>
    <!-- occupy.here meta end -->
    <div id="article-{$md5}">
      <!-- occupy.here article start -->
      <h1>{$article->title}</h1>
      <div class="meta">
        {$meta}
      </div>
      <div class="content">
        {$content}
      </div>
      <!-- occupy.here article end -->
    </div>
    <ol id="article-{$md5}-links" class="article-links">
    </ol>
  </body>
</html>
END;
        $html = new simple_html_dom();
        $html->load($content, true, false);
        $images = array();
        foreach ($html->find('img') as $img) {
            $images[] = urldecode($img->src);
        }
        $image_data = array();
        foreach ($images as $url) {
            if (!preg_match('/\\.(\\w+)$/', $url, $matches)) {
                continue;
            }
            list(, $ext) = $matches;
            $ext = strtolower($ext);
            if (empty($image_types[$ext])) {
                continue;
            }
            $type = $image_types[$ext];
            $data = download_file($url);
            $tmp = tempnam(GRID_DIR . "/public/uploads/tmp", basename($url));
            file_put_contents($tmp, $data);
            list($width, $height) = getimagesize($tmp);
            unlink($tmp);
            $base64 = base64_encode($data);
            $data_url = "data:{$type};base64,{$base64}";
            if (!empty($data)) {
                $img_list = $html->find("img[src={$url}]");
                foreach ($img_list as $img) {
                    $img->src = $data_url;
                    $img->width = $width;
                    $img->height = $height;
                }
            }
        }
        $links = array();
        foreach ($html->find("#article-{$md5} .content a[href]") as $link) {
            $links[] = urldecode($link->href);
        }
        if (!empty($links)) {
            $links = '<li>' . implode("</li>\n<li>", $links) . "</li>\n";
            list($ol) = $html->find("#article-{$md5}-links");
            $ol->innertext = $links;
        } else {
            list($ol) = $html->find("#article-{$md5}-links");
            $ol->outertext = '';
        }
        return $html->save();
    }
}
示例#27
0
                echo mysql_error();
            }
        }
    }
}
if (!login_varify()) {
    exit;
}
if (isset($_POST['action'])) {
    if ($_POST['action'] == 'manage_blob') {
        main_menu();
        upload_download_delete_blob();
    }
    if ($_POST['action'] == 'upload_file') {
        main_menu();
        upload_file();
    }
    if ($_POST['action'] == 'download_file') {
        download_file();
    }
    if ($_POST['action'] == 'delete_file') {
        main_menu();
        delete_file();
    }
}
/*

echo '<pre>';
print_r($GLOBALS);
echo '</pre>';
*/
示例#28
0
    echo "</pre>\n";
}
$user = get_logged_in_user();
//print_r($user);
$user_submit = BoincUserSubmit::lookup_userid($user->id);
if (!$user_submit) {
    error_page("no job submission access");
}
$action = get_str('action', true);
if (!$action) {
    $action = post_str('action', true);
}
switch ($action) {
    case '':
        list_files($user, "");
        break;
    case 'upload_file':
        upload_file($user);
        break;
    case 'delete_file':
        delete_file($user);
        break;
    case 'download_file':
        download_file($user);
        break;
    case 'view_file':
        view_file($user);
        break;
    default:
        error_page("no such action: {$action}");
}
if (isset($_GET['file'])) {
    $file = $_GET['file'];
    $id_ebook = $_GET['id_ebook'];
    include "../admin_digilib/config/koneksi.php";
    $file_download = substr($file, 17);
    //menampilkan id_userlogin
    $select_id = mysql_query("SELECT * from digilib_userlogin where member_id='{$member_id}'");
    $row = mysql_fetch_assoc($select_id);
    $id = $row['id_userlogin'];
    //menampilkan id_ebook
    echo $file_download;
    $ip = ambil_ip();
    $date = date("Y-m-d h:i:s");
    $member_id = $_SESSION['member_id'];
    mysql_query("INSERT INTO digilib_statistikdownload values ('','{$date}','{$id}','{$id_ebook}','{$ip}','browser')");
    download_file($file);
}
function download_file($fullPath)
{
    if (headers_sent()) {
        die('Headers Sent');
    }
    if (ini_get('zlib.output_compression')) {
        ini_set('zlib.output_compression', 'Off');
    }
    if (file_exists($fullPath)) {
        $fsize = filesize($fullPath);
        $path_parts = pathinfo($fullPath);
        $ext = strtolower($path_parts["extension"]);
        switch ($ext) {
            case "pdf":
示例#30
0
function install_vascogame($gameid)
{
    global $mysqli;
    $query = yasDB_select("SELECT * FROM `vascogames` WHERE `id` = '{$gameid}'", false);
    $result = $query->fetch_array(MYSQLI_ASSOC);
    $categories = array('action games' => 2, 'adventure games' => 3, 'strategy games' => 10, 'skill games' => 10, 'puzzle games' => 1, 'arcade games' => 9, 'shooting games' => 5, 'sports games' => 4, 'misc games' => 7, 'car games' => 4);
    //Strategy
    // Download and save game file
    if ($result['file']) {
        $g_url = str_replace("..", "", $result['file']);
        $game_file = basename($g_url);
        $game_file = "vasco_" . preg_replace('#\\W#', '', $result['title']) . "." . GetFileExtension($result['file']);
        $game_url = '../swf/' . $game_file;
        download_file($g_url, $game_url);
    } else {
        return false;
    }
    // Download and save thumbnail pic
    if ($result['thumbnail']) {
        $t_url = str_replace("..", "", $result['thumbnail']);
        $smallthumb = "vasco_" . preg_replace('#\\W#', '', $result['title']) . "." . GetFileExtension($result['thumbnail']);
        $thumb = '../img/' . $smallthumb;
        download_file($t_url, $thumb);
    }
    $desc = yasDB_clean($result['description']);
    // Prep for DB insert
    $gamename = yasDB_clean($result['title']);
    $gamefile = yasDB_clean(str_replace("../", "", $game_url));
    $gamethumb = yasDB_clean(str_replace("../", "", $thumb));
    $height = $result['height'];
    $width = $result['width'];
    $c = $result['category'];
    $category = $categories[$c];
    $query->close();
    if ($category == null || $category == '' || $category == 0) {
        $category == 7;
    }
    $query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`) VALUES (NULL, '{$gamename}', '{$desc}', '', '', '{$gamefile}', {$height}, {$width}, {$category}, 0, '', 'SWF', 'VASCOGAMES', {$gameid}, '{$gamethumb}', '', '', '','','')", false);
    if (!$query) {
        echo 'Error updating Games database';
        return false;
    }
    $query = yasDB_update("UPDATE `vascogames` SET `installed` = 1 WHERE `id` = {$result['id']}", false);
    if (!query) {
        echo 'Error updating vascogames database';
        return false;
    }
    return true;
}