Переглянути джерело

Merge pull request #2 in ~MVOELKEL/sks-landingpage from develop to master

* commit 'a5b55567aa':
  - adding Tracking for Downloads and fixing last bugs in tracking and Routing - Adding Download Class correctly with dynamic download function - create 404 Not FPund Page and integrated it correctly - include Facebook like Button - fixing background for devices with 320px display width
  - adding Tracking Class
master
Marcel Völkel 7 роки тому
джерело
коміт
893a7f9c24

+ 1
- 1
Application/Config/router.php Переглянути файл

@@ -1,3 +1,3 @@
1 1
 <?php
2 2
 $router->map('GET', '/', ROOT . DS . APP . '/Data/index.php', 'homePage');
3
-$router->map('GET', '/download/[*:trailing]', ROOT . DS . APP . '/Data/download.php', 'downloadLink');
3
+$router->map('GET', '/download/[a:controllerFile]/[*:version]?', ROOT . DS . APP . '/Data/download.php', 'downloadLink');

+ 33
- 2
Application/Data/download.php Переглянути файл

@@ -1,7 +1,38 @@
1 1
 <?php
2 2
 
3
+use SCF\Core\DI;
4
+use SCF\Additionals\Tracking;
5
+use SCF\Additionals\Download;
3 6
 /**
4 7
  *  Download page for Downloads
5 8
  */
6
-//TODO: Create Download Logic with Download Class in scf/Additionals/Download.php
7
-var_dump($match);
9
+
10
+/**
11
+ * Tracking Settings set for Database logging of Downloads
12
+ * Please Remind that this only counts Click on DL Button, User can Cancel the Download
13
+ * and the system will still think it was a finished download
14
+ */
15
+$tracking = new Tracking(DI::getInstance()->get('db'));
16
+$tracking->setCurrentUserIp($_SERVER['REMOTE_ADDR']);
17
+$tracking->setCurrentUserAgent($_SERVER['HTTP_USER_AGENT']);
18
+
19
+/**
20
+ * Check if controllerFile is NOT the EuropeanFontPatch for DownloadTracking
21
+ */
22
+if ($match['params']['controllerFile'] != 'EuropeanFontPatch') {
23
+    $tracking->saveTrackingInDb('download', $settings->getValue('sks_download_version'));
24
+    $dlFile = $settings->getValue('sks_download_file');
25
+} else {
26
+    $dlFile = $settings->getValue('sks_eufont_file');
27
+}
28
+
29
+/**
30
+ * Set Needed Variables for the Download Class
31
+ */
32
+$dl = new Download();
33
+$dl->setAbsolutePath($settings->getValue('sks_download_path'));
34
+$dl->setFileName($dlFile);
35
+
36
+$dl->startDownloadFile();
37
+
38
+$tpl->display('index.tpl');

+ 22
- 0
Application/scf/Additionals/Download.php Переглянути файл

@@ -52,5 +52,27 @@ class Download
52 52
         $this->absolutePath = $absolutePath;
53 53
     }
54 54
 
55
+    public function startDownloadFile()
56
+    {
57
+        $tmpPath = $this->getAbsolutePath();
58
+        $tmpFile = $this->getFileName();
59
+
60
+        $fh = fopen($tmpPath . $tmpFile, "r");
61
+        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
62
+        header('Content-Description: File Transfer');
63
+        header('Content-Type: application/octed-stream');
64
+        header('Content-Length: ' . @filesize($tmpPath . $tmpFile));
65
+        header("Content-Disposition: attachment; filename=" . $tmpFile);
66
+        header("Content-Transfer-Encoding: binary");
67
+
68
+        while (true) {
69
+            echo fgets($fh, 4096);
70
+            if (feof($fh)) break;
71
+            if (connection_status() != 0) break;
72
+        }
73
+        fclose($fh);
74
+
75
+    }
76
+
55 77
 //TODO: Finishing Download Class to generate correct Downloads for Page!
56 78
 }

+ 127
- 0
Application/scf/Additionals/Tracking.php Переглянути файл

