function codopm_load()
{
    $myadapter = codopm_get_adapter();
    $adapter = new Adapter();
    $user = $adapter->get_user();
    $row_class = 'row';
    codopm::$xhash = md5($user->id . codopm::$secret);
    if ($user->id == 0) {
        if ($myadapter != 'Codoforum') {
            require "error.php";
        }
    } else {
        if (isset($_GET['to'])) {
            $to = $_GET['to'];
        } else {
            $to = '';
        }
        echo '
    <script>
    var codopm={};
    codopm.path="' . codopm::$path . '";
    codopm.req_path="' . codopm::$req_path . '";
    codopm.from="' . $user->id . '";
    codopm.xhash="' . codopm::$xhash . '";
    codopm.profile_id="' . codopm::$profile_id . '";    
    codopm.profile_name="' . codopm::$profile_name . '";
    </script>';
        require "start.php";
    }
}
Beispiel #2
0
 public static function t($index)
 {
     if (!self::$trans) {
         self::$trans = self::get_lang();
     }
     if (isset(self::$trans[$index])) {
         echo self::$trans[$index];
     } else {
         echo $index;
         //echo passed if not found
     }
 }
<?php

/**
 * @package Component codoPM for Joomla! 3.0
 * @author codologic
 * @copyright (C) 2013 - codologic
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * */
defined('_JEXEC') or die;
require "../arg.php";
require "../../../configuration.php";
$jconfig = new JConfig();
codopm::$db_prefix = $jconfig->dbprefix;
try {
    codopm::$db = new PDO('mysql:host=' . $jconfig->host . ';dbname=' . $jconfig->db, $jconfig->user, $jconfig->password);
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die("CODO_PM SAYS: Error Connecting Through PDO");
}
codopm::$db->query('SET CHARACTER SET utf8');
codopm::$db->query("SET NAMES utf8");
        <div id="codopm_attachment_percent" class="codopm_attachment_percent">0%</div >
    </div>

    <button id="codopm_sendbtn" class="btn btn-primary"><?php 
codopm::t('Send');
?>
 </button>
    &nbsp;&nbsp;<span class="codopm_msg_sent"><?php 
codopm::t('Your message has been sent');
?>
!
            <a target="_blank" href="<?php 
echo codopm::$profile_path;
?>
"><?php 
codopm::t('View message');
?>
</a>
    </span>
