コード例 #1
0
ファイル: reference.php プロジェクト: xiaokunliu/php_project
function replace_html_path($arrMatche)
{
    $sPath = makeUrl($arrMatche[4]);
    if (strtolower($arrMatche[1]) == 'img') {
        $sPath .= '&bin=1';
    }
    return "<{$arrMatche[1]} {$arrMatche[2]} {$arrMatche[3]}=\"{$sPath}\"";
}
コード例 #2
0
function getPolls()
{
    global $db, $login;
    $polls = $db->selectList('detailedpoll', '*', '1', '`state` ASC, `date` DESC');
    $num = count($polls);
    for ($i = 0; $i < $num; $i++) {
        $polls[$i]['url'] = makeUrl('detailedpoll', array('pollid' => $polls[$i]['detailedpollid']));
        if ($polls[$i]['state'] == 0) {
            $polls[$i]['url_edit'] = makeUrl('detailedpoll', array('mode' => 'create', 'pollid' => $polls[$i]['detailedpollid']));
        }
        $polls[$i]['url_delete'] = makeUrl('detailedpoll', array('mode' => 'delete', 'pollid' => $polls[$i]['detailedpollid']));
        $polls[$i]['answerCount'] = countAnswers($polls[$i]['detailedpollid']);
        $polls[$i]['hasVoted'] = hasVoted($polls[$i]['detailedpollid'], $login->currentUserId());
    }
    return $polls;
}
コード例 #3
0
 public function index()
 {
     $key = C('QINIU_KEY');
     // $qiniu_api = new \Think\Upload\Driver\Qiniu\QiniuApi();
     //echo  $qiniu_api -> safeBase64Encode('sffdsafdsafdsadsfsfsfsdf');
     //原资料图片
     //http://kuwuya.qiniudn.com/userid_2014-07-10_53be26b36d146.JPG
     //需要处理
     //http://kuwuya.qiniudn.com/userid_2014-07-10_53be26b36d146.JPG?imageView/2/w/200/h/200
     //另存操作的目标空间与资源名
     //$entryURI  = "kuwuya:Ship-thumb-200.jpg";
     //编码结果
     //$base = Qiniu_Encode($entryURI);
     //dump($base);
     //需要签名
     /*
     $signingstr = "http://kuwuya.qiniudn.com/userid_2014-07-10_53be26b36d146.JPG?imageView/2/w/200/h/200|saveas/";
     
     $Sign = hash_hmac('sha1',$signingstr,'be607v_8JkDcumrzBV-tXo1VZe26sL4ZJsagwilt',true);
     echo	$Sign;
     $Token = 'be607v_8JkDcumrzBV-tXo1VZe26sL4ZJsagwilt'. ':' . $Sign;
     echo $Token;
     */
     function makeUrl($url, $bucket, $savekey, $ak = 'be607v_8JkDcumrzBV-tXo1VZe26sL4ZJsagwilt', $sk = 'GF0hJMLoGj-8RwmlEOwPPxN1HWx1DoCmRBiUnob2')
     {
         $find = array('+', '/');
         $replace = array('-', '_');
         $encode = str_replace($find, $replace, base64_encode("{$bucket}:{$savekey}"));
         $url = $url . "|saveas/" . $encode;
         $sha1 = hash_hmac('sha1', $url, $sk, true);
         $sign = $ak . ":" . str_replace($find, $replace, base64_encode($sha1));
         $data = $url . "/sign/" . $sign;
         return $data;
     }
     echo makeUrl("kuwuya.qiniudn.com/2014-07-14_53c37b05295ba.jpg?imageView/2/w/200/h/200", "userkuwuya", "widuu.png");
     //dump($Sign);
     //$this->display();
 }
コード例 #4
0
 function testVerifyFossology()
 {
     global $URL;
     global $name;
     global $safeName;
     print "starting verifyFossDirsOnly test\n";
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifyFossDirsOnly FAILED! Could not find Browse menu\n");
     //print "************ Page after upload link *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifyFossDirsOnly FAILED! did not find {$name}\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "verifyFossDirsOnly FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Meta</"), "verifyFossDirsOnly FAILED! >Meta< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "verifyFossDirsOnly FAILED! >Download< not found\n");
     /* Select archive */
     $page = $this->mybrowser->clickLink($name);
     //print "************ Page after select foss archive *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/empty\\//"), "verifyFossDirsOnly FAILED! 'empty/' not found\n");
     $this->assertTrue($this->myassertText($page, "/1 item/"), "verifyFossDirsOnly FAILED! '1 item' not found\n");
     /* Select empty link */
     $page = $this->mybrowser->clickLink('empty/');
     /* need to check that there are 9 items */
     $this->assertTrue($this->myassertText($page, "/9 items/"), "verifyFossDirsOnly FAILED! '9 items' not found\n");
     $this->assertTrue($this->myassertText($page, "/agents/"), "verifyFossDirsOnly FAILED! did not find 'agents' directory\n");
     $this->assertTrue($this->myassertText($page, "/scheduler/"), "verifyFossDirsOnly FAILED! did not find scheduler directory\n");
     /* Select the License link to View License Historgram */
     $browse = new parseBrowseMenu($page);
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     $url = makeUrl($this->host, $miniMenu['License']);
     if ($url === NULL) {
         $this->fail("verifyFossDirsOnly Failed, host is not set");
     }
     $page = $this->mybrowser->get($url);
     //print "page after get of $url is:\n$page\n";
     $this->assertTrue($this->myassertText($page, '/License Browser/'), "verifyFossDirsOnly FAILED! License Browser Title not found\n");
     $this->assertTrue($this->myassertText($page, '/Total licenses: 0/'), "verifyFossDirsOnly FAILED! Total Licenses does not equal 0\n");
     $dList = new parseLicenseTblDirs($page);
     $dirList = $dList->parseLicenseTblDirs();
     //print "dirList is:\n"; print_r($dirList) . "\n";
     /*
      * the directiory agents has 13 subdirectories all other directories
      * are empty. we are going to loop through them, but for now just
      * test a few of them out....
      */
     $url = makeUrl($this->host, $dirList['scheduler/']);
     $page = $this->mybrowser->get($url);
     //print "page after scheduler is:\n$page\n";
     $fList = new parseFolderPath($page, $url);
     $dirCnt = $fList->countFiles();
     // should only get one folder path)
     $this->assertEqual((int) $dirCnt, 1, "verifyFossDirsOnly FAILED! did not get 1 folder path back, got {$dirCnt} instead\n");
     // every entry but the last must have a non-null value (we assume parse
     // routine worked)
     $fpaths = $fList->parseFolderPath();
     $this->assertTrue($this->check4Links($fpaths), "verifyFossDirsOnly FAILED! something wrong with folder path\n" . "See this url:\n{$url}\n");
 }
コード例 #5
0
 /**
  * clean up the links to be usable
  *
  * @param array $list, the list to clean up
  * @param int $matches, the size of the list
  *
  * @return array, the cleaned up list_bucket_files
  *
  * @todo fix the docs above to much more detailed.
  */
 function _createRtnArray($list, $matches)
 {
     global $host;
     /*
      * The last entry in the array is always a leaf name with no link
      * but it has to be cleaned up a bit....
      */
     for ($i = 0; $i < $matches; $i++) {
         $cleanKey = trim($list[$i][2], "\\/<>b");
         if (empty($cleanKey)) {
             continue;
         }
         // Make a real link that can be used
         $partLink = $list[$i][1];
         $link = makeUrl($this->host, $partLink);
         $rtnList[$cleanKey] = $link;
         /* check for anything in the leaf entry, if there is, remove
          * the preceeding /
          */
         if (!empty($list[$i][3])) {
             $cleanKey = trim($list[$i][3], "\\/ ");
             if (empty($cleanKey)) {
                 continue;
             }
             $rtnList[$cleanKey] = NULL;
         }
     }
     return $rtnList;
 }