@@ -0,0 +1,127 @@
1
+<?php
2
+
3
+namespace SCF\Additionals;
4
+
5
+use SCF\Core\Database;
6
+
7
+class Tracking
8
+{
9
+
10
+    private $_db;
11
+
12
+    private $currentUserIp;
13
+
14
+    private $currentUserAgent;
15
+
16
+    private $currentUserReferer;
17
+
18
+    private $trackingTarget;
19
+
20
+    public function __construct(Database $db)
21
+    {
22
+        $this->_db = $db;
23
+    }
24
+
25
+    /**
26
+     * @param mixed $currentUserIp
27
+     */
28
+    public function setCurrentUserIp($currentUserIp)
29
+    {
30
+        $this->currentUserIp = $currentUserIp;
31
+    }
32
+
33
+    /**
34
+     * @param mixed $currentUserAgent
35
+     */
36
+    public function setCurrentUserAgent($currentUserAgent)
37
+    {
38
+        $this->currentUserAgent = $currentUserAgent;
39
+    }
40
+
41
+    /**
42
+     * @param mixed $currentUserReferer
43
+     */
44
+    public function setCurrentUserReferer($currentUserReferer)
45
+    {
46
+        $this->currentUserReferer = $currentUserReferer;
47
+    }
48
+
49
+    /**
50
+     * @return mixed
51
+     */
52
+    public function getCurrentUserIp()
53
+    {
54
+        return $this->currentUserIp;
55
+    }
56
+
57
+    /**
58
+     * @return mixed
59
+     */
60
+    public function getCurrentUserAgent()
61
+    {
62
+        return $this->currentUserAgent;
63
+    }
64
+
65
+    /**
66
+     * @return mixed
67
+     */
68
+    public function getCurrentUserReferer()
69
+    {
70
+        return $this->currentUserReferer;
71
+    }
72
+
73
+    public function checkUniqueUser()
74
+    {
75
+        $this->_db->query("SELECT ip_adress, `timestamp` FROM sks_unique_user WHERE ip_adress = '{$this->getCurrentUserIp()}' ORDER BY `timestamp` DESC LIMIT 1");
76
+        $result = $this->_db->single();
77
+        $trackedDate = date("Y-m-d", $result['timestamp']);
78
+        $currentDate = date("Y-m-d", time());
79
+        //echo $trackedDate . ' - ' . $currentDate;
80
+        if ($trackedDate == $currentDate) {
81
+            //echo 'Du warst heute um ' . date("H:i:s", $result['timestamp']) . ' Uhr schon einmal hier!';
82
+        } else {
83
+            //echo 'different Dates visit';
84
+            $this->_db->query("INSERT INTO sks_unique_user (`ip_adress`, `user_agent`, `referrer`, `timestamp`) VALUES
85
+                                      (:ip, :userAgent, :userReferer, :timeValue)");
86
+            $this->_db->bind(':ip', $this->getCurrentUserIp());
87
+            $this->_db->bind(':userAgent', $this->getCurrentUserAgent());
88
+            $this->_db->bind(':userReferer', $this->getCurrentUserReferer());
89
+            $this->_db->bind(':timeValue', time());
90
+            $this->_db->execute();
91
+        }
92
+
93
+    }
94
+
95
+    /**
96
+     * @param mixed $trackingTarget
97
+     */
98
+    public function setTrackingTarget($trackingTarget)
99
+    {
100
+        $this->trackingTarget = $trackingTarget;
101
+    }
102
+
103
+    /**
104
+     * @return mixed
105
+     */
106
+    public function getTrackingTarget()
107
+    {
108
+        return $this->trackingTarget;
109
+    }
110
+
111
+    public function saveTrackingInDb($target, $dlVersion)
112
+    {
113
+        $tmpTarget = $target;
114
+        $tmpDlVersion = $dlVersion;
115
+        $timestamp = time();
116
+        if ($tmpTarget == 'download') {
117
+            try {
118
+                $this->_db->query("INSERT INTO `sks_unique_dls` (ip_adress, timestamp, user_agent, dl_version)
119
+                              VALUES ('{$this->getCurrentUserIp()}', '{$timestamp}', '{$this->getCurrentUserAgent()}', '{$tmpDlVersion}')");
120
+                $this->_db->execute();
121
+            } catch (\PDOException $e) {
122
+                echo $e->getMessage();
123
+            }
124
+        }
125
+
126
+    }
127
+}

+ 13
- 0
Application/templates/sternenkindsaga/errorpages/404.tpl Переглянути файл

@@ -1,3 +1,16 @@
1 1
 {include file="header.tpl"}
2
+<div class="row row-width">
3
+    <div class="col-lg-12 sks-not-found">
4
+        <h1>Huch!</h1>
5
+        <h2>404 Not Found</h2>
6
+        <p>
7
+            Die Information die Du aufrufen wolltest, existiert nicht. Gehe bitte wieder zurück auf die <a
8
+                    href="{$settings->getValue('siteaddr')}">Startseite</a>
9
+        </p>
10
+        <div class="clearfix"></div>
11
+    </div>
12
+</div>
13
+
14
+
2 15
 
3 16
 {include file="footer.tpl"}

+ 1
- 1
Application/templates/sternenkindsaga/html/htmlHead.tpl Переглянути файл

@@ -2,7 +2,7 @@
2 2
 
3 3
 <html lang="en">
4 4
 <head>
5
-    <title>{$settings->getValue("sitename")}</title>
5
+    <title>{$settings->getValue("sitename")|replace:'{1}':$settings->getValue("sks_download_version")}</title>
6 6
     <meta charset="utf-8">
7 7
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
8 8
     <meta name="viewport" content="width=device-width, initial-scale=1">

+ 13
- 6
Application/templates/sternenkindsaga/index.tpl Переглянути файл

@@ -2,31 +2,38 @@
2 2
 <div class="row row-width">
3 3
     <div class="col-sm-7 less-padding sks-bottom-spacer">
4 4
         <div class="sks-box">
5
-            <strong>{$settings->getValue('lp_teaser_text_headline')}</strong>
5
+            <strong>{$settings->getValue('lp_teaser_text_headline')}</strong><br/>
6 6
             {$settings->getValue('lp_teaser_text')|nl2br}
7 7
         </div>
8 8
 
9 9
     </div>
10 10
     <div class="row">
11
-        <div class="col-sm-5 sks-bottom-spacer">
11
+        <div class="col-sm-offset-0 col-sm-5 sks-bottom-spacer">
12 12
             <div class="sks-box">
13 13
                 {include file="misc/carousel.tpl"}
14 14
                 <b> Erwecke jetzt das Sternenkind in dir!</b>
15
-                <button class="sks-download-button" id="sks-dl-button">Download</button>
15
+                <a href="download/SternenkindSaga/{$settings->getValue('sks_download_version')}">
16
+                    <button class="sks-download-button" id="sks-dl-button">Download</button>
17
+                </a>
16 18
             </div>
17 19
         </div>
18
-        <div class="col-sm-5 sks-bottom-spacer">
20
+        <div class="col-sm-offset-0 col-sm-5 sks-bottom-spacer">
19 21
             <div class="sks-box">
20 22
                 <strong>{$settings->getValue('sks_additional_files')}</strong><br/>
21 23
                 {$settings->getValue('sks_eu_patch')}
22 24
             </div>
23 25
         </div>
24
-        <div class="col-sm-5">
26
+        <div class="col-sm-offset-7 col-sm-5">
25 27
             <div class="sks-box">
26 28
                 <strong>{$settings->getValue('sks_social_media')}</strong><br/>
29
+                <div class="fb-like"
30
+                     data-href="https://www.facebook.com/pages/Sternenkind-Saga-Release-13122014/666851820057165"
31
+                     data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"
32
+                     style="float:right; margin-top:5px;"></div>
27 33
                 {$settings->getValue('sks_forum_link')}<br/>
28 34
                 {$settings->getValue('sks_facebook_link')}<br/>
29
-                {$settings->getValue('sks_homepage_link')}<br/>
35
+                {$settings->getValue('sks_homepage_link')}
36
+
30 37
             </div>
31 38
         </div>
32 39
     </div>

+ 3
- 0
bootstrap.php Переглянути файл

@@ -16,6 +16,7 @@ use Symfony\Component\Debug\Debug;
16 16
 use SCF\Core\DI;
17 17
 use SCF\Core\Database;
18 18
 use SCF\Core\System;
19
+use SCF\Additionals\Tracking;
19 20
 use SCF\Core\Templates;
20 21
 
21 22
 /**
@@ -40,9 +41,11 @@ else {
40 41
 $di = DI::getInstance();
41 42
 $di->set('db', new Database($config['dbext'], $config['server'], $config['mysqluser'], $config['mysqlpass'], $config['mysqldbname']), true);
42 43
 $di->set('router', 'AltoRouter', true);
44
+$di->set('tracking', new Tracking(DI::getInstance()->get('db')), true);
43 45
 
44 46
 $settings = new System(DI::getInstance()->get('db'));
45 47
 
46 48
 $router = DI::getInstance()->get('router');
47 49
 
50
+
48 51
 $tpl = new Templates($settings,$router);

+ 1
- 1
version Переглянути файл

@@ -1 +1 @@
1
-v1.1.2
1
+v1.1.2 Rev: 2

+ 25
- 4
web/Styles/css/sks-v2.css Переглянути файл

@@ -50,7 +50,7 @@ a:hover {
50 50
 }
51 51
 
52 52
 .row-width {
53
-    border: 1px solid #ffffff;
53
+
54 54
     width: 95%;
55 55
     max-width: 800px;
56 56
     margin: 20px auto 10px auto;
@@ -65,9 +65,18 @@ a:hover {
65 65
     margin-bottom: -10px;
66 66
 }
67 67
 
68
+.sks-not-found {
69
+    background: url("../images/sks-background.png") repeat;
70
+    border: 2px solid #e79b1f;
71
+    width: 100%;
72
+    color: #e79b1f;
73
+    margin: 5px auto 5px auto;
74
+    box-shadow: 0 5px 10px #000000;
75
+}
76
+
68 77
 .sks-dropdown {
69 78
     background: linear-gradient(#1f1a16, #4d3c32);
70
-    border: 1px solid #e79b1f;
79
+    border: 2px solid #e79b1f;
71 80
 }
72 81
 
73 82
 .sks-dropdown li a {
@@ -82,7 +91,7 @@ a:hover {
82 91
 }
83 92
 
84 93
 .sks-margin-bottom {
85
-    margin-bottom: 25%;
94
+    margin-bottom: 100px;
86 95
 }
87 96
 
88 97
 .sks-max-width {
@@ -121,7 +130,19 @@ a:hover {
121 130
     box-shadow: 0 5px 10px #000000;
122 131
 }
123 132
 
124
-@media only screen and (min-device-width: 375px) {
133
+.sks-small-text {
134
+    font-size: 80%;
135
+    margin: 0;
136
+    padding: 0;
137
+}
138
+
139
+.sks-center-text {
140
+    text-align: center;
141
+    margin: 0;
142
+    padding: 0;
143
+}
144
+
145
+@media only screen and (min-device-width: 320px) {
125 146
     body {
126 147
         background: #cfcfcf url('../images/sks-background.png') repeat;
127 148
     }

+ 10
- 0
web/index.php Переглянути файл

@@ -2,6 +2,7 @@
2 2
 require_once '../bootstrap.php';
3 3
 
4 4
 use SCF\Additionals\Carousel;
5
+use SCF\Core\DI;
5 6
 
6 7
 $c = new Carousel(ROOT . DS . 'web/Styles/sks-screens' . DS);
7 8
 
@@ -13,13 +14,22 @@ require_once ROOT.DS.APP."/Config/router.php";
13 14
 $tpl->assign('sksscreens', $c->getPicArray());
14 15
 $match = $router->match();
15 16
 
17
+$userReferer = (!isset($_SERVER['HTTP_REFERER']) ? 'direct' : $_SERVER['HTTP_REFERER']);
18
+
19
+$tracking = DI::getInstance()->get('tracking');
20
+$tracking->setCurrentUserIp($_SERVER['REMOTE_ADDR']);
21
+$tracking->setCurrentUserAgent($_SERVER['HTTP_USER_AGENT']);
22
+$tracking->setCurrentUserReferer($userReferer);
23
+$tracking->checkUniqueUser();
16 24
 if($match === false) {
25
+    var_dump($match);
17 26
     $tpl->display('errorpages/404.tpl');
18 27
 }
19 28
 else {
20 29
     try {
21 30
         require $match['target'];
22 31
     } catch(Exception $e) {
32
+        echo '3';
23 33
         return $e->getMessage();
24 34
     }
25 35
 }

+ 1
- 1
web/lib/sks.js Переглянути файл

@@ -1,5 +1,5 @@
1 1
 $(document).ready(function () {
2 2
     $(".carousel").carousel({
3
-        interval: 2000
3
+        interval: 5000
4 4
     });
5 5
 });

Завантаження…
Відмінити
Зберегти