How to use getAbsolutePath method of path class

Best Atoum code snippet using path.getAbsolutePath

ImageManagerPlugin.php

Source:ImageManagerPlugin.php Github

copy

Full Screen

...55 $file = $man->getFile($input["path"]);5657 /*58 if ($man->verifyFile($file, "edit") < 0) {59 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), $man->getInvalidFileMsg());60 return $result->toArray();61 }*/6263 $filedata = array();64 $filedata["path"] = $man->encryptPath($file->getAbsolutePath());65 $filedata["width"] = isset($input["width"]) ? $input["width"] : 0;66 $filedata["height"] = isset($input["height"]) ? $input["height"] : 0;67 $filedata["target"] = isset($input["target"]) ? $input["target"] : "";68 $filedata["temp"] = isset($input["temp"]) ? $input["temp"] : "";6970 $this->_resizeImage($man, $file, $filedata, $result);7172 return $result->toArray();7374 case "cropImage":75 $result = new Moxiecode_ResultSet("status,file,message");76 $file = $man->getFile($input["path"]);7778 /*79 if ($man->verifyFile($file, "edit") < 0) {80 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), $man->getInvalidFileMsg());81 return $result->toArray();82 }*/8384 $filedata = array();85 $filedata["path"] = $man->encryptPath($file->getAbsolutePath());86 $filedata["width"] = $input["width"];87 $filedata["height"] = $input["height"];88 $filedata["top"] = $input["top"];89 $filedata["left"] = $input["left"];90 $filedata["target"] = isset($input["target"]) ? $input["target"] : "";91 $filedata["temp"] = isset($input["temp"]) ? $input["temp"] : "";9293 $this->_cropImage($man, $file, $filedata, $result);9495 return $result->toArray();9697 case "rotateImage":98 $result = new Moxiecode_ResultSet("status,file,message");99 $file = $man->getFile($input["path"]);100101 /*102 if ($man->verifyFile($file, "edit") < 0) {103 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), $man->getInvalidFileMsg());104 return $result->toArray();105 }*/106107 $filedata = array();108 $filedata["path"] = $file->getAbsolutePath();109 $filedata["angle"] = $input["angle"];110 $filedata["target"] = isset($input["target"]) ? $input["target"] : "";111 $filedata["temp"] = isset($input["temp"]) ? $input["temp"] : "";112113 $this->_rotateImage($man, $file, $filedata, $result);114115 return $result->toArray();116117 case "flipImage":118 $result = new Moxiecode_ResultSet("status,file,message");119 $file = $man->getFile($input["path"]);120121 /*122 if ($man->verifyFile($file, "edit") < 0) {123 $result->add("ACCESS_ERROR", $man->encryptPath($file->getAbsolutePath()), $man->getInvalidFileMsg());124 return $result->toArray();125 }*/126127 $filedata = array();128 $filedata["path"] = $file->getAbsolutePath();129 $filedata["vertical"] = isset($input["vertical"]) ? $input["vertical"] : false;130 $filedata["horizontal"] = isset($input["horizontal"]) ? $input["horizontal"] : false;131 $filedata["target"] = isset($input["target"]) ? $input["target"] : "";132 $filedata["temp"] = isset($input["temp"]) ? $input["temp"] : "";133134 $this->_flipImage($man, $file, $filedata, $result);135136 return $result->toArray();137138 case "saveImage":139 $config = $man->getConfig();140 $result = new Moxiecode_ResultSet("status,file,message");141 $file = $man->getFile($input["path"]);142143 if (checkBool($config["general.demo"])) {144 $result->add("FAILED", $man->encryptPath($input["target"]), "{#error.demo}");145 $this->_cleanUp($man, $file->getParent());146 return $result->toArray();147 }148149 /*if ($man->verifyFile($file, "edit") < 0) {150 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), $man->getInvalidFileMsg());151 $this->_cleanUp($man, $file->getParent());152 return $result->toArray();153 }*/154155 $filedata = array();156 $filedata["path"] = $file->getAbsolutePath();157158 if (isset($input["target"]) && $input["target"] != "") {159 $targetFile = $man->getFile(utf8_encode($file->getParent()), $input["target"]);160 $filedata["target"] = utf8_encode($targetFile->getAbsolutePath());161 }162163 $this->_saveImage($man, $file, $filedata, $result);164 $this->_cleanUp($man, $file->getParent());165166 return $result->toArray();167 }168169 return null;170 }171172 /**173 * Gets called when data is streamed to client. This method should setup174 * HTTP headers, content type etc and simply send out the binary data to the client and the return false175 * ones that is done.176 *177 * @param MCManager $man MCManager reference that the plugin is assigned to.178 * @param string $cmd Stream command that is to be performed.179 * @param string $input Array of input arguments.180 * @return bool true/false if the execution of the event chain should continue.181 */182 function onStream(&$man, $cmd, $input) {183 switch ($cmd) {184 case "thumb":185 return $this->_streamThumb($man, $input);186 }187188 return null;189 }190191 /**192 * Gets called before a file action occurs for example before a rename or copy.193 *194 * @param ManagerEngine $man ManagerEngine reference that the plugin is assigned to.195 * @param int $action File action constant for example DELETE_ACTION.196 * @param BaseFile $file1 File object 1 for example from in a copy operation.197 * @param BaseFile $file2 File object 2 for example to in a copy operation. Might be null in for example a delete.198 * @return bool true/false if the execution of the event chain should continue.199 */200 function onBeforeFileAction(&$man, $action, $file1, $file2) {201 if ($action == DELETE_ACTION) {202 // Delete format images203 $config = $file1->getConfig();204205 if (checkBool($config['filesystem.delete_format_images'])) {206 $imageutils = new $config['thumbnail'];207 $imageutils->deleteFormatImages($file1->getAbsolutePath(), $config["upload.format"]);208 $imageutils->deleteFormatImages($file1->getAbsolutePath(), $config["edit.format"]);209 }210 }211212 return true;213 }214215 /**216 * Gets called after a file action was perforem for example after a rename or copy.217 *218 * @param MCManager $man MCManager reference that the plugin is assigned to.219 * @param int $action File action constant for example DELETE_ACTION.220 * @param string $file1 File object 1 for example from in a copy operation.221 * @param string $file2 File object 2 for example to in a copy operation. Might be null in for example a delete.222 * @return bool true/false if the execution of the event chain should continue.223 */224 function onFileAction(&$man, $action, $file1, $file2) {225 switch ($action) {226 case ADD_ACTION:227 $config = $file1->getConfig();228229 if ($config["upload.format"]) {230 $imageutils = new $config['thumbnail'];231 $imageutils->formatImage($file1->getAbsolutePath(), $config["upload.format"], $config['upload.autoresize_jpeg_quality']);232 }233234 if (checkBool($config["upload.create_thumbnail"]))235 $thumbnail = $this->_createThumb($man, $file1);236237 if (checkBool($config['upload.autoresize'])) {238 $ext = getFileExt($file1->getName());239240 if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png')))241 return true;242243 $imageInfo = @getimagesize($file1->getAbsolutePath());244 $fileWidth = $imageInfo[0];245 $fileHeight = $imageInfo[1];246247 $imageutils = new $config['thumbnail'];248 $percentage = min($config['upload.max_width'] / $fileWidth, $config['upload.max_height'] / $fileHeight);249250 if ($percentage <= 1)251 $result = $imageutils->resizeImage($file1->getAbsolutePath(), $file1->getAbsolutePath(), round($fileWidth * $percentage), round($fileHeight * $percentage), $ext, $config['upload.autoresize_jpeg_quality']);252 }253 break;254255 case DELETE_ACTION:256 $config = $file1->getConfig();257258 if ($config['thumbnail.delete'] == true) {259 $thumbnailFolder = $man->getFile(dirname($file1->getAbsolutePath()) ."/". $config['thumbnail.folder']);260 $thumbnailPath = $thumbnailFolder->getAbsolutePath() . "/" . $config['thumbnail.prefix'] . basename($file1->getAbsolutePath());261 $thumbnail = $man->getFile($thumbnailPath);262263 if ($thumbnail->exists())264 $thumbnail->delete();265266 // Check if thumbnail directory should be deleted267 if ($thumbnailFolder->exists()) {268 $files = $thumbnailFolder->listFiles();269270 if (count($files) == 0)271 $thumbnailFolder->delete();272 }273 }274275 break;276 }277278 return true; // Pass to next plugin279 }280281 /**282 * Gets called when custom data is to be added for a file custom data can for example be283 * plugin specific name value items that should get added into a file listning.284 *285 * @param MCManager $man MCManager reference that the plugin is assigned to.286 * @param BaseFile $file File reference to add custom info/data to.287 * @param string $type Where is the info needed for example list or info.288 * @param Array $custom Name/Value array to add custom items to.289 * @return bool true/false if the execution of the event chain should continue.290 */291 function onCustomInfo(&$man, &$file, $type, &$input) {292 // Is file and image293 $config = $file->getConfig();294 $input["editable"] = false;295296 if ($file->isFile() && ($type == "list" || $type == "insert" || $type == "info")) {297 // Should we get config on each file here?298 //$config = $file->getConfig();299 $ext = getFileExt($file->getName());300301 if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png', 'bmp')))302 return true;303304 $imageutils = new $config['thumbnail'];305 $canEdit = $imageutils->canEdit($ext);306307 $imageInfo = @getimagesize($file->getAbsolutePath());308309 $fileWidth = $imageInfo[0];310 $fileHeight = $imageInfo[1];311312 $targetWidth = $config['thumbnail.width'];313 $targetHeight = $config['thumbnail.height'];314315 // Check thumnail size316 if ($config['thumbnail.scale_mode'] == "percentage") {317 $percentage = min($config['thumbnail.width'] / $fileWidth, $config['thumbnail.height'] / $fileHeight);318319 if ($percentage <= 1) {320 $targetWidth = round($fileWidth * $percentage);321 $targetHeight = round($fileHeight * $percentage);322 } else {323 $targetWidth = $fileWidth;324 $targetHeight = $fileHeight;325 }326 }327328 $input["thumbnail"] = true;329330 // Check against config.331 if (($config["thumbnail.max_width"] != "" && $fileWidth > $config["thumbnail.max_width"]) || ($config["thumbnail.max_height"] != "" && $fileHeight > $config["thumbnail.max_height"]))332 $input["thumbnail"] = false;333 else {334 $input["twidth"] = $targetWidth;335 $input["theight"] = $targetHeight;336 }337338 // Get thumbnail URL339 if ($type == "insert") {340 $thumbFile = $man->getFile($file->getParent() . "/" . $config['thumbnail.folder'] . "/" . $config['thumbnail.prefix'] . $file->getName());341342 if ($thumbFile->exists())343 $input["thumbnail_url"] = $man->convertPathToURI($thumbFile->getAbsolutePath(), $config['preview.wwwroot']);344 }345346 $input["width"] = $fileWidth;347 $input["height"] = $fileHeight;348 $input["editable"] = $canEdit;349 }350351 return true;352 }353354 // * * * * * * * Private methods355356 /**357 * SaveImage358 * TODO: Check for PX or %359 */360 function _saveImage(&$man, &$file, &$filedata, &$result) {361 $config =& $file->getConfig();362363 // Find out if we have a temp file.364 $ext = getFileExt($file->getName());365366 if (!$man->isToolEnabled("edit", $config)) {367 trigger_error("{#error.no_access}", FATAL);368 die();369 }370371 // To file to save372 if (!$file->exists()) {373 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.file_not_exists}");374 return;375 }376377 if (strpos($file->getName(), "mcic_") !== 0)378 $tmpImage = "mcic_". md5(session_id() . $file->getName()) . "." . $ext;379 else380 $tmpImage = $file->getName();381382 $tempFile =& $man->getFile(utf8_encode(dirname($file->getAbsolutePath()) . "/" . $tmpImage));383 $tempFile->setTriggerEvents(false);384385 /*386 Failed when mcic_ was found due to exclude in filesystem conf387 if ($man->verifyFile($tempFile, "edit") < 0) {388 $result->add("FAILED", $man->encryptPath($tempFile->getAbsolutePath()), $man->getInvalidFileMsg());389 return;390 }391 */392393 // NOTE: add check for R/W394395 if ($tempFile->exists()) {396 if ($filedata["target"] != "") {397 $targetfile = $man->getFile($filedata["target"]);398399 // Delete format images400 $config = $targetfile->getConfig();401 $imageutils = new $config['thumbnail'];402 $imageutils->deleteFormatImages($targetfile->getAbsolutePath(), $config["upload.format"]);403404 // Just ignore it if it's the same file405 if ($tempFile->getAbsolutePath() != $targetfile->getAbsolutePath()) {406 if ($man->verifyFile($targetfile, "edit") < 0) {407 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());408 return;409 }410411 if ($targetfile->exists())412 $targetfile->delete();413414 $tempFile->renameTo($targetfile);415 $targetfile->importFile();416417 // Reformat418 if ($config["edit.format"]) {419 $imageutils = new $config['thumbnail'];420 $imageutils->formatImage($targetfile->getAbsolutePath(), $config["edit.format"], $config['edit.jpeg_quality']);421 }422 }423424 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.save_success}");425 } else {426 $file->delete();427 $tempFile->renameTo($file);428 $file->importFile();429430 $result->add("OK", $man->encryptPath($file->getAbsolutePath()), "{#message.save_success}");431 }432 } else {433 if ($filedata["target"] != "") {434 $targetfile = $man->getFile($filedata["target"]);435436 // Just ignore it if it's the same file437 if ($file->getAbsolutePath() != $targetfile->getAbsolutePath()) {438 if ($man->verifyFile($targetfile, "edit") < 0) {439 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());440 return;441 }442443 if ($targetfile->exists())444 $targetfile->delete();445446 $file->copyTo($targetfile);447 $targetfile->importFile();448 }449450 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.save_success}");451 } else {452 // No temp, no target, abort!453 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.save_failed}");454 }455 }456 }457458 /**459 * CropImage460 * TODO: Check for PX or %461 */462 function _cropImage(&$man, &$file, &$filedata, &$result) {463 $ext = getFileExt($file->getName());464 $config = $file->getConfig();465 $imageutils = new $config['thumbnail'];466467 if (!$man->isToolEnabled("edit", $config)) {468 trigger_error("{#error.no_access}", FATAL);469 die();470 }471472 // To file to crop473 if (!$file->exists()) {474 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.file_not_exists}");475 return;476 }477478 if ($filedata["temp"]) {479 if (strpos($file->getName(), "mcic_") !== 0)480 $tmpImage = "mcic_". md5(session_id() . $file->getName()) . "." . $ext;481 else482 $tmpImage = $file->getName();483484 $tempFile =& $man->getFile(dirname($file->getAbsolutePath()) . "/" . $tmpImage);485 $tempFile->setTriggerEvents(false);486487 $status = $imageutils->cropImage($file->getAbsolutePath(), $tempFile->getAbsolutePath(), $filedata["top"], $filedata["left"], $filedata["width"], $filedata["height"], $ext, $config["edit.jpeg_quality"]);488 if ($status) {489 $tempFile->importFile();490 $result->add("OK", $man->encryptPath($tempFile->getAbsolutePath()), "{#message.crop_success}");491 } else {492 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.crop_failed}");493 }494 } else {495 if (checkBool($config["general.demo"])) {496 $result->add("FAILED", $man->encryptPath($dir->getAbsolutePath()), "{#error.demo}");497 return $result->toArray();498 }499500 if ($filedata["target"] != "") {501 $targetfile = $man->getFile($filedata["target"]);502503 if ($targetfile->isDirectory()) {504 $targetfile = $man->getFile($man->addTrailingSlash($targetfile->getAbsolutePath()) . $file->getName());505 }506507 if ($man->verifyFile($targetfile, "edit") < 0) {508 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());509 return;510 }511 } else512 $targetfile = $file;513514 $status = $imageutils->cropImage($file->getAbsolutePath(), $targetfile->getAbsolutePath(), $filedata["top"], $filedata["left"], $filedata["width"], $filedata["height"], $ext, $config["edit.jpeg_quality"]);515516 if ($status) {517 $targetfile->importFile();518 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.crop_success}");519 } else {520 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), "{#error.no_access}");521 }522 }523 }524525 /**526 * ResizeImage527 */528 function _resizeImage(&$man, &$file, &$filedata, &$result) {529 $ext = getFileExt($file->getName());530 $config = $file->getConfig();531 $imageutils = new $config['thumbnail'];532533 if (!$man->isToolEnabled("edit", $config)) {534 trigger_error("{#error.no_access}", FATAL);535 die();536 }537 538 // To file to resize539 if (!$file->exists()) {540 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.file_not_exists}");541 return;542 }543544 if ($filedata["temp"]) {545 if (strpos($file->getName(), "mcic_") !== 0)546 $tmpImage = "mcic_". md5(session_id() . $file->getName()) . "." . $ext;547 else548 $tmpImage = $file->getName();549550 $tempFile =& $man->getFile(dirname($file->getAbsolutePath()) . "/" . $tmpImage);551 $tempFile->setTriggerEvents(false);552 553 $status = $imageutils->resizeImage($file->getAbsolutePath(), $tempFile->getAbsolutePath(), $filedata["width"], $filedata["height"], $ext, $config["edit.jpeg_quality"]);554 if ($status) {555 $tempFile->importFile();556 $result->add("OK", $man->encryptPath($tempFile->getAbsolutePath()), "{#message.resize_success}");557 } else {558 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.resize_failed}");559 }560 } else {561 if (checkBool($config["general.demo"])) {562 $result->add("FAILED", $man->encryptPath($dir->getAbsolutePath()), "{#error.demo}");563 return $result->toArray();564 }565566 if ($filedata["target"] != "") {567 $targetfile = $man->getFile($filedata["target"]);568569 if ($targetfile->isDirectory()) {570 $targetfile = $man->addTrailingSlash($man->getFile($targetfile->getAbsolutePath()) . $file->getName());571 }572573 if ($man->verifyFile($targetfile, "edit") < 0) {574 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());575 return;576 }577 } else578 $targetfile = $file;579580 $status = $imageutils->resizeImage($file->getAbsolutePath(), $targetfile->getAbsolutePath(), $filedata["width"], $filedata["height"], $ext, $config["edit.jpeg_quality"]);581582 if ($status) {583 $targetfile->importFile();584 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.resize_success}");585 } else {586 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), "{#error.resize_failed}");587 }588 }589 }590591 /**592 * RotateImage593 */594 function _rotateImage(&$man, &$file, &$filedata, &$result) {595 $ext = getFileExt($file->getName());596 $config = $file->getConfig();597 $imageutils = new $config['thumbnail'];598599 if (!$man->isToolEnabled("edit", $config)) {600 trigger_error("{#error.no_access}", FATAL);601 die();602 }603604 // To file to rotate605 if (!$file->exists()) {606 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.file_not_exists}");607 return;608 }609610 if ($filedata["temp"]) {611 if (strpos($file->getName(), "mcic_") !== 0)612 $tmpImage = "mcic_". md5(session_id() . $file->getName()) . "." . $ext;613 else614 $tmpImage = $file->getName();615616 $tempFile =& $man->getFile(dirname($file->getAbsolutePath()) . "/" . $tmpImage);617 $tempFile->setTriggerEvents(false);618619 $status = $imageutils->rotateImage($file->getAbsolutePath(), $tempFile->getAbsolutePath(), $ext, $filedata["angle"], $config["edit.jpeg_quality"]);620 if ($status) {621 $tempFile->importFile();622 $result->add("OK", $man->encryptPath($tempFile->getAbsolutePath()), "{#message.rotate_success}");623 } else {624 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.rotate_failed}");625 }626 } else {627 if (checkBool($config["general.demo"])) {628 $result->add("FAILED", $man->encryptPath($dir->getAbsolutePath()), "{#error.demo}");629 return $result->toArray();630 }631632 if ($filedata["target"] != "") {633 $targetfile = $man->getFile($filedata["target"]);634635 if ($targetfile->isDirectory()) {636 $targetfile = $man->addTrailingSlash($man->getFile($targetfile->getAbsolutePath()) . $file->getName());637 }638639 if ($man->verifyFile($targetfile, "edit") < 0) {640 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());641 return;642 }643 } else644 $targetfile = $file;645646 $status = $imageutils->rotateImage($file->getAbsolutePath(), $targetfile->getAbsolutePath(), $ext, $filedata["angle"], $config["edit.jpeg_quality"]);647648 if ($status) {649 $targetfile->importFile();650 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.rotate_success}");651 } else {652 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), "{#error.rotate_failed}");653 }654 }655 }656657 /**658 * FlipImage659 */660 function _flipImage(&$man, &$file, &$filedata, &$result) {661 $ext = getFileExt($file->getName());662 $config = $file->getConfig();663 $imageutils = new $config['thumbnail'];664665 if (!$man->isToolEnabled("edit", $config)) {666 trigger_error("{#error.no_access}", FATAL);667 die();668 }669670 // To file to flip671 if (!$file->exists()) {672 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.file_not_exists}");673 return;674 }675676 if ($filedata["temp"]) {677 if (strpos($file->getName(), "mcic_") !== 0)678 $tmpImage = "mcic_". md5(session_id() . $file->getName()) . "." . $ext;679 else680 $tmpImage = $file->getName();681682 $tempFile =& $man->getFile(dirname($file->getAbsolutePath()) . "/" . $tmpImage);683 $tempFile->setTriggerEvents(false);684 685 $status = $imageutils->flipImage($file->getAbsolutePath(), $tempFile->getAbsolutePath(), $ext, $filedata["vertical"], $filedata["horizontal"]);686 if ($status) {687 $tempFile->importFile();688 $result->add("OK", $man->encryptPath($tempFile->getAbsolutePath()), "{#message.flip_success}");689 } else {690 $result->add("FAILED", $man->encryptPath($file->getAbsolutePath()), "{#error.flip_failed}");691 }692 } else {693 if (checkBool($config["general.demo"])) {694 $result->add("FAILED", $man->encryptPath($dir->getAbsolutePath()), "{#error.demo}");695 return $result->toArray();696 }697698 if ($filedata["target"] != "") {699 $targetfile = $man->getFile($filedata["target"]);700701 if ($targetfile->isDirectory()) {702 $targetfile = $man->addTrailingSlash($man->getFile($targetfile->getAbsolutePath()) . $file->getName());703 }704705 if ($man->verifyFile($targetfile, "edit") < 0) {706 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), $man->getInvalidFileMsg());707 return;708 }709 } else710 $targetfile = $file;711712 $status = $imageutils->flipImage($file->getAbsolutePath(), $targetfile->getAbsolutePath(), $ext, $filedata["vertical"], $filedata["horizontal"], $config["edit.jpeg_quality"]);713714 if ($status) {715 $targetfile->importFile();716 $result->add("OK", $man->encryptPath($targetfile->getAbsolutePath()), "{#message.flip_success}");717 } else {718 $result->add("FAILED", $man->encryptPath($targetfile->getAbsolutePath()), "{#error.flip_failed}");719 }720 }721 }722723 /**724 * Clean up temp files, input is dir path.725 */726 function _cleanUp(&$man, $path) {727 $filedir =& $man->getFile($path);728 $config = $filedir->getConfig();729730 if ($man->verifyFile($filedir, "edit") < 0)731 return;732733 // If we can't access this dir, we just return.734 if (!$filedir->canWrite())735 return;736737 // Delete old files738 $files = $filedir->listFiles();739 foreach ($files as $file) {740 if (strpos($file->getName(), "mcic_") === 0 && time() - $file->getLastModified() > 3600) {741 $file->setTriggerEvents(false);742 $file->delete();743 }744 }745 }746747 /**748 * Lists file.749 */750 function _getMediaInfo(&$man, $input) {751 // Convert URL to path752 if (isset($input["url"])) {753 $url = parse_url($input["url"]);754 $input["path"] = $man->resolveURI($url["path"]);755756 if (!$man->verifyPath($input["path"]))757 trigger_error(sprintf("Could not resolve URL: %s to a filesystem path. Could be that the image is outside the configured filesystem.rootpath.", $input["url"]), FATAL);758 }759760 $file =& $man->getFile($input["path"]);761 $config = $file->getConfig();762 $parent =& $file->getParentFile();763 $files = array();764765 if ($parent->isDirectory()) {766 // Setup file filter767 $fileFilter = new Moxiecode_BasicFileFilter();768 //$fileFilter->setDebugMode(true);769 $fileFilter->setIncludeDirectoryPattern($config['filesystem.include_directory_pattern']);770 $fileFilter->setExcludeDirectoryPattern($config['filesystem.exclude_directory_pattern']);771 $fileFilter->setIncludeFilePattern($config['filesystem.include_file_pattern']);772 $fileFilter->setExcludeFilePattern($config['filesystem.exclude_file_pattern']);773 $fileFilter->setIncludeExtensions($config['filesystem.extensions']);774 $fileFilter->setOnlyFiles(true);775776 // List files777 $files =& $parent->listFilesFiltered($fileFilter);778 }779780 $match = false;781 $prev = "";782 $next = "";783784 foreach($files as $curfile) {785 if ($curfile->getAbsolutePath() == $file->getAbsolutePath()) {786 $match = true;787 continue;788 } else if (!$match)789 $prev = $curfile->getAbsolutePath();790791 if ($match) {792 $next = $curfile->getAbsolutePath();793 break;794 }795 796 }797 798 $ext = getFileExt($file->getName());799800 // Input default size?801 $width = "425";802 $height = "350";803804 // All types that getimagesize support 805 $imagearray = array('gif', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'jpc', 'jp2', 'jpx', 'jb2', 'swc', 'iff', 'wbmp', 'xbm');806807 if (in_array($ext, $imagearray)) {808 $sizeinfo = @getimagesize($file->getAbsolutePath());809 if ($sizeinfo) {810 $width = $sizeinfo[0];811 $height = $sizeinfo[1];812 }813 }814815 $result = new Moxiecode_ResultSet("name,path,url,size,type,created,modified,width,height,attribs,next,prev,custom");816 $custom = array();817 $man->dispatchEvent("onCustomInfo", array(&$file, "info", &$custom));818 $attribs = ($file->canRead() && checkBool($config["filesystem.readable"]) ? "R" : "-") . ($file->canWrite() && checkBool($config["filesystem.writable"]) ? "W" : "-");819 $url = $man->removeTrailingSlash($config['preview.urlprefix']) . $man->convertPathToURI($file->getAbsolutePath(), $config['preview.wwwroot']);820821 $result->add(822 utf8_encode($file->getName()),823 $man->encryptPath($file->getAbsolutePath()),824 utf8_encode($url),825 $file->getLength(),826 $ext,827 date($config['filesystem.datefmt'], $file->getCreationDate()),828 date($config['filesystem.datefmt'], $file->getLastModified()),829 $width,830 $height,831 $attribs,832 $man->encryptPath($next),833 $man->encryptPath($prev),834 $custom);835836 return $result->toArray();837 }838839 function _createThumb(&$man, &$file) {840 $config = $file->getConfig();841 $imageutils = new $config['thumbnail'];842 $ext = getFileExt($file->getName());843 $canEdit = $imageutils->canEdit($ext);844845 if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png', 'bmp')))846 return false;847848 // Check if we have an EXIF JPG file.849 if (($config['thumbnail.use_exif'] == true) && (function_exists("exif_thumbnail")) && (strtolower($ext) == "jpg" || strtolower($ext) == "jpeg")) {850 $image = @exif_thumbnail($file->getAbsolutePath(), $exif_width, $exif_height, $exif_type);851852 if ($image !== false)853 return false;854 }855856 // Check for thumbnails857 $havethumbnail = true;858859 // No folder or not enabled = no thumbnail, could check for thumbnail folder and delete it perhaps?860 if (($config['thumbnail.folder'] == "") || ($config['thumbnail.enabled'] == false))861 $havethumbnail = false;862863 // If we dont have GD we dont have a thumbnail.864 if (!$canEdit)865 $havethumbnail = false;866867 // Check so that we aren't inside a thumbnail folder.868 $parentFile = $file->getParentFile();869 if ($config['thumbnail.folder'] == $parentFile->getName())870 $havethumbnail = false;871872 // Ok, no thumbnail? Then lets just stream the original image.873 if (!$havethumbnail)874 return false;875876 // Ok, we have a thumbnail or should generate one, now lets check some stuff about it.877 $thumbnailFolder = $man->getFile(dirname($file->getAbsolutePath()) ."/". $config['thumbnail.folder']);878 879 if ((!$thumbnailFolder->exists()) && ($config['thumbnail.auto_generate'] == true))880 $thumbnailFolder->mkdir();881882 $thumbnailPath = $thumbnailFolder->getAbsolutePath() . "/" . $config['thumbnail.prefix'] . basename($file->getAbsolutePath());883 $thumbnail = $man->getFile(utf8_encode($thumbnailPath));884 $thumbnail->setTriggerEvents(false);885 $thumbnailQuality = $config['thumbnail.jpeg_quality'];886 $thumbnailResult = false;887888 $imageInfo = @getimagesize($file->getAbsolutePath());889 $fileWidth = $imageInfo[0];890 $fileHeight = $imageInfo[1];891 $fileType = $imageInfo[2];892 $thumbnailType = $fileType;893894 // Calculate thumbnail width and height895 $targetWidth = $config['thumbnail.width'];896 $targetHeight = $config['thumbnail.height'];897898 if ($config['thumbnail.scale_mode'] == "percentage") {899 $percentage = min($config['thumbnail.width'] / $fileWidth, $config['thumbnail.height'] / $fileHeight);900901 if ($percentage <= 1) {902 $targetWidth = round($fileWidth * $percentage);903 $targetHeight = round($fileHeight * $percentage);904 } else {905 $targetWidth = $fileWidth;906 $targetHeight = $fileHeight;907 }908 }909910 if ($thumbnail->exists()) {911 $thumbnailInfo = @getimagesize($thumbnail->getAbsolutePath());912 $thumbnailWidth = $thumbnailInfo[0];913 $thumbnailHeight = $thumbnailInfo[1];914 $thumbnailType = $thumbnailInfo[2];915916 // Check width and height against config917 //debug($thumbnailHeight . " - " . $targetHeight . " - " . $thumbnailWidth . " - " . $targetWidth);918 if (($thumbnailHeight != $targetHeight) || ($thumbnailWidth != $targetWidth)) {919 $thumbnail->delete();920 $thumbnailResult = $imageutils->resizeImage($file->getAbsolutePath(), $thumbnail->getAbsolutePath(), $targetWidth, $targetHeight, $ext, $thumbnailQuality);921 }922923 // Check modificationdate against original image924 if ($file->getLastModified() != $thumbnail->getLastModified()) {925 $thumbnail->delete();926 $thumbnailResult = $imageutils->resizeImage($file->getAbsolutePath(), $thumbnail->getAbsolutePath(), $targetWidth, $targetHeight, $ext, $thumbnailQuality);927 }928929 if ($thumbnailResult)930 $thumbnail->setLastModified($file->getLastModified());931 932 } else if ((!$thumbnail->exists()) && ($config['thumbnail.auto_generate'] == true)) {933 $thumbnailResult = $imageutils->resizeImage($file->getAbsolutePath(), $thumbnail->getAbsolutePath(), $targetWidth, $targetHeight, $ext, $thumbnailQuality);934 if ($thumbnailResult) {935 $thumbnailInfo = @getimagesize($thumbnail->getAbsolutePath());936 $thumbnailType = $thumbnailInfo[2];937 $thumbnail->setLastModified($file->getLastModified());938 $thumbnail->importFile();939 }940 }941942 // failsafe check943 if ($thumbnail->exists() && $thumbnailType)944 return $thumbnail;945946 return false;947 }948949 function _streamThumb(&$man, $input) {950 if (!$man->verifyPath($input["path"]) < 0) {951 trigger_error("Path verification failed.", FATAL);952 die();953 }954955 $path = $man->decryptPath($input["path"]);956 $file =& $man->getFile($path);957 $ext = getFileExt($file->getName());958959 $config = $file->getConfig();960961 $urlprefix = $man->toUnixPath($config['preview.urlprefix']);962 $urlsuffix = $man->toUnixPath($config['preview.urlsuffix']);963964 // NOTE: Verify more stuff here before proceeding.965 if ($man->verifyFile($file, "thumbnail", $config) < 0) {966 trigger_error("Path verification failed.", FATAL);967 die();968 }969970 //$imageutils = new $config['thumbnail'];971 //$canEdit = $imageutils->canEdit($ext);972973 // Check if we have an EXIF JPG file.974 if (($config['thumbnail.use_exif'] == true) && (function_exists("exif_thumbnail")) && (strtolower($ext) == "jpg" || strtolower($ext) == "jpeg")) {975 $image = @exif_thumbnail($file->getAbsolutePath(), $exif_width, $exif_height, $exif_type);976977 if ($image !== false) {978 header('Content-type: '. image_type_to_mime_type($exif_type));979 echo $image;980 return null;981 }982 }983984 $thumbnail = $this->_createThumb($man, $file);985986 if ($thumbnail != false) {987 header('Content-type: ' . mapMimeTypeFromUrl($thumbnail->getName(), "../" . $config['stream.mimefile']));988989 if (!readfile($thumbnail->getAbsolutePath()))990 header("Location: ". $urlprefix . $man->convertPathToURI($thumbnail->getAbsolutePath(), $config['preview.wwwroot']) . $urlsuffix);991 } else {992 header('Content-type: ' . mapMimeTypeFromUrl($file->getName(), "../" . $config['stream.mimefile']));993994 if (!readfile($file->getAbsolutePath()))995 header("Location: " . $urlprefix . $man->convertPathToURI($file->getAbsolutePath(), $config['preview.wwwroot']) . $urlsuffix);996 }997998 return null;999 }10001001 /**#@-*/1002}10031004// Add plugin to MCManager1005$man->registerPlugin("imagemanager", new Moxiecode_ImageManagerPlugin(), "im");1006 ...

Full Screen

Full Screen

FileManagerPlugin.php

Source:FileManagerPlugin.php Github

copy

Full Screen

...125 $zipFile = $man->getFile($man->decryptPath($input["topath"]) . '/' . $input["toname"] . ".zip");126 $config = $fromFile->getConfig();127128 if (checkBool($config['general.demo'])) {129 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.demo}");130 continue;131 }132133 // Check write access134 if (!checkBool($config["filesystem.writable"])) {135 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");136 continue;137 }138139 if ($man->verifyFile($fromFile, "createzip") < 0) {140 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());141 continue;142 }143144 if ($man->verifyFile($zipFile, "createzip") < 0) {145 $result->add("FAILED", $man->encryptPath($zipFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());146 continue;147 }148149 if (!$fromFile->exists()) {150 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_from_file}");151 continue;152 }153154 if ($man->verifyFile($fromFile, "zip") < 0) {155 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());156 continue;157 }158159 if ($fromFile->copyTo($toFile))160 $result->add("OK", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#message.zip_success}");161 else162 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.createzip_failed}");163 }164165 return $result->toArray();166 }167168 function _copyFiles(&$man, &$input) {169 $result = new Moxiecode_ResultSet("status,fromfile,tofile,message");170 $config = $man->getConfig();171172 if (!$man->isToolEnabled("copy", $config)) {173 trigger_error("{#error.no_access}", FATAL);174 die();175 }176177 for ($i=0; isset($input["frompath" . $i]); $i++) {178 $fromFile =& $man->getFile($input["frompath" . $i]);179 $fromType = $fromFile->isFile() ? MC_IS_FILE : MC_IS_DIRECTORY;180181 if (isset($input["toname" . $i])) {182 $toFile =& $man->getFile($fromFile->getParent(), $input["toname" . $i], $fromType);183 } else {184 if (isset($input["topath" . $i]))185 $toFile =& $man->getFile($input["topath" . $i], "", $fromType);186 else187 $toFile =& $man->getFile($input["topath"], $fromFile->getName(), $fromType);188 }189190 if (!$fromFile->exists()) {191 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_from_file}");192 continue;193 }194195 if ($toFile->exists()) {196 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.tofile_exists}");197 continue;198 }199200 $toConfig = $toFile->getConfig();201202 if (checkBool($toConfig['general.demo'])) {203 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.demo}");204 continue;205 }206207 if ($man->verifyFile($toFile, "copy") < 0) {208 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());209 continue;210 }211212 if (!$toFile->canWrite()) {213 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");214 continue;215 }216217 if (!checkBool($toConfig["filesystem.writable"])) {218 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");219 continue;220 }221222 // Check if file can be zipped223 if (getClassName($toFile) == 'moxiecode_zipfileimpl') {224 if ($man->verifyFile($fromFile, "zip") < 0) {225 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());226 continue;227 }228 }229230 // Check if file can be unzipped231 if (getClassName($fromFile) == 'moxiecode_zipfileimpl') {232 if ($man->verifyFile($toFile, "unzip") < 0) {233 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());234 continue;235 }236 }237238 if ($fromFile->copyTo($toFile))239 $result->add("OK", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#message.copy_success}");240 else241 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.copy_failed}");242 }243244 return $result->toArray();245 }246247 function _moveFiles(&$man, &$input) {248 $result = new Moxiecode_ResultSet("status,fromfile,tofile,message");249 $config = $man->getConfig();250251 if (!$man->isToolEnabled("rename", $config) && !$man->isToolEnabled("cut", $config)) {252 trigger_error("{#error.no_access}", FATAL);253 die();254 }255256 for ($i=0; isset($input["frompath" . $i]); $i++) {257 $fromFile =& $man->getFile($input["frompath" . $i]);258 $fromType = $fromFile->isFile() ? MC_IS_FILE : MC_IS_DIRECTORY;259260 if (isset($input["toname" . $i])) {261 $toFile =& $man->getFile($fromFile->getParent(), $input["toname" . $i], $fromType);262 } else {263 if (isset($input["topath" . $i]))264 $toFile =& $man->getFile($input["topath" . $i], "", $fromType);265 else266 $toFile =& $man->getFile($input["topath"], $fromFile->getName(), $fromType);267 }268269 // User tried to change extension270 if ($fromFile->isFile() && getFileExt($fromFile->getName()) != getFileExt($toFile->getName())) {271 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.move_failed}");272 continue;273 }274275 if (!$fromFile->exists()) {276 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_from_file}");277 continue;278 }279280 if ($toFile->exists()) {281 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.tofile_exists}");282 continue;283 }284285 $toConfig = $toFile->getConfig();286287 if (checkBool($toConfig['general.demo'])) {288 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.demo}");289 continue;290 }291292 if ($man->verifyFile($toFile, "rename") < 0) {293 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());294 continue;295 }296297 if (!$toFile->canWrite()) {298 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");299 continue;300 }301302 if (!checkBool($toConfig["filesystem.writable"])) {303 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");304 continue;305 }306307 // Check if file can be zipped308 if (getClassName($toFile) == 'moxiecode_zipfileimpl') {309 if ($man->verifyFile($fromFile, "zip") < 0) {310 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());311 continue;312 }313 }314315 // Check if file can be unzipped316 if (getClassName($fromFile) == 'moxiecode_zipfileimpl') {317 if ($man->verifyFile($toFile, "unzip") < 0) {318 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());319 continue;320 }321 }322323 if ($fromFile->renameTo($toFile))324 $result->add("OK", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#message.move_success}");325 else326 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.move_failed}");327 }328329 return $result->toArray();330 }331332 function _createDocs(&$man, &$input) {333 $result = new Moxiecode_ResultSet("status,fromfile,tofile,message");334 $config = $man->getConfig();335336 if (!$man->isToolEnabled("createdoc", $config)) {337 trigger_error("{#error.no_access}", FATAL);338 die();339 }340341 for ($i=0; isset($input["frompath" . $i]) && isset($input["toname" . $i]); $i++) {342 $fromFile =& $man->getFile($input["frompath" . $i]);343 $ext = getFileExt($fromFile->getName());344 $toFile =& $man->getFile($input["topath" . $i], $input["toname" . $i] . '.' . $ext);345 $toConfig = $toFile->getConfig();346347 if (checkBool($toConfig['general.demo'])) {348 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.demo}");349 continue;350 }351352 if ($man->verifyFile($toFile, "createdoc") < 0) {353 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), $man->getInvalidFileMsg());354 continue;355 }356357 if (!$toFile->canWrite()) {358 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");359 continue;360 }361362 if (!checkBool($toConfig["filesystem.writable"])) {363 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.no_write_access}");364 continue;365 }366367 if (!$fromFile->exists()) {368 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.template_missing}");369 continue;370 }371372 if ($fromFile->copyTo($toFile)) {373 // Replace title374 $fields = $input["fields"];375376 // Replace all fields377 if ($fields) {378 // Read all data379 $stream = $toFile->open('r');380 $fileData = $stream->readToEnd();381 $stream->close();382383 // Replace fields384 foreach ($fields as $name => $value)385 $fileData = str_replace('${' . $name . '}', htmlentities($value), $fileData);386387 // Write file data388 $stream = $toFile->open('w');389 $stream->write($fileData);390 $stream->close();391 }392393 $result->add("OK", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#message.createdoc_success}");394 } else395 $result->add("FAILED", $man->encryptPath($fromFile->getAbsolutePath()), $man->encryptPath($toFile->getAbsolutePath()), "{#error.createdoc_failed}");396 }397398 return $result->toArray();399 }400401 function _loadContent(&$man, &$input) {402 $file = $man->getFile($input["path"]);403 $config = $file->getConfig();404405 if (!$man->isToolEnabled("edit", $config)) {406 trigger_error("{#error.no_access}", FATAL);407 die();408 }409 ...

Full Screen

Full Screen

getAbsolutePath

Using AI Code Generation

copy

Full Screen

1$absolutePath = $path->getAbsolutePath();2echo $absolutePath;3$relativePath = $path->getRelativePath();4echo $relativePath;5$relativePathFrom = $path->getRelativePathFrom($path);6echo $relativePathFrom;7$relativePath = $path->getRelativePath();8echo $relativePath;9$relativePathFrom = $path->getRelativePathFrom($path);10echo $relativePathFrom;11$relativePath = $path->getRelativePath();12echo $relativePath;13$relativePathFrom = $path->getRelativePathFrom($path);14echo $relativePathFrom;15$relativePath = $path->getRelativePath();16echo $relativePath;17$relativePathFrom = $path->getRelativePathFrom($path);18echo $relativePathFrom;19$relativePath = $path->getRelativePath();20echo $relativePath;21$relativePathFrom = $path->getRelativePathFrom($path);22echo $relativePathFrom;23$relativePath = $path->getRelativePath();24echo $relativePath;25$relativePathFrom = $path->getRelativePathFrom($path);26echo $relativePathFrom;

Full Screen

Full Screen

getAbsolutePath

Using AI Code Generation

copy

Full Screen

1$path = new Path();2echo $path->getAbsolutePath('1.php');3$path = new Path();4echo $path->getRelativePath('/var/www/html/1.php');5$path = new Path();6echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html');7$path = new Path();8echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html/');9$path = new Path();10echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html', true);11$path = new Path();12echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html/', true);13$path = new Path();14echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html', false);15$path = new Path();16echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html/', false);17$path = new Path();18echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html', true);19$path = new Path();20echo $path->getRelativePath('/var/www/html/1.php', '/var/www/html/', true);21$path = new Path();22echo $path->getRelativePath('/var/www/html/1.php',

