Exemple #1
0
    private function sketch($rawdata)
    {
        //Before I do all of this, get information about the artist and display before showing sketches of other similar artists
        $artist = string_to_ascii($_GET['artist']);
        $user = string_to_ascii($_GET['username']);
        $primer = $artist / $user * 100;
        ?>
			<script type="text/javascript">
				$(function() {
					$("#one").slider({
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#one_amount").val(ui.value);
						}
						});
					});
			
				$(function() {
					$("#two").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#two_amount").val(ui.value);
						}
					});
				});
				
				$(function() {
					$("#three").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#three_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#four").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#four_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#five").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#five_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#six").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#six_amount").val(ui.value);
						}
					});
				});
			
			</script>
																		
			<?php 
        lastfm::getArtistInfo($_GET['artist']);
        ?>
			
			<div id="eq">
				<div id="one" 				style="width: 200px; margin: 15px;"></div>			
				<div id="two" 				style="height:100px; margin: 15px; float: left;"></div>
				<div id="three" 			style="height:100px; margin: 15px; float: left;"></div>		
				<div id="four" 				style="height:100px; margin: 15px; float: left;"></div>	
				<div id="five" 				style="height:100px; margin: 15px; float: left;"></div>	
				<div id="six" 				style="height:100px; margin: 15px; float: left;"></div>	
			</div>
			
			<?php 
        $xml = new SimpleXMLElement($rawdata);
        $i = 1;
        foreach ($xml->similarartists->artist as $artist) {
            $artistcln = str_replace(' ', '%20', $artist->name);
            $artistTags = "http://ws.audioscrobbler.com/2.0/?method=artist.gettoptags&";
            $artistTags .= "artist={$artistcln}&";
            $artistTags .= "api_key={$this->apikey}&";
            $rawdata = lastfm::talkToLastFM($artistTags);
            $tags = new SimpleXMLElement($rawdata);
            $name = string_to_ascii($artistcln);
            $genre = string_to_ascii($tags->toptags->tag[0]->name);
            $count = $tags->toptags->tag[0]->count;
            ?>
			
<script id="script<?php 
            echo $i;
            ?>
" type="application/processing">

float center1 = 2;
float center2 = 2;

void setup(){
  size(500,800);
  smooth();
  frameRate(8);
}

void draw(){


int genre = <?php 
            echo $genre;
            ?>
; 
int name = <?php 
            echo $name;
            ?>
;
int sound = <?php 
            $tone = strlen($genre * $name) * rand(1, $name) / 100 + rand(1, $genre);
            echo $tone;
            ?>
;
int one = $("#one").slider("value");
int two = $("#two").slider("value");
int three = $("#three").slider("value");
int four = $("#four").slider("value");
int five = $("#five").slider("value");
int six = $("#six").slider("value");

background(two+sound, three+sound, four+sound, five+sound);
 
  float inc = random(-one, one);
  float inc2 = random(-one , one);

  float big = six;

  float end2 = center2 + inc2;
  float end = center1 + inc;
  
  stroke(0,50);
  strokeWeight(name/30);
  line(center1, center2, end, end2);
  
  strokeWeight(name*genre/1000);
  stroke(255-two+sound, 255-three+sound, 255-four+sound, 255-five+sound);
  
  if(big < genre){
		fill(255 - genre, name);
		rect(center1, center2, big, big);
  } else if (big > genre) {
		fill(255 - genre, name);
		ellipse(center1, center2, big, big);
  } 
  rectMode(CENTER);
	  center1 += inc;
	  center2 += inc2;
	 
	  if(center2 > 600){
	    center2 = 300;
	  }
	  if(center2 < 0 ){
	    center2 = 300;
	  }
	
	  if(center1 > 600 ){
	    center1 = 300;
	  }
	  if(center1 < 0){
	    center1 = 500;
	  }
}
				</script>	
				<div class="sketch">
				<a class="viz" title="<?php 
            echo $artist->name;
            ?>
" href="/your/site/url/AV-Browser/?username=<?php 
            echo $this->user;
            ?>
&view=related&artist=<?php 
            echo $artist->name;
            ?>
&type=info" >
				<h2><?php 
            echo $artist->name;
            ?>
</h2></a>
				
				<a class="viz" title="<?php 
            echo $artist->name;
            ?>
" href="/your/site/url/AV-Browser/?username=<?php 
            echo $this->user;
            ?>
&view=related&artist=<?php 
            echo $artist->name;
            ?>
" >
				<canvas title="<?php 
            echo $artist->name;
            ?>
" id="canvas<?php 
            echo $i;
            ?>
" width="800px" height="500px"></canvas></a>
				</div>
				<script>
				  canvas<?php 
            echo $i;
            ?>
 = document.getElementById("canvas<?php 
            echo $i;
            ?>
");
				  script<?php 
            echo $i;
            ?>
 = document.getElementById("script<?php 
            echo $i;
            ?>
").text;
				  Processing(canvas<?php 
            echo $i;
            ?>
, script<?php 
            echo $i;
            ?>
);
				</script>     			
				<?php 
            $i++;
        }
    }
function cancella_conf($findme, $verbose = false)
{
    $file = 'Util/config.php';
    // Apro il file di configurazione
    $fr = fopen($file, 'r+');
    // In lettura + scrittura, con il puntatore all'inizio del file
    $my_file = file_get_contents($file);
    // E lo leggo
    $lenght = strlen($findme);
    // quanto è lunga
    $pos = strpos($my_file, $findme);
    //cerco la cosa da cancellare
    if ($pos === false) {
        echo $verbose ? "The string '{$findme}' was not found in the string Util/config.php" : "";
    } else {
        echo $verbose ? "The string '{$findme}' was found in the string Util/config.php" : "";
        echo $verbose ? " and exists at position {$pos} <br>" : "";
        fseek($fr, $pos + $lenght, SEEK_SET);
        $byte = fread($fr, 2);
        $nbyte = string_to_ascii($byte);
        if ($nbyte[0] == 13) {
            //scritto da windows, mac
            if ($nbyte[1] == 10) {
                //scritto da windows
                echo $verbose ? "the (ASCII 13 + 10 (0x0D + 0x0A)), carriage return and new line (line feed) Alias WINDWOS new line were found " : "";
                $newfile = substr_replace($my_file, "", $pos, $lenght + 2);
                //$newfile=preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $newfile);
                rewind($fr);
                ftruncate($fr, 0);
                fwrite($fr, $newfile);
            } else {
                //scritto dal mac
                echo $verbose ? "the (ASCII 13 (0x0D)) a carriage return  Alias MACHINTOSH new line was found " : "";
                $newfile = substr_replace($my_file, "", $pos, $lenght + 1);
                //$newfile=preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $newfile);
                rewind($fr);
                ftruncate($fr, 0);
                fwrite($fr, $newfile);
            }
        } else {
            //scritto da linux
            echo $verbose ? "the (ASCII 10 (0x0A)) a new line (line feed) Alias UNIX new line  was found " : "";
            $newfile = substr_replace($my_file, "", $pos, $lenght + 1);
            //$newfile=preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $newfile);
            rewind($fr);
            ftruncate($fr, 0);
            fwrite($fr, $newfile);
        }
        fclose($fr);
    }
    $verbose ? exb(3) : "";
}
print "</pre>";
foreach ($weighpointLijst as $weighpoint) {
    $challengeId = $weighpoint->getChallenge()->getChallengeId();
    echo $challengeId . "</br>";
}
print "<pre>";
print_r($viewerLijst);
print "</pre>";
?>

        <?php 
$string = "foxbarrelinc";
$ascii = string_to_ascii($string);
echo $string . "</br>";
var_dump($ascii);
var_dump(string_to_ascii("!liesenborghs"));
$check = check_valid_input($string, 6);
var_dump($check);
var_dump(check_valid_input($string, 6));
$fox = $userDAO->getByUsername("foxbarrelinc");
var_dump($fox);
//        $userSvc = new UserService();
//        $service = $userSvc->checkLogin("foxbarrelinc", "adminpwd");
//        var_dump($service);
$par1 = $_SERVER['REMOTE_ADDR'];
var_dump($par1);
$par2 = gethostbyaddr($par1);
var_dump($par2);
var_dump(redirect_arrayName());
var_dump(redirect_par());
$_SESSION[redirect_arrayName()] = redirect_par();
function check_password($string)
{
    $passwordCheck = FALSE;
    $numberCount = 0;
    $capitalCount = 0;
    if (check_valid_input($string, 6)) {
        $asciiArray = string_to_ascii($string);
        foreach ($asciiArray as $ascii) {
            switch (TRUE) {
                case $ascii >= 48 && $ascii <= 57:
                    //numbers
                    $numberCount++;
                    break;
                case $ascii >= 65 && $ascii <= 90:
                    //UpperCase letters
                    $capitalCount++;
                    break;
            }
        }
        if ($numberCount > 0 && $capitalCount > 0) {
            $passwordCheck = TRUE;
        }
    }
    return $passwordCheck;
}
" style="fill:none; stroke:black; stroke-width:3" />
            <polyline points="<?php 
echo $sD . ',' . $sW . ' ' . $eD . ',' . $eW;
?>
" style="fill:none; stroke:black; stroke-width:3"/>  
            <polyline points="10,100 50,145 100,188 120,190 200,320 250,200" style="fill:none; stroke:red; stroke-width:3"/>
            <circle cx="50" cy="145" r="5" stroke="black" stroke-width="1" fill="red" />
            <a xlink:href="http://www.w3schools.com/svg/" target="_blank">
                <circle cx="100" cy="188" r="5" stroke="black" stroke-width="1" fill="red" />
            </a>
            <text x="0" y="<?php 
echo $width;
?>
" fill="red">0</text>
            <text x="10" y="<?php 
echo $width;
?>
" fill="red">1</text>
            </svg>

        </div>
        <?php 
$string = "Kristof Liesenborghs";
$test = string_to_ascii($string);
echo "ASCII '" . $string . "' = " . $test;
$mCode = string_to_morse($string);
echo "<pre>morse '" . $string . "' = " . $mCode . "</pre>";
?>
    </body>
</html>