コード例 #6
0
<?output('_header.html.php',$output);?>

    <!-- custom javascript -->
    <script type="text/javascript" >
        var default_url = '<?= makeUrl(cfg('default_uri')) ?>';
    </script>
    <?=includeJS("jquery-ui-1.8.11.custom.min.js");?>
    <?=includeJS("jquery.ui.nestedSortable.js");?>
    <?=includeJS("admin_projects_list.js");?>

    
<?output('_header2.html.php',$output);?>
    <div class="pad" >
        <a href="#newproject" class="button">add new project</a>
        <div id="list-holder" >
            <?=projects()->getMenu(false)?>
        </div>
    </div>
<?output('_footer.html.php',$output);?>
コード例 #7
0
ファイル: functions.php プロジェクト: ramonztro/lightwork-mvc
function metaImage($return = false)
{
    if ($return) {
        return current(makeUrl(array(ENV_META_IMAGE)));
    } else {
        echo current(makeUrl(array(ENV_META_IMAGE)));
    }
}
コード例 #8
0
ファイル: update.inc.php プロジェクト: n-vlad/Blog
<?php

// Start the session.
session_start();
// Include the functions so you can create an URL.
include_once 'functions.inc.php';
// Include the image handling class.
include_once 'images.inc.php';
include_once 'db.inc.php';
$db = new PDO(DB_INFO, DB_USER, DB_PASS);
// Initial check.
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['submit'] == 'Save Entry' && !empty($_POST['page']) && !empty($_POST['title']) && !empty($_POST['entry'])) {
    // Create an URL to be saved in the database.
    $url = makeUrl($_POST['title']);
    // Retrieves entries for the given URL.
    $e = retrieveEntries($db, $_POST['page'], $url);
    // We run a check to see if there already is an image saved for the entry.
    // Otherwise we upload one if needed.
    if (empty($e['image'])) {
        // We check if there is an image to upload.
        if (!empty($_FILES['image']['tmp_name'])) {
            try {
                // Instantiate the class and set a save path.
                $img = new ImageHandler("/files/");
                // Process the file and store the returned path.
                $img_path = $img->processUploadedImage($_FILES['image']);
                // Output the uploaded image as it was saved.
                echo '<img src=" ', $img_path, ' "/><br/>';
            } catch (Exception $e) {
                // If an error occurred, output your custom error message.
                die($e->getMessage());
コード例 #9
0
 function test3filesCopyright()
 {
     global $URL;
     global $name;
     global $safeName;
     // Note the entry: COPYRIGHT ,
     // should really be:
     //
     // '* Copyright (c) 2002-2004 Sam Leffler, Errno Consulting, Atheros' => 1,
     // Likewise: copyrighted by Affero should be:
     // copyrighted by 278 Affero, Inc.
     // this string has ossolated between removing the id: and not
     // 'id: copyright v 1.2 / / : samleffler exp' => 1,
     $copyStd = array('copyright (c) free software foundation inc' => 1, 'copyright (c) free software foundation inc. made with' => 1, 'copyright (c) sam leffler errno consulting atheros' => 1, 'copyright v 1.2 / / : samleffler exp' => 1, 'copyright (c) <year> <name of author' => 1, 'copyright affero inc' => 1);
     print "starting Verify3filesCopyright test\n";
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verify3files FAILED! Could not find Browse menu\n");
     $page = $this->mybrowser->clickLink('Copyright');
     //print "************ Page after upload link *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/Browse/"), "verify3files FAILED! Browse Title not found\n");
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verify3files FAILED! did not find {$name}\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "verify3files FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Info</"), "verify3files FAILED! >Info< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "verify3files FAILED! >Download< not found\n");
     /* Select archive */
     $page = $this->mybrowser->clickLink($name);
     $page = $this->mybrowser->clickLink('3files.tar');
     //print "************ Page after select foss archive *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/Affero-v1\\.0/"), "verify3files FAILED! '3files/' not found\n");
     $this->assertTrue($this->myassertText($page, "/3 items/"), "verify3files FAILED! '3 items' not found\n");
     /* Select the Copyright/Email/URL link  */
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     $url = makeUrl($this->host, $miniMenu['Copyright/Email/URL']);
     if ($url === NULL) {
         $this->fail("FATAL! verify3files Failed, host is not set or url " . "cannot be made, Stopping this test");
         exit(1);
     }
     $page = $this->mybrowser->get($url);
     //print "page after get of $url is:\n$page\n";
     $this->assertTrue($this->myassertText($page, '/Copyright\\/Email\\/URL Browser/'), "verify3files FAILED! Copyright/Email/URL Browser Title not found\n");
     $this->assertTrue($this->myassertText($page, '/Total Copyrights: 6/'), "verify3files FAILED! Total copyrights does not equal 6\n");
     $this->assertTrue($this->myassertText($page, '/Unique Copyrights: 6/'), "verify3files FAILED! Unique Copyrights does not equal 6\n");
     // get the count, show links and text or link
     $copyR = new domParseLicenseTbl($page, 'copyright');
     $copyR->parseLicenseTbl();
     if (empty($copyR->hList)) {
         $this->fail("FATAL! table with id=copyright was not found on" . "the page, nothing to process, stopping test\n");
         exit(1);
     }
     //print "entries in the table:\n";print_r($copyR->hList) . "\n";
     // Verify text and counts are correct
     $notFound = array();
     $found = NULL;
     foreach ($copyR->hList as $copyFound) {
         $key = $copyFound['textOrLink'];
         if (array_key_exists($key, $copyStd)) {
             $this->pass("Pass: found {$key} in copyright table\n");
             $found = 1;
             // found one, check the count
             $foundCount = $copyFound['count'];
             $count = $copyStd[$key];
             $this->assertEqual($count, $foundCount, "verify3files FAILED! the counts are not equal\n\n         Expected:{$count}\nGot:{$foundCount}\n");
             continue;
         } else {
             $notFound[] = $key;
         }
     }
     // foreach $copyR->
     //} // foreach $copyStd
     // this is a hack for now... should be a better way to filter
     // Try in_array before insert?
     $uniqueNF = array();
     $uniqueNF = array_unique($notFound);
     if (!empty($uniqueNF)) {
         $this->fail("verify3files FAILED! the following items did not" . " match any standard, are any false positives?:\n");
         print "\n";
         foreach ($uniqueNF as $falsePos) {
             print "{$falsePos}\n---------------------\n";
         }
     }
     $email = new domParseLicenseTbl($page, 'copyrightemail');
     $email->parseLicenseTbl();
     // empty table?, verify counts are zero
     if ($email->noRows) {
         $this->assertTrue($this->myassertText($page, '/Total Emails: 0/'), "verify3files FAILED! Total Emails does not equal 0\n");
         $this->assertTrue($this->myassertText($page, '/Unique Emails: 0/'), "verify3files FAILED! Unique Emails does not equal 0\n");
     } else {
         if (empty($email->hList)) {
             $this->fail("FATAL! table with id=copyrightemail was not found on" . "the page, nothing to process, stopping test\n");
             exit(1);
         }
     }
     $urls = new domParseLicenseTbl($page, 'copyrighturl');
     $urls->parseLicenseTbl();
     // empty table?, verify counts are zero
     if ($urls->noRows) {
         $this->assertTrue($this->myassertText($page, '/Total URLs: 0/'), "verify3files FAILED! Total URL's does not equal 0\n");
         $this->assertTrue($this->myassertText($page, '/Unique URLs: 0/'), "verify3files FAILED! Unique URL's does not equal 0\n");
     } else {
         if (empty($urls->hList)) {
             $this->fail("FATAL! table with id=copyrighturl was not found on" . "the page, nothing to process, stopping test\n");
             exit(1);
         }
     }
 }
コード例 #10
0
ファイル: ad.mod.php プロジェクト: tech-nik89/lpm4
        $upload = new Upload();
        $upload->dir = 'media/boximages/ad/';
        $upload->tag_name = 'image';
        $upload->uploadFile();
        $imgdir = "./media/boximages/ad/";
        include_once './core/simple.image.core.php';
        $image = new SimpleImage();
        $image->load($imgdir . $upload->file_name);
        if ($image->getWidth() > (int) $config->get('ad', 'standard_image_width')) {
            $image->resizeToWidth((int) $config->get('ad', 'standard_image_width'));
        }
        if ($image->getHeight() > (int) $config->get('ad', 'standard_image_height')) {
            $image->resizeToHeight((int) $config->get('ad', 'standard_image_height'));
        }
        unlink($imgdir . $upload->file_name);
        $image->save($imgdir . $upload->file_name);
        if (substr($_POST['newurl'], 0, 7) != "http://") {
            $_POST['newurl'] = "http://" . $_POST['newurl'];
        }
        $db->insert($tbl_ad, array('img', 'url'), array("'" . $upload->file_name . "'", "'" . $_POST['newurl'] . "'"));
    }
}
$allads = $db->selectList($tbl_ad, '*', 1);
$counter = 0;
$ads = array();
foreach ($allads as $ad) {
    $ads[$counter] = $ad;
    $ads[$counter++]['imgurl'] = makeUrl('ad', array('mode' => 'edit'));
}
$smarty->assign('ads', $ads);
$smarty->assign('path', $template_dir . "/ad.view.tpl");
コード例 #11
0
ファイル: login.html.php プロジェクト: nmyers/Microfolio
<?output('_header.html.php',$output);?>
<?output('_header2.html.php',$output);?>
<div class="loginform" >
<form name="logform" method=post action="<?=makeUrl("/login/");?>">
    <label>Username</label><input type="text" name="username" value="" /><br />
    <label>Password</label><input type="password" name="password" value="" /><br />
    <div class="buttons" >
    <a class="button" href="#" onclick="document.logform.submit();" >login</a>
    <a class="button" href="<?=makeUrl("index");?>" >cancel</a>
    </div>
</form>
</div>
<?output('_footer.html.php',$output);?>
コード例 #12
0
/**
 * This function will use the resource cache to lookup all controllers and their methods.  Then it
 * will create a Triumph_Url instance for each method; note that the routes file is 
 * also consulted and we will generate URLs for the default controller.
 *
 * @param  string  $sourceDir            the root directory of the project in question
 * @param  string  $resourceDbFileName   the location of the resource cache SQLite file; as created by Triumph
 * @param  string  $host                 the hostname of the application; this will be used a the prefix on all URLs
 * @param  boolean $doSkip               out parameter; if TRUE then this detector does not know how
 *                                       to detect URLs for the given source directory; this situation
 *                                       is different than zero URLs being detected.
 * @return Triumph_Url[]               array of Triumph_Url instances the detected URLs
 */
function detectUrls($sourceDir, $resourceDbFileName, $host, &$doSkip)
{
    $doSkip = TRUE;
    if (!is_file($resourceDbFileName)) {
        return array();
    }
    $sourceDir = \opstring\ensure_ends_with($sourceDir, DIRECTORY_SEPARATOR);
    $host = \opstring\ensure_ends_with($host, '/');
    // TODO: handle multiple apps
    // need this define so that we can include code igniter files directly
    if (!defined('BASEPATH')) {
        define('BASEPATH', '');
    }
    if (!is_file($sourceDir . 'application/config/routes.php') || !is_file($sourceDir . 'application/config/config.php')) {
        // this source directory does not contain a code igniter directory.
        return array();
    }
    $doSkip = FALSE;
    // get the code igniter configuration so that we can use it to build the
    // correct routes
    $config = array();
    $route = array();
    include $sourceDir . 'application/config/routes.php';
    include $sourceDir . 'application/config/config.php';
    $allUrls = array();
    // lookup all controller files from the resource cache, only controllers are accessible via URLs
    // since file names in the cache are OS dependant, need to use the correct directory separators
    $pdo = Zend_Db::factory('Pdo_Sqlite', array("dbname" => $resourceDbFileName));
    $fileItemTable = new Triumph_FileItemTable($pdo);
    $controllerDir = $sourceDir . 'application' . DIRECTORY_SEPARATOR . 'controllers';
    $matchingFiles = $fileItemTable->MatchingFiles($controllerDir);
    // lookup all of the methods for all controller files.
    $resourceTable = new Triumph_ResourceTable($pdo);
    $methods = $resourceTable->PublicMethodsFromFiles($matchingFiles);
    foreach ($methods as $resource) {
        // need to handle any sub-directories underneath the controllers; as the subdirectory
        // is propagated in the URL
        $controllerFile = \opstring\after($resource->fullPath, $controllerDir);
        $subDirectory = dirname($controllerFile);
        if ('\\' == $subDirectory || '/' == $subDirectory) {
            // hack to work around special case when there is no subdirectory
            $subDirectory = '';
        }
        // constructors are not web-accessible
        // code igniter makes methods that start with underscore
        if (\opstring\compare_case('__construct', $resource->identifier) && !\opstring\begins_with($resource->identifier, '_')) {
            // TODO: any controller arguments ... should get these from the user somehow
            $extra = '';
            $appUrl = makeUrl($route, $config, $subDirectory, $resource->fullPath, $resource->className, $resource->identifier, $extra);
            $appUrl->url = $host . $appUrl->url;
            $allUrls[] = $appUrl;
        }
    }
    return $allUrls;
}
コード例 #13
0
 function tournamentTable()
 {
     global $smarty;
     global $template_dir;
     global $db;
     global $config;
     $encList = $db->selectList('tournamentencounters', '*', "`tournamentid`=" . $this->tournamentId, "`roundid` ASC, `encounterid` ASC");
     foreach ($encList as $encounter) {
         $y = $encounter['roundid'];
         $x = $encounter['encounterid'];
         $curEnc = new EliminationEncounter($this->tournamentId, $y, $x);
         $finalList[$x][$y]['round'] = $x;
         $finalList[$x][$y]['encid'] = $y;
         foreach ($this->participants as $participant) {
             if ($participant->getId() == $curEnc->getPlayer1id()) {
                 $player1 = $participant;
             }
             if ($participant->getId() == $curEnc->getPlayer2id()) {
                 $player2 = $participant;
             }
         }
         // Only player 2 (in the last enc) could be a dummy
         if ($curEnc->getPlayer2id() == -1) {
             $player2 = newDummy();
         }
         if ($curEnc->getPlayer1id() == 0) {
             $player1 = newUnknown();
         }
         if ($curEnc->getPlayer2id() == 0) {
             $player2 = newUnknown();
         }
         if ($curEnc->getPlayer1id() > 0 && $curEnc->getPlayer2id() > 0) {
             $finalList[$x][$y]['link'] = makeUrl('tournament', array('tournamentid' => $this->tournamentId, 'encid' => $x, 'roundid' => $y, 'mode' => 'view'));
         }
         $finalList[$x][$y]['p1name'] = $player1->getName();
         $finalList[$x][$y]['p1url'] = $player1->getUrl();
         $finalList[$x][$y]['p2name'] = $player2->getName();
         $finalList[$x][$y]['p2url'] = $player2->getUrl();
         $finalList[$x][$y]['timestatus'] = $curEnc->getEncTimeState();
         if ($curEnc->isFinished()) {
             $finalList[$x][$y]['p1points'] = $curEnc->getPoints1();
             $finalList[$x][$y]['p2points'] = $curEnc->getPoints2();
             $finalList[$x][$y]['winner'] = $curEnc->winner();
         }
     }
     $smarty->assign('roundsandmaps', $this->getRoundsAndMaps($y + 1));
     $smarty->assign('table', $finalList);
     $smarty->assign('encounterWidth', $config->get('tournament', 'tree-encounter-width'));
     $smarty->assign('encTempl', $template_dir . '/kothencounter.tpl');
     $smarty->assign('path', $template_dir . '/koth.tpl');
 }
コード例 #14
0
 function encounter($roundId, $encId)
 {
     global $breadcrumbs, $template_dir, $smarty, $tournamentList, $notify, $lang, $config, $rights;
     $tournament = $tournamentList->getTournament($this->tournamentId);
     $smarty->assign('tournament', $tournament);
     $enc = new EliminationEncounter($this->tournamentId, $roundId, $encId);
     foreach ($this->participants as $participant) {
         if ($participant->getId() == $enc->getPlayer1id()) {
             $player1 = $participant;
         }
         if ($participant->getId() == $enc->getPlayer2id()) {
             $player2 = $participant;
         }
     }
     if (!isset($player1) || !isset($player2)) {
         $notify->add($lang->get('encounter'), $lang->get('ntfy_submit_err_player'));
         $this->tournamentTable();
         return false;
     } else {
         $breadcrumbs->addElement($player1->getName() . " vs. " . $player2->getName(), makeURL('tournament', array('tournamentid' => $_GET['tournamentid'], 'encid' => $_GET['encid'], 'roundid' => $_GET['roundid'], 'mode' => 'view')));
         $smarty->assign('path', $template_dir . "/eliminationencounter_detail.tpl");
         $smarty->assign('player1', array('name' => $player1->getName(), 'url' => $player1->getUrl()));
         $smarty->assign('player2', array('name' => $player2->getName(), 'url' => $player2->getUrl()));
         $enc_arr['points1'] = $enc->getPoints1();
         $enc_arr['points2'] = $enc->getPoints2();
         $enc_arr['finished'] = $enc->isFinished();
         $enc_arr['winner'] = $enc->getPoints1() > $enc->getPoints2() ? 1 : 2;
         $enc_arr['map'] = $this->getMap($roundId + 1);
         if ($config->get('tournament', 'allow_undoing_encounter_points') && $rights->isAllowed('tournament', 'add_remove_edit') && $enc->isFinished() && $tournament['state'] == 2) {
             $enc_arr['undoLink'] = makeHtmlUrl($lang->get('undo_encounter'), makeUrl('tournament', array('tournamentid' => $this->tournamentId, 'encid' => $enc->getId(), 'roundid' => $roundId, 'mode' => 'view', 'undo' => 1)));
         }
         if ($enc->getStart() != 0) {
             $enc_arr['start'] = $enc->getStart() > time() ? timeLeft($enc->getStart()) : formatTime($enc->getStart());
             $tEnd = $enc->getStart() + $enc->getDuration();
             $enc_arr['end'] = $enc->getStart() < time() && $tEnd > time() ? timeLeft($tEnd) : formatTime($tEnd);
         }
         $smarty->assign('enc', $enc_arr);
         $smarty->assign('user_can_submit', $this->checkSubmitRights($enc, $player1, $player2));
         $smarty->assign('_GET', $_GET);
     }
 }
コード例 #15
0
ファイル: minitools.mod.php プロジェクト: tech-nik89/lpm4
require_once $mod_dir . "/minitools.function.php";
$lang->addModSpecificLocalization($mod);
/*
	
	$breadcrumbs->addElement($lang->get('stat'), makeURL($mod));
	$statistic['config']['visitors_month_enabled'] = (int)$config->get('stat', 'show-visitors-this-month');
*/
$breadcrumbs->addElement($lang->get('minitools'), makeURL($mod));
$mode = @$_GET['mode'];
$availableModes = array('base64', 'roman');
switch ($mode) {
    case 'edit':
        $breadcrumbs->addElement($lang->get('minitoolsedit'), makeURL($mod, array('mode' => 'edit')));
        if (isset($_POST['send'])) {
            saveMinitools(@$_POST['data']);
            redirect(makeUrl('minitools'));
        }
        $smarty->assign('minitools', getAllMinitools($availableModes));
        $smarty->assign('path', $template_dir . "/edit.tpl");
        break;
    case 'base64':
        $breadcrumbs->addElement($lang->get('base64'), makeURL($mod, array('mode' => 'base64')));
        $menu->addSubElement('minitools', $lang->get('base64encode'), 'base64', array('action' => 'encode'));
        $menu->addSubElement('minitools', $lang->get('base64decode'), 'base64', array('action' => 'decode'));
        $action = @$_GET['action'];
        if ($action == 'decode') {
            $breadcrumbs->addElement($lang->get('base64decode'), makeURL($mod, array('mode' => 'base64', 'action' => 'decode')));
            if (isset($_POST['send'])) {
                if (isset($_POST['text']) && trim($_POST['text']) != '') {
                    $base64decoded = base64_decode(trim($_POST['text']));
                    $smarty->assign('base64decoded', $base64decoded);
コード例 #16
0
                            var data = jQuery.parseJSON(json);
                            showMessage(data.message,data.message_type);
                        }
                    });
                    return false;
                })
	});
