/** * Event callback after triggering "user_forum_post_created". * * @param array $info * Details about forum post. */ function nodejs_forum_event_user_forum_post_created_callback($info) { $postID = intval(vartrue($info['data']['post_id'], 0)); $postUserID = intval(vartrue($info['data']['post_user'], 0)); $postThreadID = intval(vartrue($info['data']['post_thread'], 0)); if ($postID === 0 || $postThreadID === 0) { return; } // Get forum plugin preferences. $plugForumPrefs = e107::getPlugConfig('forum')->getPref(); $db = e107::getDb(); // Load thread. $thread = $db->retrieve('forum_thread', '*', 'thread_id = ' . $postThreadID); $threadUser = intval(vartrue($thread['thread_user'], 0)); // Load forum to check (read) permission. $forum = $db->retrieve('forum', '*', 'forum_id = ' . intval(vartrue($thread['thread_forum_id'], 0))); // Author of the forum post. $authorPost = e107::user($postUserID); // Author of the forum topic. $authorThread = e107::user($threadUser); e107_require_once(e_PLUGIN . 'nodejs/nodejs.main.php'); $template = e107::getTemplate('nodejs_forum'); $sc = e107::getScBatch('nodejs_forum', true); $tp = e107::getParser(); // Get topic page number. $postNum = $db->count('forum_post', '(*)', "WHERE post_id <= " . $postID . " AND post_thread = " . $postThreadID . " ORDER BY post_id ASC"); $postPage = ceil($postNum / vartrue($plugForumPrefs['postspage'], 10)); // Push rendered row item into Latest Forum Posts menu. $sc_vars = array('author' => $authorPost, 'post' => $info['data'], 'thread' => $thread, 'topicPage' => $postPage); $sc->setVars($sc_vars); $markup = $tp->parseTemplate($template['MENU']['RECENT']['ITEM'], true, $sc); $message = (object) array('broadcast' => true, 'channel' => 'nodejs_notify', 'callback' => 'nodejsForumMenu', 'type' => 'latestForumPosts', 'markup' => $markup); nodejs_enqueue_message($message); // Broadcast logged in users to inform about new forum post created. if ($authorPost) { $sc->setVars($sc_vars); $markup = $tp->parseTemplate($template['NOTIFICATION']['POST_ALL'], true, $sc); // It's a public forum, so broadcast every online user. if (intval(vartrue($forum['forum_class'], 0)) === 0) { $message = (object) array('broadcast' => true, 'channel' => 'nodejs_notify', 'callback' => 'nodejsForum', 'type' => 'newForumPostAny', 'markup' => $markup, 'exclude' => $postUserID); nodejs_enqueue_message($message); } else { $forumClass = vartrue($forum['forum_class'], 0); $db->select('nodejs_presence'); while ($row = $db->fetch()) { if (isset($row['uid']) && check_class($forumClass, null, $row['uid'])) { $message = (object) array('channel' => 'nodejs_user_' . $row['uid'], 'callback' => 'nodejsForum', 'type' => 'newForumPostAny', 'markup' => $markup, 'exclude' => $postUserID); nodejs_enqueue_message($message); } } } } // Broadcast logged in (thread-author) user to inform about new forum post created in his/her topic. if (isset($authorThread['user_id'])) { $sc->setVars($sc_vars); $markup = $tp->parseTemplate($template['NOTIFICATION']['POST_OWN'], true, $sc); $message = (object) array('channel' => 'nodejs_user_' . $authorThread['user_id'], 'callback' => 'nodejsForum', 'type' => 'newForumPostOwn', 'markup' => $markup, 'exclude' => $postUserID); nodejs_enqueue_message($message); } }
/** * Render menu contents. */ function renderMenu() { $template = e107::getTemplate('nodejs_online'); $sc = e107::getScBatch('nodejs_online', true); $tp = e107::getParser(); e107_require_once(e_PLUGIN . 'nodejs_online/includes/nodejs_online.php'); $users = nodejs_online_get_online_users(); $sc->setVars(array('count' => count($users))); $text = $tp->parseTemplate($template['MENU']['HEADER'], true, $sc); foreach ($users as $uid => $user) { $sc->setVars(array('user' => $user)); $text .= $tp->parseTemplate($template['MENU']['ITEM'], true, $sc); } $text .= $tp->parseTemplate($template['MENU']['FOOTER'], true); e107::getRender()->tablerender(LAN_NODEJS_ONLINE_MENU_01, $text); unset($text); }
/** * Send messages to clients for updating online menu. */ public function nodejs_update_online_menu() { e107_require_once(e_PLUGIN . 'nodejs/nodejs.main.php'); e107_require_once(e_PLUGIN . 'nodejs_online/includes/nodejs_online.php'); $template = e107::getTemplate('nodejs_online'); $sc = e107::getScBatch('nodejs_online', true); $tp = e107::getParser(); $users = nodejs_online_get_online_users(); $message = (object) array('broadcast' => true, 'callback' => 'nodejsOnlineMenu', 'type' => 'nodejsOnlineMenuBadge', 'markup' => count($users)); nodejs_enqueue_message($message); $list = '<li role="presentation" class="nav-header dropdown-header">' . LAN_NODEJS_ONLINE_MENU_01 . '</li>'; foreach ($users as $uinfo => $row) { $sc->setVars(array('user' => $row)); $list .= $tp->parseTemplate($template['MENU']['ITEM'], true, $sc); } $message = (object) array('broadcast' => true, 'callback' => 'nodejsOnlineMenu', 'type' => 'nodejsOnlineMenuList', 'markup' => $list); nodejs_enqueue_message($message); }
/** * Scan plugin directories and get information from e_libraries.php files. */ function pluginsPage() { e107_require_once(e_PLUGIN . 'libraries/libraries.php'); $mes = e107::getMessage(); $tpl = e107::getTemplate('libraries'); $sc = e107::getScBatch('libraries', true); $tp = e107::getParser(); $addonsList = libraries_update_addon_list(); $summ = count($addonsList); $message = str_replace('[summ]', $summ, LAN_PLUGIN_LIBRARIES_ADMIN_03); $mes->addInfo($message); $this->addTitle(LAN_PLUGIN_LIBRARIES_ADMIN_02); $output = $mes->render(); $libraries = libraries_info(); $output .= $tp->parseTemplate($tpl['TABLE']['HEADER']); foreach ($libraries as $machine_name => $info) { $details = libraries_detect($machine_name); $sc->setVars(array('name' => $details['name'], 'plugin' => varset($details['plugin'], false), 'theme' => varset($details['theme'], false), 'vendor' => $details['vendor url'], 'download' => $details['download url'], 'installed' => array('status' => $details['installed'], 'error' => varset($details['error'], ''), 'message' => varset($details['error message'], '')))); $output .= $tp->parseTemplate($tpl['TABLE']['ROW'], true, $sc); } $output .= $tp->parseTemplate($tpl['TABLE']['FOOTER']); return $output; }
/** * Event callback after triggering "postcomment". * * @param array $comment * Comment item. * * $comment contains: * - comment_pid * - comment_item_id * - comment_subject * - comment_author_id * - comment_author_name * - comment_author_email * - comment_datestamp * - comment_comment * - comment_blocked * - comment_ip * - comment_type * - comment_lock * - comment_share * - comment_nick * - comment_time * - comment_id * * getCommentData() returns with array, which contains: * - comment_datestamp * - comment_author_id * - comment_author * - comment_comment * - comment_subject * - comment_type * - comment_title * - comment_url */ function nodejs_comment_event_postcomment_callback($comment) { e107_require_once(e_PLUGIN . 'nodejs/nodejs.main.php'); $tpl = e107::getTemplate('nodejs_comment'); $sc = e107::getScBatch('nodejs_comment', true); $tp = e107::getParser(); $cm = e107::getComment(); $cid = (int) vartrue($comment['comment_id'], 0); $pid = (int) vartrue($comment['comment_pid'], 0); $uid = (int) vartrue($comment['comment_author_id'], 0); $commentData = $cm->getCommentData(1, 0, 'comment_id=' . $cid); if (!isset($commentData[0])) { return; } $authorData = e107::user($uid); // Send notification to everyone for updating latest comments menu. $sc->setVars($commentData[0]); $markup = $tp->parseTemplate($tpl['MENU']['LATEST']['ITEM'], true, $sc); $message = (object) array('broadcast' => true, 'channel' => 'nodejs_notify', 'callback' => 'nodejsCommentMenu', 'type' => 'latestComments', 'markup' => $markup); nodejs_enqueue_message($message); // Send notification to everyone for notifying about new comment. $sc->setVars(array('account' => $authorData, 'comment' => $commentData[0])); $markup = $tp->parseTemplate($tpl['NOTIFICATION']['POST_ALL'], true, $sc); $message = (object) array('broadcast' => true, 'channel' => 'nodejs_notify', 'callback' => 'nodejsComments', 'type' => 'newCommentAny', 'markup' => $markup, 'exclude' => $authorData['user_id']); nodejs_enqueue_message($message); // Reply on comment. if ($pid > 0) { $commentParentData = $cm->getCommentData(1, 0, 'comment_id=' . $pid); array_pop($commentParentData); $authorParentData = e107::user(); // Send notification to author of parent comment for notifying about new reply. $sc->setVars(array('account' => $authorData, 'comment' => $commentData[0])); $markup = $tp->parseTemplate($tpl['NOTIFICATION']['POST_OWN'], true, $sc); $message = (object) array('channel' => 'nodejs_user_' . $authorParentData['user_id'], 'callback' => 'nodejsComments', 'type' => 'newCommentOwn', 'markup' => $markup, 'exclude' => $authorData['user_id']); nodejs_enqueue_message($message); } }
/** * Retrieve JS Manager singleton object * * @return e_jsmanager */ public static function getJs() { static $included = false; if (!$included) { e107_require_once(e_HANDLER . 'js_manager.php'); $included = true; } return e_jsmanager::getInstance(); }
function message_handler($mode, $message, $line = 0, $file = '') { if (!defined('e_HANDLER')) { echo $message; return; } e107_require_once(e_HANDLER . 'message_handler.php'); show_emessage($mode, $message, $line, $file); }
/** * Send an email to any number of recipients, using a template * * The template may contain normal shortcodes, which must already have been loaded. @see e107_themes/email_template.php * * The template (or other body text) may also contain field names in the form |USER_NAME| (as used in the bulk mailer edit page). These are * filled in from $templateData - field name corresponds to the array index name (case-sensitive) * * The template definition may contain an array $template['email_overrides'] of values which override normal mailer settings. * * The template definition MUST contain a template variable $template['email_body'] * * In general, any template definition which isn't overridden uses the default which should be specified in e_THEME.'templates/email_templates.php' * * There is a presumption that the email is being templated because it contains HTML, although this isn't mandatory. * * Any language string constants required in the template must be defined either by loading the requisite language file prior to calling this * routine, or by loading them in the template file. * * @param array|string $templateName - if a string, the name of the template - information is loaded from theme and default templates. * - if an array, template data as returned by gettemplateInfo() (and defined in the template files) * - if empty, sends a simple email using the default template (much as the original sendemail() function in mail.php) * @param array $emailData - defines the email information (generally as the 'mail_content' and 'mail_other' info above): * $emailData = array( 'mail_create_app' => 'notify', 'mail_title' => 'NOTIFY', 'mail_subject' => $subject, 'mail_sender_email' => $pref['siteadminemail'], 'mail_sender_name' => $pref['siteadmin'], 'mail_send_style' => 'textonly', 'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!! 'mail_body' => $message ); * @param array|string $recipientData - if a string, its the email address of a single recipient. * - if an array, each entry is the data for a single recipient, as the 'mail_recipients' definition above * $recipientData = array('mail_recipient_id' => $row['user_id'], 'mail_recipient_name' => $row['user_name'], 'mail_recipient_email' => $row['user_email'] ); * ....and other data as appropriate * @param boolean|array $options - any additional parameters to be passed to the mailer - as accepted by arraySet method. * These parameters will override any defaults, and any set in the template * if ($options['mail_force_queue'] is TRUE, the mail will be added to the queue regardless of the number of recipients * * @return boolean TRUE if either added to queue, or sent, successfully (does NOT indicate receipt). FALSE on any error * (Note that with a small number of recipients FALSE indicates that one or more emails weren't sent - some may have been sent successfully) */ public function sendEmails($templateName, $emailData, $recipientData, $options = false) { $log = e107::getAdminLog(); $log->addDebug(print_r($emailData, true), true); $log->addDebug(print_r($recipientData, true), true); $log->toFile('mail_manager', 'Mail Manager Log', true); if (!is_array($emailData)) { return false; } if (!is_array($recipientData)) { $recipientData = array('mail_recipient_email' => $recipientData, 'mail_recipient_name' => $recipientData); } $emailData['mail_content_status'] = MAIL_STATUS_TEMP; if ($templateName == '') { $templateName = varset($emailData['mail_send_style'], 'textonly'); // Safest default if nothing specified } $templateName = trim($templateName); if ($templateName == '') { return false; } $this->currentMailBody = $emailData['mail_body']; // In case we send immediately $this->currentTextBody = strip_tags($emailData['mail_body']); // $emailData['mail_body_templated'] = $ourTemplate->mainBodyText; // $emailData['mail_body_alt'] = $ourTemplate->altBodyText; if (!isset($emailData['mail_overrides'])) { $emailData['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides']; } if (!empty($emailData['template'])) { $this->currentMailBody = $emailData['mail_body']; unset($emailData['mail_body_templated']); if ($this->debugMode) { echo "<h4>" . $emailData['template'] . " Template detected</h4>"; } } if (is_array($options) && isset($options['mail_force_queue'])) { $forceQueue = $options['mail_force_queue']; unset($options['mail_force_queue']); } if ($this->debugMode) { echo "<h4>" . __CLASS__ . " :: " . __METHOD__ . " - Line " . __LINE__ . "</h4>"; print_a($emailData); print_a($recipientData); } if (count($recipientData) <= 5 && !$forceQueue) { if ($this->mailer == NULL) { e107_require_once(e_HANDLER . 'mail.php'); $this->mailer = new e107Email($options); } $tempResult = TRUE; $eCount = 0; // @TODO: Generate alt text etc foreach ($recipientData as $recip) { // Fill in other bits of email // $emailData['mail_target_info'] = $recip ; $merged = array_merge($emailData, $recip); $mailToSend = $this->makeEmailBlock($merged); // Substitute mail-specific variables, attachments etc /* echo "<h2>MERGED</h2>"; print_a($merged); echo "<h2>RETURNED</h2>"; print_a($mailToSend); echo "<hr />"; continue; */ if (false == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, true)) { $tempResult = FALSE; if ($this->debugMode) { echo "<h4>Failed to send to: " . $recip['mail_recipient_email'] . " [" . $recip['mail_recipient_name'] . "]</h4>"; print_a($mailToSend); } } else { // Success here if ($this->debugMode) { echo "<h4>Mail Sent successfully to: " . $recip['mail_recipient_email'] . " [" . $recip['mail_recipient_name'] . "]</h4>"; print_a($mailToSend); } if ($eCount == 0) { // Only send these on first email - otherwise someone could get inundated! unset($emailData['mail_copy_to']); unset($emailData['mail_bcopy_to']); } $eCount++; // Count number of successful emails sent } } return $tempResult; } // ----------- Too many recipients to send at once - add to the emailing queue ---------------- // // @TODO - handle any other relevant $options fields $emailData['mail_total_count'] = count($recipientData); $result = $this->saveEmail($emailData, TRUE); if ($result === FALSE) { // TODO: Handle error return FALSE; // Probably nothing else we can do } elseif (is_numeric($result)) { $mailMainID = $emailData['mail_source_id'] = $result; } else { // TODO: Handle strange error return FALSE; // Probably nothing else we can do } $this->mailInitCounters($mailMainID); // Initialise counters for emails added // Now add email addresses to the list foreach ($recipientData as $email) { $result = $this->mailAddNoDup($mailMainID, $email, MAIL_STATUS_TEMP); } $this->mailUpdateCounters($mailMainID); // Update the counters $counters = $this->mailRetrieveCounters($mailMainID); // Retrieve the counters if ($counters['add'] == 0) { $this->deleteEmail($mailMainID); // Probably a fault, but precautionary - delete email // Don't treat as an error if no recipients } else { $this->activateEmail($mailMainID, FALSE); // Actually mark the email for sending } return TRUE; }
function sc_content_content_table_images($parm = '') { //need to rewrite global $CONTENT_CONTENT_TABLE_IMAGES, $row, $content_image_path, $aa, $tp, $authordetails, $content_pref, $mainparent; if ($content_pref["content_content_images"]) { $authordetails = $aa->getAuthor($row['content_author']); $imagestmp = explode(",", $row['content_image']); foreach ($imagestmp as $key => $value) { if ($value == "") { unset($imagestmp[$key]); } } $images = array_values($imagestmp); e107_require_once(e_PLUGIN . 'gallery/includes/gallery_load.php'); // Load prettyPhoto settings and files. gallery_load_prettyphoto(); $hook = 'data-gal'; $class = 'gallery-thumb img-responsive'; $rel = 'prettyPhoto[pp_gal]'; $content_image_popup_name = $row['content_heading']; $CONTENT_CONTENT_TABLE_IMAGES = ""; $gen = new convert(); $datestamp = preg_replace("# -.*#", "", $gen->convert_date($row['content_datestamp'], "long")); for ($i = 0; $i < count($images); $i++) { // thumbnail $oIconWidth = isset($content_pref["content_upload_image_size_thumb"]) && $content_pref["content_upload_image_size_thumb"] ? $content_pref["content_upload_image_size_thumb"] : "100"; $attThumb = array('w' => $oIconWidth, 'h' => $oIconWidth, 'class' => $class, 'alt' => $subheading, 'x' => 0, 'crop' => 1); $oSrcThumb = e107::getParser()->thumbUrl($images[$i], $att); $oMaxWidth = isset($content_pref["content_upload_image_size"]) && $content_pref["content_upload_image_size"] ? $content_pref["content_upload_image_size"] : "500"; $att = array('w' => $oMaxWidth, 'h' => $oMaxWidth, 'class' => $class, 'alt' => $subheading, 'x' => 0, 'crop' => 1); $oSrc = e107::getParser()->thumbUrl($images[$i], $att); $subheading = $tp->toHTML($row['content_subheading'], TRUE); $popupname = $tp->toHTML($content_image_popup_name, TRUE); $author = $tp->toHTML($authordetails[1], TRUE); $oTitle = $popupname . " " . ($i + 1); $oText = $popupname . " " . ($i + 1) . "<br />" . $subheading . "<br />" . $author . " (" . $datestamp . ")"; if ($video = $tp->toVideo($images[$i])) { $text .= $video; } else { $text .= "<a class='" . $class . "' title='" . $oTitle . "' href='" . $oSrc . "' " . $hook . "='" . $rel . "'>"; $text .= $tp->toImage($images[$i], $attThumb); $text .= "</a>"; } $CONTENT_CONTENT_TABLE_IMAGES .= $text; } return $CONTENT_CONTENT_TABLE_IMAGES; } }
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Admin Navigation * * $Source: /cvs_backup/e107_0.8/e107_admin/ad_links.php,v $ * $Revision$ * $Date$ * $Author$ */ if (!defined('e107_INIT')) { exit; } if (file_exists(THEME . 'admin_images/admin_images.php')) { e107_require_once(THEME . 'admin_images/admin_images.php'); } // Small Category Images if (!defined('E_16_CAT_SETT')) { define('E_16_CAT_SETT', e_IMAGE . 'admin_images/cat_settings_16.png'); } if (!defined('E_16_CAT_USER')) { define('E_16_CAT_USER', e_IMAGE . 'admin_images/cat_users_16.png'); } if (!defined('E_16_CAT_CONT')) { define('E_16_CAT_CONT', e_IMAGE . 'admin_images/cat_content_16.png'); } if (!defined('E_16_CAT_FILE')) { define('E_16_CAT_FILE', e_IMAGE . 'admin_images/cat_files_16.png'); } if (!defined('E_16_CAT_TOOL')) {
/** * Print out upload form elements and/or process submitted uploads. * Your <form> tag must include: enctype='multipart/form-data' - in order to work. * * Example usage: * <code> * // Process uploaded file (sent by the form below), it'll print out message (if any) * if(isset($_POST['etrigger_uploadfiles'])) * { * // NOTE: chmod permissions after upload are set to 0755 * echo e107::getParser()->parseTemplate('{UPLOADFILE='.e_MEDIA.'public|process=1&upload_file_mask=jpg,jpeg,png,gif&upload_final_chmod=493}'); * } * * // Render upload form * echo '<form action="'.e_SELF.'" enctype="multipart/form-data" method="post">'; * echo e107::getParser()->parseTemplate('{UPLOADFILE='.e_MEDIA.'public|nowarn&trigger=etrigger_uploadfiles}'); * echo '</form>'; * </code> * * @todo Human readable *nix like permissions option (upload_final_chmod) e.g. 'rw-rw-r--' --> 0664, 'rwxrwxrwx' --> 0777 * * @param string $parm upload_path|parameters (GET query format) * Available parameters: * - trigger [render] (string): name attribute of upload trigger button, default 'uploadfiles' * - name [render|processing] (string): name of upload (file) field, without array brackets ([]), default 'file_userfile' * - up_container [render] (string): the id attribute of upload container (containing upload field(s)), default 'up_container' * - up_row [render] (string): the id attribute of upload added fields (diuplicates), default 'upline' * - process [render|processing] ('0'|'1' boolean): main shortcode action, 0 - render markup, 1 - process uploaded files, default '0' * - upload_file_mask [processing] (string): 'file_mask' parameter of process_uploaded_files() - comma-separated list of file types which if defined limits the allowed file types to those which are * in both this list and the file specified by the 'filetypes' option. Enables restriction to, for example, image files. {@link process_uploaded_files()), * default is empty string * - upload_filetypes [processing] (string): 'filetypes' parameter of process_uploaded_files() - name of file containing list of valid file types, default is empty string * - upload_extra_file_types [processing] (string): 'extra_file_types' parameter of process_uploaded_files() - '0' (default) rejects totally unknown file extensions; * '1' accepts totally unknown file extensions which are in $options['filetypes'] file; comma-separated list of additional permitted file extensions * - upload_final_chmod [processing] (string): 'final_chmod' parameter of process_uploaded_files() - chmod() to be applied to uploaded files (0644 default). * NOTE: you need to provide number with numerci base of decimal (as a string) which will be auto-converted to octal number * Example: '493' --> 0755; '511' --> 0777 * - upload_max_upload_size [processing] (string): 'max_upload_size' parameter of process_uploaded_files() - maximum size of uploaded files in bytes, * or as a string with a 'multiplier' letter (e.g. 16M) at the end, default is empty string * - upload_overwrite [processing] ('0'|'1' boolean): 'overwrite' parameter of process_uploaded_files() - maximum number of files which can be uploaded - default is '0' (unlimited) * - return_type [processing] ('0'|'message'|'result'): 'message' (default) - return messages (eMessage::render() method); * 'result' - return array generated by process_uploaded_files(); * '0' - return empty string; * NOTE: upload messages are added to 'upload_shortcode' message namespace * <code> * // render messages manually (return_type=0) * echo e107::getMessage()->render('upload_shortcode'); * // OR copy them to the default message namespace * e107::getMessage()->moveStack('upload_shortcode', 'default'); * // Do something... and render all messages * echo e107::getMessage()->render(); * <code> * @return mixed Based on 'return_type' parameter - string or uploaded array result */ function uploadfile_shortcode($parm) { if (!FILE_UPLOADS) { return LAN_UPLOAD_SERVEROFF; } if (USER_AREA === TRUE && !check_class(e107::getPref('upload_class'))) { return LAN_DISABLED; } $parm = explode('|', $parm, 2); $path = $parm[0]; if ($path && !is_writable($path)) { return LAN_UPLOAD_777 . " <b>" . str_replace("../", "", $path) . "</b>"; } $parms = array(); parse_str(varset($parm[1], ''), $parms); $parms = array_merge(array('trigger' => 'uploadfiles', 'name' => 'file_userfile', 'up_container' => 'up_container', 'up_row' => 'upline', 'process' => '0', 'upload_file_mask' => '', 'upload_filetypes' => '', 'upload_extra_file_types' => '0', 'upload_final_chmod' => '', 'upload_max_upload_size' => '0', 'upload_max_file_count' => '0', 'upload_overwrite' => '0', 'return_type' => 'message', 'disable_button' => '0'), $parms); // PROCESS UPLOADED FILES, optional usage by external code if ($parms['process']) { e107_require_once(e_HANDLER . 'upload_handler.php'); $options = array('file_mask' => $parms['upload_file_mask'], 'filetypes' => $parms['upload_filetypes'], 'extra_file_types' => $parms['upload_extra_file_types'] ? true : false, 'final_chmod' => $parms['upload_final_chmod'] ? intval(intval($parms['upload_final_chmod']), 8) : 0644, 'max_upload_size' => $parms['upload_max_upload_size'], 'file_array_name' => $parms['name'], 'max_file_count' => $parms['upload_max_file_count'], 'overwrite' => $parms['upload_overwrite'] ? true : false); $uploaded = process_uploaded_files($path, false, $options); if ($uploaded) { $emessage = e107::getMessage(); foreach ($uploaded as $finfo) { $emessage->addStack($finfo['message'], 'upload_shortcode', $finfo['error'] ? E_MESSAGE_ERROR : E_MESSAGE_SUCCESS); } if ($parms['return_type'] == 'message') { return $emessage->render('upload_shortcode'); } } return $parms['return_type'] == 'result' ? $uploaded : ''; } // RENDER FORM $onclickt = !isset($parms['nowarn']) ? " onclick=\"return jsconfirm('" . LAN_UPLOAD_CONFIRM . "')\"" : ''; $onclickd = " onclick=\"duplicateHTML('{$parms['up_row']}','{$parms['up_container']}');\""; $name = $parms['name'] . '[]'; $text .= "\n\t <!-- Upload Shortcode -->\n\t\t\t<div>\n\t\t\t\t<div class='field-spacer'>\n\t\t\t\t\t<button class='action duplicate' type='button' value='no-value'{$onclickd}><span>" . LAN_UPLOAD_ADDFILE . "</span></button>"; // Media Manager does the submit, not the shortcode. if (!$parms['disable_button']) { $text .= "<button class='upload' type='submit' name='{$parms['trigger']}' value='no-value'{$onclickt}><span>" . LAN_UPLOAD_FILES . "</span></button>"; } $text .= "\n\t\t\t\t</div>\n\t\t\t\t<div id='{$parms['up_container']}'>\n\t\t\t\t\t<div id='{$parms['up_row']}' class='nowrap'>\n\t\t\t\t\t\t<input class='tbox file' type='file' name='{$name}' />\n\t\t\t </div>\n\t\t\t\t</div>\n\t\t\t\t<div class='field-help'>Upload to: <strong>" . str_replace('../', '', $path) . "</strong></div>\n\t\t\t</div>\n\t\t\t<!-- End Upload Shortcode -->\n\t\t"; return $text; }
* $Source: /cvs_backup/e107_0.8/e107_plugins/links_page/links.php,v $ * $Revision$ * $Date$ * $Author$ */ require_once '../../class2.php'; if (!plugInstalled('links_page')) { header("location:" . e_BASE . "index.php"); exit; } require_once e_HANDLER . "rate_class.php"; $rater = new rater(); require_once e_PLUGIN . 'links_page/link_shortcodes.php'; require_once e_PLUGIN . 'links_page/link_defines.php'; require_once e_HANDLER . "userclass_class.php"; e107_require_once(e_HANDLER . 'arraystorage_class.php'); $eArrayStorage = new ArrayData(); require_once e_HANDLER . "form_handler.php"; $rs = new form(); require_once e_HANDLER . "file_class.php"; $fl = new e_file(); require_once e_HANDLER . "comment_class.php"; $cobj = new comment(); require_once e_PLUGIN . 'links_page/link_class.php'; $lc = new linkclass(); global $tp; $linkspage_pref = $lc->getLinksPagePref(); $deltest = array_flip($_POST); if (e_QUERY) { $qs = explode(".", e_QUERY); if (is_numeric($qs[0])) {
/** * Tries to detect a library and its installed version. * * @param $name * The machine name of a library to return registered information for. * * @return array|false * An associative array containing registered information for the library specified by $name, or FALSE if the library * $name is not registered. In addition to the keys returned by libraries_info(), the following keys are contained: * - installed: A boolean indicating whether the library is installed. Note that not only the top-level library, but * also each variant contains this key. * - version: If the version could be detected, the full version string. * - error: If an error occurred during library detection, one of the following error statuses: * "not found", "not detected", "not supported". * - error message: If an error occurred during library detection, a detailed error message. */ function libraries_detect($name) { // Re-use the statically cached value of libraries_info() to save memory. $library =& libraries_info($name); // Exit early if the library was not found. if ($library === false) { return $library; } // If 'installed' is set, library detection ran already. if (isset($library['installed'])) { return $library; } $library['installed'] = false; // Check whether the library exists. if (!isset($library['library path'])) { $library['library path'] = libraries_get_path($library['machine name']); } if ($library['library path'] === false || !file_exists($library['library path'])) { $library['error'] = LAN_PLUGIN_LIBRARIES_GLOBAL_09; $replace = array('[x]'); $replace_with = array($library['name']); $library['error message'] = str_replace($replace, $replace_with, LAN_PLUGIN_LIBRARIES_GLOBAL_03); return $library; } // TODO: // Invoke callbacks in the 'pre-detect' group. libraries_invoke('pre-detect', $library); // Detect library version, if not hardcoded. if (!isset($library['version'])) { if (varset($library['plugin'], false)) { e107_require_once(e_PLUGIN . $library['plugin'] . '/e_libraries.php'); $addonClass = $library['plugin'] . '_libraries'; } elseif (varset($library['theme'], false)) { e107_require_once(e_THEME . $library['theme'] . '/e_libraries.php'); $addonClass = $library['theme'] . '_libraries'; } // We support both a single parameter, which is an associative array, and an // indexed array of multiple parameters. if (isset($library['version arguments'][0])) { if (isset($addonClass) && class_exists($addonClass)) { $class = new $addonClass(); if (method_exists($class, $library['version callback'])) { // Add the library as the first argument. // Call PLUGIN_libraries::VARIANT_CALLBACK(). $variant['installed'] = call_user_func_array(array($class, $library['version callback']), array_merge(array($library), $library['version arguments'])); } } } else { if (isset($addonClass) && class_exists($addonClass)) { $class = new $addonClass(); if (method_exists($class, $library['version callback'])) { $library['version'] = $class->{$library}['version callback']($library, $library['version arguments']); } } } if (empty($library['version'])) { $library['error'] = LAN_PLUGIN_LIBRARIES_GLOBAL_10; $replace = array('[x]'); $replace_with = array($library['name']); $library['error message'] = str_replace($replace, $replace_with, LAN_PLUGIN_LIBRARIES_GLOBAL_04); return $library; } } // Determine to which supported version the installed version maps. if (!empty($library['versions'])) { ksort($library['versions']); $version = 0; foreach ($library['versions'] as $supported_version => $version_properties) { if (version_compare($library['version'], $supported_version, '>=')) { $version = $supported_version; } } if (!$version) { $library['error'] = LAN_PLUGIN_LIBRARIES_GLOBAL_11; $replace = array('[x]', '[y]'); $replace_with = array($library['version'], $library['name']); $library['error message'] = str_replace($replace, $replace_with, LAN_PLUGIN_LIBRARIES_GLOBAL_05); return $library; } // Apply version specific definitions and overrides. $library = array_merge($library, $library['versions'][$version]); unset($library['versions']); } // Check each variant if it is installed. if (!empty($library['variants'])) { foreach ($library['variants'] as $variant_name => &$variant) { // If no variant callback has been set, assume the variant to be installed. if (!isset($variant['variant callback'])) { $variant['installed'] = true; } else { if (varset($library['plugin'], false)) { e107_require_once(e_PLUGIN . $library['plugin'] . '/e_libraries.php'); $addonClass = $library['plugin'] . '_libraries'; } elseif (varset($library['theme'], false)) { e107_require_once(e_THEME . $library['theme'] . '/e_libraries.php'); $addonClass = $library['theme'] . '_libraries'; } // We support both a single parameter, which is an associative array, and an indexed array of multiple // parameters. if (isset($variant['variant arguments'][0])) { if (isset($addonClass) && class_exists($addonClass)) { $class = new $addonClass(); if (method_exists($class, $variant['variant callback'])) { // Add the library as the first argument, and the variant name as the second. // Call PLUGIN_libraries::VARIANT_CALLBACK(). $variant['installed'] = call_user_func_array(array($class, $variant['variant callback']), array_merge(array($library, $variant_name), $variant['variant arguments'])); } else { $variant['installed'] = true; } } else { $variant['installed'] = true; } } else { if (isset($addonClass) && class_exists($addonClass)) { $class = new $addonClass(); if (method_exists($class, $variant['variant callback'])) { $variant['installed'] = $class->{$variant}['variant callback']($library, $variant_name, $variant['variant arguments']); } else { $variant['installed'] = true; } } else { $variant['installed'] = true; } } if (!$variant['installed']) { $variant['error'] = LAN_PLUGIN_LIBRARIES_GLOBAL_09; $replace = array('[x]', '[y]'); $replace_with = array($variant_name, $library['name']); $variant['error message'] = str_replace($replace, $replace_with, LAN_PLUGIN_LIBRARIES_GLOBAL_06); } } } } // If we end up here, the library should be usable. $library['installed'] = true; // Invoke callbacks in the 'post-detect' group. libraries_invoke('post-detect', $library); return $library; }
<?php /** * @file * This file is loaded every time the core of e107 is included. ie. Wherever * you see require_once("class2.php") in a script. It allows a developer to * modify or define constants, parameters etc. which should be loaded prior to * the header or anything that is sent to the browser as output. It may also be * included in Ajax calls. */ // Load "libraries" functions for using them globally on the site, so developers can load libraries in their plugins, // for example to load a jquery plugin in their e_header.php file, or a PHP library wherever in their plugins. e107_require_once(e_PLUGIN . 'libraries/libraries.php'); // Register events. $event = e107::getEvent(); $event->register('admin_plugin_install', 'libraries_update_addon_list'); $event->register('admin_plugin_uninstall', 'libraries_update_addon_list'); $event->register('admin_plugin_upgrade', 'libraries_update_addon_list'); $event->register('admin_plugin_refresh', 'libraries_update_addon_list');
function upgrade_post($var) { e107_require_once(e_PLUGIN . 'libraries/libraries.php'); libraries_update_addon_list(); }
function getPDFPrefs() { global $sql, $eArrayStorage; if (!is_object($eArrayStorage)) { e107_require_once(e_HANDLER . 'arraystorage_class.php'); $eArrayStorage = new ArrayData(); } if (!is_object($sql)) { $sql = new db(); } $num_rows = $sql->db_Select('core', '*', "e107_name='pdf' "); if ($num_rows == 0) { $tmp = $this->getDefaultPDFPrefs(); $tmp2 = $eArrayStorage->WriteArray($tmp); $sql->db_Insert('core', "'pdf', '" . $tmp2 . "' "); $sql->db_Select('core', '*', "e107_name='pdf' "); } $row = $sql->db_Fetch(); $pdfPref = $eArrayStorage->ReadArray($row['e107_value']); return $pdfPref; }
/** * Send an email notification following an event. * * For up to a (hard-coded) number of recipients, the mail is sent immediately. * Otherwise its added to the queue * * @param string $id - identifies event actions * @param string $subject - subject for email * @param string $message - email message body * @return none * * @todo handle 'everyone except' clauses (email address filter done) * @todo set up pref to not notify originator of event which caused notify (see $blockOriginator) */ function send($id, $subject, $message) { $e107 = e107::getInstance(); $subject = $e107->tp->toEmail(SITENAME . ': ' . $subject); $message = $e107->tp->toEmail($message); $emailFilter = ''; $notifyTarget = $this->notify_prefs['event'][$id]['class']; if ($notifyTarget == '-email') { $emailFilter = $this->notify_prefs['event'][$id]['email']; } $blockOriginator = FALSE; // TODO: set this using a pref if (is_numeric($this->notify_prefs['event'][$id]['class'])) { switch ($notifyTarget) { case e_UC_MAINADMIN: $qry = "`user_admin` = 1 AND `user_perms` = '0' AND `user_ban` = 0"; break; case e_UC_ADMIN: $qry = "`user_admin` = 1 AND `user_ban` = 0"; break; case e_UC_MEMBER: $qry = "`user_ban` = 0"; break; default: $qry = "user_ban = 0 AND user_class REGEXP '(^|,)(" . $this->notify_prefs['event'][$id]['class'] . ")(,|\$)'"; break; } $qry = 'SELECT user_id,user_name,user_email FROM `#user` WHERE ' . $qry; if ($blockOriginator) { $qry .= ' AND `user_id` != ' . USERID; } if (FALSE !== ($count = $e107->sql->db_Select_gen($qry))) { if ($count <= 5) { // Arbitrary number below which we send emails immediately e107_require_once(e_HANDLER . 'mail.php'); while ($email = $e107->sql->db_Fetch()) { if ($email['user_email'] != $emailFilter) { sendemail($email['user_email'], $subject, $message, $email['user_name']); } } } else { // Otherwise add to mailout queue require_once e_HANDLER . 'mail_manager_class.php'; $mailer = new e107MailManager(); // Start by creating the mail body $mailData = array('mail_content_status' => MAIL_STATUS_TEMP, 'mail_create_app' => 'notify', 'mail_title' => 'NOTIFY', 'mail_subject' => $subject, 'mail_sender_email' => $pref['siteadminemail'], 'mail_sender_name' => $pref['siteadmin'], 'mail_send_style' => 'textonly', 'mail_notify_complete' => 0, 'mail_body' => $message); $result = $mailer->saveEmail($mailData, TRUE); if (is_numeric($result)) { $mailMainID = $mailData['mail_source_id'] = $result; } else { // TODO: Handle error return; // Probably nothing else we can do } $mailer->mailInitCounters($mailMainID); // Initialise counters for emails added // Now add email addresses to the list while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC)) { if ($row['user_email'] != $emailFilter) { $uTarget = array('mail_recipient_id' => $row['user_id'], 'mail_recipient_name' => $row['user_name'], 'mail_recipient_email' => $row['user_email']); $result = $mailer->mailAddNoDup($mailMainID, $uTarget, MAIL_STATUS_TEMP); } } $mailer->mailUpdateCounters($mailMainID); // Update the counters $counters = $mailer->mailRetrieveCounters($mailMainID); // Retrieve the counters if ($counters['add'] == 0) { $mailer->deleteEmail($mailMainID); // Probably a fault, but precautionary - delete email } else { $mailer->activateEmail($mailMainID, FALSE); // Actually mark the email for sending } } $e107->admin_log->e_log_event(10, -1, 'NOTIFY', $subject, $message, FALSE, LOG_TO_ROLLING); } } elseif ($notifyTarget == 'email') { // Single email address - that can always go immediately if (!$blockOriginator || $this->notify_prefs['event'][$id]['email'] != USEREMAIL) { e107_require_once(e_HANDLER . 'mail.php'); sendemail($this->notify_prefs['event'][$id]['email'], $subject, $message); } } }