예제 #1
0
 /**
  * Метод получает экземпляр класса и, если нужно, кеширует его.
  */
 public static function getClassInstance($__DIR__, $subDir, $className, $parent, $caching = true)
 {
     if (!is_valid_file_name($className)) {
         return null;
         //---
     }
     $className = get_file_name($className);
     if ($className == $parent) {
         //Абстрактный класс/интерфейс лежит рядом с классами реализации - пропустим его
         return null;
     }
     //Абсолютный путь к классу
     $classPath = file_path(array($__DIR__, $subDir), $className, PsConst::EXT_PHP);
     //Ключ кеширования
     $cacheKey = md5($classPath);
     $CACHE = $caching ? SimpleDataCache::inst(__CLASS__, __FUNCTION__) : null;
     if ($CACHE && $CACHE->has($cacheKey)) {
         return $CACHE->get($cacheKey);
     }
     $INST = null;
     if (is_file($classPath)) {
         //Подключим данный класс
         require_once $classPath;
         //Проверим, существует ли класс
         $rc = PsUtil::newReflectionClass($className, false);
         $INST = $rc && $rc->isSubclassOf($parent) ? $rc->newInstance() : null;
     }
     if ($CACHE && $INST) {
         $CACHE->set($cacheKey, $INST);
     }
     return $INST;
 }
예제 #2
0
파일: index.php 프로젝트: jkinner/ringside
/**
 * Prints out a list of files and their comments
 *
 * @param unknown_type $rootDirs
 * @param unknown_type $relPath
 * @param unknown_type $title
 */
function print_files($rootDirs, $relPath, $title, $comments)
{
    if ($comments) {
        echo "<div><h2>{$title}</h2>";
    } else {
        echo "<div class='api-list' style='float: left;'><h2>{$title}</h2>";
    }
    foreach ($rootDirs as $dir) {
        if (!file_exists($dir . $relPath)) {
            continue;
        }
        $files = scandir($dir . $relPath);
        echo '<ul>';
        foreach ($files as $file) {
            if (!is_dir($file)) {
                echo '<li><STRONG>' . get_file_name($file) . '</STRONG></li>';
                if ($comments) {
                    echo '<li><STRONG>File Path:</STRONG> ' . $dir . DIRECTORY_SEPARATOR . $relPath . DIRECTORY_SEPARATOR . $file . '</li>';
                    echo '<li>' . getComments($dir . DIRECTORY_SEPARATOR . $relPath . DIRECTORY_SEPARATOR . $file) . '</li>';
                }
            }
        }
        echo '</ul>';
    }
    echo '</div>';
}
예제 #3
0
function dimpConsoleLog()
{
    global $CALLED_FILE;
    if ($CALLED_FILE) {
        $log = file_path(dirname($CALLED_FILE), get_file_name($CALLED_FILE), 'log');
        $FULL_LOG = PsLogger::controller()->getFullLog();
        $FULL_LOG = mb_convert_encoding($FULL_LOG, 'UTF-8', 'cp866');
        file_put_contents($log, $FULL_LOG);
    }
}
예제 #4
0
 public function testIdNumbering()
 {
     /* try to see if the dirs are being created */
     $this->assertEquals(get_file_name("data/uploads/0/020"), Submission::getPathToCodeFromId(20));
     $this->assertEquals(get_file_name("data/uploads/1/000"), Submission::getPathToCodeFromId(1000));
     $this->assertEquals(get_file_name("data/uploads/1/999"), Submission::getPathToCodeFromId(1999));
     $this->assertEquals(get_file_name("data/uploads/178/456"), Submission::getPathToCodeFromId(178456));
     assert(is_dir(get_file_name("data/uploads/1")));
     assert(is_dir(get_file_name("data/uploads/178")));
 }
