Ejemplo n.º 1
0
/**
 * Send an email in the recipient's language
 *
 * @param string $rlang Recipient language
 * @param string $remail Recipient email
 * @param string $rusername Recipient name
 */
function cot_send_translated_mail($rlang, $remail, $rusername)
{
    global $cfg, $usr;
    require_once cot_langfile('pm', 'module', $cfg['defaultlang'], $rlang);
    if (!$L || !isset($L['pm_notify'])) {
        global $L;
    }
    $rsubject = $L['pm_notifytitle'];
    $rbody = sprintf($L['pm_notify'], $rusername, htmlspecialchars($usr['name']), $cfg['mainurl'] . '/' . cot_url('pm', '', '', true));
    cot_mail($remail, $rsubject, $rbody);
}
Ejemplo n.º 2
0
 public function send($data)
 {
     if (empty($data['fromName'])) {
         $data['fromName'] = cot::$cfg['maintitle'];
     }
     if (empty($data['fromEmail'])) {
         $data['fromEmail'] = cot::$cfg['adminemail'];
     }
     $fromName = mb_encode_mimeheader($data['fromName'], 'UTF-8', 'B', "\n");
     $headers = "From: \"" . $fromName . "\" <" . $data['fromEmail'] . ">\n" . "Reply-To: <" . cot::$cfg['adminemail'] . ">\n";
     $ret = cot_mail($data['toEmail'], $data['subject'], $data['body'], $headers, false, null, true);
     return $ret;
 }
