index.php 7.78 KB
Newer Older
is161024's avatar
is161024 committed
1 2
<?php

is161024's avatar
is161024 committed
3
if(is_dir("install"))
is161024's avatar
is161024 committed
4 5 6 7 8 9
{
        echo "Du wirst auf die Installation umgeleitet.<br>
         Solltest du in f&uuml;nf Sekunden nicht dort angelangt sein, klicke <a href='install'>hier.</a>

        <meta http-equiv='refresh' content='5; url=install' />";
die();
is161024's avatar
is161024 committed
10
}
is161024's avatar
is161024 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192

include ('design.php');
include ('mysqli/opendb.php');
include ('einstellungen/einstellungen.php');
$rows_per_page_index=$einstellungen['Eintraege_pro_Seite'];

$stmt=$mysqli->prepare("SELECT ort, DATE_FORMAT(datum, '%a, %d.%m.%Y - %H:%i'), DATE_FORMAT(datum, '%Y-%m-%dT%H:%i'), DATE_FORMAT(datum, '%Y-%m-%d'), firma FROM stammtische WHERE datum >= NOW() ORDER BY datum ASC LIMIT 1");
   $stmt->execute();
  // var_dump($stmt);
   $stmt->bind_result($ort, $datum_1, $datum_2, $datum_3, $firma);
   $stmt->fetch();
   
    if(isset($ort))
    {
   $next_stammtisch="<article class='next_stammtisch' itemprop='event' itemscope itemtype='http://schema.org/Event'>
    <strong><span>N&auml;chster Stammtisch</span><br /><span itemprop='startDate' content='".$datum_2."'>".$datum_1."</span></strong><meta itemprop='endDate' content='".$datum_3."'><br /><a itemprop='url' href='stammtische.php'><span itemprop='name'>".$firma."</span></a> in <span itemprop='location' content='".$ort."'>".$ort."</span>
   </article><br>"; 
    }                  
    $stmt->close();
    
echo "<!DOCTYPE html>
<html>
 <head>
";
echo $cssfile;
echo $head;
echo "\n  <meta name='description' content='".$einstellungen['Beschreibung_Index']."'>
  <title>Home - ".$einstellungen['Titel']."</title>";