예제 #5
0
function createJson()
{
    global $wpdb;
    $table2album = $wpdb->prefix . "xy_album";
    $table2photo = $wpdb->prefix . "xy_photo";
    $albums = $wpdb->get_results("SELECT * FROM {$table2album}");
    $i = 0;
    $j = 0;
    foreach ($albums as $album) {
        $album_name[$i] = $album->album_name;
        $album_intro[$i] = $album->album_intro;
        $album_cover[$i] = $album->album_cover;
        $album_id = $album->album_ID;
        $photos = $wpdb->get_results("SELECT * FROM {$table2photo} where photo_album = {$album_id}");
        foreach ($photos as $photo) {
            $photo_name[$i][$j] = get_file_name($photo->photo_url);
            $photo_intro[$i][$j] = $photo->photo_intro;
            $photo_tag[$i][$j] = $photo->photo_tag;
            $photo_thumb_url[$i][$j] = $photo->photo_thumb_url;
            $photo_url[$i][$j] = $photo->photo_url;
            $j++;
        }
        $i++;
    }
    $albumJson = '[';
    for ($k = 0; $k < $i; $k++) {
        $albumJson = $albumJson . '{ "album_name":"' . $album_name[$k] . '","album_intro":"' . $album_intro[$k] . '","album_cover":"' . $album_cover[$k] . '","photo":[';
        for ($m = 0; $m < $j; $m++) {
            if ($photo_name[$k][$m] == "") {
                $var = trim($albumJson);
                $len = strlen($var) - 1;
                $str = $var[$len];
                //最后一个字符是逗号才去删除
                if ($str == ",") {
                    $albumJson = substr($albumJson, 0, strlen($albumJson) - 1);
                    $flag = 1;
                }
                continue;
            }
            $albumJson = $albumJson . '{ "photo_name":"' . $photo_name[$k][$m] . '", "photo_intro":"' . $photo_intro[$k][$m] . '", "photo_tag":"' . $photo_tag[$k][$m] . '","photo_thumb_url":"' . $photo_thumb_url[$k][$m] . '","photo_url":"' . $photo_url[$k][$m] . '" }';
            if ($m != $j - 1) {
                $albumJson = $albumJson . ',';
            }
            //echo $photo_name[$k][$m];
        }
        $albumJson = $albumJson . ']}';
        if ($k != $i - 1) {
            $albumJson = $albumJson . ',';
        }
        //echo "<br />";
    }
    $albumJson = $albumJson . ']';
    return $albumJson;
}
예제 #6
0
function upload_download_delete_blob()
{
    echo '<table><form method=post enctype=\'multipart/form-data\'>';
    foreach ($_POST as $key => $value) {
        if ($key != 'action') {
            echo '<tr><td>' . $key . '</td><td><input type=text readonly name=\'' . $key . '\' value=\'' . $value . '\'></td></tr>';
        }
    }
    $fname = get_file_name($_POST['_attachment_id']);
    echo '<tr><td>File to upload</td>';
    echo '<td><input type=file name=attachment></td><td><input type=reset value=clear></td></tr>';
    echo '<tr><td>Filename</td><td><input readonly type=text name=attachment_name value=\'' . $fname . '\'></td></tr>';
    echo '<tr><td colspan=5 ><input type=submit name=action value=upload_file>';
    echo '<input type=submit name=action value=download_file>';
    echo '<input type=submit name=action value=delete_file></td></tr></table></form>';
}
예제 #7
0
	public function tearDown ()
	{
		contestDB::get_zend_db ()->closeConnection();
		$datadir = get_file_name ("data/");
		
		/* let's move our log file somewhere */
		/* close the logger. */
		Logger::flush ();
		$logfile = "$datadir/logs/" . posix_getuid () . ".log";

		if (is_file ($logfile)) {
			$contents = file_get_contents ($logfile);
			file_put_contents ("logs/" . posix_getuid () . ".log", $contents, FILE_APPEND);
		}
		safeSystem ("fusermount -zu $datadir");
	} 
예제 #8
0
 //$subdir = win_dir_format($subdir);
 $indexSavePath = "./data/index/{$key}/" . $subdir;
 makeDir($indexSavePath);
 $mapFile = $indexSavePath . "/paper_url_mapping.log";
 delFile($mapFile);
 $icount = 1;
 while ($line = readLine($fp)) {
     $arr = explode("\t", $line);
     $u = $arr[6];
     $paperName = $arr[0];
     $paperName = win_dir_format($paperName);
     //echo $paperName . "\n";
     $htmlFileName = $indexSavePath . "/" . $paperName . ".html";
     $tmpFile = iconv("utf-8", "gb2312//IGNORE", $htmlFileName);
     $dbCode = get_db_code($u);
     $fileName = get_file_name($u);
     $tableName = get_table_name($u);
     $realUrl = get_real_url($dbCode, $fileName, $tableName);
     if (file_exists($tmpFile)) {
         if (filesize($tmpFile) < 100) {
             delFile($htmlFileName);
         } else {
             echo "Cache hit! continue -> {$htmlFileName}\n";
             $mapContent = "{$paperName}\t{$realUrl}\n";
             save($mapFile, $mapContent, "a+");
             continue;
         }
     }
     $indexContent = @file_get_contents($realUrl);
     if (strlen($indexContent) == 0) {
         die("{$realUrl}");
예제 #9
0
         }
     }
     $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 'w') or die("can't open file");
     fwrite($pageToBeDeployedHandle, $pageToBeDeployed);
     chmod(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 0777);
     // Close reference to file
     fclose($pageToBeDeployedHandle);
     if (FTP_ENABLED) {
         $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $datarow[CSV_URL_INDEX], 'r') or die("can't open file");
         // change to proper dir
         if (!@ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($filePath))) {
             build_directory_structure_ftp($conn_id, get_file_dir($filePath));
             ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($filePath));
         }
         // try to upload $file
         if (ftp_fput($conn_id, get_file_name($filePath), $pageToBeDeployedHandle, FTP_ASCII)) {
             $successArray[] = "http://www.iwanttolol.com/" . $datarow[CSV_URL_INDEX];
         } else {
             $errorArray[] = "FTP error: {$thePage}";
         }
         // Close reference to file
         fclose($pageToBeDeployedHandle);
     }
 } else {
     $errorArray[] = "No content (" . strlen($theContent) . "): {$thePage}";
     error_log("No content: {$thePage}.   Content: \n" . $theContent, 0);
 }
 $counter++;
 if (DEBUG_MODE && $counter > 8) {
     break;
 }