Full Screen

Full Screen

getAbsolutePath

Using AI Code Generation

copy

Full Screen

1$filePath = new Path('1.php');2echo $filePath->getAbsolutePath();3$filePath = new Path('1.php');4echo $filePath->getRelativePath();5$filePath = new Path('1.php');6echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');7$filePath = new Path('1.php');8echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');9$filePath = new Path('1.php');10echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');11$filePath = new Path('1.php');12echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');13$filePath = new Path('1.php');14echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');15$filePath = new Path('1.php');16echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');17$filePath = new Path('1.php');18echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');19$filePath = new Path('1.php');20echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');21$filePath = new Path('1.php');22echo $filePath->getRelativePathFrom('C:\xampp\htdocs\test\2.php');

Full Screen

Full Screen

getAbsolutePath

Using AI Code Generation

copy

Full Screen

1$path = new Path();2echo $path->getAbsolutePath('1.php');3echo $path->getAbsolutePath('1.php', true);4$path = new Path();5echo $path->getAbsolutePath('1/1.php');6echo $path->getAbsolutePath('1/1.php', true);7$path = new Path();8echo $path->getAbsolutePath('1/1/1.php');9echo $path->getAbsolutePath('1/1/1.php', true);10$path = new Path();11echo $path->getAbsolutePath('1/1/1/1.php');12echo $path->getAbsolutePath('1/1/1/1.php', true);13$path = new Path();14echo $path->getAbsolutePath('1/1/1/1/1.php');15echo $path->getAbsolutePath('1/1/1/1/1.php', true);16$path = new Path();17echo $path->getAbsolutePath('1/1/1/1/1/1.php');18echo $path->getAbsolutePath('1/1/1/1/1/1.php', true);19$path = new Path();20echo $path->getAbsolutePath('1/1/1/1/1/1/1.php');21echo $path->getAbsolutePath('1/1/1/1/1/1/1.php', true);22$path = new Path();23echo $path->getAbsolutePath('1/1/1/1/1/1/1/1.php');24echo $path->getAbsolutePath('1/1/1/1

Full Screen

Full Screen

getAbsolutePath

Using AI Code Generation

copy

Full Screen

1require_once 'Path.php';2$path = new Path();3$abs_path = $path->getAbsolutePath("1.php");4echo "Absolute path of 1.php is: $abs_path";5require_once 'Path.php';6$path = new Path();7$rel_path = $path->getRelativePath("C:\xampp\htdocs\path\1.php");8echo "Relative path of 1.php is: $rel_path";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful