示例#1
0
 /**
  * Function used to send PM EMAIL
  */
 function send_pm_email($array)
 {
     global $cbemail, $userquery;
     $sender = $userquery->get_user_field_only($array['from'], 'username');
     $content = clean($array['content']);
     $subject = clean($array['subj']);
     $msgid = $array['msg_id'];
     //Get To(Emails)
     $emails = $this->get_users_emails($array['to']);
     $vars = array('{sender}' => $sender, '{content}' => $content, '{subject}' => $subject, '{msg_id}' => $msgid);
     $tpl = $cbemail->get_template($this->email_template);
     $subj = $cbemail->replace($tpl['email_template_subject'], $vars);
     $msg = $cbemail->replace($tpl['email_template'], $vars);
     cbmail(array('to' => $emails, 'from' => WEBSITE_EMAIL, 'subject' => $subj, 'content' => $msg, 'nl2br' => true));
 }
示例#2
0
    /**
     * Show some nice error
     * 
     * @param STRING $error
     */
    function show_error($error)
    {
        $backtrace = debug_backtrace();
        $useful = array();
        foreach ($backtrace as $back) {
            $good = array('file' => $back['file'], 'line' => $back['line'], 'function' => $back['function'], 'class' => $back['class'], 'type' => $back['type'], 'args' => $back['args']);
            $useful[] = $good;
        }
        $backtraceDetails = "";
        foreach ($useful as $msg) {
            if ($backtraceDetails) {
                $backtraceDetails .= "\r\n\r\n=======\r\n";
            }
            foreach ($msg as $key => $val) {
                $backtraceDetails .= "\r\n" . $key . " : " . (is_array($val) ? json_encode($val) : $val);
            }
        }
        if ($this->send_email_on_error && $this->admin_email) {
            $message = $error;
            $message .= "<br>Query<br>" . $this->last_query;
            $message .= "<br>More Details<br>";
            $message .= nl2br($backtraceDetails);
            //mail ( $this->admin_email, 'Database Error', $message);
            if (function_exists('cbmail')) {
                cbmail(array('to' => $this->admin_email, 'subject' => "Database error on " . BASEURL, 'content' => $message));
                cbmail(array('to' => $this->dev_emial, 'subject' => "Database error on " . BASEURL, 'content' => $message));
            }
        }
        if ($this->enable_errors) {
            echo '<html>';
            echo '<head>';
            echo '<title>DB Connection issue - Tune.pk</title>';
            echo '<style>';
            echo 'body{margin:0px; padding:15px; font-family:"Open Sans",Helvetica,sans-serif}';
            echo '.error_div{padding:14px; margin:14px; background-color:#e4eaee; 
							text-align:center;font-size:14px; font-weight:bold}';
            echo '</style>';
            echo '</head>';
            echo '<body>';
            echo '<div class="error_div">';
            echo '<h2>Wooops..</h2>';
            echo $error;
            if ($this->last_query && $this->show_last_query_on_error) {
            }
            echo '<br>';
            echo 'Query : ';
            echo $this->last_query;
            echo '</div>';
            echo '</body>';
            echo '</html>';
            exit;
        }
    }