예제 #10
0
 /**
  * Метод сохраняет ошибку выполнения в файл
  * 
  * @param Exception $exception
  */
 public static function dumpError(Exception $exception, $additionalInfo = '')
 {
     if (ConfigIni::exceptionsMaxDumpCount() <= 0) {
         return;
         //---
     }
     $additionalInfo = trim("{$additionalInfo}");
     //Поставим защиту от двойного дампинга ошибки
     $SafePropName = 'ps_ex_dumped';
     if (property_exists($exception, $SafePropName)) {
         return;
         //---
     }
     $exception->{$SafePropName} = true;
     try {
         $INFO[] = 'SERVER: ' . (isset($_SERVER) ? print_r($_SERVER, true) : '');
         $INFO[] = 'REQUEST: ' . (isset($_REQUEST) ? print_r($_REQUEST, true) : '');
         $INFO[] = 'SESSION: ' . (isset($_SESSION) ? print_r($_SESSION, true) : '');
         $INFO[] = 'FILES: ' . (isset($_FILES) ? print_r($_FILES, true) : '');
         if ($additionalInfo) {
             $INFO[] = "ADDITIONAL:\n{$additionalInfo}\n";
         }
         $INFO[] = 'STACK:';
         $INFO[] = ExceptionHelper::formatStackFile($exception);
         $original = ExceptionHelper::extractOriginal($exception);
         $fname = get_file_name($original->getFile());
         $fline = $original->getLine();
         $DM = DirManager::autogen('exceptions');
         if ($DM->getDirContentCnt() >= ConfigIni::exceptionsMaxDumpCount()) {
             $DM->clearDir();
         }
         $DM->getDirItem(null, PsUtil::fileUniqueTime() . " [{$fname} {$fline}]", 'err')->putToFile(implode("\n", $INFO));
     } catch (Exception $ex) {
         //Если в методе дампа эксепшена ошибка - прекращаем выполнение.
         die("Exception [{$exception->getMessage()}] dump error: [{$ex->getMessage()}]");
     }
 }
예제 #11
0
 /** @return BaseDialog */
 public function getDialog($ident)
 {
     return $this->getEntityClassInst(get_file_name($ident));
 }
