function deletePicture($imageId, $db, $access, $userId, $deleteOriginal) { try { $filePath = getFilePath($imageId, $db, $userId); $sql = "SELECT * FROM picture\n\t\t\t\t\tJOIN pictureset ON picture.pictureset = pictureset.id\n\t\t\t\t\tWHERE picture.id = ?;"; $sth = $db->prepare($sql); $sth->bindParam(1, $imageId); $sth->execute(); $result = $sth->fetch(); $imagesetId = $result['id']; /** * If user owns picture, OR is admin with accesslevel 1 */ if (($result['person'] == $userId || $access == 1) && isset($result['pictureSet'])) { $sql2 = "SELECT * FROM pictureOrder \n\t\t\t\t\t\tWHERE picture = ?"; $sth2 = $db->prepare($sql2); $sth2->bindParam(1, $imageId); $sth2->execute(); /** **\ * Deletes picture if it doesnt exist in a pictureOrder * */ if (!$sth2->fetch()) { //Picture is not in a set, will then be deleted! $sql3 = ""; if ($deleteOriginal == 0) { //Happens when deleting single images $sql3 = "DELETE FROM picture\n\t\t\t\t\t\t\t\tWHERE id = ? AND isOriginal = 0"; } else { if ($deleteOriginal == 1) { //Happens when deleting whole imagesets $sql3 = "DELETE FROM picture\n\t\t\t\t\t\t\t\tWHERE id = ?"; } } $sth3 = $db->prepare($sql3); $sth3->bindParam(1, $imageId); $sth3->execute(); //Checks if the picture got deleted $sql4 = "SELECT * FROM picture WHERE id = ?"; $sth4 = $db->prepare($sql); $sth4->bindParam(1, $imageId); $sth4->execute(); if ($sth4->rowCount() == 0) { //Picture got deleted! $sql5 = "UPDATE pictureset\n\t\t\t\t\t\t\t\tSET pictureAmount=(pictureAmount-1)\n\t\t\t\t\t\t\t\tWHERE id = ?"; $sth5 = $db->prepare($sql5); $sth5->bindParam(1, $imagesetId); $sth5->execute(); unlink($filePath); } } } } catch (Exception $ex) { json_encode(0); } }
function getPhoto($chat_id) { $out = json_decode(file_get_contents($GLOBALS['api'] . '/getUserProfilePhotos?user_id=' . $chat_id), TRUE); if (!$out['result']['photos']['0']['0']['file_id']) { mysql_query("UPDATE `users` SET `avatarka`='no.jpg' WHERE `telegram_id`='" . $chat_id . "'"); return; } $path = getFilePath($out['result']['photos']['0']['0']['file_id']); $file = 'https://api.telegram.org/file/bot' . $GLOBALS['access_token'] . '/' . $path; $newfile = $chat_id . '.jpg'; mysql_query("UPDATE `users` SET `avatarka`='" . $newfile . "' WHERE `telegram_id`='" . $chat_id . "'"); copy($file, $newfile); }
function getFileSysName($id) { if ($id == -1) { return ""; } if (mysql_num_rows($result = mysql_query("SELECT * FROM `amsn_files` WHERE id=" . $id . ";")) != 1) { return ""; } else { $row = mysql_fetch_assoc($result); if ($row['filename'] !== '') { return getFilePath($row['filename']); } else { return $row['url']; } } }
function treatURLUploadForm() { if (isset($_POST['url'])) { // Here we get the file name $filename = $_POST['url']; $ch = curl_init($_POST['url']); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = curl_exec($ch); curl_close($ch); $headers = explode("\n", $headers); foreach ($headers as $header) { $header = trim($header); if (strncasecmp($header, "Content-Disposition:", 20) == 0) { $content = explode(";", $header); foreach ($content as $tag) { $tag = trim($tag); if (strncasecmp($tag, "filename=", 9) == 0) { $filename = trim(substr($tag, 9)); if (substr($filename, 0, 1) == '"' && substr($filename, strlen($filename) - 1, 1) == '"') { $filename = substr($filename, 1, strlen($filename) - 2); } } } } } $filename = basename($filename); if (copy($_POST['url'], getFilePath($filename))) { $q = mysql_query("SELECT * FROM `amsn_files` WHERE id = " . (int) $_POST['id'] . ";"); $row = mysql_fetch_assoc($q); if ($row['filename'] != '') { unlink(getFilePath($row['filename'])); } if (mysql_query("UPDATE `amsn_files` SET filename = '" . $filename . "', `url` = '', `lastmod` = NOW() WHERE id = '" . (int) $_POST['id'] . "' LIMIT 1")) { return array('success' => "File {$filename} successfully modified"); } else { #echo mysql_error(); return array('error' => "There was an error when trying to update the database registry"); } } else { return array('error' => "Copy file error"); } } }
/** * 获取API格式数据 * * @return array */ public function formatToApi() { if ($this->employee) { $employeeInfo = $this->employeeInfo->simpleFormatToApi(); } else { $employeeInfo = NULL; } if ($this->employer) { $employerInfo = $this->employerInfo->simpleFormatToApi(); } else { $employerInfo = NULL; } $path = 'http://' . $_SERVER['HTTP_HOST']; if (!empty($this->voice)) { $voice = getFilePath($this->voice, 'voice'); } else { $voice = $this->voice; } $employerComment = $this->employerComment($this->employer, $this->id); $employeeComment = $this->employeeComment($this->employee, $this->id); // print_r($employerComment);exit; // 雇主的评论 if ($employerComment) { $this->ercomment_id = $employerComment->id; $employer_comment = $this->ercommentInfo->formatToApi(); } else { $employer_comment = NULL; } // 雇员的评论 if ($employeeComment) { $this->eecomment_id = $employeeComment->id; $employee_comment = $this->eecommentInfo->formatToApi(); } else { $employee_comment = NULL; } if ($this->serviceInfo) { $service_type = $this->serviceInfo->formatToApi(); } else { $service_type = NULL; } return array('id' => $this->id, 'order_sn' => $this->order_sn, 'order_status' => $this->order_status, 'pay_code' => $this->pay_code, 'employer' => $employerInfo, "employee" => $employeeInfo, 'offer_price' => $this->offer_price, 'appointment_time' => $this->appointment_time, 'transaction_price' => $this->transaction_price, 'service_type' => $service_type, 'location' => apiLocation($this->location), 'to' => apiLocation($this->to), 'rank' => $this->rank, 'accept_time' => apiTime($this->accept_time), 'push_number' => $this->push_number, 'duration' => $this->duration, 'content' => array('text' => $this->text, 'voice' => $voice), 'employer_comment' => $employer_comment, 'employee_comment' => $employee_comment, 'created_at' => apiTime($this->created_at)); // return $this->user; }
/** * Collects all the files in a directory and puts them into a single * returned string. Recursive. * * Directory path is relative to env.php. */ static function collectDir($dname) { $directory = getFilePath() . "/{$dname}"; $dir = dir($directory); $l = array(); while ($f = $dir->read()) { if (is_dir("{$directory}/{$f}")) { if (!preg_match("/^\\./", $f)) { $l[] = self::collectDir("{$dname}/{$f}"); } } else { $l[] = self::getContents("{$dname}/{$f}"); } } $dir->close(); return join("\n\n", $l); }
if (!empty($package) && !SCRIPT_LOCKED) { ?> <form method="post" action="index.php?package=<?php echo $package; ?> &step=<?php echo $nextstep; ?> "> <div class="border"> <h3><?php echo $steps[$step]; ?> </h3> <?php include getFilePath($package, $step); ?> </div> </form> <?php } elseif (!SCRIPT_LOCKED) { ?> <?php if (version_compare(PHP_VERSION, '5.0.0', '<') && empty($_REQUEST['skip_php'])) { ?> <div class="border"> <h3>Error: PHP Version mismatch</h3> <div class="bbody"> Support for PHP 4 has been discontinued since Viscacha 0.8 RC7.<br /> Please consider upgrading to (the latest version of) PHP 5 or you can't use Viscacha. </div>
function treatURLUploadForm($prefix) { $field_name = $prefix . 'url'; if (isset($_POST[$field_name])) { // Here we get the file name $filename = $_POST[$field_name]; $ch = curl_init($_POST[$field_name]); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = curl_exec($ch); curl_close($ch); $headers = explode("\n", $headers); foreach ($headers as $header) { $header = trim($header); if (strncasecmp($header, "Content-Disposition:", 20) == 0) { $content = explode(";", $header); foreach ($content as $tag) { $tag = trim($tag); if (strncasecmp($tag, "filename=", 9) == 0) { $filename = trim(substr($tag, 9)); if (substr($filename, 0, 1) == '"' && substr($filename, strlen($filename) - 1, 1) == '"') { $filename = substr($filename, 1, strlen($filename) - 2); } } } } } $filename = basename($filename); if (copy($_POST[$field_name], getFilePath($filename))) { if (!mysql_num_rows($q = mysql_query("SELECT id FROM `amsn_files` WHERE `filename` = '" . $filename . "';"))) { if (mysql_query("INSERT INTO `amsn_files` (filename,lastmod) VALUES ('" . $filename . "',NOW());")) { return array('id' => mysql_insert_id(), 'name' => $filename); } else { unlink(getFilePath($filename)); return array('error' => mysql_error()); } } else { $row = mysql_fetch_assoc($q); return array('id' => $row['id'], 'name' => $filename); } } else { return array('error' => "Copy file error"); } } }
} else { $gorev = "goster"; } } $itemId = JRequest::getVar('Itemid'); $itemId = isset($itemId) ? $itemId : JRequest::getVar('prevItemId'); $itemIdStr = isset($itemId) ? '&prevItemId=' . $itemId : ''; $itemIdStrOrj = isset($itemId) ? '&Itemid=' . $itemId : ''; if ($gorev == "goster") { formGoster($itemIdStr); } else { if ($gorev == "hepsi") { hepsiIleListele($itemIdStrOrj); } else { if ($gorev == "indir") { $file = getFilePath(JRequest::getVar('denetimId')); if ($file != -1) { FormFactory::readFileFromDB($file); } } } } function formGoster($itemIdStr) { $db =& JFactory::getOracleDBO(); ?> <form action="index.php?option=com_denetim_ara<?php echo $itemIdStr; ?> " method="post"><input type="hidden" value="hepsi" name="gorev" />
<?php include '../../_logger.php'; $caller = "checkFiles.php"; $files = getFilePath($_REQUEST["filename"], $caller); if (file_exists($files)) { //echo "$files exists"; $node = '<files>yes</files>'; } else { //echo "$files does not exist"; $node = '<files>no</files>'; } $result = '<root>' . $node . '</root>'; //return $result; echo "{$result}"; function getFilePath($rawFilePath, $caller) { include '../../_paths.php'; logit($caller, "getFilePath:" . $rawFilePath); if ($rawFilePath == "''" || $rawFilePath == "") { return $rawFilePath; } $path_info = pathinfo($rawFilePath); $fileExtension = $path_info['extension']; // get file extension logit($caller, "File Extension:" . $fileExtension); if ($fileExtension == "flv" || $fileExtension == "f4v") { $rawFilePath = $videoRootPath . $rawFilePath; logit($caller, "Regular Video file extension:" . $fileExtension . ". Returning path:" . $rawFilePath); } else { logit($caller, "Non video file extension:" . $fileExtension . ". Returning same path");
if (!file_exists($sResourcePath)) { $oS3Object->getObject(Phpfox::getParam('core.amazon_bucket'), $sLocalPath, $sResourcePath); } $sResourcePath = $sTmpImage; } elseif (is_numeric(strpos($sImage, Phpfox::getParam('core.path')))) { $sResourcePath = PHPFOX_DIR . $sLocalPath; } else { if (!file_exists($sResourcePath)) { grabImage($sImage, $sResourcePath); } } return array($sResourcePath, $sDestPath); } // File name & location $sExt = ''; list($sImage, $sOutputFile) = getFilePath($sImage); $sOutputFile .= PHPFOX_DS . $sDesFile; if (!file_exists($sImage)) { header('HTTP/1.0 404 Not Found'); exit; } // Check file existance if (!file_exists($sOutputFile)) { $oResize = new resize($sImage); $oResize->resizeImage($iWidth, $iHeight, $sOption); $oResize->saveImage($sOutputFile, 100); } // return image ob_clean(); header('Content-Type: image/' . $sExt); echo file_get_contents($sOutputFile);
} else { echo $val; } echo '</li>'; } ?> </ul> <?php } ?> </div> <div id="content"> <?php if (!empty($package) && !SCRIPT_LOCKED) { ?> <form method="post" action="index.php?package=<?php echo $package;?>&step=<?php echo $nextstep; ?>"> <div class="border"> <h3><?php echo $steps[$step]; ?></h3> <?php include(getFilePath($package, $step)); ?> </div> </form> <?php } elseif (!SCRIPT_LOCKED) { ?> <?php if (version_compare(PHP_VERSION, '5.0.0', '<') && empty($_REQUEST['skip_php'])) { ?> <div class="border"> <h3>Error: PHP Version mismatch</h3> <div class="bbody"> Support for PHP 4 has been discontinued since Viscacha 0.8 RC7.<br /> Please consider upgrading to (the latest version of) PHP 5 or you won't be able to use Viscacha. </div> <div class="bfoot center"><a class="submit" href="index.php?skip_php=1">Continue anyway</a></div> </div> <?php } else { ?> <div class="border"> <h3>Viscacha Setup</h3>
/** * Save page. * @param array $fields * @return bool */ function savePageContent($fields) { if (@get_magic_quotes_gpc()) { $fields = array_map(stripslashes, $fields); } $file = getFilePath($fields['title']); $do = file_put_contents($file, trim($fields['content'])); if ($do) { header("Location: ./?" . titleToId($fields['title'])); exit; } else { return false; } }