</script>

<?output('_header2.html.php',$output);?>
<? if(is_writable(cfg('admin_dir').'config/config.php')): ?>
<div class="settings-top" >
<a href="#savesettings" class="button savesettings">save settings</a>
</div>
        <div id="list-settings" >
            <form id="settingsform" name="settingsform" method=post action="<?=makeUrl("admin/settings");?>">
            <input type="hidden" name="posted" value="1" />
            <? foreach($config as $key => $value): ?>
            <div class="setting" >
                <label><?=ucfirst(str_replace('_', ' ', $key))?></label>
            <input type="<?=stripos($key,'password')!==FALSE?'password':'******'?>" name="<?=$key?>" value="<?=$value?>" />
            </div>
            <? endforeach; ?>
            </form>
        </div>
<? else: ?>
<div>
    Your configuration file is not writable. <br />
    You have to change the permission of this file before proceeding:<br />
    <ol>
        <li>Connect to your FTP</li>
コード例 #17
0
function makeTournamentList($tournaments, $userid)
{
    if (count($tournaments) < 1) {
        return false;
    }
    $finalTournaments = array();
    foreach ($tournaments as $tournament) {
        $nextEnc = '';
        $ranking = '';
        switch ($tournament['state']) {
            // Inactive
            case 0:
                $url = $tournament['title'];
                break;
                // Joining
            // Joining
            case 1:
                $url = makeHTMLUrl($tournament['title'], makeUrl('tournament', array('tournamentid' => $tournament['tournamentid'])));
                break;
                // Running
            // Running
            case 2:
                $url = makeHTMLUrl($tournament['title'], makeUrl('tournament', array('tournamentid' => $tournament['tournamentid'], 'mode' => 'table')));
                $nextEnc = getNextEncounter($tournament, $userid);
                break;
                // Finished
            // Finished
            case 3:
                $url = makeHTMLUrl($tournament['title'], makeUrl('tournament', array('tournamentid' => $tournament['tournamentid'], 'mode' => 'table')));
                $tournament_obj = getTournamentObject($tournament);
                $ranking = $tournament_obj->ranking();
                break;
        }
        $finalTournaments[] = array('url' => $url, 'listcolor' => makeListColor($tournament['state']), 'nextencounter' => $nextEnc, 'state' => $tournament['state'], 'statename' => tournamentStateToString($tournament['state']), 'ranking' => $ranking, 'tournamentid' => $tournament['tournamentid'], 'title' => $tournament['title']);
    }
    return $finalTournaments;
}
コード例 #18
0
 public function recieve($n = 1, $full_urls = false)
 {
     global $db, $SITE_ROOT;
     $ret = array();
     for ($i = -1; $n > ++$i && ($arr = $db->get_row_array());) {
         //print_r($arr);
         $vals = explode('~~', $arr['data']);
         // $arr['created'] = EcTable::formatCreated($arr['created']);
         unset($arr['data']);
         for ($j = count($vals); $j--;) {
             $kv = explode('::', $vals[$j]);
             if (count($kv) > 1 && array_key_exists($kv[0], $this->fields)) {
                 if ($this->fields[$kv[0]]->valueIsObject()) {
                     $arr[$kv[0]] = json_decode($kv[1], true);
                 } elseif ($full_urls && $this->fields[$kv[0]]->type == "photo" && $kv[1] != '') {
                     $arr[$kv[0]] = sprintf('http://%s/%s%s/%s/__getImage?img=%s', $_SERVER['HTTP_HOST'], trim($SITE_ROOT, '/') . '/', $this->projectName, $this->name, $kv[1]);
                 } elseif ($full_urls && $this->fields[$kv[0]]->valueIsFile() && $kv[1] != '') {
                     if (strstr($kv[1], $this->survey->name . '~')) {
                         $arr[$kv[0]] = makeUrl($kv[1]);
                     } else {
                         $arr[$kv[0]] = makeUrl($this->survey->name . '~' . $kv[1]);
                     }
                 } else {
                     $arr[$kv[0]] = $kv[1];
                 }
             }
         }
         array_push($ret, $arr);
     }
     return $ret;
 }