예제 #12
0
function _rename($dir, $file_src, $file_dest, $force = false)
{
    $oldwd = getcwd();
    chdir(realpath($dir));
    if (!file_exists($file_src)) {
        return false;
    }
    $copy = "";
    $file_name = get_file_name($file_dest);
    $file_ext = get_file_extension($file_dest);
    if (!$force && strtolower($file_src) == $file_dest && substr(PHP_OS, 0, 3) != "WIN") {
        $n = 2;
        while (file_exists($file_name . $copy . "." . $file_ext)) {
            $copy = "_" . $n;
            $n++;
        }
    }
    $file = $file_name . $copy . "." . $file_ext;
    $ok = rename($file_src, $file);
    chdir($oldwd);
    return $ok ? $file : false;
}
예제 #13
0
function buildListPage($listPageObject)
{
    global $errorArray;
    global $successArray;
    global $templateHtml;
    global $statusFile;
    global $pageBeforeContent;
    global $pageAfterContent;
    global $conn_id;
    global $listCounter;
    global $numListPages;
    $errorSize = count($errorArray);
    fwrite($statusFile, "<strong>(" . ($listCounter + 1) . "/{$numListPages}) Memory Used:" . memory_get_usage() . "</strong>  " . $listPageObject->url . ":<br>");
    fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $listPageObject->toString() . "<br>");
    //Open handle to page
    if (!file_exists(DOC_ROOT_PATH . "{$listPageObject->url}")) {
        build_directory_structure($listPageObject->url);
    }
    $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $listPageObject->url, 'w') or die("can't open file");
    //Insert title into head section
    $updatedPageBeforeContent = str_replace("#head-additional-styles-and-scripts#", "<title>{$listPageObject->listingName} Vacation and Resort Listing</title>", $pageBeforeContent);
    // Add the remote path where the installation is located
    $updatedPageBeforeContent = str_replace("#remote-install-path#", REMOTE_INSTALL_PATH, $updatedPageBeforeContent);
    // Replace the agency code
    $updatedPageBeforeContent = str_replace("#agency-code#", AGENCY_CODE, $updatedPageBeforeContent);
    //Insert country code and empty hotel code for search
    $updatedPageBeforeContent = str_replace("#country-code-upper##hotel-code-upper#", "", $updatedPageBeforeContent);
    if (property_exists($listPageObject, "countryCode")) {
        $updatedPageBeforeContent = str_replace("#country-code-upper#", $listPageObject->countryCode, $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#dest-region#", "", $updatedPageBeforeContent);
    } else {
        // Chain pages we aren't sure of country or hotel, so just filter by destination region
        $updatedPageBeforeContent = str_replace("#country-code-upper#", "", $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#hotel-code-upper#", "", $updatedPageBeforeContent);
        $updatedPageBeforeContent = str_replace("#dest-region#", DEST_REGION_FILTER, $updatedPageBeforeContent);
    }
    $updatedPageBeforeContent = str_replace("#meta-keywords#", $listPageObject->listingName . ", " . $listPageObject->listingName . " hotel, " . $listPageObject->listingName . " resort, " . $listPageObject->listingName . " all inclusive", $updatedPageBeforeContent);
    $updatedPageBeforeContent = str_replace("#meta-description#", PRETTY_SITE_NAME . " provides All-inclusive vacations to " . $listPageObject->listingName . ".  Great prices, personal service, and can price match (then beat) any other offer.", $updatedPageBeforeContent);
    //Write html before the content
    fwrite($pageToBeDeployedHandle, $updatedPageBeforeContent);
    //Check to see if we should treat as a hotel chain object or standard hotel object
    if (strcmp(get_class($listPageObject), "ChainListPageObject") != 0) {
        foreach ($listPageObject->hotelCodes as $childHotel) {
            $hotelListObject = get_hotel_info($listPageObject->countryCode, $childHotel);
            if (!empty($hotelListObject->hotelName)) {
                $listOutput = $hotelListObject->formattedOutput();
                fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $hotelListObject->hotelName . "<br>");
                //Write html for current hotel
                fwrite($pageToBeDeployedHandle, $listOutput);
            } else {
                $errorArray[$hotelListObject->countryCode . $hotelListObject->hotelCode] = "countryCode:{$hotelListObject->countryCode}, hotelCode:{$hotelListObject->hotelCode}";
            }
            if (kill_build()) {
                fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                $errorArray[] = "Build Killed!";
                break;
            }
        }
    } else {
        foreach ($listPageObject->hotels as $hotelListObject) {
            if (!empty($hotelListObject->hotelName)) {
                $listOutput = $hotelListObject->formattedOutput();
                fwrite($statusFile, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $hotelListObject->hotelName . "<br>");
                //Write html for current hotel
                fwrite($pageToBeDeployedHandle, $listOutput);
            } else {
                $errorArray[$hotelListObject->countryCode . $hotelListObject->hotelCode] = "countryCode:{$hotelListObject->countryCode}, hotelCode:{$hotelListObject->hotelCode}";
            }
            if (kill_build()) {
                fwrite($statusFile, "<br>BUILD KILLED!!!<br>");
                $errorArray[] = "Build Killed!";
                break;
            }
        }
    }
    fwrite($statusFile, "<br>");
    $pageAfterContent = str_replace("#pretty-site-name#", PRETTY_SITE_NAME, $pageAfterContent);
    //Write html after the content
    fwrite($pageToBeDeployedHandle, $pageAfterContent);
    chmod(DOC_ROOT_PATH . "{$listPageObject->url}", 0777);
    // Close reference to file
    fclose($pageToBeDeployedHandle);
    if (FTP_ENABLED) {
        $pageToBeDeployedHandle = fopen(DOC_ROOT_PATH . $listPageObject->url, 'r') or die("can't open file");
        // change to proper dir
        build_directory_structure_ftp($conn_id, get_file_dir($listPageObject->url));
        ftp_chdir($conn_id, REMOTE_DOC_ROOT_PATH . get_file_dir($listPageObject->url));
        // try to upload $file and check if all the hotels in list were successfully added (errors start == errors end)
        if (ftp_fput($conn_id, get_file_name($listPageObject->url), $pageToBeDeployedHandle, FTP_ASCII) && $errorSize == count($errorArray)) {
            $successArray[] = "http://" . SITE_DOMAIN . $listPageObject->url;
        } else {
            if ($errorSize == count($errorArray)) {
                // If the error count is equal then it is FTP error, else has been logged above
                $errorArray[] = "FTP error: {$listPageObject->url}";
            }
        }
        // Close reference to file
        fclose($pageToBeDeployedHandle);
    }
}
예제 #14
0
파일: deal.php 프로젝트: jechiy/xiu-cms
function upload()
{
    $dir = post('dir');
    $file = post('file');
    $suffix = strtolower(get_file_name($file, '.'));
    if (strpos('jpg,gif,png,bmp,jpeg,rar,zip,pdf', $suffix) !== false) {
        move_uploaded_file($_FILES['file_path']['tmp_name'], $dir . $file);
        set_cookie('file', $dir . $file);
    }
}
예제 #15
0
        } else {
            echo "You have to specify an end time or duration.\n";
            exit(1);
        }
    }
    $endTime = $dom->createElement("contestEndTime", date($xsdformat, $unix));
    $root->appendChild($endTime);
}
if (empty($name)) {
    $name = "Unnamed contest";
}
$e = $dom->createElement("name", $name);
$root->appendChild($e);
if (!empty($enable_queue_privacy)) {
    $e = $dom->createElement("enable-queue-privacy", "true");
    $root->appendChild($e);
}
$frontend = $dom->createElement("frontend");
$root->appendChild($frontend);
$home = $dom->createElement("page", "Home");
$frontend->appendChild($home);
$home->setAttribute("id", "home");
$home->setAttribute("href", "general/home.html");
file_put_contents(get_file_name("data/contests/{$id}.xml"), $dom->saveXML());
chmod(get_file_name("data/contests/{$id}.xml"), 0755);
if (empty($quiet)) {
    echo "-----LOG-----\n";
    echo $dom->saveXML();
    echo "\nJust verify that the timestamps have been correctly parsed.\n";
    Logger::get_logger()->info("contest added with: " . $argv);
}
예제 #16
0
$res->appendChild($element);
if (!empty($checker)) {
    $element = $dom->createElement("checker", $checker);
    $root->appendChild($element);
}
if (empty($grading_style)) {
    $grading_style = config::$default_grading_style;
}
$element = $dom->createElement("grading-style", $grading_style);
$root->appendChild($element);
if (empty($rlim)) {
    $rlim = "";
}
$element = $dom->createElement("resourcelimits_string", $rlim);
$root->appendChild($element);
file_put_contents(get_file_name("data/problems/" . $id . ".xml"), $dom->saveXML());
chmod(get_file_name("data/problems/{$id}.xml"), 0755);
chmod(get_file_name("data/problems/{$id}"), 0755);
echo "-----LOG-----\n";
echo $dom->saveXML();
$db = contestDB::get_zend_db();
$id = pg_escape_string($id);
$nick = pg_escape_string($nick);
$rlim = pg_escape_string($rlim);
if (empty($onlyupdate)) {
    $sql = "insert into problemdata (id,numcases,nickname,state,submissionlimit,owner) values \n('{$id}',{$numcases},'{$nick}','ok',{$sublim},'{$contest}')";
} else {
    $sql = "update problemdata set numcases={$numcases},nickname='{$nick}',\nstate='ok',submissionlimit={$sublim},owner='{$contest}' where id='{$id}'";
}
$db->query($sql);
echo "Done, copy your problem statement to " . config::$problems_directory . "/{$id}/index.{html|pdf|ps}. Note that html file should contain only the body " . "part!\n";
예제 #17
0
function copy_file($image_src, $image_dest, $image_media_file, $dest_file_name, $type, $filter = 1, $move = 1)
{
    $image_src_file = $image_src . "/" . $image_media_file;
    $dest_file_name = $filter ? filterFileName($dest_file_name) : $dest_file_name;
    $ok = 0;
    if (!file_exists($image_dest) || !is_dir($image_dest)) {
        $oldumask = umask(0);
        $result = _mkdir($image_dest);
        @chmod($image_dest, CHMOD_DIRS);
        umask($oldumask);
    }
    switch ($type) {
        case 1:
            // overwrite mode
            if (file_exists($image_src . "/" . $image_media_file)) {
                if (file_exists($image_dest . "/" . $dest_file_name)) {
                    unlink($image_dest . "/" . $dest_file_name);
                }
                $ok = copy($image_src . "/" . $image_media_file, $image_dest . "/" . $dest_file_name);
            }
            break;
        case 2:
            // create new with incremental extention
            if (file_exists($image_src . "/" . $image_media_file)) {
                $file_extension = get_file_extension($dest_file_name);
                $file_name = get_file_name($dest_file_name);
                $n = 2;
                $copy = "";
                while (file_exists($image_dest . "/" . $file_name . $copy . "." . $file_extension)) {
                    $copy = "_" . $n;
                    $n++;
                }
                $new_file = $file_name . $copy . "." . $file_extension;
                $ok = copy($image_src . "/" . $image_media_file, $image_dest . "/" . $new_file);
                $dest_file_name = $new_file;
            }
            break;
        case 3:
            // do nothing if exists, highest protection
        // do nothing if exists, highest protection
        default:
            if (file_exists($image_src . "/" . $image_media_file)) {
                if (file_exists($image_dest . "/" . $dest_file_name)) {
                    $ok = 0;
                } else {
                    $ok = copy($image_src . "/" . $image_media_file, $image_dest . "/" . $dest_file_name);
                }
            }
            break;
    }
    if ($ok) {
        if ($move) {
            @unlink($image_src_file);
        }
        @chmod($image_dest . "/" . $dest_file_name, CHMOD_FILES);
        return $dest_file_name;
    } else {
        return false;
    }
}
예제 #18
0
global $LSP_URL;
if (!SESSION_EMPTY() && (get_user_id(SESSION()) == get_file_owner(GET('file')) || is_admin(get_user_id(SESSION())))) {
    if (GET('confirmation') == "true") {
        if (delete_file(GET('file'))) {
            display_success('File deleted successfully', array('Delete'));
        } else {
            display_error('Sorry, file ' . GET('file') . ' could not be deleted', array('Delete'));
        }
        get_latest();
    } else {
        display_warning('This will delete all comments and ratings.', array('Delete', get_file_url()));
        echo '<div class="col-md-9">';
        $form = new form(null, 'Confirm Delete', 'fa-trash');
        ?>
		<p class="lead">Confirm deletion of <strong><?php 
        echo get_file_name(GET('file'));
        ?>
</strong>?</p>
		<div class="form-group">
		<a class="btn btn-danger" href="<?php 
        echo "{$LSP_URL}?content=delete&confirmation=true&file=" . GET('file');
        ?>
">
		<span class="fa fa-check"></span>&nbsp;Delete</a>
		<a class="btn btn-warning" href="<?php 
        echo "{$LSP_URL}?action=show&file=" . GET('file');
        ?>
">
		<span class="fa fa-close"></span>&nbsp;Cancel</a>
		</form>
		<?php 
예제 #19
0
 function viewAction()
 {
     if (!$this->validateProblemAccess()) {
         return;
     }
     $prob = $this->view->prob;
     $this->view->content_html = file_get_contents(get_file_name("data/problems/" . $this->_request->get("probid") . "/index.html"));
     if (function_exists("tidy_parse_string") && $this->_request->get("tidy") != "false") {
         /* tidy to XHTML strict */
         $opt = array("output-xhtml" => true, "add-xml-decl" => true, "bare" => true, "clean" => true, "quote-ampersand" => true, "doctype" => "strict");
         $tidy = tidy_parse_string($this->view->content_html, $opt);
         tidy_clean_repair($tidy);
         $this->view->content_html = tidy_get_output($tidy);
         $this->fixImages();
         /* redo the tidy, I agree it's slow, but easy way out. :) */
         $opt = array("output-xhtml" => true, "doctype" => "strict", "show-body-only" => true);
         $tidy = tidy_parse_string($this->view->content_html, $opt);
         tidy_clean_repair($tidy);
         $this->view->content_html = tidy_get_output($tidy);
     }
     if ($this->_request->get("plain") == "true") {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $this->getResponse()->setBody($this->view->content_html);
     }
 }
예제 #20
0
 public function getPathBase()
 {
     return get_file_name($this->path);
 }
예제 #21
0
파일: utils.php 프로젝트: kmklr72/lmms.io
function read_project($file_id)
{
    global $DATA_DIR;
    $extension = parse_extension(get_file_name($file_id));
    switch ($extension) {
        case '.mmp':
            // Treat as plain XML
            return simplexml_load_file($DATA_DIR . $file_id);
        case '.mmpz':
            // Open binary file for reading
            $handle = fopen($DATA_DIR . $file_id, "rb");
            // Skip the first 4 bytes for compressed mmpz files
            fseek($handle, 4);
            $data = fread($handle, filesize($DATA_DIR . $file_id) - 4);
            return simplexml_load_string(zlib_decode($data));
        default:
            return null;
    }
}
예제 #22
0
파일: .model.php 프로젝트: Vatia13/funtime
     $slide = base64_encode(serialize(array('img' => $slide['img'], 'name' => $slide['name'])));
 } else {
     $slide = base64_encode(serialize($slider_images));
 }
 $operation = intval($_POST['op']);
 $comments = intval($_POST['comments']);
 $favorit_news = intval($_POST['favorit_news']);
 $text = str_replace("'", "`", PHP_slashes($_POST['textarea1']));
 if (!empty($_POST['sakimg'])) {
     $sak_dir = first_par_url($_POST['sakimg']);
     $sakfiles = glob($_SERVER['DOCUMENT_ROOT'] . generate_unknown($sak_dir) . '*.{jpeg,gif,png,jpg,JPG,PNG,GIF,JPEG}', GLOB_BRACE);
     $sakcount = count($sakfiles);
     sort($sakfiles);
     // echo generate_unknown($_SERVER['DOCUMENT_ROOT'].$slide_dir);
     for ($i = 0; $i < $sakcount; $i++) {
         if (in_array(get_file_name(last_par_url($sakfiles[$i])), $numbers)) {
             $sakim .= '<p><img src="http://funtime.ge:80' . $sak_dir . last_par_url($sakfiles[$i]) . '" width="700"/></p>';
         }
     }
     $text .= '<div class="fix"></div>' . $sakim;
 }
 $text_short = PHP_slashes($_POST['lidi']);
 $date_dd = intval($_POST['date_dd']);
 $date_mm = intval($_POST['date_mm']);
 $date_yy = intval($_POST['date_yy']);
 $style = intval($_POST['style']);
 $user_id = intval($_POST['author']);
 $test = intval($_POST['victo']);
 if (isset($_POST['author']) > 0) {
     $author = $user_id;
 } else {
예제 #23
0
파일: helpers.php 프로젝트: tchalvak/airl
function ftp_to_deployment_site($localFile, $remoteDir = REMOTE_DOC_ROOT_PATH)
{
    // set up basic connection
    $conn_id = ftp_connect(FTP_SERVER);
    // login with username and password
    $login_result = ftp_login($conn_id, FTP_USERNAME, FTP_PASSWORD);
    $pageToBeDeployedHandle = fopen($localFile, 'r') or die("can't open file");
    // change to proper dir
    if (!ftp_chdir($conn_id, $remoteDir)) {
        build_directory_structure_ftp($conn_id, $remoteDir);
        ftp_chdir($conn_id, $remoteDir);
        error_log("Built dir for ftp_to_deployment_site: " . $remoteDir, 0);
    }
    // try to upload $file
    if (!ftp_fput($conn_id, get_file_name($localFile), $pageToBeDeployedHandle, FTP_ASCII)) {
        echo "There was a problem while uploading {$localFileName}\n";
        error_log("There was a problem while uploading {$localFileName}", 0);
    }
    // Close reference to file
    fclose($pageToBeDeployedHandle);
    // close the connection and the file handler
    ftp_close($conn_id);
}
예제 #24
0
         message_box("您选择要上传的文件太大,请重新上传!", XJT_ADMIN, go_to(array('/xjt_admin/replacement.php' => '返回')));
     }
     if (preg_match('/.*\\.xls$/', $excelfile['name'])) {
         //得到学校信息
         $schoolData = array();
         $soap->admSchInfo($userData['m_account'], $schoolData);
         //得到学校信息
         chserverdir($conn, '学校上传清单');
         chserverdir($conn, $schoolData['SchName']);
         chserverdir($conn, $schoolData['SchAreaName']);
         $result = $soap->getForTransBuss($userData['m_account'], $soapData);
         chserverdir($conn, $soapData[$cur_buss]['bussName'] . '_' . $soapData[$cur_buss]['bussId']);
         //业务
         //include_once('../includes/upload.php');//引入上传类
         ftp_pasv($conn, true);
         $upload = ftp_put($conn, get_file_name($soap, $schoolData, $excelfile['name']), $excelfile['tmp_name'], FTP_BINARY);
         ftp_close($conn);
         //关闭ftp
         if ($upload) {
             message_box("文件已经上传到服务器!", XJT_ADMIN, go_to(array('/xjt_admin/home.php' => '返回')));
         } else {
             message_box("文件上传失败!", XJT_ADMIN, go_to(array('/xjt_admin/home.php' => '返回')));
         }
         exit;
     } else {
         message_box("您选择要上传的文件不是excel,请重新上传!", XJT_ADMIN, go_to(array('/xjt_admin/replacement.php' => '返回')));
         exit;
     }
 } else {
     message_box("您没有选择要上传的文件!", XJT_ADMIN, go_to(array('/xjt_admin/replacement.php' => '返回')));
     exit;
예제 #25
0
        $file_extension = $regs[2];
        $file['file_name'] = $file_name . ($size ? "_" . $size : "") . "." . $file_extension;
        $file['file_path'] = is_local_file($image_row['image_media_file']) ? dirname($image_row['image_media_file']) . "/" . $file['file_name'] : MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $file['file_name'];
    }
    if ($user_info['user_level'] != ADMIN) {
        $sql = "UPDATE " . IMAGES_TABLE . "\n            SET image_downloads = image_downloads + 1\n            WHERE image_id = {$image_id}";
        $site_db->query($sql);
    }
    if (!empty($file['file_path'])) {
        @set_time_limit(120);
        if ($remote_url) {
            redirect($file['file_path']);
        }
        if ($action == "zip" && !preg_match("/\\.zip\$/i", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) {
            include ROOT_PATH . "includes/zip.php";
            $zipfile = new zipfile();
            $zipfile->add_file(file_get_contents($file['file_path']), $file['file_name']);
            $zipfile->send(get_file_name($file['file_name']) . ".zip");
        } else {
            send_file($file['file_name'], $file['file_path']);
        }
        exit;
    } else {
        echo $lang['download_error'] . "\n<!-- EMPTY FILE PATH //-->";
        exit;
    }
} else {
    echo $lang['download_error'] . "\n<!-- NO ACTION SPECIFIED //-->";
    exit;
}
exit;
예제 #26
0
 function GetModulesList()
 {
     global $GV;
     $list = read_dir_ext($GV["modules_dir"], $GV["module_ext"]);
     for ($i = 0; $i < count($list); ++$i) {
         $list[$i] = get_file_name($list[$i]);
     }
     return $list;
 }