echo"
 </head> 
 <body onLoad='startTimer();'>
  <div class='textbody'>
   <header>
    ".$header."    
   </header>
   <main class='inhalt'>
    <div class='right'>
    ".$next_stammtisch."
    </div> 
    <h1>".$einstellungen['Index_Titel']."</h1>";
   
   function softTrim($text, $id)
   {
    $count=580;
    $wrapText='... <a href="story.php?id='.$id.'">[Weiterlesen]</a>';
    if(strlen($text)>$count)
    {
        var_dump(preg_match('/^.{0,' . $count . '}(?:.*?)\b/siu', $text, $matches));
        $text = $matches[0];
        
    }
    else
    {
    //echo 0;
        $wrapText = '';
    }
    return $text . $wrapText;
   }
   
   function trim_characters( $text, $id_1)
   {
    $length = 580;
    //$text = nl2br(trim(  $text ) );
     if ( strlen( $text ) > $length )
     {
      $text = substr( $text, 0, $length + 1 );
      $words = preg_split( "/[\s]|&nbsp;/", $text, -1, PREG_SPLIT_NO_EMPTY );
      preg_match( "/[\s]|&nbsp;/", $text, $lastchar, 0, $length );
      if ( empty( $lastchar ) )
      {
        array_pop( $words );
      }
      $text = implode( ' ', $words ).'... <a href="story.php?id='.$id_1.'" rel="bookmark">[Weiterlesen]</a>'; 
     }
    return $text;
   }
   function printTruncated($maxLength, $html, $id_1, $isUtf8=false)
   {
    $printedLength = 0;
    $position = 0;
    $tags = array();
    $output="";
    // For UTF-8, we need to count multibyte sequences as one character.
    $re = $isUtf8
        ? '{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;|[\x80-\xFF][\x80-\xBF]*}'
        : '{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}';

    while ($printedLength < $maxLength && preg_match($re, $html, $match, PREG_OFFSET_CAPTURE, $position))
    {
        list($tag, $tagPosition) = $match[0];

        // Print text leading up to the tag.
        $str = substr($html, $position, $tagPosition - $position);
        if ($printedLength + strlen($str) > $maxLength)
        {
            $output.=substr($str, 0, $maxLength - $printedLength);
            $printedLength = $maxLength;
            break;
        }

        $output.=$str;
        $printedLength += strlen($str);
        if ($printedLength >= $maxLength) break;

        if ($tag[0] == '&' || ord($tag) >= 0x80)
        {
            // Pass the entity or UTF-8 multibyte sequence through unchanged.
            $output.=$tag;
            $printedLength++;
        }
        else
        {
            // Handle the tag.
            $tagName = $match[1][0];
            if ($tag[1] == '/')
            {
                // This is a closing tag.

                $openingTag = array_pop($tags);
                assert($openingTag == $tagName); // check that tags are properly nested.

                $output.=$tag;
            }
            else if ($tag[strlen($tag) - 2] == '/')
            {
                // Self-closing tag.
                $output.=$tag;
            }
            else
            {
                // Opening tag.
                $output.=$tag;
                $tags[] = $tagName;
            }
        }

        // Continue after the tag.
        $position = $tagPosition + strlen($tag);
    }

    // Print any remaining text.
    if ($printedLength < $maxLength && $position < strlen($html))
        $output.=substr($html, $position, $maxLength - $printedLength);
    
    if($maxLength< strlen($html))
        $output.='&nbsp;...&nbsp;<a href="story.php?id='.$id_1.'" rel="bookmark">[Weiterlesen]</a>';
   
    // Close any open tags.
    while (!empty($tags))
        $output.= "</".array_pop($tags).">";
        
    
        
    return $output;    
   }

   $seite=$_GET['seite'];
   if (!isset($seite))
   { 
    $seite = 0;
   }
   $sql = "SELECT * FROM news";
   $stmt=$mysqli->query($sql);
   $total_records =$stmt->num_rows;

   $pages = ceil($total_records / $rows_per_page_index);
   $stmt->close();

   $start = $seite * $rows_per_page_index; 
   $stmt=$mysqli->prepare("SELECT mitglieder.id, n_id, titel, news.text, DATE_FORMAT(datum, '%d. %m. %Y'), DATE_FORMAT(datum, '%Y-%m-%dT%H:%i'), vorname, b_id FROM news JOIN mitglieder ON autor=id LEFT JOIN beschreibungen ON autor=mitglied ORDER BY datum DESC LIMIT $start, $rows_per_page_index");
   $stmt->execute();
   $stmt->bind_result($mitglieder_id, $id, $titel, $text, $datum, $datum_microformat, $autor, $b_id);
   echo "<section itemscope itemtype='http://schema.org/Blog'>
         <meta itemprop='headline' content='".$einstellungen['Index_Titel']." - ".$einstellungen['Titel']."'>
         <meta itemprop='inLanguage' content='".$einstellungen['Sprache_Code_Kurz']."'>";
   while($stmt->fetch())
   {
   echo "\n    <article itemprop='blogPost' itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>";
   if(is_int(strpos($text, "stellenausschreibungen")))
   {
    echo "\n<meta itemprop='about' content='jobs'>";
   }
is161024's avatar
is161024 committed
193
   if(strlen($b_id)>0 && strstr($einstellungen['Aktive_Plugins'], "mitglieder"))
is161024's avatar
is161024 committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
   {
    $schreiberling="<a class='autorlink' itemprop='author' rel='author' href='vorstand.php?page=einzeln&mitglied=".$mitglieder_id."'>".$autor."</a>";
   }
   else
   {
    $schreiberling="<span class='autor' itemprop='author'>".$autor."</span>";
   }
   echo "\n<meta itemprop='inLanguage' content='".$einstellungen['Sprache_Code_Kurz']."'>
   <p>
    <a href='story.php?id=".$id."' class='news_link' rel='bookmark' itemprop='url'>
     <h2 itemprop='headline'>".$titel."</h2>
    </a>
     <span class='news_span'>Vom <time itemprop='datePublished' content='".$datum_microformat."' datetime='".$datum_microformat."'>".$datum."</time> von ".$schreiberling."</span><br />
     <span itemprop='articleBody'>".printTruncated(580, $text, $id)."</span>
   </p>
  </article>";  
   }
   echo "</section>";
   
   $stmt->close();
  //Navigationslinks 
  

if ($seite > 0) {
  $url = "index.php?seite=" . ($seite - 1);
  echo "\n<span class='seitenlinks'><a href=\"$url\" rel='nofollow'>Zur&uuml;ck</a></span>\n";
}

 for ((($seite)==0 ? $i = 0 : $i = $seite ); ($i<$seite+9)&&($i < $pages); $i++) {
  $url = "index.php?seite=" . $i;
  echo "<span class='seitenlinks'><a href=\"$url\" rel='nofollow'>$i</a></span>";
}
if ($seite < $pages-1 && $pages != 1) {
  $url = "index.php?seite=" . ($seite + 1);
  echo "<span class='seitenlinks'><a href=\"$url\" rel='nofollow'>Weiter</a></span>\n";
}

echo"   </main>
   <br class='clear'>
   <footer class='footer'>
    ".$footer."
   </footer>
  </div>
 </body>
</html>";



?>