コード例 #19
0
ファイル: stats.php プロジェクト: Olybri/Minecrew
}
echo "</tr>\n";
foreach ($statList as $key => $values) {
    if (!isset($dates) && $key == "average") {
        continue;
    }
    if (!$config["UNUSED_STATS"] && !in_array($key, array("total", "average", "everyHour")) && array_sum(array_column($players, $key)) <= 0) {
        if (!isset($unlisted)) {
            $unlisted = "<b>Non-listés :</b> ";
        }
        $unlisted .= $values[0] . " | ";
        continue;
    }
    echo "<tr>";
    $sorted = $key == $sortStat;
    echo "<th " . (in_array($key, array("total", "average", "everyHour")) ? "" : "title='{$key}'") . "onclick='printStats(" . makeUrl($statCat, $key, $sortPlayer) . ");' " . ($sorted ? " class='sorted'>" : "class='unsorted'>") . "{$values['0']}</td>";
    foreach ($players as $name => $player) {
        $sorted = $name == $sortPlayer || $key == $sortStat;
        echo "<td" . ($sorted ? " class='sorted'>" : ">") . formatValue($player[$key], $statList[$key][1]) . "</td>";
        if ($name == "Total") {
            echo "<td class='blank'></td>";
        }
    }
    echo "</tr>\n";
    if ($key == "everyHour" || $statCat == "biomes" && $key == "total") {
        echo "<tr><td class='blank'></td></tr>\n";
    }
}
echo "</table>";
if ($showUnlisted) {
    echo isset($unlisted) ? "<br>" . substr($unlisted, 0, -3) : "";
コード例 #20
0
ファイル: _header2.html.php プロジェクト: nmyers/Microfolio
    <title>Microfolio :: <?=$admin_title?></title>
</head>
<iframe id="mainFrame" name="mainFrame" class="ui-layout-center" frameborder="0" scrolling="auto" src="">
</iframe>
<div class="ui-layout-west">
<div id="design" >&nbsp;</div>
<div id="header" >
    <div class="in" >
        <div class="middle" >
            <a href="#" >Microfolio</a>
        </div>
        <div class="left" >
            <a href="<?=makeUrl('admin/projects');?>" ><?=$admin_title?></a>
        </div>
        
        <div class="right" >
            <ul id="menu">
                
                <li><a href="<?=makeUrl('admin/settings');?>" >Settings</a></li>
                <li><a href="<?=makeUrl('admin/help');?>" >Help</a></li>
                <li class="last" ><a href="<?=makeUrl('logout');?>" >Logout</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="warnings" >
    <?=warnings();?>
</div>
<div id="main" >
コード例 #21
0
 function testVerifyFossI16L518()
 {
     global $URL;
     global $name;
     global $safeName;
     print "starting VerifyFossI16L518 test\n";
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifyFossI16L518 FAILED! Could not find Browse menu\n");
     /* Testing folder */
     $page = $this->mybrowser->clickLink('Testing');
     //print "************ Page after upload link *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/Browse/"), "verifyFossI16L518 FAILED! Browse Title not found\n");
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifyFossI16L518 FAILED! did not find {$name}\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "verifyFossI16L518 FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Meta</"), "verifyFossI16L518 FAILED! >Meta< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "verifyFossI16L518 FAILED! >Download< not found\n");
     /* Select archive */
     $page = $this->mybrowser->clickLink($name);
     //print "************ Page after select foss archive *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/fossology\\//"));
     /* Select fossology link */
     $page = $this->mybrowser->clickLink('fossology/');
     /* need to check that there are 16 items */
     /* check that all the [xxx] items add to 519 */
     $this->assertTrue($this->myassertText($page, "/Makefile/"));
     $this->assertTrue($this->myassertText($page, "/mkcheck\\.sh/"), "FAIL! did not find mkcheck.sh\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "FAIL! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Meta</"), "FAIL! >Meta< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "FAIL! >Download< not found\n");
     /* Select the License link to View License Historgram */
     $browse = new parseBrowseMenu($page);
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     print "DEBUG: miniMenu is:\n";
     print_r($miniMenu) . "\n";
     $url = makeUrl($this->host, $miniMenu['License']);
     if ($url === NULL) {
         $this->fail("verifyFossI16L518 Failed, host is not set");
     }
     $page = $this->mybrowser->get($url);
     //print "page after get of $url is:\n$page\n";
     $this->assertTrue($this->myassertText($page, '/License Browser/'), "verifyFossI16L518 FAILED! License Browser Title not found\n");
     $this->assertTrue($this->myassertText($page, '/Total licenses: 518/'), "verifyFossI16L518 FAILED! Total Licenses does not equal 518\n");
     // get the 'Show' links and License color links
     $licTbl = new parseLicenseTbl($page);
     $licTable = $licTbl->parseLicenseTbl();
     /* FIX THIS Select show 'Public Domain, verify, select 'LGPL v2.1', verify */
     $pdURL = makeUrl($this->host, $licTable['Public Domain']);
     $lgplURL = makeUrl($this->host, $licTable['\'LGPL v2.1\'-style']);
     $page = $this->mybrowser->get($pdURL);
     $licFileList = new parseFolderPath($page, $URL);
     $fileCount = $licFileList->countFiles();
     print "Checking the number of files based on Public Domain\n";
     $this->assertEqual($fileCount, 4, "verifyFossI16L518 FAILED! Should be 4 files based on Public Domain got:{$fileCount}\n");
     $page = $this->mybrowser->get($lgplURL);
     $licFileList->setPage($page);
     $flist = $licFileList->countFiles();
     print "Checking the number of files based on LGPL v2.1-style\n";
     $this->assertEqual($flist, 16, "verifyFossI16L518 FAILED! Should be 16 files based on LGPL v2.1-style got:{$flist}\n");
 }