</div>
<script>
    CODOF.hook.add('on_scripts_loaded', function() {

        codopm.files_attached = 0;

        codopm.delete_attachment = function(id) {

            $('#' + id).remove();
            $('#visible_' + id).remove();

            if ($('.codopm_compose_attachments').children().length === 0) {
                            <div id="codopm_reply_attachments_list" class="codopm_reply_attachments_list">
                            </div>

                            <div class="codopm_compose_attachments" id="codopm_reply_attachments">
                                <input class="codopm_default_reply_file" type="file" name="file_0"/>
                            </div>
                        </form>

                        <div style="display:none" class="codopm_reply_toolbar" id="codopm_reply_toolbar">

                            <button id="codopm_reply_btn" class="btn-primary btn"><?php 
codopm::t('Reply');
?>
 </button>
                            <div id="codopm_reply_attach" class="codopm_reply_attach btn"> <?php 
codopm::t('Add files');
?>
 </div>
                            <div style="top: 10px;left: 20px;" id="codopm_attachment_progress_r" class="codopm_attachment_progress">
                                <div id="codopm_attachment_bar_r" class="codopm_attachment_bar"></div>
                                <div id="codopm_attachment_percent_r" class="codopm_attachment_percent">0%</div >
                            </div>

                        </div>
                    </div>

                    <div class="codopm_conversation_content" id="codopm_conversation_content">


                    </div>
                </div>
 public function setup_tables()
 {
     codopm::$table['mail_column'] = 'mail';
     codopm::$upload_path = PLUGIN_DIR . "codopm/";
 }
                    data = JSON.parse(data);

                    codopm.create_range(data.start, data.end, data.count);
                    codopm.my_name = data.my_name;

                    if (data.has_error == false) {

                        var messages = data.messages,
                                len = messages.length,
                                str = '',
                                today = new Date(), pretty_time,
                                date, bg_cls, frm_name;

                        if (len === 0)
                            str = '<div class="codopm_nomsgs"><?php 
codopm::t('No messages found!');
?>
</div>';

                        for (var i = 0; i < len; i++) {

                            date = new Date(messages[i].time * 1000);

                            pretty_time = get_pretty_time(today, date);


                            var message = '';

                            if (messages[i].message !== null) {
                                message = messages[i].message.substring(0, 50);
                                message = message.replace(/<br\/>/g, " ");
function codopm_do_route()
{
    if (isset($_GET['do'])) {
        require 'config.php';
        $conf = new Config(codopm::$db);
        codopm::$config = $conf->get_config();
        require 'getmessages.php';
        $do = $_GET['do'];
        if ($do == 'get_config') {
            echo json_encode(codopm::$config);
        } else {
            if ($do == 'send') {
                if (!isset($_POST['to'])) {
                    $resp = new response();
                    $resp->has_error = true;
                    $resp->msg = "file size exceeded maximum post size, please remove some files";
                    echo json_encode($resp);
                    return;
                }
                send_message((int) $_GET['id'], (int) $_POST['to'], strip_tags($_POST['message']));
            } else {
                if ($do == 'get_messages') {
                    $id = (int) $_GET['id'];
                    $my_name = save_my_details($id);
                    $per_page = codopm::$config['msgs_per_page'];
                    $start = (int) $_GET['range']['from'];
                    $end = (int) $_GET['range']['to'];
                    $resp = new response();
                    if ($_GET['type'] == 'default') {
                        $start = 0;
                    } else {
                        if ($_GET['type'] == 'next') {
                            $start += $per_page;
                        } else {
                            if ($_GET['type'] == 'previous') {
                                $start -= $per_page;
                            } else {
                                exit;
                            }
                        }
                    }
                    $messages = get_messages($id, $start);
                    $msg_cnt = count($messages);
                    $count = get_message_count($id);
                    $cnt = $count[0]["count"];
                    if ($msg_cnt < $per_page) {
                        $end = $cnt;
                    } else {
                        $end = $start + $per_page - 1;
                    }
                    if ($start === 0 && $cnt != 0) {
                        $start = 1;
                        $end = $per_page;
                    }
                    if ($end > $cnt || $end < $cnt && $cnt < $per_page) {
                        $end = $cnt;
                    }
                    $resp->has_error = false;
                    $resp->start = $start;
                    $resp->end = $end;
                    $resp->per_page = $per_page;
                    $resp->messages = $messages;
                    $resp->my_name = $my_name;
                    $resp->count = $cnt;
                    echo json_encode($resp);
                } else {
                    if ($do == 'get_conversations') {
                        $to = (int) $_GET['msg_to'];
                        $from = (int) $_GET['msg_from'];
                        $offset = codopm::$config['conv_load_offset'];
                        $res = get_conversations($to, $from, (int) $_GET['id'], codopm::$config['conv_per_page'] + 1);
                        $conversations = $res['conversations'];
                        $count = $res['count'];
                        set_message_read($to, $from, (int) $_GET['id']);
                        $resp = new response();
                        $resp->has_error = false;
                        if ($count > codopm::$config['conv_per_page']) {
                            array_pop($conversations);
                            $resp->read_more = 'yes';
                        } else {
                            $resp->read_more = 'no';
                        }
                        $resp->conversations = $conversations;
                        $resp->offset = $offset;
                        echo json_encode($resp);
                    } else {
                        if ($do == 'delete_conversation') {
                            delete_conversation((int) $_POST['msg_id']);
                            $resp = new response();
                            $resp->has_error = false;
                            echo json_encode($resp);
                        } else {
                            if ($do == 'load_more_conversations') {
                                $to = (int) $_GET['msg_to'];
                                $from = (int) $_GET['msg_from'];
                                $offset = (int) $_GET['msg_offset'];
                                $res = get_conversations($to, $from, (int) $_GET['id'], codopm::$config['conv_load_offset'] + 1, $offset);
                                $conversations = $res['conversations'];
                                $count = $res['count'];
                                $resp = new response();
                                $resp->has_error = false;
                                if ($count > codopm::$config['conv_load_offset']) {
                                    array_pop($conversations);
                                    $resp->read_more = 'yes';
                                } else {
                                    $resp->read_more = 'no';
                                }
                                $resp->conversations = $conversations;
                                $resp->offset = $offset;
                                echo json_encode($resp);
                            } else {
                                if ($do == 'autocomplete') {
                                    $results = array();
                                    if (isset($_GET['term'])) {
                                        $terms = strip_tags($_GET['term']);
                                        if (strpos($terms, ",") !== FALSE) {
                                            $_term = explode(",", $terms);
                                            $term = trim(end($_term));
                                        } else {
                                            $term = $terms;
                                        }
                                        $query = "SELECT name,username FROM " . codopm::$db_prefix . "users " . "WHERE (username LIKE :term1 OR name LIKE :term2)";
                                        $sth = codopm::$db->prepare($query);
                                        $variable_array = array(":term1" => $term . '%', ":term2" => $term . '%');
                                        $sth->execute($variable_array);
                                        $result = $sth->fetchAll();
                                        foreach ($result as $res) {
                                            $label = $res['name'];
                                            if (empty($label)) {
                                                $label = $res['username'];
                                            } else {
                                                if ($res['name'] != $res['username']) {
                                                    $label = $res['name'] . " " . "(" . $res['username'] . ")";
                                                }
                                            }
                                            $results[] = array("id" => $res['username'], "label" => $label, "value" => $res['username']);
                                        }
                                    }
                                    echo json_encode($results);
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        die("CODOPM SAYS: Invalid Req");
    }
}