예제 #27
0
        }
    }
    $data = array();
    $data['total_images'] = $total_images;
    $data['total_categories'] = $total_categories;
    $data['auth_viewcat']['IN'] = $auth_cat_sql['auth_viewcat']['IN'];
    $data['auth_viewcat']['NOTIN'] = $auth_cat_sql['auth_viewcat']['NOTIN'];
    save_cache_file($cache_id, serialize($data));
} else {
    $data = unserialize($data);
    $total_images = $data['total_images'];
    $total_categories = $data['total_categories'];
    $auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
    $auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];
}
$file = get_file_name(basename(MAIN_SCRIPT));
$array = array("page_categories" => false, "page_details" => false, "page_index" => false, "page_lightbox" => false, "page_member" => false, "page_postcards" => false, "page_register" => false, "page_search" => false, "page_top" => false, "categories" => false, "details" => false, "index" => false, "member" => false, "postcards" => false, "register" => false, "search" => false, "top" => false);
if (isset($array[$file])) {
    $array[$file] = true;
}
if (isset($array["page_" . $file])) {
    $array["page_" . $file] = true;
}
$site_template->register_vars($array);
$site_template->register_vars(array("home_url" => ROOT_PATH, "media_url" => MEDIA_PATH, "thumb_url" => THUMB_PATH, "icon_url" => ICON_PATH, "template_url" => TEMPLATE_PATH, "template_image_url" => TEMPLATE_PATH . "/images", "template_lang_image_url" => TEMPLATE_PATH . "/images_" . $config['language_dir'], "site_name" => $config['site_name'], "site_email" => $config['site_email'], "user_loggedin" => $user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING ? 0 : 1, "user_loggedout" => $user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING ? 1 : 0, "is_admin" => $user_info['user_level'] == ADMIN ? 1 : 0, "self" => $site_sess->url($self_url), "self_full" => $site_sess->url($script_url . "/" . $self_url), "script_version" => SCRIPT_VERSION, "cp_link" => $user_info['user_level'] != ADMIN ? "" : "\n<p align=\"center\">[<a href=\"" . $site_sess->url(ROOT_PATH . "admin/index.php") . "\">Admin Control Panel</a>]</p>\n", "total_categories" => $total_categories, "total_images" => $total_images, "url_new_images" => $site_sess->url(ROOT_PATH . "search.php?search_new_images=1"), "url_top_images" => $site_sess->url(ROOT_PATH . "top.php"), "url_top_cat_images" => $site_sess->url(ROOT_PATH . "top.php" . ($cat_id && preg_match("/categories.php/", $self_url) ? "?" . URL_CAT_ID . "=" . $cat_id : "")), "url_register" => !empty($url_register) ? $site_sess->url($url_register) : $site_sess->url(ROOT_PATH . "register.php"), "url_search" => $site_sess->url(ROOT_PATH . "search.php"), "url_lightbox" => $site_sess->url(ROOT_PATH . "lightbox.php"), "url_control_panel" => !empty($url_control_panel) ? $site_sess->url($url_control_panel) : $site_sess->url(ROOT_PATH . "member.php?action=editprofile"), "url_categories" => $site_sess->url(ROOT_PATH . "categories.php"), "url_home" => $site_sess->url(ROOT_PATH . "index.php"), "url_login" => !empty($url_login) ? $site_sess->url($url_login) : $site_sess->url(ROOT_PATH . "login.php"), "url_logout" => !empty($url_logout) ? $site_sess->url($url_logout) : $site_sess->url(ROOT_PATH . "logout.php"), "url_member" => !empty($url_member) ? $site_sess->url($url_member) : $site_sess->url(ROOT_PATH . "member.php"), "url_upload" => !empty($url_upload) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH . "member.php?action=uploadform"), "url_lost_password" => !empty($url_lost_password) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH . "member.php?action=lostpassword"), "url_captcha_image" => $site_sess->url(ROOT_PATH . "captcha.php"), "thumbnails" => "", "paging" => "", "paging_stats" => "", "has_rss" => false, "rss_title" => "", "rss_url" => "", "copyright" => '
<p id="copyright" align="center">
  Powered by <b>4images</b> ' . SCRIPT_VERSION . '
  <br />
  Copyright &copy; 2002-' . date('Y') . ' <a href="http://www.4homepages.de" target="_blank">4homepages.de</a>
</p>
'));
예제 #28
0
function create_unique_filename($base, $file)
{
    $ext = get_file_extension($file);
    $name = get_file_name($file);
    $n = 2;
    $copy = "";
    while (file_exists($base . "/" . $name . $copy . "." . $ext)) {
        $copy = "_" . $n;
        $n++;
    }
    return $name . $copy . "." . $ext;
}
function get_image_thumb($file_name)
{
    return get_file_name($file_name) . '_' . 'thumb' . '.' . get_file_extension($file_name);
}
예제 #30
0
파일: PsUtil.php 프로젝트: ilivanoff/www
 /**
  * Метод возвращает название класса
  */
 public static function getClassName($class)
 {
     return check_condition(is_object($class) ? get_class($class) : get_file_name($class), 'Illegal class name');
 }