コード例 #22
0
ファイル: pmbox.mod.php プロジェクト: tech-nik89/lpm4
             $db->insert($tbl_inbox, array('pmid', 'senderid', 'recieverid', 'timestamp', 'subject', 'message'), array('NULL', $login->currentUserID(), $u[0]['userid'], time(), "'" . $_POST['subject'] . "'", "'" . $_POST['message'] . "'"));
             // insert into outbox
             $db->insert($tbl_outbox, array('pmid', 'senderid', 'recieverid', 'timestamp', 'subject', 'message'), array('NULL', $login->currentUserID(), $u[0]['userid'], time(), "'" . $_POST['subject'] . "'", "'" . $_POST['message'] . "'"));
             // notify about success
             $notify->add($lang->get('pmbox'), $lang->get('pm_sent'));
             // Send email, if enabled
             if ($config->get($mod, 'email-notification') == '1') {
                 $me = $login->currentUser();
                 $eMail->setVar('sender', $me['nickname']);
                 $eMail->setVar('url', getSelfURL());
                 $result = $eMail->send($lang->get('pm_recieved_subject'), $lang->get('pm_recieved_text'), $u[0]['email']);
                 if ($result) {
                     $notify->add($lang->get('pmbox'), $lang->get('pm_mail_sent'));
                 }
             }
             redirect(makeUrl('pmbox'));
         } else {
             // inbox of reciever is full, notify
             $notify->add($lang->get('pmbox'), $lang->get('inbox_full'));
         }
     } else {
         // no user found, notify
         $notify->add($lang->get('pmbox'), $lang->get('user_not_found'));
     }
 } else {
     if (isset($_POST['send'])) {
         $notify->add($lang->get('pmbox'), $lang->get('fill_all_fields'));
     }
 }
 if (@$_GET['answerid'] != '' && !isset($_POST['send'])) {
     // get message
コード例 #23
0
            </tr>
        </thead>
        <tbody>
<?php 
foreach ($LIST as $c) {
    ?>
            <tr>
                <td><?php 
    print $c['id'];
    ?>
</td>
                <td><?php 
    print $c['name'];
    ?>
</td>
                <td><?php 
    print $c['email'];
    ?>
</td>
                <td><?php 
    print makeUrl($c['id']);
    ?>
</td>
            </tr>
<?php 
}
?>
        </tbody>
    </table>
    </body>
</html>
コード例 #24
0
ファイル: index.php プロジェクト: nmyers/Microfolio
function redirect($action="") {
    header("Location: " . makeUrl($action));
    die();
}
コード例 #25
0
    function _AdsDel_ListAds($options = NULL)
    {
        function makeUrl($u, $anchor_text, $tt, $fragment = 'adsense_list')
        {
            return "<a href=\"{$u}#{$fragment}\" title=\"{$tt}\">{$anchor_text}</a>";
        }
        $action_url = $_SERVER[PHP_SELF] . '?page=' . basename(__FILE__);
        $get_url = $_SERVER[PHP_SELF] . '?page=' . basename(__FILE__);
        $def_url = $get_url . "&amp;fn=default";
        $edit_url = $get_url . "&amp;fn=edit";
        $delete_url = $get_url . "&amp;fn=del";
        $enable_url = $get_url . "&amp;fn=enable";
        echo <<<END
\t<form action="{$action_url}" name="adsform" method="post">
\t<fieldset class="options">
\t<legend id="adsense_list"><span style="font-weight:bold;color:#00C;">AdSense Blocks</span></legend> 
\t<input type="hidden" name="fn" value="update" />
\t<div align="center">
\t<table border="0" width="95%" cellpadding="3" cellspacing="3" >
END;
        if (!isset($options)) {
            echo '<tr><td>Internal Error: missing $options</td></tr>';
        } else {
            $altclass = 'alternate';
            echo "<tr><th>Name</th><th>Description</th><th>Actions</th><th>On</th></tr>";
            foreach ($options['ads'] as $key => $vals) {
                // setup locals for on/off checkboxes
                $onOffChecked = '';
                if ($vals['enabled']) {
                    $onOffChecked = 'checked="checked"';
                }
                if ($options['default'] == $key) {
                    echo "<tr style=\"background-color:#CCFF99;\">";
                } else {
                    echo "<tr class=\"{$altclass}\">";
                }
                echo "<td align=\"center\">&lt;!--adsense";
                if ($options['default'] != $key) {
                    echo '#' . $key;
                }
                echo "--&gt;</td>";
                echo '<td style="font-size:.9em;">' . '<a title="Click to Preview This Ad Style in a new window" onClick=\'' . AdsDel_makePreviewUrl($vals['adsense'], get_settings('home'), $key) . '\'>' . $vals['desc'] . '</a></td>';
                echo '<td style="font-size:.9em;" align="center">';
                echo makeUrl($delete_url . '&amp;kw=' . $key, 'delete', 'Delete AdSense') . ' | ';
                echo makeUrl($def_url . '&amp;kw=' . $key, 'default', 'Make this the default') . "\n | ";
                echo makeUrl($edit_url . '&amp;kw=' . $key, 'edit', 'Edit this configuration', 'template');
                echo '</td>' . "\n";
                // on/off checkbox
                echo '<td align="center"><input type="checkbox" name="' . $key . '" value="1" ' . $onOffChecked . '/></td></tr>' . "\n";
                $altclass = $altclass == '' ? 'alternate' : '';
            }
        }
        $all_on_checked = '';
        $posts_on_checked = '';
        $home_on_checked = '';
        $archives_on_checked = '';
        $page_on_checked = '';
        if ($options['all_enabled']) {
            $all_on_checked = 'checked="checked"';
        }
        if ($options['enabled_for']['home']) {
            $home_on_checked = 'checked="checked"';
        }
        if ($options['enabled_for']['archives']) {
            $archives_on_checked = 'checked="checked"';
        }
        if ($options['enabled_for']['page']) {
            $page_on_checked = 'checked="checked"';
        }
        if ($options['enabled_for']['posts']) {
            $posts_on_checked = 'checked="checked"';
        }
        echo <<<END
\t\t<tr><td>&nbsp;</td><td colspan="3" align="center"><i style="color:gray;">The options below this line control where Ads will be shown.</i></td></tr>
\t\t<tr>
\t\t\t<td colspan="3" align="right">Enable Ads on Individual Posts</td>
\t\t\t<td align="center"><input type="checkbox" name="posts_on" value="1" {$posts_on_checked} /></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td colspan="3" align="right">Enable Ads on Home page</td>
\t\t\t<td align="center"><input type="checkbox" name="home_on" value="1" {$home_on_checked} /></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td colspan="3" align="right">Enable Ads on &quot;pages&quot;</td>
\t\t\t<td align="center"><input type="checkbox" name="page_on" value="1" {$page_on_checked} /></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td colspan="3" align="right">Enable Ads on any Archive page</td>
\t\t\t<td align="center"><input type="checkbox" name="archives_on" value="1" {$archives_on_checked} /></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td colspan="3" align="right"><b>Globally enable/disable all ads</b></td>
\t\t\t<td align="center"><input type="checkbox" name="all_on" value="1" {$all_on_checked}/></td>
\t\t</tr>
\t\t<tr><td colspan="4" align="right"><input type="submit" name="submit" value="Update Enabled Options &raquo;" /></td></tr>
\t\t</table>
\t\t</div>
\t\t</fieldset>
\t\t</form>
END;
    }
コード例 #26
0
ファイル: printLicTbl.php プロジェクト: DanielDobre/fossology
 function testLicTbl()
 {
     global $URL;
     global $name;
     global $safeName;
     print "starting print lics\n";
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifySimpleTest FAILED! Could not find Browse menu\n");
     $this->assertTrue($this->myassertText($page, "/Browse/"), "verifySimpleTest FAILED! Browse Title not found\n");
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifySimpleTest FAILED! did not find {$name}\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "verifySimpletest FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Info</"), "verifySimpletest FAILED! >Info< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "verifySimpletest FAILED! >Download< not found\n");
     /* Select archive */
     $page = $this->mybrowser->clickLink('Testing');
     $page = $this->mybrowser->clickLink($name);
     //print "************ Page after select RedHat.tar *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/1 item/"), "verifySimpletest FAILED! '1 item' not found\n");
     $this->assertTrue($this->myassertText($page, "/RedHat/"), "verifySimpletest FAILED! 'RedHat' not found\n");
     $page = $this->mybrowser->clickLink('RedHat/');
     //print "************ Page after select RedHat Link *************\n$page\n";
     /* Select the link to get copyright info */
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     //print "MiniMenu is:\n";print_r($miniMenu) . "\n";
     $url = makeUrl($this->host, $miniMenu['Nomos License']);
     if ($url === NULL) {
         $this->fail("RHEL Lics Failed, host/URL is not set");
     }
     $page = $this->mybrowser->get($url);
     // get the 'Show' links and License color links
     $ct = new domParseLicenseTbl($page, 'lichistogram');
     $ct->parseLicenseTbl();
     // empty table? Error
     if ($ct->noRows) {
         $this->fail("Error! table with id=copyright has no rows!" . " nothing to process, There should be!\n");
     } else {
         if (empty($ct->hList)) {
             $this->fail("Error! table with id=copyright was not found on" . "the page, There should be one\n");
         } else {
             $total = 0;
             print "\$copyStd = array(\n";
             foreach ($ct->hList as $list) {
                 $cs = cleanString($list['textOrLink']);
                 print "    '{$cs}' => {$list['count']},\n";
                 $total += (int) $list['count'];
             }
             print ");\n";
         }
     }
 }