示例#3
0
 /**
  * function send emails
  */
 function send_emails($id)
 {
     global $db, $userquery, $cbemail;
     if (!is_array($id)) {
         $email = $this->get_email($id);
     } else {
         $email = $id;
     }
     if ($email['status'] == 'completed') {
         return false;
     }
     $settings = json_decode($email['configs'], true);
     $users = $email['users'];
     $total = $email['total'];
     //Creating limit
     $start_index = $email['start_index'];
     $limit = $start_index . ',' . $settings['loop_size'];
     //Creating condition
     $condition = "";
     //Levels
     $level_query = "";
     $levels = $settings['level'];
     if ($levels) {
         foreach ($levels as $level) {
             if ($level_query) {
                 $level_query .= " OR ";
             }
             $level_query .= " level='{$level}' ";
         }
         if ($condition) {
             $condition .= " AND ";
         }
         $condition = $level_query = " ( " . $level_query . ") ";
     }
     //Categories
     $cats_query = "";
     $cats = $settings['cat'];
     if ($cats) {
         foreach ($cats as $cat) {
             if ($cats_query) {
                 $cats_query .= " OR ";
             }
             $cats_query .= " category='{$cat}' ";
         }
         $cats_query = " ( " . $cats_query . ") ";
         if ($condition) {
             $condition .= " AND ";
         }
         $condition .= $cats_query;
     }
     //Ative users
     if ($settings['active'] != 'any') {
         if ($condition) {
             $condition .= " AND ";
         }
         if ($settings['active'] == 'yes') {
             $condition .= "\tusr_status = 'Ok' ";
         }
         if ($settings['active'] == 'no') {
             $condition .= "\tusr_status = 'ToActivate' ";
         }
     }
     //Banned users
     if ($settings['ban'] != 'any') {
         if ($condition) {
             $condition .= " AND ";
         }
         if ($settings['ban'] == 'yes') {
             $condition .= "\tban_status = 'yes' ";
         }
         if ($settings['ban'] == 'no') {
             $condition .= "\tban_status = 'no' ";
         }
     }
     if (!$users) {
         $users = $db->select(tbl("users"), "*", $condition, $limit, " userid ASC ");
         if (!$total) {
             $total = $db->count(tbl("users"), "userid", $condition);
         }
         $sent = $email['sent'];
         $send_msg = array();
         foreach ($users as $user) {
             $var = array('{username}' => $user['username'], '{userid}' => $user['userid'], '{email}' => $user['email'], '{datejoined}' => $user['doj'], '{avcode}' => $user['avcode'], '{avlink}' => BASEURL . '/activation.php?av_username='******'username'] . '&avcode=' . $user['avcode']);
             $subj = $cbemail->replace($email['email_subj'], $var);
             $msg = nl2br($cbemail->replace($email['email_msg'], $var));
             $send_message = "";
             //Now Finally Sending Email
             cbmail(array('to' => $user['email'], 'from' => $email['email_from'], 'subject' => $subj, 'content' => $msg));
             $sent++;
             $send_msg[] = $user['userid'] . ": Email has been sent to <strong><em>" . $user['username'] . "</em></strong>";
         }
         $sent_to = $start_index + $settings['loop_size'];
         if ($sent_to > $total) {
             $sent_to = $total;
         }
         e(sprintf(lang("Sending email from %s to %s"), $start_index + 1, $sent_to), "m");
         $start_index = $start_index + $settings['loop_size'];
         if ($sent == $total || $sent > $total) {
             $status = 'completed';
         } else {
             $status = 'sending';
         }
         $db->update(tbl('mass_emails'), array('sent', 'total', 'start_index', 'status', 'last_update'), array($sent, $total, $start_index, $status, now()), " id='" . $email['id'] . "' ");
         return $send_msg;
     }
 }
