~lss-team/lilsoftstats/trunk

« back to all changes in this revision

Viewing changes to inc/main.php

  • Committer: Nick
  • Date: 2011-11-14 04:10:28 UTC
  • Revision ID: nick@little-apps.org-20111114041028-cvmpwq6z6hx3pkya
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Little Software Stats
 
4
 *
 
5
 * An open source program that allows developers to keep track of how their software is being used
 
6
 *
 
7
 * @package             Little Software Stats
 
8
 * @author              Little Apps
 
9
 * @copyright           Copyright (c) 2011, Little Apps
 
10
 * @license             http://www.gnu.org/licenses/gpl.html GNU General Public License v3
 
11
 * @link                http://little-apps.org
 
12
 * @since               Version 0.1
 
13
 * @filesource
 
14
 */
 
15
 
 
16
require_once(dirname(__FILE__) . '/config.php');
 
17
require_once(dirname(__FILE__) . '/class.mysql.php');
 
18
require_once(dirname(__FILE__) . '/class.securelogin.php');
 
19
require_once(dirname(__FILE__) . '/class.geekmail.php');
 
20
require_once(dirname(__FILE__) . '/class.api.php');
 
21
 
 
22
if (!isset($sMySQL))
 
23
    $sMySQL = new MySQL();
 
24
        
 
25
if (!isset($sLogin))
 
26
    $sLogin = new SecureLogin($sMySQL);
 
27
        
 
28
if (!isset($sGeekMail))
 
29
    $sGeekMail = new GeekMail();
 
30
 
 
31
if (!isset($sAPI))
 
32
    $sAPI = new API($sMySQL);
 
33
        
 
34
if (!defined(SITE_NAME)) {
 
35
        define(SITE_NAME, strtolower($_SERVER['SERVER_NAME']));
 
36
        if (substr(SITE_NAME, 0, 4) == 'www.' )
 
37
                define(SITE_NAME,substr(SITE_NAME, 4));
 
38
}
 
39
 
 
40
if (!defined(SITE_NOREPLYEMAIL)) {
 
41
    define(SITE_NOREPLYEMAIL, 'noreply@'. SITE_NAME);
 
42
}
 
43
 
 
44
if (!defined(SITE_URL)) {
 
45
        $sSchema = (($_SERVER['HTTPS'] != '') ? ('https://') : ('http://'));
 
46
        $sHost = strtolower($_SERVER['SERVER_NAME']);
 
47
        $sPort = (($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) ? (':'.$_SERVER['SERVER_PORT']) : (''));
 
48
        
 
49
        define(SITE_URL, $sSchema . $sHost . $sPort . '/');
 
50
}
 
51
 
 
52
/**
 
53
 * Sends mail using geek mail
 
54
 * @param string $to e-mail address to send to
 
55
 * @param string $subject subject
 
56
 * @param string $message message to send
 
57
 * @param string $attach files to attach
 
58
 * @return Returns true if message was sent
 
59
 */
 
60
function SendMail($to, $subject, $message, $attach='') {
 
61
    global $sGeekMail;
 
62
    
 
63
    $sGeekMail->from(SITE_NOREPLYEMAIL, 'Little Software Stats');
 
64
    $sGeekMail->to($to);
 
65
    $sGeekMail->subject($subject);
 
66
    $sGeekMail->message($message);
 
67
    if ($attach != '')
 
68
        $sGeekMail->attach($attach);
 
69
    
 
70
    return $sGeekMail->send();
 
71
}
 
72
        
 
73
/**
 
74
 * Generates a green message box
 
75
 * @param type $sText Caption of message box
 
76
 * @return string HTML code 
 
77
 */
 
78
function GreenMsgBox($sText) {
 
79
        return "<div id=\"message-green\">
 
80
                <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
 
81
                <tbody>
 
82
                <tr>
 
83
                        <td class=\"green-left\">$sText</td>
 
84
                        <td class=\"green-right\"><a class=\"close-green\"><img alt=\"Close\" src=\"images/table/icon_close_green.gif\"></a></td>
 
85
                </tr>
 
86
                </tbody>
 
87
                </table>
 
88
                </div>";
 
89
}
 
90
 
 
91
/**
 
92
 * Generates a red message box
 
93
 * @param type $sText Caption of message box
 
94
 * @return string HTML code 
 
95
 */
 
96
function RedMsgBox($sText) {
 
97
        return "<div id=\"message-red\">
 
98
                <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
 
99
                <tbody>
 
100
                <tr>
 
101
                        <td class=\"red-left\">$sText</td>
 
102
                        <td class=\"red-right\"><a class=\"close-red\"><img alt=\"Close\" src=\"images/table/icon_close_red.gif\"></a></td>
 
103
                </tr>
 
104
                </tbody>
 
105
                </table>
 
106
                </div>";
 
107
}
 
108
 
 
109
/**
 
110
 * Generates a yellow message box
 
111
 * @param type $sText Caption of message box
 
112
 * @return string HTML code 
 
113
 */
 
114
function YellowMsgBox($sText) {
 
115
        return "<div id=\"message-yellow\">
 
116
                <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
 
117
                <tbody>
 
118
                <tr>
 
119
                        <td class=\"yellow-left\">$sText</td>
 
120
                        <td class=\"yellow-right\"><a class=\"close-yellow\"><img alt=\"Close\" src=\"images/table/icon_close_yellow.gif\"></a></td>
 
121
                </tr>
 
122
                </tbody>
 
123
                </table>
 
124
                </div>";
 
125
}
 
126
?>
 
 
b'\\ No newline at end of file'