コード例 #27
0
ファイル: models.php プロジェクト: nmyers/Microfolio
    public function render($resize_code='full', $force_thumbnail=false) {
        if (preg_match('/(r|c|t|f)(\d+)x(\d+)/i', $resize_code, $matches)) {

            $r = $matches[1];
            $w = $matches[2];
            $h = $matches[3];

            if ($this->type == 'embed') {
                if ($w < 250 || $h < 250 || $force_thumbnail) {
                    $url = str_replace('http://', '', getEmbedCode($this->src, true));
                    return sprintf('<img src="%s" alt="%s" width="%s" height="%s" class="embed %s" />',
                            makeUrl('image/' . $resize_code . '/ext/' . $url), $this->title,
                            $w, $h, $resize_code);
                } else {
                    return getEmbedCode($this->src);
                }
            } elseif ($this->type == 'image') {
                return sprintf('<img src="%s" alt="%s" width="" height="" class="image %s" />',
                        makeUrl('image/' . $resize_code . '/' . $this->slug . '/' . $this->src), $this->title,
                        $w, $h, $resize_code);
            }
        } elseif ($resize_code == 'full') {
            if ($this->type == 'embed') {
                return getEmbedCode($this->src);
            } elseif ($this->type == 'image') {
                return sprintf('<img src="%s" alt="%s" class="image full" />',
                        makeUrl('image/' . $resize_code . '/' . $this->slug . '/' . $this->src), $this->title);
            }
        }
    }
