function uploadNewPics($overRideThumb = false) { global $config; $thumbOnly = $config->uploadThumbOnly; $PicIDs = array(); if ($thumbOnly && !$overRideThumb) { $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where ThumbUpload=0"; $result = getSQLResult("uploadNewPics 1", $query); for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) { $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime); } foreach ($PicIDs as $PicID => $values) { $filename = $values["Filename"]; make_thumb($filename, "/dev/shm/upload/thumb.jpg", 240); $pic = file_get_contents("/dev/shm/upload/thumb.jpg"); $upload = uploadPic($pic, $values['PictureTime'], true, $PicID); if ($upload) { $query = "update Motion set ThumbUpload=1 where MID=?"; $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID); } } } else { $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where FullUpload=0"; $result = getSQLResult("uploadNewPics 2", $query); for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) { $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime); } foreach ($PicIDs as $PicID => $values) { $filename = $values["Filename"]; $pic = file_get_contents($filename); logMessage("Found pic to upload PicID={$PicID} filename={$filename}, size=" . strlen($pic)); $upload = uploadPic($pic, $values['PictureTime'], false, $PicID); if ($upload) { $query = "update Motion set ThumbUpload=1,FullUpload=1 where MID=?"; $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID); } } } }
<?php function getSQLResult($sql) { return mysql_fetch_array(full_query($sql)); } require_once dirname(__FILE__) . '/../../../dbconnect.php'; require_once dirname(__FILE__) . '/../../../includes/functions.php'; require_once dirname(__FILE__) . '/lib.php'; session_start(); $user_id = $_SESSION["uid"]; $vm_id = $_GET["id"]; // Check VM access $sql = sprintf("SELECT \n service_id \n FROM \n tblonappservices \n LEFT JOIN tblhosting ON tblhosting.id = service_id \n WHERE \n userid = '%s' \n AND vm_id = '%s';", stripcslashes($user_id), stripcslashes($vm_id)); $sql_result = getSQLResult($sql); if (!isset($sql_result["service_id"])) { die("Access denied to this Console"); } else { $service_id = $sql_result["service_id"]; } unset($sql); unset($sql_result); // Load VM server id $service = get_service($service_id); $onapp_config = get_onapp_config($service['serverid']); $user = get_onapp_client($service_id); if (!$onapp_config) { die("Can't found active OnApp server #" . addslashes($server_id) . " in Data Base"); } // Load VM $vm = new OnApp_VirtualMachine();