示例#4
0
function send_email($from, $to, $subj, $message)
{
    return cbmail(array('from' => $from, 'to' => $to, 'subject' => $subj, 'content' => $message));
}
示例#5
0
 /**
  * Function used to perform several actions with a video
  */
 function action($case, $vid)
 {
     global $db, $eh;
     $vid = mysql_clean($vid);
     $video = $this->get_video_details($vid);
     if (!$video) {
         return false;
     }
     //Lets just check weathter video exists or not
     switch ($case) {
         //Activating a video
         case 'activate':
         case 'av':
         case 'a':
             $db->update(tbl("video"), array('active'), array('yes'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_act_msg"), 'm');
             if (SEND_VID_APPROVE_EMAIL == 'yes') {
                 //Sending Email
                 global $cbemail, $userquery;
                 $tpl = $cbemail->get_template('video_activation_email');
                 $user_fields = $userquery->get_user_field($video['userid'], "username,email");
                 $more_var = array('{username}' => $user_fields['username'], '{video_link}' => videoLink($video));
                 if (!is_array($var)) {
                     $var = array();
                 }
                 $var = array_merge($more_var, $var);
                 $subj = $cbemail->replace($tpl['email_template_subject'], $var);
                 $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
                 //Now Finally Sending Email
                 cbmail(array('to' => $user_fields['email'], 'from' => WEBSITE_EMAIL, 'subject' => $subj, 'content' => $msg));
             }
             if (($video['broadcast'] == 'public' || $video['broadcast'] == "logged") && $video['subscription_email'] == 'pending') {
                 //Sending Subscription email in background
                 if (stristr(PHP_OS, 'WIN')) {
                     exec(php_path() . " -q " . BASEDIR . "/actions/send_subscription_email.php {$vid} ");
                 } else {
                     exec(php_path() . " -q " . BASEDIR . "/actions/send_subscription_email.php {$vid} &> /dev/null &");
                 }
             }
             break;
             //Deactivating a video
         //Deactivating a video
         case "deactivate":
         case "dav":
         case "d":
             $db->update(tbl("video"), array('active'), array('no'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_act_msg1"), 'm');
             break;
             //Featuring Video
         //Featuring Video
         case "feature":
         case "featured":
         case "f":
             $db->update(tbl("video"), array('featured', 'featured_date'), array('yes', now()), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_fr_msg"), 'm');
             break;
             //Unfeatured video
         //Unfeatured video
         case "unfeature":
         case "unfeatured":
         case "uf":
             $db->update(tbl("video"), array('featured'), array('no'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_fr_msg1"), 'm');
             break;
     }
 }
示例#6
0
 /**
  * Function used to invite members to group
  */
 function invite_member($user, $gid, $owner = NULL)
 {
     global $cbemail, $db, $userquery;
     $group = $this->get_group_details($gid);
     if (!$owner) {
         $owner = userid();
     }
     $sender = $userquery->get_user_details($owner);
     $reciever = $userquery->get_user_details($user);
     if (!$group) {
         e(lang("grp_exist_error"));
     } elseif (!$sender) {
         e(lang("unknown_sender"));
     } elseif (!$reciever) {
         e(lang("unknown_reciever"));
     } elseif ($this->is_member($user, $gid)) {
         e(lang("user_already_group_mem"));
     } elseif ($owner != $group['userid']) {
         e(lang("grp_owner_err1"));
     } else {
         //Inserting Invitation Code in database
         $db->insert(tbl($this->gp_invite_tbl), array('group_id', 'userid', 'invited', 'date_added'), array($gid, $owner, $reciever['userid'], now()));
         e(lang("grp_inv_msg"), "m");
         //Now Sending Email To User
         $tpl = $cbemail->get_template('group_invitation');
         $more_var = array('{reciever}' => $reciever['username'], '{sender}' => $sender['username'], '{group_url}' => group_link(array('details' => $group)), '{group_name}' => $group['group_name'], '{group_description}' => $group['group_description']);
         if (!is_array($var)) {
             $var = array();
         }
         $var = array_merge($more_var, $var);
         $subj = $cbemail->replace($tpl['email_template_subject'], $var);
         $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
         //Now Finally Sending Email
         cbmail(array('to' => $reciever['email'], 'from' => WEBSITE_EMAIL, 'subject' => $subj, 'content' => $msg));
     }
 }
示例#7
0
 /**
  * Function used to content
  */
 function share_content($id)
 {
     global $db, $userquery;
     $ok = true;
     $tpl = $this->share_template_name;
     $var = $this->val_array;
     $id = mysql_clean($id);
     //First checking weather object exists or not
     if ($this->exists($id)) {
         global $eh;
         if (userid()) {
             $post_users = mysql_clean(post('users'));
             $users = explode(',', $post_users);
             if (is_array($users) && !empty($post_users)) {
                 foreach ($users as $user) {
                     if (!$userquery->user_exists($user) && !isValidEmail($user)) {
                         e(sprintf(lang('user_no_exist_wid_username'), $user));
                         $ok = false;
                         break;
                     }
                     $email = $user;
                     if (!isValidEmail($user)) {
                         $email = $userquery->get_user_field_only($user, 'email');
                     }
                     $emails_array[] = $email;
                 }
                 if ($ok) {
                     global $cbemail;
                     $tpl = $cbemail->get_template($tpl);
                     $more_var = array('{user_message}' => post('message'));
                     $var = array_merge($more_var, $var);
                     $subj = $cbemail->replace($tpl['email_template_subject'], $var);
                     $msg = $cbemail->replace($tpl['email_template'], $var);
                     //Setting Emails
                     $emails = implode(',', $emails_array);
                     //Now Finally Sending Email
                     $from = $userquery->get_user_field_only(username(), "email");
                     cbmail(array('to' => $emails_array, 'from' => $from, 'from_name' => username(), 'subject' => $subj, 'content' => $msg, 'use_boundary' => true));
                     e(sprintf(lang("thnx_sharing_msg"), $this->name), 'm');
                 }
             } else {
                 e(sprintf(lang("share_video_no_user_err"), $this->name));
             }
         } else {
             e(lang("you_not_logged_in"));
         }
     } else {
         e(sprintf(lang("obj_not_exists"), $this->name));
     }
 }
示例#8
0
 /**
  * Function used to add comment
  * This is more advance function , 
  * in this function functions can be applied on comments
  */
 function add_comment($comment, $obj_id, $reply_to = NULL, $type = 'v', $obj_owner = NULL, $obj_link = NULL, $force_name_email = false)
 {
     global $userquery, $eh, $db, $Cbucket;
     //Checking maximum comments characters allowed
     if (defined("MAX_COMMENT_CHR")) {
         if (strlen($comment) > MAX_COMMENT_CHR) {
             e(sprintf("'%d' characters allowed for comment", MAX_COMMENT_CHR));
         }
     }
     if (!verify_captcha()) {
         e(lang('usr_ccode_err'));
     }
     if (empty($comment)) {
         e(lang("pelase_enter_something_for_comment"));
     }
     $params = array('comment' => $comment, 'obj_id' => $obj_id, 'reply_to' => $reply_to, 'type' => $type);
     $this->validate_comment_functions($params);
     /* 		
      if($type=='video' || $type=='v')
      {
      if(!$this->video_exists($obj_id))
      e(lang("class_vdo_del_err"));
     
      //Checking owner of video
      if(!USER_COMMENT_OWN)
      {
      if(userid()==$this->get_vid_owner($obj_id));
      e(lang("usr_cmt_err2"));
      }
      }
     */
     if (!userid() && $Cbucket->configs['anonym_comments'] != 'yes') {
         e(lang("you_not_logged_in"));
     }
     if (!userid() && $Cbucket->configs['anonym_comments'] == 'yes' || $force_name_email) {
         //Checking for input name and email
         if (empty($_POST['name'])) {
             e(lang("please_enter_your_name"));
         }
         if (empty($_POST['email'])) {
             e(lang("please_enter_your_email"));
         }
         $name = mysql_clean($_POST['name']);
         $email = mysql_clean($_POST['email']);
     }
     if (empty($eh->error_list)) {
         $attributes = get_message_attributes($comment);
         if (is_array($attributes)) {
             $attributes = json_encode($attributes);
         }
         $fields = array('type' => $type, 'comment' => $comment, 'comment_attributes' => $attributes, 'type_id' => $obj_id, 'userid' => userid(), 'date_added' => now(), 'parent_id' => $reply_to, 'anonym_name' => $name, 'anonym_email' => $email, 'comment_ip' => mysql_clean(client_ip()), 'type_owner_id' => $obj_owner);
         $cid = db_insert(tbl('comments'), $fields);
         $db->update(tbl("users"), array("total_comments"), array("|f|total_comments+1"), " userid='" . userid() . "'");
         e(lang("grp_comment_msg"), "m");
         //$cid = $db->insert_id();
         $own_details = $userquery->get_user_field_only($obj_owner, 'email');
         $username = username();
         $username = $username ? $username : post('name');
         $useremail = $email;
         //Adding Comment Log
         $log_array = array('success' => 'yes', 'action_obj_id' => $cid, 'action_done_id' => $obj_id, 'details' => "made a comment", 'username' => $username, 'useremail' => $useremail);
         insert_log($type . '_comment', $log_array);
         //sending email
         if (SEND_COMMENT_NOTIFICATION == 'yes' && $own_details) {
             global $cbemail;
             $tpl = $cbemail->get_template('user_comment_email');
             $more_var = array('{username}' => $username, '{obj_link}' => $obj_link . '#comment_' . $cid, '{comment}' => $comment, '{obj}' => get_obj_type($type));
             if (!is_array($var)) {
                 $var = array();
             }
             $var = array_merge($more_var, $var);
             $subj = $cbemail->replace($tpl['email_template_subject'], $var);
             $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
             //Now Finally Sending Email
             cbmail(array('to' => $own_details, 'from' => WEBSITE_EMAIL, 'subject' => $subj, 'content' => $msg));
         }
         add_users_mentioned($comment, NULL, $cid);
         return $cid;
     }
     return false;
 }
示例#9
0
$reason = post('reason');
$message = post('message');
if (isset($_POST['contact'])) {
    if (empty($name)) {
        e(lang("name_was_empty"));
    } elseif (empty($email) || !is_valid_syntax('email', $email)) {
        e(lang("invalid_email"));
    } elseif (empty($reason)) {
        e(lang("pelase_enter_reason"));
    } elseif (empty($message)) {
        e(lang("please_enter_something_for_message"));
    } elseif (!verify_captcha()) {
        e(lang('usr_ccode_err'));
    } else {
        $tpl = $cbemail->get_template('contact_form');
        $more_var = array('{name}' => substr($name, 0, 100), '{email}' => substr($email, 0, 100), '{reason}' => substr($reason, 0, 300), '{message}' => $message, '{ip_address}' => $_SERVER['REMOTE_ADDR'], '{now}' => now());
        if (!is_array($var)) {
            $var = array();
        }
        $var = array_merge($more_var, $var);
        $subj = $cbemail->replace($tpl['email_template_subject'], $var);
        $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
        //Now Finally Sending Email
        if (cbmail(array('to' => SUPPORT_EMAIL, 'from' => $email, 'subject' => $subj, 'content' => $msg))) {
            e(lang("email_send_confirm"), "m");
        }
    }
}
subtitle(lang("contact_us"));
template_files('contact.html');
display_it();
示例#10
0
 /**
  * Function used to get list of subscribed users and then
  * send subscription email
  */
 function sendSubscriptionEmail($vidDetails, $updateStatus = true)
 {
     global $cbemail, $db;
     $v = $vidDetails;
     if (!$v['videoid']) {
         e(lang("invalid_videoid"));
         return false;
     }
     if (!$v['userid']) {
         e(lang("invalid_userid"));
         return false;
     }
     //Lets get the list of subscribers
     $subscribers = $this->get_user_subscribers_detail($v['userid'], false);
     //Now lets get details of our uploader bhai saab
     $uploader = $this->get_user_details($v['userid']);
     //Loading subscription email template
     $tpl = $cbemail->get_template('video_subscription_email');
     $total_subscribers = count($subscribers);
     if ($subscribers) {
         foreach ($subscribers as $subscriber) {
             $var = $this->custom_subscription_email_vars;
             $more_var = array('{username}' => $subscriber['username'], '{uploader}' => $uploader['username'], '{video_title}' => $v['title'], '{video_description}' => $v['description'], '{video_link}' => video_link($v), '{video_thumb}' => get_thumb($v));
             if (!is_array($var)) {
                 $var = array();
             }
             $var = array_merge($more_var, $var);
             $subj = $cbemail->replace($tpl['email_template_subject'], $var);
             $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
             //Now Finally Sending Email
             cbmail(array('to' => $subscriber['email'], 'from' => WELCOME_EMAIL, 'subject' => $subj, 'content' => $msg));
         }
     }
     if ($total_subscribers) {
         //Updating video subscription email status to sent
         if ($updateStatus) {
             $db->update(tbl('video'), array('subscription_email'), array('sent'), " videoid='" . $v['videoid'] . "'");
         }
         $s = "";
         if ($total_subscribers > 1) {
             $s = "s";
         }
         e(sprintf(lang('subs_email_sent_to_users'), $total_subscribers, $s), "m");
         return true;
     }
     e(lang("no_user_subscribed_to_uploader"));
     return true;
 }