コード例 #28
0
ファイル: WebAPI.php プロジェクト: skyshore2001/JDCloud
 /** @api */
 function callSvr($ac, $param = null, $data = null, $opt = null)
 {
     $h = curl_init();
     checkParam($param);
     checkParam($data);
     $dbgLevel = intval(getenv("P_DEBUG"));
     if (isset($dbgLevel) && $dbgLevel > 0) {
         self::addParam($param, "_debug", $dbgLevel);
         if ($dbgLevel >= 9) {
             self::addParam($param, "XDEBUG_SESSION_START", "netbeans-xdebug");
         }
     }
     $_app = getenv("P_APP");
     if ($_app != "") {
         self::addParam($param, "_app", $_app);
     }
     $_test = self::getTestMode();
     if ($_test) {
         self::addParam($param, "_test", $_test);
     }
     $url = makeUrl($ac, $param);
     curl_setopt($h, CURLOPT_URL, $url);
     curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($h, CURLOPT_HEADER, 1);
     curl_setopt($h, CURLOPT_COOKIEFILE, $this->cookieFile);
     curl_setopt($h, CURLOPT_COOKIEJAR, $this->cookieFile);
     curl_setopt($h, CURLOPT_USERAGENT, 'RTEST');
     $header = array();
     if ($this->markInitDB) {
         $header[] = "bc-initdb: 1";
         $this->markInitDB = false;
     }
     if (isset($data)) {
         $boundary = null;
         if (!@$opt["forBatch"]) {
             $contentType = "application/x-www-form-urlencoded";
         } else {
             $boundary = "WebTest" . rand(1000, 9999);
             $contentType = "multipart/form-data; boundary={$boundary}";
         }
         if (is_array($data)) {
             $data = makeParam($data, $boundary);
         } else {
             // use file as content
             if (is_string($data) && $data[0] === '@') {
                 $fname = substr($data, 1);
                 $data = file_get_contents($fname);
                 if ($data === false) {
                     die("cannot read file {$fname}");
                 }
             }
         }
         curl_setopt($h, CURLOPT_POST, 1);
         curl_setopt($h, CURLOPT_POSTFIELDS, $data);
         if ($boundary) {
             # show in log
             $data = "(uploaded files)\n";
         }
     } else {
         $contentType = 'text/plain';
     }
     $header[] = "Content-Type: {$contentType}";
     if (isset($data)) {
         $header[] = 'Expect:';
     }
     # disable header: "Expect: 100-continue". direct post, dont ask server.
     curl_setopt($h, CURLOPT_HTTPHEADER, $header);
     // log request
     $this->logit(sprintf("=== REQUEST: %s\r\n%s %s\r\n%s\r\n\r\n%s", $ac, isset($data) ? "POST" : "GET", $url, empty($header) ? "" : join("\r\n", $header), isset($data) ? "{$data}\r\n\r\n" : ""));
     # for https, ignore cert errors (e.g. for self-signed cert)
     curl_setopt($h, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($h, CURLOPT_SSL_VERIFYHOST, 0);
     $rv = curl_exec($h);
     $this->logit(sprintf("=== RESPONSE: %s\r\n", $ac));
     if ($rv === false) {
         $err = curl_error($h);
         curl_close($h);
         $this->logit($err);
         throw new BadHttpReponseException($err);
     }
     curl_close($h);
     $outputFile = @$opt["outputFile"];
     // log response
     if (!$outputFile) {
         $this->logit($rv);
         $res = new HttpResponse($rv);
     } else {
         $p1 = strpos($rv, "\r\n\r\n");
         if ($p1 === false) {
             $hdr = $rv;
         } else {
             $hdr = substr($rv, 0, $p1 + 4);
         }
         $this->logit($hdr);
         $res = new HttpResponse($hdr);
         if ($p1 !== false) {
             file_put_contents($outputFile, substr($rv, $p1 + 4));
             $this->logit("=== content is saved in file `{$outputFile}`");
         }
     }
     return $res;
 }
コード例 #29
0
ファイル: near.php プロジェクト: kojoty/opencaching-pl
            $wiersz = XDb::xFetchArray($wynik);
            $rekord['username'] = $wiersz['username'];
            $znalezione[] = $rekord;
            $lista[] = $rekord['wp_oc'];
            $i++;
        }
        $url = $_SERVER['REQUEST_URI'];
        $tpl->assign('lista', $lista);
        stronicowanie($_GET['page'], 'viewcache', $znalezione, $i, $url);
        exit;
    } else {
        $tpl->assign('error', 1);
    }
} elseif (isset($_POST['city']) && isset($_POST['radius'])) {
    if (!empty($_POST['city']) && !empty($_POST['radius']) && preg_match("/^\\d+\$/", $_POST['radius']) && $_POST['radius'] >= 1 && $_POST['radius'] <= 25) {
        $city = makeUrl($_POST['city']);
        $jsonurl = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . $city;
        $input = file_get_contents($jsonurl);
        $output = json_decode($input, true);
        $output = $output[results][0][geometry][location];
        $lat_h = intval($output[lat]);
        $lat_m = cords2($output[lat]);
        $lon_h = intval($output[lng]);
        $lon_m = cords2($output[lng]);
        if ($lat_h > 0) {
            $ns = 'N';
        } else {
            $ns = 'S';
            $lat_h = abs($lat_h);
        }
        if ($lon_h > 0) {
コード例 #30
0
 function testVerifyFossl16L335()
 {
     global $URL;
     global $name;
     global $safeName;
     // licenseCounts recorded 2010-11-19 for release 1.3
     $licenseCounts = array('GPL_v2' => 224, 'No_license_found' => 72, 'GPL' => 23, 'LGPL_v2.1' => 17, 'Apache_v2.0' => 2, 'GFDL' => 2, 'Public-domain' => 8, 'APSL_v2.0' => 1, 'Artistic' => 1, 'Boost' => 1, 'BSD' => 1, 'FSF-possibility' => 1, 'GPL_v2-possibility' => 1, 'LGPL_v2.1+' => 1, 'LGPL_v3+' => 1, 'NPL' => 1, 'OSL_v3.0' => 1, 'PHP-possibility' => 1, 'Python' => 1, 'See-doc(OTHER)' => 1, 'X11-possibility' => 1, 'Zope' => 1);
     $licenseSummary = array('Unique licenses' => 22, 'Licenses found' => 291, 'Files with no licenses' => 72, 'Files' => 345);
     print "starting VerifyFossl16L335 test\n";
     $page = $this->mybrowser->clickLink('Browse');
     $this->assertTrue($this->myassertText($page, '/Browse/'), "verifyFossl16L335 FAILED! Could not find Browse menu\n");
     /* Testing folder */
     $page = $this->mybrowser->clickLink('Testing');
     //print "************ Page after upload link *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/Browse/"), "verifyFossl16L335 FAILED! Browse Title not found\n");
     $this->assertTrue($this->myassertText($page, "/{$safeName}/"), "verifyFossl16L335 FAILED! did not find {$name}\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "verifyFossl16L335 FAILED! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Info</"), "verifyFossl16L335 FAILED! >Info< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "verifyFossl16L335 FAILED! >Download< not found\n");
     /* Select archive */
     $page = $this->mybrowser->clickLink($name);
     //print "************ Page after select foss archive *************\n$page\n";
     $this->assertTrue($this->myassertText($page, "/fossI16L335U29\\.tar/"), "FAILURE! Could not find fossI16L335U29.tar link\n");
     /* Select fossology link */
     $page = $this->mybrowser->clickLink('fossI16L335U29.tar');
     $page = $this->mybrowser->clickLink('fossology/');
     /* need to check that there are 16 items */
     /* check that all the [xxx] items add to 335 */
     $this->assertTrue($this->myassertText($page, "/Makefile/"));
     $this->assertTrue($this->myassertText($page, "/mkcheck\\.sh/"), "FAIL! did not find mkcheck.sh\n");
     $this->assertTrue($this->myassertText($page, "/>View</"), "FAIL! >View< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Info</"), "FAIL! >Info< not found\n");
     $this->assertTrue($this->myassertText($page, "/>Download</"), "FAIL! >Download< not found\n");
     /* Select the License link to View License Historgram */
     $mini = new parseMiniMenu($page);
     $miniMenu = $mini->parseMiniMenu();
     $url = makeUrl($this->host, $miniMenu['License Browser']);
     if ($url === NULL) {
         $this->fail("verifyFossl16L335 Failed, host/url is not set");
     }
     $page = $this->mybrowser->get($url);
     //print "page after get of $url is:\n$page\n";
     $this->assertTrue($this->myassertText($page, '/License Browser/'), "verifyFossl16L335 FAILED! Nomos License Browser Title not found\n");
     // check that license summarys are correct
     $licSummary = new domParseLicenseTbl($page, 'licsummary', 0);
     $licSummary->parseLicenseTbl();
     foreach ($licSummary->hList as $summary) {
         $key = $summary['textOrLink'];
         $this->assertEqual($licenseSummary[$key], $summary['count'], "verifyFossl16L335 FAILED! {$key} does not equal {$licenseSummary[$key]},\n  \t\tgot {$summary['count']}\n");
         //print "summary is:\n";print_r($summary) . "\n";
     }
     // get the license names and 'Show' links
     $licHistogram = new domParseLicenseTbl($page, 'lichistogram', 1);
     $licHistogram->parseLicenseTbl();
     if ($licHistogram->noRows === TRUE) {
         $this->fail("FATAL! no table rows to process, there should be many for" . " this test, Stopping the test");
         return;
     }
     // verify every row against the standard by comparing the counts.
     /*
      * @todo check the show links, but to do that, need to gather another
      * standard array to match against  or just use the count from the
      * baseline?
      */
     foreach ($licHistogram->hList as $licFound) {
         $key = $licFound['textOrLink'];
         //print "VDB: key is:$key\n";
         //print "licFound is:\n";print_r($licFound) . "\n";
         if (array_key_exists($key, $licenseCounts)) {
             $this->assertEqual($licenseCounts[$key], $licFound['count'], "verifyFossl16L335 FAILED! the baseline count {$licenseCounts[$key]} does" . " not equal {$licFound['count']} for license {$key},\n" . "Expected: {$licenseCounts[$key]},\n" . "     Got: {$licFound['count']}\n");
         } else {
             $this->fail("verifyFossl16L335 A License was found that is " . "not in the standard:\n{$key}\n");
         }
     }
 }