Ejemplo n.º 3
0
     $rtransfer['trn_status'] = 'canceled';
     if ($db->update($db_payments_transfers, $rtransfer, "trn_id=" . $id)) {
         $payinfo['pay_userid'] = $transfer['trn_from'];
         $payinfo['pay_area'] = 'balance';
         $payinfo['pay_code'] = $id;
         $payinfo['pay_summ'] = $transfer['pay_summ'];
         $payinfo['pay_cdate'] = $sys['now'];
         $payinfo['pay_pdate'] = $sys['now'];
         $payinfo['pay_adate'] = $sys['now'];
         $payinfo['pay_status'] = 'done';
         $payinfo['pay_desc'] = sprintf($L['payments_balance_transfer_cancel_desc'], $id);
         $db->insert($db_payments, $payinfo);
         // Отправка уведомления об отмене перевода
         $subject = $L['payments_balance_transfer_cancel_subject'];
         $body = sprintf($L['payments_balance_transfer_cancel_body'], $transfer['user_name'], $id);
         cot_mail($transfer['user_email'], $subject, $body);
     }
     cot_redirect(cot_url('admin', 'm=payments&p=payouts'));
 }
 $where = array();
 if (!empty($sq)) {
     $where['search'] = "(u.user_name LIKE '%" . $db->prep($sq) . "%' OR u.user_email LIKE '%" . $db->prep($sq) . "%')";
 }
 $where = array_filter($where);
 $where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
 $transfers = $db->query("SELECT * FROM {$db_payments_transfers} AS t\n\t\tLEFT JOIN {$db_users} AS u ON u.user_id=t.trn_from\n\t\tLEFT JOIN {$db_payments} AS p ON p.pay_code=t.trn_id AND p.pay_area='transfer'\n\t\t{$where}\n\t\tORDER BY pay_cdate DESC")->fetchAll();
 if (count($transfers) > 0) {
     foreach ($transfers as $transfer) {
         $t->assign(array('TRANSFER_ROW_ID' => $transfer['trn_id'], 'TRANSFER_ROW_SUMM' => $transfer['trn_summ'], 'TRANSFER_ROW_COMMENT' => $transfer['trn_comment'], 'TRANSFER_ROW_DATE' => $transfer['trn_date'], 'TRANSFER_ROW_DONE' => $transfer['trn_done'], 'TRANSFER_ROW_STATUS' => $transfer['trn_status'], 'TRANSFER_ROW_LOCALSTATUS' => $L['payments_balance_payout_status_' . $transfer['trn_status']], 'TRANSFER_ROW_DONE_URL' => cot_url('admin', 'm=payments&p=transfers&a=done&id=' . $transfer['trn_id']), 'TRANSFER_ROW_CANCEL_URL' => cot_url('admin', 'm=payments&p=transfers&a=cancel&id=' . $transfer['trn_id'])));
         $t->assign(cot_generate_usertags($transfer['trn_from'], 'TRANSFER_ROW_FROM_'));
         $t->assign(cot_generate_usertags($transfer['trn_to'], 'TRANSFER_ROW_FOR_'));
Ejemplo n.º 4
0
function cot_sbr_sendpost($id, $text, $to, $from = 0, $type = '', $mail = false, $rfiles = array())
{
    global $db, $db_sbr_posts, $db_sbr, $db_sbr_files, $db_users, $sys, $cfg, $L, $R;
    $rpost['post_sid'] = $id;
    $rpost['post_text'] = $text;
    $rpost['post_date'] = $sys['now'];
    $rpost['post_from'] = $from;
    $rpost['post_to'] = $to;
    $rpost['post_type'] = $type;
    /* === Hook === */
    foreach (cot_getextplugins('sbr.post.add.query') as $pl) {
        include $pl;
    }
    /* ===== */
    if ($db->insert($db_sbr_posts, $rpost)) {
        $postid = $db->lastInsertId();
        $sbr_path = $cfg['plugin']['sbr']['filepath'] . '/' . $id . '/';
        if (!file_exists($sbr_path)) {
            mkdir($sbr_path);
            @chmod($sbr_path, $cfg['dir_perms']);
        }
        for ($j = 0; $j < 10; $j++) {
            if ($rfiles['size'][$j] > 0 && $rfiles['error'][$j] == 0) {
                $u_tmp_name_file = $rfiles['tmp_name'][$j];
                $u_type_file = $rfiles['type'][$j];
                $u_name_file = $rfiles['name'][$j];
                $u_size_file = $rfiles['size'][$j];
                $u_name_file = str_replace("\\'", '', $u_name_file);
                $u_name_file = trim(str_replace("\"", '', $u_name_file));
                $dotpos = strrpos($u_name_file, ".") + 1;
                $f_extension = substr($u_name_file, $dotpos, 5);
                if (!empty($u_tmp_name_file)) {
                    $fcheck = cot_file_check($u_tmp_name_file, $u_name_file, $f_extension);
                    if ($fcheck == 1) {
                        if (in_array($f_extension, explode(',', $cfg['plugin']['sbr']['extensions']))) {
                            $u_newname_file = $postid . "_" . md5(uniqid(rand(), true)) . "." . $f_extension;
                            $file = $sbr_path . $u_newname_file;
                            move_uploaded_file($u_tmp_name_file, $file);
                            @chmod($file, 0766);
                            $rfile['file_sid'] = $id;
                            $rfile['file_url'] = $file;
                            $rfile['file_title'] = $u_name_file;
                            $rfile['file_area'] = 'post';
                            $rfile['file_code'] = $postid;
                            $rfile['file_ext'] = $f_extension;
                            $rfile['file_size'] = floor($u_size_file / 1024);
                            $db->insert($db_sbr_files, $rfile);
                        }
                    }
                }
            }
        }
        // Отправка сообщения на почту!
        if ($mail) {
            $sbr = $db->query("SELECT * FROM {$db_sbr} WHERE sbr_id=" . $id)->fetch();
            if (!empty($to)) {
                $recipients[] = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $to)->fetch();
            } else {
                $recipients[] = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $sbr['sbr_performer'])->fetch();
                $recipients[] = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $sbr['sbr_employer'])->fetch();
            }
            if (!empty($from)) {
                $sender = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $from)->fetch();
            }
            foreach ($recipients as $recipient) {
                if (!empty($from)) {
                    $rsubject = cot_rc($L['sbr_mail_posts_header'], array('sbr_id' => $id, 'sbr_title' => $sbr['sbr_title']));
                    $rbody = cot_rc($L['sbr_mail_posts_body'], array('user_name' => $recipient['user_name'], 'sender_name' => $sender['user_name'], 'post_text' => $text, 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)));
                } else {
                    $rsubject = cot_rc($L['sbr_mail_notification_header'], array('sbr_id' => $id, 'sbr_title' => $sbr['sbr_title']));
                    $rbody = cot_rc($L['sbr_mail_notification_body'], array('user_name' => $recipient['user_name'], 'post_text' => $text, 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)));
                }
                cot_mail($recipient['user_email'], $rsubject, $rbody, '', false, null, true);
            }
        }
        /* === Hook === */
        foreach (cot_getextplugins('sbr.post.add.done') as $pl) {
            include $pl;
        }
        /* ===== */
        return $db->lastInsertId();
    }
    return false;
}
Ejemplo n.º 5
0
    }
    /* ===== */
    $prj = array();
    if ($cfg['projects']['prevalidate'] && !$usr['isadmin']) {
        $prj['item_state'] = 2;
        $r_url = empty($ritem['item_alias']) ? cot_url('projects', 'c=' . $ritem['item_cat'] . '&id=' . $id, '', true) : cot_url('projects', 'c=' . $ritem['item_cat'] . '&al=' . $ritem['item_alias'], '', true);
        if (!$usr['isadmin']) {
            $rbody = cot_rc($L['project_senttovalidation_mail_body'], array('user_name' => $item['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($item['user_email'], $L['project_senttovalidation_mail_subj'], $rbody);
        }
    } else {
        $prj['item_state'] = 0;
        $r_url = empty($item['item_alias']) ? cot_url('projects', 'c=' . $item['item_cat'] . '&id=' . $id, '', true) : cot_url('projects', 'c=' . $item['item_cat'] . '&al=' . $item['item_alias'], '', true);
        if (!$usr['isadmin']) {
            $rbody = cot_rc($L['project_added_mail_body'], array('user_name' => $item['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', 'id=' . $id, '', true)));
            cot_mail($item['user_email'], $L['project_added_mail_subj'], $rbody);
        }
    }
    $db->update($db_projects, $prj, "item_id=" . (int) $id);
    cot_projects_sync($item['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('projects.preview.save.done') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
$out['subtitle'] = $L['projects'];
$mskin = cot_tplfile(array('projects', 'preview', $structure['projects'][$item['item_cat']]['tpl']));
/* === Hook === */
Ejemplo n.º 6
0
    foreach (cot_getextplugins('projects.offers.addpost.error') as $pl) {
        include $pl;
    }
    /* ===== */
    if (!empty($offer_post['post_text']) && (in_array($usr['id'], array($offer['offer_userid'], $item['item_userid'])) || $usr['isadmin']) && !cot_error_found()) {
        $db->insert($db_projects_posts, $offer_post);
        if ($usr['id'] == $offer['offer_userid']) {
            $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
            $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title']));
            $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $item['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true)));
            cot_mail($item['user_email'], $rsubject, $rbody);
        } else {
            $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
            $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title']));
            $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $offer['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true)));
            cot_mail($offer['user_email'], $rsubject, $rbody);
        }
        cot_message($L['offers_add_post'], 'ok');
        /* === Hook === */
        foreach (cot_getextplugins('projects.offers.addpost.done') as $pl) {
            include $pl;
        }
        /* ===== */
    }
    cot_redirect(cot_url('projects', 'id=' . $id, '', true));
    exit;
}
$t_o = new XTemplate(cot_tplfile(array('projects', 'offers', $structure['projects'][$item['item_cat']]['tpl'])));
// Вычисление выбранного исполнителя по проекту
if ($item['item_performer']) {
    $t_o->assign(cot_generate_usertags($item['item_performer'], 'PRJ_PERFORMER_'));
Ejemplo n.º 7
0
        $advCommenterName = cot::$L['Anonymous'];
        $advCommenterUrl = '';
        if (cot::$usr['id'] > 0) {
            $advCommenterName = cot_user_full_name(cot::$usr['profile']);
            $advCommenterUrl = cot_url('users', array('m' => 'details', 'id' => cot::$usr['id'], 'u' => htmlspecialchars(cot::$usr['name'])));
            if (!cot_url_check($advCommenterUrl)) {
                $advCommenterUrl = COT_ABSOLUTE_URL . $advCommenterUrl;
            }
        } elseif ($comarray['com_author'] != '') {
            $advCommenterName = $comarray['com_author'];
        }
        // /Автор комментария
        $mailView = new View();
        $mailView->advert = $advert;
        $mailView->owner = $owner;
        $mailView->commentText = $advComText;
        $mailView->commentUrl = $advertUrl . "#c" . $id;
        $mailView->commenter = cot::$usr['id'] > 0 ? cot::$usr['profile'] : array();
        $mailView->commenterName = $advCommenterName;
        $mailView->commenterUrl = $advCommenterUrl;
        $mailView->advertUrl = $advertUrl;
        $mailView->advertEditUrl = $advertEditUrl;
        $mailView->myAdvsUrl = $myAdvsUrl;
        $mailView->advertText = $text;
        $mailSubject = cot::$L['advboard_new_comment'];
        $mailBody = $mailView->render('advboard.notify_comment.' . $userLang . '.' . $advert->category);
        cot_mail($advert->getEmail(false, true), $mailSubject, $mailBody, '', false, null, true);
        // Вернем язык на место
        cot::$L = $tmpL;
    }
}
Ejemplo n.º 8
0
if ($a == 'public') {
    $ritem = array();
    if ($cfg['folio']['prevalidate']) {
        $ritem['item_state'] = $usr['isadmin'] ? 0 : 2;
    } else {
        $ritem['item_state'] = 0;
    }
    $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $id) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
    $r_url = cot_url('folio', $urlparams, '', true);
    if (!$usr['isadmin']) {
        if ($ritem['item_state'] == 2) {
            $rbody = cot_rc($L['folio_senttovalidation_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($usr['profile']['user_email'], $L['folio_senttovalidation_mail_subj'], $rbody);
        } else {
            $rbody = cot_rc($L['folio_added_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($usr['profile']['user_email'], $L['folio_added_mail_subj'], $rbody);
        }
    }
    $db->update($db_folio, $ritem, 'item_id = ?', $id);
    cot_folio_sync($item['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('folio.edit.public') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
if ($a == 'hide') {
    $ritem = array();
    $ritem['item_state'] = 1;
Ejemplo n.º 9
0
            $payinfo['pay_summ'] = $recipientsumm;
            $payinfo['pay_cdate'] = $sys['now'];
            $payinfo['pay_pdate'] = $sys['now'];
            $payinfo['pay_adate'] = $sys['now'];
            $payinfo['pay_status'] = 'done';
            $payinfo['pay_desc'] = sprintf($L['payments_balance_transfer_desc'], $usr['name'], $recipient['user_name'], $comment);
            $db->insert($db_payments, $payinfo);
            $pid = $db->lastInsertId();
            // Отправка уведомления админу о переводе между пользователями
            $subject = $L['payments_balance_transfer_admin_subject'];
            $body = sprintf($L['payments_balance_transfer_admin_body'], $usr['name'], $recipient['user_name'], $summ, $taxsumm, $sendersumm, $recipientsumm, $cfg['payments']['valuta'], cot_date('d.m.Y в H:i', $sys['now']), $comment);
            cot_mail($cfg['adminemail'], $subject, $body);
            // Отправка уведомления админу о переводе между пользователями
            $subject = $L['payments_balance_transfer_recipient_subject'];
            $body = sprintf($L['payments_balance_transfer_recipient_body'], $usr['name'], $recipient['user_name'], $summ, $taxsumm, $sendersumm, $recipientsumm, $cfg['payments']['valuta'], cot_date('d.m.Y в H:i', $sys['now']), $comment);
            cot_mail($recipient['user_email'], $subject, $body);
            cot_redirect(cot_url('payments', 'm=balance&n=history', '', true));
        }
        cot_redirect(cot_url('payments', 'm=balance&n=transfer', '', true));
    }
    cot_display_messages($t, 'MAIN.TRANSFERFORM');
    $t->assign(array('TRANSFER_FORM_ACTION_URL' => cot_url('payments', 'm=balance&n=transfer&a=add'), 'TRANSFER_FORM_SUMM' => cot_inputbox('text', 'summ', $summ), 'TRANSFER_FORM_TAX' => $taxsumm, 'TRANSFER_FORM_TOTAL' => !empty($sendersumm) ? $sendersumm : 0, 'TRANSFER_FORM_COMMENT' => $comment, 'TRANSFER_FORM_USERNAME' => $username));
    $t->parse('MAIN.TRANSFERFORM');
}
if ($n == 'history') {
    $pays = $db->query("SELECT * FROM {$db_payments} \n\t\tWHERE pay_userid=" . $usr['id'] . " AND pay_status='done' AND pay_summ>0\n\t\tORDER BY pay_pdate DESC")->fetchAll();
    foreach ($pays as $pay) {
        $t->assign(cot_generate_paytags($pay, 'HIST_ROW_'));
        $t->parse('MAIN.HISTORY.HIST_ROW');
    }
    $t->parse('MAIN.HISTORY');
// Выплаты продавцам по завершению гарантийного срока по оформленным заказам
$warranty = $cfg['plugin']['marketorders']['warranty'] * 60 * 60 * 24;
$marketorders = $db->query("SELECT * FROM {$db_market_orders} AS o\n\tLEFT JOIN {$db_market} AS m ON m.item_id=o.order_pid\n\tWHERE order_status='paid' AND order_paid+" . $warranty . "<" . $sys['now'])->fetchAll();
foreach ($marketorders as $marketorder) {
    // Выплата продавцу на счет
    $seller = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $marketorder['order_seller'])->fetch();
    $summ = $marketorder['order_cost'] - $marketorder['order_cost'] * $cfg['plugin']['marketorders']['tax'] / 100;
    $payinfo['pay_userid'] = $marketorder['order_seller'];
    $payinfo['pay_area'] = 'balance';
    $payinfo['pay_code'] = 'marketorders:' . $marketorder['order_id'];
    $payinfo['pay_summ'] = $summ;
    $payinfo['pay_cdate'] = $sys['now'];
    $payinfo['pay_pdate'] = $sys['now'];
    $payinfo['pay_adate'] = $sys['now'];
    $payinfo['pay_status'] = 'done';
    $payinfo['pay_desc'] = cot_rc($L['marketorders_done_payments_desc'], array('product_title' => $marketorder['item_title'], 'order_id' => $marketorder['order_id']));
    if ($db->insert($db_payments, $payinfo)) {
        // Уведомляем продавца о поступлении оплаты на его счет
        $rsubject = cot_rc($L['marketorders_done_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
        $rbody = cot_rc($L['marketorders_done_mail_toseller_body'], array('product_id' => $marketorder['item_id'], 'product_title' => $marketorder['item_title'], 'order_id' => $marketorder['order_id'], 'summ' => $summ . ' ' . $cfg['payments']['valuta'], 'tax' => $cfg['plugin']['marketorders']['tax'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)));
        cot_mail($seller['user_email'], $rsubject, $rbody);
        $rorder['order_done'] = $sys['now'];
        $rorder['order_status'] = 'done';
        $db->update($db_market_orders, $rorder, "order_id=" . $marketorder['order_id']);
        /* === Hook === */
        foreach (cot_getextplugins('marketorders.order.done') as $pl) {
            include $pl;
        }
        /* ===== */
    }
}
Ejemplo n.º 11
0
                                $rfile['file_title'] = $u_name_file;
                                $rfile['file_area'] = 'stage';
                                $rfile['file_code'] = $i;
                                $rfile['file_ext'] = $f_extension;
                                $rfile['file_size'] = floor($u_size_file / 1024);
                                $db->insert($db_sbr_files, $rfile);
                            }
                        }
                    }
                }
            }
        }
        $performer = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $rsbr['sbr_performer'])->fetch();
        $rsubject = cot_rc($L['sbr_mail_toperformer_new_header'], array('sbr_title' => $rsbr['sbr_title']));
        $rbody = cot_rc($L['sbr_mail_toperformer_new_body'], array('performer_name' => $performer['user_name'], 'employer_name' => $usr['profile']['user_name'], 'sbr_title' => $rsbr['sbr_title'], 'sbr_cost' => $rsbr['sbr_cost'] . ' ' . $cfg['payments']['valuta'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)));
        cot_mail($performer['user_email'], $rsubject, $rbody);
        cot_sbr_sendpost($id, $L['sbr_posts_performer_new'], $rsbr['sbr_performer'], 0, 'info');
        cot_sbr_sendpost($id, $L['sbr_posts_employer_new'], $usr['id'], 0, 'info');
        /* === Hook === */
        foreach (cot_getextplugins('sbr.add.add.done') as $pl) {
            include $pl;
        }
        /* ===== */
        cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
    }
}
$out['subtitle'] = $L['sbr_addtitle'];
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('sbr', 'add'), 'plug');
/* === Hook === */
foreach (cot_getextplugins('sbr.add.main') as $pl) {
Ejemplo n.º 12
0
        switch ($ritem['item_state']) {
            case 0:
                if (!$usr['isadmin']) {
                    $rbody = cot_rc($L['project_added_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prj_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', 'id=' . $id, '', true)));
                    cot_mail($usr['profile']['user_email'], $L['project_added_mail_subj'], $rbody);
                }
                $urlparams = empty($ritem['item_alias']) ? array('c' => $ritem['item_cat'], 'id' => $id) : array('c' => $ritem['item_cat'], 'al' => $ritem['item_alias']);
                $r_url = cot_url('projects', $urlparams, '', true);
                break;
            case 1:
                $r_url = cot_url('projects', 'm=preview&id=' . $id, '', true);
                break;
            case 2:
                if (!$usr['isadmin']) {
                    $rbody = cot_rc($L['project_senttovalidation_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prj_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
                    cot_mail($usr['profile']['user_email'], $L['project_senttovalidation_mail_subj'], $rbody);
                }
                $urlparams = empty($ritem['item_alias']) ? array('c' => $ritem['item_cat'], 'id' => $id) : array('c' => $ritem['item_cat'], 'al' => $ritem['item_alias']);
                $r_url = cot_url('projects', $urlparams, '', true);
                break;
        }
        cot_redirect($r_url);
        exit;
    } else {
        cot_redirect(cot_url('projects', 'm=add&c=' . $c . '&type=' . $type, '', true));
    }
}
if (empty($ritem['item_cat']) && !empty($c)) {
    $ritem['item_cat'] = $c;
    $usr['isadmin'] = cot_auth('projects', $ritem['item_cat'], 'A');
}
            cot_redirect(cot_url('admin', 'm=market&p=default', '', true));
            break;
        case 'validate':
            foreach ($prd_arr as $prd_id) {
                /* === Hook: Part 1 === */
                foreach ($extpl as $pl) {
                    include $pl;
                }
                /* ===== */
                $sql = $db->query("SELECT * FROM {$db_market} AS m LEFT JOIN {$db_users} AS u ON u.user_id=m.item_userid WHERE item_id='{$prd_id}' LIMIT 1");
                cot_die($sql->rowCount() == 0);
                $item = $sql->fetch();
                $db->update($db_market, array('item_state' => 0), "item_id=?", array($prd_id));
                cot_market_sync($item['item_cat']);
                $rbody = cot_rc($L['market_added_mail_body'], array('user_name' => $item['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('market', 'id=' . $prd_id, '', true)));
                cot_mail($item['user_email'], $L['market_added_mail_subj'], $rbody);
                /* === Hook: Part 2 === */
                foreach ($extpl1 as $pl) {
                    include $pl;
                }
                /* ===== */
            }
            cot_redirect(cot_url('admin', 'm=market&p=default', '', true));
            break;
        default:
            cot_redirect(cot_url('admin', 'm=market&p=default', '', true));
            break;
    }
}
$t = new XTemplate(cot_tplfile('market.admin.default', 'module'));
$where = array();
Ejemplo n.º 14
0
 /**
  * Обработка Ajax запроса на подписку на рассылку
  * Используется виджетом
  * Принимает email пользователя
  * Допускается подписка неавторизованными пользователями (они должны подтвердить email)
  */
 public function ajxSubscribeAction()
 {
     global $db_users;
     $ret = array('error' => '', 'message' => '');
     $id = cot_import('id', 'P', 'INT');
     $email = cot_import('email', 'P', 'TXT');
     if (!$id) {
         $ret['error'] = cot::$L['subscribe_err_not_found'];
         echo json_encode($ret);
         exit;
     }
     $subscribe = subscribe_model_Subscribe::getById($id);
     if (!$subscribe) {
         $ret['error'] = cot::$L['subscribe_err_not_found'];
         echo json_encode($ret);
         exit;
     }
     if (!$subscribe->active) {
         $ret['error'] = cot::$L['subscribe_err_disabled'];
         echo json_encode($ret);
         exit;
     }
     if (empty($email)) {
         $ret['error'] = cot::$L['field_required'] . ': ' . cot::$L['Email'];
         echo json_encode($ret);
         exit;
     }
     $tmp = subscribe_checkEmail($email);
     if ($tmp !== true) {
         $ret['error'] = $tmp;
         echo json_encode($ret);
         exit;
     }
     $email = mb_strtolower($email);
     $subscriber = subscribe_model_Subscriber::fetchOne(array(array('subscribe', $id), array('email', $email)));
     if ($subscriber) {
         if ($subscriber->active) {
             $ret['error'] = sprintf(cot::$L['subscribe_err_user_subscribed'], $email, $subscribe->title);
             echo json_encode($ret);
             exit;
         }
     } else {
         $subscriber = new subscribe_model_Subscriber();
     }
     $sql = cot::$db->query("SELECT * FROM {$db_users} WHERE user_email = ? LIMIT 1", $email);
     $user = $sql->fetch();
     $subscriber->subscribe = $id;
     $subscriber->email = $email;
     if (!empty($user)) {
         $subscriber->user = $user['user_id'];
         $subscriber->name = cot_user_full_name($user);
     }
     $needConfirm = cot::$cfg['subscribe']['guestConfirmMail'];
     if (cot::$usr['id'] > 0) {
         if (cot::$usr['id'] == $user['user_id'] || cot::$usr['isadmin']) {
             $needConfirm = false;
         }
     }
     if ($needConfirm) {
         // Возможно пользователь уже подтверждал свой email
         $tmp = subscribe_model_Subscriber::count(array(array('email', $email), array('email_valid', 1)));
         if ($tmp > 0) {
             $needConfirm = false;
         }
     }
     if (!$needConfirm) {
         $subscriber->email_valid = 1;
         $subscriber->email_valid_date = date('Y-m-d H:i:s', cot::$sys['now']);
         $subscriber->active = 1;
     }
     // Сохранение
     $subscriber->save();
     $ret['message'] = sprintf(cot::$L['subscribe_msg_you_subscribed'], $subscribe->title);
     // Письмо для поджтверждения e-mail адреса
     if ($needConfirm) {
         $confirmUrl = cot_url('subscribe', array('m' => 'user', 'a' => 'confirm', 'code' => $subscriber->unsubscr_code));
         if (!cot_url_check($confirmUrl)) {
             $confirmUrl = cot::$cfg['mainurl'] . '/' . $confirmUrl;
         }
         $mailView = new View();
         $mailView->subscriber = $subscriber;
         $mailView->subscribe = $subscribe;
         $mailView->confirmUrl = $confirmUrl;
         $mailTpl = array('subscribe', 'mail_confirm', cot::$usr['lang']);
         $mailBody = $mailView->render($mailTpl);
         cot_mail($email, cot::$L['subscribe_confirm'], $mailBody, '', false, null, true);
         $ret['message'] .= cot::$L['subscribe_wait_confirm'];
     }
     echo json_encode($ret);
     exit;
 }
Ejemplo n.º 15
0
             $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$url_params['c']]['path']));
         }
         if ($cfg['cache_index']) {
             $cache->page->clear('index');
         }
     }
     $cfg['cache_page'] = $cfg['cache_index'] = false;
     cot_extrafield_movefiles();
     $_SESSION['cot_comments_edit'][$id] = $sys['now'];
     if ($cfg['plugin']['comments']['mail']) {
         $sql = $db->query("SELECT * FROM {$db_users} WHERE user_maingrp=5");
         $email_title = $L['plu_comlive'];
         $email_body = $L['User'] . ' ' . preg_replace('#[^\\w\\p{L}]#u', '', $usr['id'] == 0 ? $rname : $usr['name']) . ' ' . $L['plu_comlive2'];
         $email_body .= COT_ABSOLUTE_URL . cot_url($url_area, $url_params, '#c' . $id, true) . "\n\n";
         while ($adm = $sql->fetch()) {
             cot_mail($adm['user_email'], $email_title, $email_body);
         }
         $sql->closeCursor();
     }
     /* == Hook == */
     foreach (cot_getextplugins('comments.send.new') as $pl) {
         include $pl;
     }
     /* ===== */
     cot_message($L['com_commentadded']);
     cot_shield_update(20, 'New comment');
     cot_redirect(cot_url($url_area, $url_params, '#c' . $id, true));
 }
 if ($usr['id'] == 0 && $area == 'page' && $cache) {
     if ($cfg['cache_page']) {
         $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$url_params['c']]['path']));
