function scrapeHTML($param, $type)
{
    $html = scraperWiki::scrape("http://www.norwegian.no/fly/lavpris/?D_City=CPH&A_City=DUB&TripType=2&D_Day=1&D_Month=201104&R_Day=1&R_Month=201104&AdultCount=1&ChildCount=0&InfantCount=0");
    $dom = new simple_html_dom();
    $dom->load($html);
    // Iterate over table rows and get flight details.
    foreach ($dom->find("TR[@HEIGHT='25']") as $data) {
        // Flight details.
        $tds = $data->find("div");
        $airline = removeSpaces($tds[0]->plaintext);
        $flight_type = $type;
        $flight_num = removeSpaces($tds[1]->plaintext);
        $destination = removeSpaces($tds[2]->plaintext);
        $time = removeSpaces($tds[3]->plaintext);
        $gate = removeSpaces($tds[4]->plaintext);
        $remarks = removeSpaces($tds[5]->plaintext);
        // Skip header row. Cheesy, but effective.
        if ($airline == "Airline") {
            continue;
        }
        // Set the date.
        $date = date("m.d.y");
        // Build up record to store.
        $flight_data = array("date" => $date, "airline" => $airline, "flight_type" => $flight_type, "flight_num" => $flight_num, "destination" => $destination, "time" => $time, "gate" => $gate, "remarks" => $remarks);
        // Save the record.
        saveData(array("date", "airline", "flight_type", "flight_num"), $flight_data);
    }
    $dom->clear();
}
function scrapeHTML($param, $type)
{
    $html = scraperWiki::scrape(BASE_URL . "?type={$param}");
    $dom = new simple_html_dom();
    $dom->load($html);
    // Iterate over table rows and get flight details.
    foreach ($dom->find("TR[@HEIGHT='25']") as $data) {
        // Flight details.
        $tds = $data->find("td");
        $airline = removeSpaces($tds[0]->plaintext);
        $flight_type = $type;
        $flight_num = removeSpaces($tds[1]->plaintext);
        $destination = removeSpaces($tds[2]->plaintext);
        $time = removeSpaces($tds[3]->plaintext);
        $gate = removeSpaces($tds[4]->plaintext);
        $remarks = removeSpaces($tds[5]->plaintext);
        // Skip header row. Cheesy, but effective.
        if ($airline == "Airline") {
            continue;
        }
        // Set the date.
        $date = date("m.d.y");
        // Build up record to store.
        $flight_data = array("date" => $date, "airline" => $airline, "flight_type" => $flight_type, "flight_num" => $flight_num, "destination" => $destination, "time" => $time, "gate" => $gate, "remarks" => $remarks);
        // Save the record.
        saveData(array("date", "airline", "flight_type", "flight_num"), $flight_data);
    }
    $dom->clear();
}
Beispiel #3
0
function printTableData(simple_html_dom $dom)
{
    foreach ($dom->find('tr.gridViewRow, tr.gridViewAlternateRow') as $tr) {
        $td = $tr->find('td');
        echo removeSpaces($td[0]->innertext . ';' . $td[1]->innertext . ';' . $td[2]->innertext . ';');
        echo $td[3]->find('a', 0)->href . ';';
        echo $td[4]->find('img', 0)->alt . "\n";
    }
}
function createAccordionSection($header, $content)
{
    $header_SPC = removeSpaces($header);
    $delete_icon = getIcon('delete', 'icon_danger');
    $edit_icon = getIcon('edit', 'icon_inform');
    //$copy_icon = getIcon('copy', 'icon_inform');
    $return = '<h3 id="' . $header_SPC . '_accordchild">' . $header . '<span id="' . $header_SPC . '_delete" class="mini_btn">' . $delete_icon . '</span><span id="' . $header_SPC . '_edit" class="mini_btn">' . $edit_icon . '</span></span></h3>';
    $return .= '<div>';
    $return .= $content;
    $return .= '</div>';
    return $return;
}
Beispiel #5
0
function pullOutSponsors($sponsors)
{
    if (count($sponsors) == 0) {
        return '';
    }
    global $apis;
    $output = '';
    foreach ($apis as $k => $api) {
        if (in_array(strtolower(removeSpaces($api[0])), $sponsors)) {
            unset($apis[$k]);
            sort($apis);
            $output .= outputApi($api);
        }
    }
    return $output;
}
function scrapeHTML($param, $type)
{
    $html = scraperWiki::scrape("http://www.butxaca.com/");
    $dom = new simple_html_dom();
    $dom->load($html);
    foreach ($dom->find("table.eventtable TR") as $data) {
        $tds = $data->find("td");
        $td = 0;
        foreach ($tds as $cell) {
            switch ($i) {
                case 0:
                    $horas[] = $cell->plaintext . PHP_EOL;
                    break;
                case 2:
                    $titles[] = $cell->find('a.enllasEsdeveniment span.titol')->innertext . PHP_EOL;
                    break;
            }
            $i++;
            // Set the date.
            $dates[] = date("m.d.y");
        }
    }
    // Build up record to store.
    $flight_data = array("date" => $dates, "hora" => $horas, "time" => $titles);
    // Save the record.
    saveData(array("date"), $flight_data);
    exit;
    // Iterate over table rows and get flight details.
    foreach ($dom->find("TR[@HEIGHT='25']") as $data) {
        // Flight details.
        $tds = $data->find("td");
        $airline = removeSpaces($tds[0]->plaintext);
        $flight_type = $type;
        $flight_num = removeSpaces($tds[1]->plaintext);
        $destination = removeSpaces($tds[2]->plaintext);
        $time = removeSpaces($tds[3]->plaintext);
        $gate = removeSpaces($tds[4]->plaintext);
        $remarks = removeSpaces($tds[5]->plaintext);
        // Skip header row. Cheesy, but effective.
        if ($airline == "Airline") {
            continue;
        }
        // Set the date.
        $date = date("m.d.y");
        // Build up record to store.
        $flight_data = array("date" => $date, "airline" => $airline, "flight_type" => $flight_type, "flight_num" => $flight_num, "destination" => $destination, "time" => $time, "gate" => $gate, "remarks" => $remarks);
        // Save the record.
        saveData(array("date", "airline", "flight_num"), $flight_data);
    }
}
Beispiel #7
0
function processCheckBox($rawItems, $question, $questionNum, $required, $answerItem, $name)
{
    global $log;
    $log->debug("Inside processCheckBox method");
    $items = convertPipeToArray($rawItems);
    $convertedAnswer = $answerItem;
    ?>
    <br> 
    <div class="row">
        <div class="col-xs-12 col-lg-12">
            <h6><strong>
                <?php 
    echo $questionNum . ". " . $question;
    ?>
                <?php 
    if ($required) {
        ?>
                    <i class="text-danger"> *(REQUIRED)</i>
                <?php 
    }
    ?>
            </strong></h6>
        </div>
    </div>
    <?php 
    foreach ($items as $item) {
        ?>
        <div class="checkbox">
            <?php 
        if (is_array($convertedAnswer)) {
            ?>
                <?php 
            if (isItemContainedInArray($convertedAnswer, $item)) {
                ?>
                    <h6><input type="checkbox" id="<?php 
                echo $name . "_" . removeSpaces($item);
                ?>
" name="<?php 
                echo $name;
                ?>
" value="<?php 
                echo $item;
                ?>
" checked><?php 
                echo $item;
                ?>
</h6>
                <?php 
            } else {
                ?>
 <!-- end of test is item contained in array -->
                    <h6><input type="checkbox" id="<?php 
                echo $name . "_" . removeSpaces($item);
                ?>
" name="<?php 
                echo $name;
                ?>
" value="<?php 
                echo $item;
                ?>
"><?php 
                echo $item;
                ?>
</h6>
                <?php 
            }
            ?>
 <!-- end of else that item was not array -->
            <?php 
        } else {
            ?>
 <!-- end of if to to test for array -->
                <?php 
            if (strlen($convertedAnswer) > 0 && $item == $convertedAnswer) {
                ?>
                    <h6><input type="checkbox" id="<?php 
                echo $name . "_" . removeSpaces($item);
                ?>
" name="<?php 
                echo $name;
                ?>
" value="<?php 
                echo $item;
                ?>
" checked><?php 
                echo $item;
                ?>
</h6>
                <?php 
            } else {
                ?>
 <!-- end of test if single item is contained in list -->
                    <h6><input type="checkbox" id="<?php 
                echo $name . "_" . removeSpaces($item);
                ?>
" name="<?php 
                echo $name;
                ?>
" value="<?php 
                echo $item;
                ?>
"><?php 
                echo $item;
                ?>
</h6>
                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </div>
    <?php 
    }
    ?>
 <!-- end of foreach loop on all items -->
<?php 
}
/**
* create the image from the db or uploaded file
*/
function createImage($categoryID,$filename,$extension,$fileType,$fileSize,$fileID) {
	//create a folder within images
	global $system_default_path,$home_url,$default_randomlower,$default_randomupper;
	global $image_dir0,$image_dir1,$image_dir2,$image_dir3,$image_dir4;
	global $gallery;
	
	$dir=0;
	$dir=rand($default_randomlower,$default_randomupper);

	//use any of the five folders under images
	$folderarray=array();
	$folderarray[0]=$image_dir0;
	$folderarray[1]=$image_dir1;
	$folderarray[2]=$image_dir2;
	$folderarray[3]=$image_dir3;
	$folderarray[4]=$image_dir4;

	//pick the variable
	$var=0;
	$var=rand(0,4);

	//setup the path
	$path=0;
	$path=$system_default_path."images/$folderarray[$var]/";
	//make a $path dir
	if(!is_dir($path)) {
		mkdir($path,0755);
		chmod($path,0755);
	}

	//append to the path
	$path.="_$dir/";
	//make a $path dir
	if(!is_dir($path)) {
		mkdir($path,0755);
		chmod($path,0755);
	}
	
	//remove spaces
	$filename=removeSpaces($filename,".");
	//avoid conflicts
	$filename=removeFileConflict($path,$filename);
	
	//file creation
	$image=0;
				
	switch($extension) {
		case GIF:
		case gif:
			if(function_exists("imagegif")) {
				$image=ImageCreateFromGIF($_FILES['userfile']['tmp_name']);
				ImageGIF($image,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
		case JPEG:
		case jpeg:
		case JPG:
		case jpg:
			if(function_exists("imagejpeg")) {
				$image=ImageCreateFromJPEG($_FILES['userfile']['tmp_name']);
				ImageJPEG($image,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
		case PNG:
		case png:
			if(function_exists("imagepng")) {
				$image=ImageCreateFromPNG($_FILES['userfile']['tmp_name']);
				ImagePNG($image,$path.$filename);
				chmod($path.$filename,0755);
			}
		break;
	}
	if($gallery) {
		//create an icon 49 x 49
		createIcon("small",$path,$path.$filename,$filename,49,49,$extension,$home_url."images/$folderarray[$var]/_$dir/");
		//resize image to 386 x 256
		resizeImage($path,$path.$filename,$filename,386,256,$extension);
		//db storage
		$fileData=0;
		$fileData=addslashes(file_get_contents($path.$filename));
		//filesize
		$fileSize=0;
		$fileSize=filesize($path.$filename);
		//update the db record
		mysqlquery("update vl_filenames set 
					file='$fileData', 
					size='$fileSize' 
					where id='$fileID'");
	}

	return $path.$filename." :: ".$home_url."images/$folderarray[$var]/_$dir/$filename";
}
Beispiel #9
0
                 <li>Before people split off into teams, you can "roll the dice" and have API Randomizer choose the type of projects, theme, beneficiary, and APIs taht will be used for all the groups. The winner can be chosen based on whoever creates the most well liked (best) app within these constraints.</li>
                 <li>After teams are split off, each team can "roll the dice" to find out waht their app will be for.</li>
                 <li>You can give bonus points to any teams that are willing to accept the API Randomizer challenge instead of choosing their own projects ahead of time</li>
              </ol>
              <h2>How to Feature a Hackathon Sponsor</h2>
              <p>
                 You can make sure that <strong>one</strong> of your sponsors shows up in every refresh of the page. To do this, simply add the name of the api to the end of the URL. 
              </p>
              <?php 
$rand = getRandomApi();
?>
              <p><strong>Example:</strong> <a href="http://apirandomizer.com/<?php 
echo strtolower($rand[0]);
?>
" target="_blank">http://apirandomizer.com/<?php 
echo strtolower(removeSpaces($rand[0]));
?>
</a> - Will cause every click of the button to show the <?php 
echo $rand[0];
?>
 API as the first item in the suggested APIs to use.</p>
           </div>
      </div>
      <div class="row-fluid" id="footer">
         <div class="span12">
            <a href="tips.php">Find out API Randomizer tips for your hackathon</a><hr /><br />
            To make a suggestion or ask a question, send a tweet to <a href="http://twitter.com/mbernier">@mbernier</a><br />
            Created by <a href="http://mkbernier.com">Matt Bernier</a>
         </div>
      </div>
      <script src="assets/js/jquery.js"></script>