Skip to content

Commit

Permalink
Uzlabota ātrdarbība un veiktspēja
Browse files Browse the repository at this point in the history
  • Loading branch information
M4t1ss committed Sep 28, 2020
1 parent 7092c97 commit a36569a
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 125 deletions.
Binary file added img/appl.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/burg.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 0 additions & 35 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,5 @@ function showHide(shID) {
</div>
</div>
</div>
<?php
$OpenInNewWindow = "1";
$BLKey = "6J6E-27JM-7U51";
if(isset($_SERVER['SCRIPT_URI']) && strlen($_SERVER['SCRIPT_URI'])){
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_URI'].((strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}
if(!isset($_SERVER['REQUEST_URI']) || !strlen($_SERVER['REQUEST_URI'])){
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].((isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']))?'?'.$_SERVER['QUERY_STRING']:'');
}
$QueryString = "LinkUrl=".urlencode(((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$QueryString .= "&Key=" .urlencode($BLKey);
$QueryString .= "&OpenInNewWindow=" .urlencode($OpenInNewWindow);


if(intval(get_cfg_var('allow_url_fopen')) && function_exists('readfile')) {
@readfile("http://www.backlinks.com/engine.php?".$QueryString);
}
elseif(intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
if($content = @file("http://www.backlinks.com/engine.php?".$QueryString))
print @join('', $content);
}
elseif(function_exists('curl_init')) {
$ch = curl_init ("http://www.backlinks.com/engine.php?".$QueryString);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);

if(curl_error($ch))
print "Error processing request";

curl_close ($ch);
}
else {
print "It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.";
}
?>
</body>
</html>
25 changes: 25 additions & 0 deletions loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
include "includes/init_sql.php";

//dabū 10 jaunākos tvītus
$latest = mysqli_query($connection, "SELECT distinct media_url, expanded_url, date, text FROM media JOIN tweets ON tweets.id = media.tweet_id GROUP BY media_url ORDER BY date DESC limit 0, 25");

while($p=mysqli_fetch_array($latest)){
$media_url = $p["media_url"];
$expanded_url = $p["expanded_url"];
$ttime = $p["date"];
$ttext = $p["text"];

if (@getimagesize($media_url)) {
?>
<div style="<?php if ((time()-StrToTime($ttime))<5){echo"opacity:".((time()-StrToTime($ttime))/5).";";}?> display:inline;" >
<a target="_blank" href="<?php echo $expanded_url; ?>">
<img alt="<?php echo $ttext;?>" src="<?php echo str_replace('http://', 'https://', $media_url); ?>" />
</a>
</div>
<?php
}else{
//Delete this one - probably doesn't exist anymore...
}
}
?>
124 changes: 34 additions & 90 deletions stream.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php
include "includes/init_sql.php";
include "classify/evaluate_bayes.php";
?>
<div style="margin:30px; background-color:#E7FFFE;background-opacity:0.2;border-radius:15px;padding:15px;border:2px solid #FFF;">
TwitĒdiens ievāc datus no <a style="font-weight:bold;" href="http://twitter.com">Twitter</a>
TwitĒdiens ievāc datus no Twitter
- visus tvītus, kur kaut kas minēts par ēšanu, dzeršanu (apēdu, izdzēru, ...)
ēdienreizēm (pusdienas, brokastis, vakariņas, ...) vai ēdieniem, dzērieniem
(tēja, šokolāde, kafija, gaļa, saldējums, pankūka, kartupeļi, kūka, pelmeņi, ...).
Expand Down Expand Up @@ -35,96 +31,44 @@
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
$(function() {
setInterval(function() {
$("#content").load(location.href+" #content>*","");
}, 1500);
if(!isOpera && !isChrome){
$(document).ready(function(){
$("#content").load("tviti.php");
$("#photos").load("loader.php");
$(function() {
setInterval(function() {
$("#content2").load(location.href+" #content2>*","");
}, 5000);
}
}
);
$("#content").load("tviti.php");
}, 1500);
if(!isOpera && !isChrome){
setInterval(function() {
$("#photos").load("loader.php");
}, 5000);
}
});
});
</script>
<?php
//dabū 10 jaunākos tvītus
$latest = mysqli_query($connection, "SELECT * FROM tweets ORDER BY created_at DESC limit 0, 10");
?>

<div id="content">
<?php
while($p=mysqli_fetch_array($latest)){
$username = $p["screen_name"];
$text = $p["text"];
$ttime = $p["created_at"];

$automatic = classify($text);
switch ($automatic){
case "pos":
$color = "#00FF00";
break;
case "neg":
$color = "#FF3D3D";
break;
case "nei":
$color = "black";
break;
default:
$color = "black";
}

#Iekrāso un izveido saiti uz katru pieminēto lietotāju tekstā
#Šo vajadzētu visur...
$matches = array();
if (preg_match_all('/@[^[:space:]]+/', $text, $matches)) {
foreach ($matches[0] as $match){
$text = str_replace(trim($match), '<a style="text-decoration:none;color:#658304;" href="/draugs/'.str_replace('@','',trim($match)).'">'.trim($match).'</a> ', $text);
}
}

if (preg_match_all('/http[^[:space:]]+/', $text, $matches)) {
foreach ($matches[0] as $match){
$text = str_replace(trim($match), '<a style="text-decoration:none;color:#658304;" target="_blank" href="'.trim($match).'">'.trim($match).'</a> ', $text);
}
}

?>
<div style="<?php if ((time()-StrToTime($ttime))<5){echo"opacity:".((time()-StrToTime($ttime))/5).";";}?>" class="tweet">
<div class="lietotajs" style="border-bottom: 0.18em dashed <?php echo $color; ?>;"><?php echo '<a style="text-decoration:none;color:#658304;" href="/draugs/'.trim($username).'">@'.trim($username).'</a> ';?> ( <?php echo $ttime;?> )</div>
<?php echo $text."<br/>";
?><br/>
</div>
<?php
}
?>
<img src="/img/burg.gif" style="height:64px; text-align:center;" />
</div>
<?php
//dabū 10 jaunākos tvītus
$latest = mysqli_query($connection, "SELECT distinct media_url, expanded_url, date, text FROM media JOIN tweets ON tweets.id = media.tweet_id GROUP BY media_url ORDER BY date DESC limit 0, 25");
?>

<div id="content2">
<section id="photos">
<?php
while($p=mysqli_fetch_array($latest)){
$media_url = $p["media_url"];
$expanded_url = $p["expanded_url"];
$ttime = $p["date"];
$ttext = $p["text"];

if (@getimagesize($media_url)) {
?>
<div style="<?php if ((time()-StrToTime($ttime))<5){echo"opacity:".((time()-StrToTime($ttime))/5).";";}?> display:inline;" >
<a target="_blank" href="<?php echo $expanded_url; ?>">
<img alt="<?php echo $ttext;?>" src="<?php echo str_replace('http://', 'https://', $media_url); ?>" />
</a>
</div>
<?php
}else{
//Delete this one - probably doesn't exist anymore...
}
}
?>
</section>
<section id="photos">
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
<img src="/img/appl.gif" style="height:64px; text-align:center;" />
</section>
</div>
52 changes: 52 additions & 0 deletions tviti.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
include "includes/init_sql.php";
include "classify/evaluate_bayes.php";

//dabū 10 jaunākos tvītus
$latest = mysqli_query($connection, "SELECT * FROM tweets ORDER BY created_at DESC limit 0, 10");


while($p=mysqli_fetch_array($latest)){
$username = $p["screen_name"];
$text = $p["text"];
$ttime = $p["created_at"];

$automatic = classify($text);
switch ($automatic){
case "pos":
$color = "#00FF00";
break;
case "neg":
$color = "#FF3D3D";
break;
case "nei":
$color = "black";
break;
default:
$color = "black";
}

#Iekrāso un izveido saiti uz katru pieminēto lietotāju tekstā
#Šo vajadzētu visur...
$matches = array();
if (preg_match_all('/@[^[:space:]]+/', $text, $matches)) {
foreach ($matches[0] as $match){
$text = str_replace(trim($match), '<a style="text-decoration:none;color:#658304;" href="/draugs/'.str_replace('@','',trim($match)).'">'.trim($match).'</a> ', $text);
}
}

if (preg_match_all('/http[^[:space:]]+/', $text, $matches)) {
foreach ($matches[0] as $match){
$text = str_replace(trim($match), '<a style="text-decoration:none;color:#658304;" target="_blank" href="'.trim($match).'">'.trim($match).'</a> ', $text);
}
}

?>
<div style="<?php if ((time()-StrToTime($ttime))<5){echo"opacity:".((time()-StrToTime($ttime))/5).";";}?>" class="tweet">
<div class="lietotajs" style="border-bottom: 0.18em dashed <?php echo $color; ?>;"><?php echo '<a style="text-decoration:none;color:#658304;" href="/draugs/'.trim($username).'">@'.trim($username).'</a> ';?> ( <?php echo $ttime;?> )</div>
<?php echo $text."<br/>";
?><br/>
</div>
<?php
}
?>

0 comments on commit a36569a

Please sign in to comment.