Ejemplo n.º 16
0
if ($a == 'public') {
    $ritem = array();
    if ($cfg['market']['prevalidate']) {
        $ritem['item_state'] = $usr['isadmin'] ? 0 : 2;
    } else {
        $ritem['item_state'] = 0;
    }
    $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $id) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
    $r_url = cot_url('market', $urlparams, '', true);
    if (!$usr['isadmin']) {
        if ($ritem['item_state'] == 2) {
            $rbody = cot_rc($L['market_senttovalidation_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($usr['profile']['user_email'], $L['market_senttovalidation_mail_subj'], $rbody);
        } else {
            $rbody = cot_rc($L['market_added_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($usr['profile']['user_email'], $L['market_added_mail_subj'], $rbody);
        }
    }
    $db->update($db_market, $ritem, 'item_id = ?', $id);
    cot_market_sync($item['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('market.edit.public') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
if ($a == 'hide') {
    $ritem = array();
    $ritem['item_state'] = 1;
Ejemplo n.º 17
0
                $urlparams = empty($ritem['item_alias']) ? array('c' => $ritem['item_cat'], 'id' => $id) : array('c' => $ritem['item_cat'], 'al' => $ritem['item_alias']);
                $r_url = cot_url('folio', $urlparams, '', true);
                break;
            case 1:
                $r_url = cot_url('folio', 'm=preview&id=' . $id, '', true);
                break;
            case 2:
                $urlparams = empty($ritem['item_alias']) ? array('c' => $ritem['item_cat'], 'id' => $id) : array('c' => $ritem['item_cat'], 'al' => $ritem['item_alias']);
                $r_url = cot_url('folio', $urlparams, '', true);
                if (!$usr['isadmin']) {
                    $rbody = cot_rc($L['folio_senttovalidation_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
                    cot_mail($usr['profile']['user_email'], $L['folio_senttovalidation_mail_subj'], $rbody);
                }
                if ($cfg['folio']['notiffolio_admin_moderate']) {
                    $nbody = cot_rc($L['folio_notif_admin_moderate_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
                    cot_mail($cfg['adminemail'], $L['folio_notif_admin_moderate_mail_subj'], $nbody);
                }
                break;
        }
        cot_redirect($r_url);
        exit;
    } else {
        cot_redirect(cot_url('folio', 'm=add&c=' . $c, '', true));
    }
}
if (empty($ritem['item_cat']) && !empty($c)) {
    $ritem['item_cat'] = $c;
    $usr['isadmin'] = cot_auth('folio', $ritem['item_cat'], 'A');
}
if (empty($ritem['item_type']) && !empty($type)) {
    $ritem['item_type'] = $type;
        $db->update($db_market_orders, $rorder, 'order_id=' . $id);
        $seller = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $marketorder['order_seller'])->fetch();
        $customer = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $marketorder['order_userid'])->fetch();
        // Уведопляем продавца о том, что подана жалоба по этому заказу
        $rsubject = cot_rc($L['marketorders_addclaim_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
        $rbody = cot_rc($L['marketorders_addclaim_mail_toseller_body'], array('product_title' => $marketorder['item_title'], 'order_id' => $marketorder['order_id'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)));
        cot_mail($seller['user_email'], $rsubject, $rbody);
        // Уведопляем админа о том, что подана жалоба по этому заказу
        $rsubject = cot_rc($L['marketorders_addclaim_mail_toadmin_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
        $rbody = cot_rc($L['marketorders_addclaim_mail_toadmin_body'], array('product_title' => $marketorder['item_title'], 'order_id' => $marketorder['order_id'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)));
        /* === Hook === */
        foreach (cot_getextplugins('marketorders.addclaim.done') as $pl) {
            include $pl;
        }
        /* ===== */
        cot_mail($cfg['adminemail'], $rsubject, $rbody);
        cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
        exit;
    }
    cot_redirect(cot_url('marketorders', 'm=addclaim&id=' . $id, '', true));
    exit;
}
$out['subtitle'] = $L['marketorders_neworder_title'];
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('marketorders', 'addclaim', $structure['market'][$item['item_cat']]['tpl']), 'plug');
/* === Hook === */
foreach (cot_getextplugins('marketorders.addclaim.main') as $pl) {
    include $pl;
}
/* ===== */
$t = new XTemplate($mskin);
Ejemplo n.º 19
0
        if ($row['user_maingrp'] == 3) {
            $env['status'] = '403 Forbidden';
            cot_log("Password recovery failed, user banned : " . $rusername);
            cot_redirect(cot_url('message', 'msg=153&num=' . $row['user_banexpire'], '', true));
        }
        $validationkey = md5(microtime());
        $newpass = cot_randomstring();
        $ruserpass = array();
        $ruserpass['user_passsalt'] = cot_unique(16);
        $ruserpass['user_passfunc'] = empty($cfg['hashfunc']) ? 'sha256' : $cfg['hashfunc'];
        $ruserpass['user_password'] = cot_hash($newpass, $ruserpass['user_passsalt'], $ruserpass['user_passfunc']);
        $ruserpass['user_lostpass'] = $validationkey;
        $sql = $db->update($db_users, $ruserpass, "user_id={$ruserid}");
        $rsubject = $L['pasrec_title'];
        $rbody = $L['Hi'] . " " . $rusername . ",\n\n" . $L['pasrec_email2'] . "\n\n" . $newpass . "\n\n" . $L['aut_contactadmin'];
        cot_mail($rusermail, $rsubject, $rbody);
        $msg = 'auth';
    } else {
        $env['status'] = '403 Forbidden';
        cot_shield_update(7, "Log in");
        cot_log("Pass recovery failed, user : " . $rusername);
        cot_redirect(cot_url('message', 'msg=151', '', true));
    }
}
$out['subtitle'] = $L['pasrec_title'];
$out['head'] .= $R['code_noindex'];
$title[] = $L['pasrec_title'];
$mskin = cot_tplfile('users.passrecover', 'module');
/* === Hook === */
foreach (cot_getextplugins('users.passrecover.main') as $pl) {
    include $pl;
            cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
            exit;
        }
        // Отменяем жалобу
        if ($a == 'cancelclaim') {
            $rorder['order_claim'] = 0;
            $rorder['order_status'] = 'paid';
            if ($db->update($db_market_orders, $rorder, 'order_id=' . $id)) {
                $customer = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $marketorder['order_userid'])->fetch();
                // Уведопляем покупателя об отклонении жалобы
                $rsubject = cot_rc($L['marketorders_cancelclaim_mail_tocustomer_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
                $rbody = cot_rc($L['marketorders_cancelclaim_mail_tocustomer_body'], array('product_title' => $marketorder['item_title'], 'order_id' => $marketorder['order_id'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)));
                /* === Hook === */
                foreach (cot_getextplugins('marketorders.order.cancelclaim.done') as $pl) {
                    include $pl;
                }
                /* ===== */
                cot_mail($customer['user_email'], $rsubject, $rbody);
            }
            cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
            exit;
        }
        $t->parse('MAIN.CLAIM.ADMINCLAIM');
    }
    $t->parse('MAIN.CLAIM');
}
/* === Hook === */
foreach (cot_getextplugins('marketorders.order.tags') as $pl) {
    include $pl;
}
/* ===== */
Ejemplo n.º 21
0
/**
 * Adds new user
 *
 * @param array $ruser User data array
 * @param string $email Email address
 * @param string $name User name; defaults to $email if omitted
 * @param string $password Password; randomly generated if omitted
 * @param string $maingrp Custom main grp
 * @param float $sendemail Send email if need activation
 * @return int New user ID or false
 * @global CotDB $db
 */
function cot_add_user($ruser, $email = null, $name = null, $password = null, $maingrp = null, $sendemail = true)
{
    global $cfg, $cot_extrafields, $db, $db_users, $db_groups_users, $db_x, $L, $R, $sys, $uploadfiles, $usr;
    $ruser['user_email'] = !empty($email) ? $email : $ruser['user_email'];
    $ruser['user_name'] = !empty($name) ? $name : $ruser['user_name'];
    $ruser['user_password'] = !empty($password) ? $password : $ruser['user_password'];
    empty($ruser['user_password']) && ($ruser['user_password'] = cot_randomstring());
    empty($ruser['user_name']) && ($ruser['user_name'] = $ruser['user_email']);
    $password = $ruser['user_password'];
    $user_exists = (bool) $db->query("SELECT user_id FROM {$db_users} WHERE user_name = ? LIMIT 1", array($ruser['user_name']))->fetch();
    $email_exists = (bool) $db->query("SELECT user_id FROM {$db_users} WHERE user_email = ? LIMIT 1", array($ruser['user_email']))->fetch();
    if (!cot_check_email($ruser['user_email']) || $user_exists || !$cfg['useremailduplicate'] && $email_exists) {
        return false;
    }
    $ruser['user_gender'] = in_array($ruser['user_gender'], array('M', 'F')) ? $ruser['user_gender'] : 'U';
    $ruser['user_country'] = mb_strlen($ruser['user_country']) < 4 ? $ruser['user_country'] : '';
    $ruser['user_timezone'] = !$ruser['user_timezone'] ? 'GMT' : $ruser['user_timezone'];
    $ruser['user_maingrp'] = $db->countRows($db_users) == 0 ? 5 : $cfg['users']['regnoactivation'] ? 4 : 2;
    $ruser['user_maingrp'] = (int) $maingrp > 0 ? $maingrp : $ruser['user_maingrp'];
    $ruser['user_passsalt'] = cot_unique(16);
    $ruser['user_passfunc'] = empty($cfg['hashfunc']) ? 'sha256' : $cfg['hashfunc'];
    $ruser['user_password'] = cot_hash($ruser['user_password'], $ruser['user_passsalt'], $ruser['user_passfunc']);
    $ruser['user_birthdate'] = is_null($ruser['user_birthdate']) || $ruser['user_birthdate'] > $sys['now'] ? '0000-00-00' : cot_stamp2date($ruser['user_birthdate']);
    $ruser['user_lostpass'] = md5(microtime());
    cot_shield_update(20, "Registration");
    $ruser['user_hideemail'] = 1;
    $ruser['user_theme'] = $cfg['defaulttheme'];
    $ruser['user_scheme'] = $cfg['defaultscheme'];
    $ruser['user_lang'] = empty($ruser['user_lang']) ? $cfg['defaultlang'] : $ruser['user_lang'];
    $ruser['user_regdate'] = (int) $sys['now'];
    $ruser['user_logcount'] = 0;
    $ruser['user_lastip'] = empty($ruser['user_lastip']) ? $usr['ip'] : $ruser['user_lastip'];
    $ruser['user_token'] = cot_unique(16);
    if (!$db->insert($db_users, $ruser)) {
        return;
    }
    $userid = $db->lastInsertId();
    $db->insert($db_groups_users, array('gru_userid' => (int) $userid, 'gru_groupid' => (int) $ruser['user_maingrp']));
    cot_extrafield_movefiles();
    /* === Hook for the plugins === */
    foreach (cot_getextplugins('users.adduser.done') as $pl) {
        include $pl;
    }
    /* ===== */
    if ($ruser['user_maingrp'] == 2 && $sendemail) {
        if ($cfg['users']['regrequireadmin']) {
            $subject = $L['aut_regrequesttitle'];
            $body = sprintf($L['aut_regrequest'], $ruser['user_name']);
            $body .= "\n\n" . $L['aut_contactadmin'];
            cot_mail($ruser['user_email'], $subject, $body);
            $subject = $L['aut_regreqnoticetitle'];
            $inactive = $cfg['mainurl'] . '/' . cot_url('users', 'gm=2&s=regdate&w=desc', '', true);
            $body = sprintf($L['aut_regreqnotice'], $ruser['user_name'], $inactive);
            cot_mail($cfg['adminemail'], $subject, $body);
        } else {
            $subject = $L['Registration'];
            $activate = $cfg['mainurl'] . '/' . cot_url('users', 'm=register&a=validate&token=' . $ruser['user_token'] . '&v=' . $ruser['user_lostpass'] . '&y=1', '', true);
            $deactivate = $cfg['mainurl'] . '/' . cot_url('users', 'm=register&a=validate&token=' . $ruser['user_token'] . '&v=' . $ruser['user_lostpass'] . '&y=0', '', true);
            $body = sprintf($L['aut_emailreg'], $ruser['user_name'], $activate, $deactivate);
            $body .= "\n\n" . $L['aut_contactadmin'];
            cot_mail($ruser['user_email'], $subject, $body);
        }
    }
    return $userid;
}
Ejemplo n.º 22
0
        $ritem['item_state'] = 2;
        $r_url = empty($item['item_alias']) ? cot_url('folio', 'c=' . $item['item_cat'] . '&id=' . $id, '', true) : cot_url('folio', 'c=' . $item['item_cat'] . '&al=' . $item['item_alias'], '', true);
        if (!$usr['isadmin']) {
            $rbody = cot_rc($L['folio_senttovalidation_mail_body'], array('user_name' => $item['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($item['user_email'], $L['folio_senttovalidation_mail_subj'], $rbody);
        }
        if ($cfg['folio']['notiffolio_admin_moderate']) {
            $nbody = cot_rc($L['folio_notif_admin_moderate_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
            cot_mail($cfg['adminemail'], $L['folio_notif_admin_moderate_mail_subj'], $nbody);
        }
    } else {
        $ritem['item_state'] = 0;
        $r_url = empty($item['item_alias']) ? cot_url('folio', 'c=' . $item['item_cat'] . '&id=' . $id, '', true) : cot_url('folio', 'c=' . $item['item_cat'] . '&al=' . $item['item_alias'], '', true);
        if (!$usr['isadmin']) {
            $rbody = cot_rc($L['folio_added_mail_body'], array('user_name' => $item['user_name'], 'prd_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('folio', 'id=' . $id, '', true)));
            cot_mail($item['user_email'], $L['folio_added_mail_subj'], $rbody);
        }
    }
    $db->update($db_folio, $ritem, "item_id=" . (int) $id);
    cot_folio_sync($item['item_cat']);
    /* === Hook === */
    foreach (cot_getextplugins('folio.preview.done') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_redirect($r_url);
    exit;
}
$out['subtitle'] = $L['folio'];
$mskin = cot_tplfile(array('folio', 'preview', $structure['folio'][$item['item_cat']]['tpl']));
/* === Hook === */
Ejemplo n.º 23
0
 /**
  * Рассылка уведомлений об истечении сроков публикации объявления
  */
 public static function sendExpireNotify()
 {
     global $L;
     $cacheFileName = cot::$cfg["modules_dir"] . '/advboard/inc/send.txt';
     if (file_exists($cacheFileName)) {
         $adv_send = file_get_contents($cacheFileName);
     } else {
         $adv_send = 0;
     }
     $tmp = getdate(cot::$sys['now']);
     $today = mktime(0, 0, 0, $tmp["mon"], $tmp["mday"], $tmp["year"]);
     // Рассылаем раз в сутки
     if ($today - $adv_send >= 86400) {
         // Период за который рассылаем
         if ($adv_send == 0) {
             // не разу не рассылали еще
             $adv_sendPer = cot::$cfg['advboard']['expNotifyPeriod'];
         } else {
             $adv_sendPer = floor(($today - $adv_send) / 86400);
         }
         // Уведомляем об истечении
         // Пока тупо шлем напоминание всем объявлениям у которых дата истечения
         // Больше той, когда заходили последний раз, но меньше текущей минус <уведомить за>
         $stDay = $tmp["mday"] + cot::$cfg['advboard']['expNotifyPeriod'] - $adv_sendPer;
         $periodStart = mktime(0, 0, 0, $tmp["mon"], $stDay, $tmp["year"]);
         if ($periodStart < cot::$sys['now']) {
             $periodStart = cot::$sys['now'];
         }
         $periodEnd = mktime(0, 0, 0, $tmp["mon"], $tmp["mday"] + cot::$cfg['advboard']['expNotifyPeriod'], $tmp["year"]);
         $condition = array(array('expire', $periodStart, '>='), array('expire', $periodEnd, '<'), array('state', advboard_model_Advert::PUBLISHED), array('user', 0, '>'));
         $advertisement = advboard_model_Advert::find($condition, 0, 0, array(array('id', 'ASC')));
         $cnt = 0;
         if ($advertisement) {
             foreach ($advertisement as $advRow) {
                 if (!$advRow->issetEmail(true)) {
                     return false;
                 }
                 $advertUrl = $advRow->getUrl();
                 if (!cot_url_check($advertUrl)) {
                     $advertUrl = COT_ABSOLUTE_URL . $advertUrl;
                 }
                 $advertEditUrl = $advRow->getEditUrl();
                 if (!cot_url_check($advertEditUrl)) {
                     $advertEditUrl = COT_ABSOLUTE_URL . $advertEditUrl;
                 }
                 $myAdvsUrl = cot_url('advboard', 'm=user');
                 if (!cot_url_check($myAdvsUrl)) {
                     $myAdvsUrl = COT_ABSOLUTE_URL . $myAdvsUrl;
                 }
                 $tmpL = $L;
                 $text = $advRow->description;
                 if (empty($text)) {
                     $text = $advRow->text;
                 }
                 $user = null;
                 $userLang = cot::$cfg['defaultlang'];
                 $owner = $advRow->getOwner();
                 if ($owner['user_id'] > 0) {
                     if (cot::$cfg['defaultlang'] != $owner['user_lang']) {
                         $userLang = $owner['user_lang'];
                         include cot_langfile('main', 'core', cot::$cfg['defaultlang'], $owner['user_lang']);
                         include cot_langfile('advboard', 'module', cot::$cfg['defaultlang'], $owner['user_lang']);
                     }
                 }
                 $mailView = new View();
                 $mailView->advert = $advRow;
                 $mailView->user = $owner;
                 $mailView->advertUrl = $advertUrl;
                 $mailView->advertEditUrl = $advertEditUrl;
                 $mailView->myAdvsUrl = $myAdvsUrl;
                 $mailView->advertText = $text;
                 $mailSubject = cot::$L['advboard_expire_title'];
                 $mailBody = $mailView->render('advboard.notify_expire.' . $userLang . '.' . $advRow->category);
                 if (cot_mail($advRow->getEmail(false, true), $mailSubject, $mailBody, '', false, null, true)) {
                     $cnt++;
                 }
                 // Вернем язык на место
                 $L = $tmpL;
             }
         }
         file_put_contents($cacheFileName, $today);
         return $cnt;
     }
     return 0;
 }
Ejemplo n.º 24
0
                    cot_mail($usr['profile']['user_email'], $L['project_added_mail_subj'], $rbody);
                }
                break;
            case 1:
                $r_url = cot_url('projects', 'm=preview&id=' . $id, '', true);
                break;
            case 2:
                $urlparams = empty($ritem['item_alias']) ? array('c' => $ritem['item_cat'], 'id' => $id) : array('c' => $ritem['item_cat'], 'al' => $ritem['item_alias']);
                $r_url = cot_url('projects', $urlparams, '', true);
                if (!$usr['isadmin']) {
                    $rbody = cot_rc($L['project_senttovalidation_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prj_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
                    cot_mail($usr['profile']['user_email'], $L['project_senttovalidation_mail_subj'], $rbody);
                }
                if ($cfg['projects']['notif_admin_moderate']) {
                    $nbody = cot_rc($L['project_notif_admin_moderate_mail_body'], array('user_name' => $usr['profile']['user_name'], 'prj_name' => $ritem['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . $r_url));
                    cot_mail($cfg['adminemail'], $L['project_notif_admin_moderate_mail_subj'], $nbody);
                }
                break;
        }
        cot_redirect($r_url);
        exit;
    } else {
        cot_redirect(cot_url('projects', 'm=add&c=' . $c . '&type=' . $type, '', true));
    }
}
if (empty($ritem['item_cat']) && !empty($c)) {
    $ritem['item_cat'] = $c;
    $usr['isadmin'] = cot_auth('projects', $ritem['item_cat'], 'A');
}
if (empty($ritem['item_type']) && !empty($type)) {
    $ritem['item_type'] = $type;
Ejemplo n.º 25
0
            $headers = "From: \"" . $rcontact['contact_author'] . "\" <" . $rcontact['contact_email'] . ">\n";
            $context = array('sitetitle' => $cfg["maintitle"], 'siteurl' => $cfg['mainurl'], 'author' => $rcontact['contact_author'], 'email' => $rcontact['contact_email'], 'subject' => $rcontact['contact_subject'], 'text' => $rcontact['contact_text']);
            $rextras = '';
            if (!empty(cot::$extrafields[cot::$db->contact])) {
                foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
                    $exfld_title = cot_extrafield_title($exfld, 'contact_');
                    $ex_body = cot_build_extrafields_data('contact', $exfld, $rcontact['contact_' . $exfld['field_name']]);
                    $rextras .= "\n" . $exfld_title . ": " . $ex_body;
                    $context['extra' . $exfld['field_name']] = $ex_body;
                    $context['extra' . $exfld['field_name'] . '_title'] = $exfld_title;
                    $context['extra' . $exfld['field_name'] . '_value'] = $rcontact['contact_' . $exfld['field_name']];
                }
            }
            $context['extra'] = $rextras;
            $rtextm = cot_rc(empty(cot::$cfg['plugin']['contact']['template']) ? cot::$R['contact_message'] : cot::$cfg['plugin']['contact']['template'], $context);
            cot_mail($semail, $rcontact['contact_subject'], $rtextm, $headers);
        }
        $sent = true;
        cot_message('contact_message_sent');
        cot_extrafield_movefiles();
    }
}
cot::$out['subtitle'] = cot::$L['contact_title'];
cot_display_messages($t);
if (!$sent) {
    $t->assign(array('CONTACT_FORM_SEND' => cot_url('plug', 'e=contact&tpl=' . $tplfile), 'CONTACT_FORM_AUTHOR' => cot::$usr['id'] == 0 ? cot_inputbox('text', 'ruser', $rcontact['contact_author'], 'size="24" maxlength="24"') : cot_inputbox('text', 'ruser', cot::$usr['name'], 'size="24" maxlength="24" readonly="readonly"'), 'CONTACT_FORM_EMAIL' => cot_inputbox('text', 'remail', $rcontact['contact_email'], 'size="24"'), 'CONTACT_FORM_SUBJECT' => cot_inputbox('text', 'rsubject', $rcontact['contact_subject'], 'size="24"'), 'CONTACT_FORM_TEXT' => cot_textarea('rtext', $rcontact['contact_text'], 8, 50, 'style="width:90%"')));
    // Extra fields
    if (!empty(cot::$extrafields[cot::$db->contact])) {
        foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields('rcontact' . $exfld['field_name'], $exfld, $rcontact[$exfld['field_name']]);
Ejemplo n.º 26
0
    if ($row_contact_delete = $sql_contact_delete->fetch()) {
        $db->delete($db_contact, "contact_id = {$id}");
        foreach ($cot_extrafields[$db_contact] as $exfld) {
            cot_extrafield_unlinkfiles($row_contact_delete['contact_' . $exfld['field_name']], $exfld);
        }
        cot_message('Deleted');
    }
} elseif ($a == 'val') {
    $db->update($db_contact, array('contact_val' => 1), "contact_id = {$id}");
    cot_message('Updated');
} elseif ($a == 'unval') {
    $db->update($db_contact, array('contact_val' => 0), "contact_id = {$id}");
    cot_message('Updated');
} elseif ($a == 'send' && $rtext != '') {
    $row = $db->query("SELECT contact_email FROM {$db_contact} WHERE contact_id = {$id}")->fetch();
    cot_mail($row['contact_email'], $cfg['mainurl'], $rtext);
    $db->update($db_contact, array('contact_reply' => $rtext), "contact_id = {$id}");
    cot_message('Done');
}
$adminsubtitle = $L['contact_title'];
$tuman = new XTemplate(cot_tplfile('contact.tools', 'plug', true));
$totallines = $db->query("SELECT COUNT(*) FROM {$db_contact}")->fetchColumn();
$sql = $db->query("SELECT * FROM {$db_contact} ORDER BY contact_val ASC, contact_id DESC LIMIT {$d}, " . $cfg['maxrowsperpage']);
$pagnav = cot_pagenav('admin', 'm=other&p=contact', $d, $totallines, $cfg['maxrowsperpage'], 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$i = 0;
foreach ($sql->fetchAll() as $row) {
    $i++;
    $shorttext = $row['contact_text'];
    $shorttext = cot_string_truncate($shorttext, 150);
    $shorttext .= '...';
    $val = $row['contact_val'] == 1 ? 'unval' : 'val';
Ejemplo n.º 27
0
        $db->update($db_users, array('user_maingrp' => $ruser['user_maingrp']), 'user_id=' . $id);
        foreach ($cot_groups as $k => $i) {
            if (isset($rusergroupsms[$k])) {
                if ($db->query("SELECT gru_userid FROM {$db_groups_users} WHERE gru_userid={$id} AND gru_groupid={$k}")->rowCount() == 0 && !($id == 1 && in_array($k, array(COT_GROUP_BANNED, COT_GROUP_INACTIVE)))) {
                    $db->insert($db_groups_users, array('gru_userid' => (int) $id, 'gru_groupid' => (int) $k));
                }
            } else {
                $db->delete($db_groups_users, "gru_userid={$id} AND gru_groupid={$k}");
            }
        }
        if ($ruser['user_maingrp'] == COT_GROUP_MEMBERS && $urr['user_maingrp'] == COT_GROUP_INACTIVE) {
            $rsubject = $L['useed_accountactivated'];
            $rbody = $L['Hi'] . " " . $urr['user_name'] . ",\n\n";
            $rbody .= $L['useed_email'];
            $rbody .= $L['auth_contactadmin'];
            cot_mail($urr['user_email'], $rsubject, $rbody);
        }
        /* === Hook === */
        foreach (cot_getextplugins('users.edit.update.done') as $pl) {
            include $pl;
        }
        /* ===== */
        cot_auth_clear($id);
        cot_log("Edited user #" . $id, 'adm');
        cot_message('User_data_updated');
        cot_redirect(cot_url('users', "m=edit&id=" . $id, '', true));
    } else {
        cot_redirect(cot_url('users', "m=edit&id={$id}", '', true));
    }
}
$sql = $db->query("SELECT * FROM {$db_users} WHERE user_id={$id} LIMIT 1");
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=users.auth.check.done
 * [END_COT_EXT]
 */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['regpay']['summ'] > 0) {
    require_once cot_langfile('regpay', 'plug');
    $urr = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $ruserid)->fetch();
    if ($urr['user_logcount'] == 1) {
        $payinfo['pay_userid'] = $urr['user_id'];
        $payinfo['pay_area'] = 'balance';
        $payinfo['pay_code'] = 'register';
        $payinfo['pay_summ'] = $cfg['plugin']['regpay']['summ'];
        $payinfo['pay_cdate'] = $sys['now'];
        $payinfo['pay_pdate'] = $sys['now'];
        $payinfo['pay_adate'] = $sys['now'];
        $payinfo['pay_status'] = 'done';
        $payinfo['pay_desc'] = $L['regpay_payments_desc'];
        if ($db->insert($db_payments, $payinfo)) {
            cot_mail($urr['user_email'], $L['regpay_mail_subject'], sprintf($L['regpay_mail_body'], $urr['user_name']));
            cot_log("Payment for register");
        }
    }
}
Ejemplo n.º 29
0
 public function notifyUserModerated()
 {
     global $db_users, $L;
     $advertUrl = $this->getUrl();
     if (!cot_url_check($advertUrl)) {
         $advertUrl = COT_ABSOLUTE_URL . $advertUrl;
     }
     $tmpL = $L;
     $text = $this->_data['description'];
     if (empty($text)) {
         $text = $this->_data['text'];
     }
     $user = null;
     $userLang = cot::$cfg['defaultlang'];
     if (!$this->issetEmail(true)) {
         return false;
     }
     $this->getOwner();
     if ($this->_data['user'] > 0) {
         if (cot::$cfg['defaultlang'] != $this->_owner['user_lang']) {
             $userLang = $this->_owner['user_lang'];
             include cot_langfile('main', 'core', cot::$cfg['defaultlang'], $this->_owner['user_lang']);
             include cot_langfile('advboard', 'module', cot::$cfg['defaultlang'], $this->_owner['user_lang']);
         }
     }
     $mailView = new View();
     $mailView->advert = $this;
     $mailView->user = $this->_owner;
     $mailView->advertUrl = $advertUrl;
     $mailView->advertText = $text;
     $mailSubject = $L['advboard_moderated'];
     $mailBody = $mailView->render('advboard.notify_user_moderated.' . $userLang . '.' . $this->_data['category']);
     cot_mail($this->getEmail(false, true), $mailSubject, $mailBody, '', false, null, true);
     // Вернем язык на место
     $L = $tmpL;
     // Сбросить флаг уведомления
     static::$_db->update(static::$_tbname, array('admin_notified' => '1970-01-01 00:00:01'), 'id=' . $this->_data['id']);
 }