Example #1
0
 function init()
 {
     $fl = e107::getFile();
     $importClassList = $fl->get_files(e_PLUGIN . 'import/providers', "^.+?_import_class\\.php\$", "standard", 1);
     foreach ($importClassList as $file) {
         $tag = str_replace('_class.php', '', $file['fname']);
         $key = str_replace("_import_class.php", "", $file['fname']);
         include_once $file['path'] . $file['fname'];
         // This will set up the variables
         $this->providers[$key] = $this->getMeta($tag);
         if (vartrue($_GET['type'])) {
             $this->importClass = $_GET['type'] . "_import";
         }
     }
 }
Example #2
0
File: docs.php Project: armpit/e107
 function init()
 {
     $fl = e107::getFile();
     $helplist_all = $fl->get_files(DOC_PATH_ALT);
     if (!is_dir(DOC_PATH) || DOC_PATH == DOC_PATH_ALT) {
         $helplist = $helplist_all;
     } else {
         $helplist = $fl->get_files(DOC_PATH);
     }
     sort($helplist);
     self::$helpList = $helplist;
     foreach ($helplist as $key => $helpdata) {
         $id = 'doc-' . $key;
         $k = 'main/' . $id;
         $this->adminMenu[$k] = array('caption' => str_replace("_", " ", $helpdata['fname']), 'perm' => false, 'uri' => "#" . $id);
     }
 }
Example #3
0
/**
 * Update addon list.
 */
function libraries_update_addon_list()
{
    $fl = e107::getFile();
    $plugList = $fl->get_files(e_PLUGIN, "^plugin\\.(php|xml)\$", "standard", 1);
    $pluginList = array();
    $themeList = array();
    $addonsList = array('plugin' => array(), 'theme' => array());
    $siteTheme = e107::getPref('sitetheme');
    $adminTheme = e107::getPref('admintheme');
    // Remove Duplicates caused by having both plugin.php AND plugin.xml.
    foreach ($plugList as $num => $val) {
        $key = basename($val['path']);
        $pluginList[$key] = $val;
    }
    $themes = $fl->get_dirs(e_THEME);
    foreach ($themes as $theme) {
        if (!in_array($theme, $themeList)) {
            $themeList[] = $theme;
        }
    }
    // Addon list.
    foreach ($pluginList as $p) {
        $p['path'] = substr(str_replace(e_PLUGIN, '', $p['path']), 0, -1);
        $plugin = $p['path'];
        if (is_readable(e_PLUGIN . $plugin . '/e_libraries.php')) {
            if (e107::isInstalled($plugin)) {
                $addonsList['plugin'][] = $plugin;
            }
        }
    }
    // Addon list.
    foreach ($themeList as $theme) {
        if (is_readable(e_THEME . $theme . '/e_libraries.php')) {
            if ($theme == $siteTheme || $theme == $adminTheme) {
                $addonsList['theme'][] = $theme;
            }
        }
    }
    e107::getPlugConfig('libraries')->set('addon_list', $addonsList)->save();
    return $addonsList;
}
Example #4
0
 /**
  * Return a list of Installed Language Packs
  * 
  * @return array
  */
 function installed()
 {
     if (null == $this->lanlist) {
         $fl = e107::getFile();
         $dirArray = $fl->get_dirs(e_LANGUAGEDIR);
         //	$handle = opendir(e_LANGUAGEDIR);
         $lanlist = array();
         //	while ($file = readdir($handle))
         foreach ($dirArray as $file) {
             if ($file != '.' && $file != '..' && is_readable(e_LANGUAGEDIR . $file . '/' . $file . '.php')) {
                 $lanlist[] = $file;
             }
         }
         // closedir($handle);
         $this->lanlist = array_intersect($lanlist, $this->list);
     }
     return $this->lanlist;
 }
Example #5
0
 function installCheck($do_one = FALSE)
 {
     global $e107;
     $sql = e107::getDb();
     $fl = e107::getFile();
     $ns = e107::getRender();
     $mes = e107::getMessage();
     // Pick up a list of emote packs from the database
     $pack_local = array();
     if ($sql->db_Select("core", "*", "`e107_name` LIKE 'emote_%'")) {
         while ($row = $sql->db_Fetch()) {
             $pack_local[substr($row['e107_name'], 6)] = TRUE;
         }
     }
     foreach ($this->packArray as $value) {
         if (strpos($value, ' ') !== FALSE) {
             // Highlight any directory names containing spaces - not allowed
             $msg = "\r\n\t\t\t\t\t<strong>" . EMOLAN_17 . "</strong> " . EMOLAN_18 . ":\r\n\t\t\t\t\t<div>" . LAN_NAME . ": {$value}</div>\r\n\t\t\t\t\t<div>" . EMOLAN_20 . ": " . e_IMAGE_ABS . "emotes/</div>\r\n\t\t\t\t";
             $mes->addError($msg);
             $ns->tablerender(EMOLAN_PAGE_TITLE . ' - ' . EMOLAN_21, $mes->render());
             return FALSE;
         }
         if (array_key_exists($value, $pack_local)) {
             unset($pack_local[$value]);
         }
         if ($do_one == $value || !$do_one && !$sql->db_Select("core", "*", "e107_name='emote_" . $value . "' ")) {
             // Pack info not in DB, or to be re-scanned
             $no_error = TRUE;
             $File_type = EMOLAN_32 . ":";
             // Array of all files in the directory of the selected emote pack
             $fileArray = $fl->get_files(e_IMAGE . "emotes/" . $value);
             // We actually want all the files in the directory
             $confFile = '';
             foreach ($fileArray as $k => $file) {
                 if (strstr($file['fname'], ".xml")) {
                     $confFile = array('file' => $file['fname'], 'type' => "xml");
                 } else {
                     if (strstr($file['fname'], ".pak")) {
                         $confFile = array('file' => $file['fname'], 'type' => "pak");
                     } else {
                         if (strstr($file['fname'], ".php")) {
                             $confFile = array('file' => $file['fname'], 'type' => "php");
                         }
                     }
                 }
                 if ($confFile) {
                     unset($fileArray[$k]);
                     break;
                 }
             }
             /* .pak file */
             if ($confFile['type'] == "pak") {
                 $filename = e_IMAGE . "emotes/" . $value . "/" . $confFile['file'];
                 $pakconf = file($filename);
                 $contentArray = array();
                 foreach ($pakconf as $line) {
                     if (trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) {
                         $contentArray[] = $line;
                     }
                 }
                 $confArray = array();
                 foreach ($contentArray as $pakline) {
                     $tmp = explode("=+:", $pakline);
                     $confIC = str_replace(".", "!", $tmp[0]);
                     $confArray[$confIC] = trim($tmp[2]);
                 }
                 // $tmp = addslashes(serialize($confArray));
                 $tmp = e107::getArrayStorage()->WriteArray($confArray);
                 $File_type = EMOLAN_22 . ":";
             }
             /* end  */
             /* .xml file  */
             if ($confFile['type'] == "xml") {
                 $filename = e_IMAGE . "emotes/" . $value . "/" . $confFile['file'];
                 $contents = file_get_contents($filename);
                 $confArray = array();
                 $xml_type = 0;
                 if (strpos($contents, "<icon>") !== FALSE && strpos($contents, "<icondef>") !== FALSE) {
                     // xep-0038 format
                     /* Example:
                     		  <icon>
                     			<text>:-)</text>
                     			<text>:)</text>
                     			<object mime="image/png">happy.png</object>
                     			<object mime="audio/x-wav">choir.wav</object>
                     		  </icon>*/
                     preg_match_all("#\\<icon>(.*?)\\<\\/icon\\>#si", $contents, $match);
                     $xml_type = 1;
                     // $match[0] - complete emoticon entry
                     // $match[1] - match string and object specification
                     $item_index = 1;
                 } elseif (strpos($contents, "<emoticon") !== FALSE) {
                     //  "Original" E107 format (as used on KDE, although they may be changing to XEP-0038)
                     //echo "Decoding standard XML file<br />";
                     preg_match_all("#\\<emoticon file=\"(.*?)\"\\>(.*?)\\<\\/emoticon\\>#si", $contents, $match);
                     $xml_type = 2;
                     // $match[0] - complete emoticon entry
                     // $match[1] - filename (may or may not not have file extension/suffix)
                     // $match[2] - match string(s) representing emote
                     $item_index = 2;
                 }
                 if ($xml_type) {
                     for ($a = 0; $a < count($match[0]); $a++) {
                         $e_file = '';
                         switch ($xml_type) {
                             case 1:
                                 // xep-0038
                                 // Pull out a file name (only support first image type) - its in $fmatch[1]
                                 if (preg_match("#\\<object\\s*?mime\\=[\"\\']image\\/.*?\\>(.*?)\\<\\/object\\>#si", $match[1][$a], $fmatch)) {
                                     $e_file = $fmatch[1];
                                     //							  echo "xep-0038 file: ".$e_file."<br />";
                                     // Pull out all match strings - need to pick out any language definitions for posterity
                                     // but currently accept all language strings
                                     preg_match_all("#\\<text(?:\\s*?\\>|\\s*?xml\\:lang\\=\"(.*?)\"\\>)(.*?)\\<\\/text\\>#si", $match[1][$a], $match2);
                                     // $match2[1] is the languages
                                     // $match2[2] is the match strings
                                     $codet = implode(" ", $match2[2]);
                                 }
                                 break;
                             case 2:
                                 $e_file = $match[1][$a];
                                 // Now pull out all the 'match' strings
                                 preg_match_all("#\\<string\\>(.*?)\\<\\/string\\>#si", $match[2][$a], $match2);
                                 $codet = implode(" ", $match2[1]);
                                 break;
                         }
                         // $e_file has the emote file name
                         // $match2 has an array of substitution strings
                         $file = '';
                         foreach ($fileArray as $emote) {
                             // Check that the file exists
                             if (strpos($e_file, ".") === FALSE) {
                                 // File extension not specified - accept any file extension for match
                                 if (strpos($emote['fname'], $e_file . ".") === 0) {
                                     $file = str_replace(".", "!", $emote['fname']);
                                     break;
                                 }
                             } else {
                                 // File extension specified - do simple match
                                 if ($emote['fname'] == $e_file) {
                                     $file = str_replace(".", "!", $emote['fname']);
                                     break;
                                 }
                             }
                         }
                         // Only add if the file exists. OK if no definition - might want to be added
                         if ($file) {
                             $confArray[$file] = $codet;
                         }
                     }
                 } else {
                     //echo "Unsupported XML File Format<br /><br />";
                     $mes->addWarning(EMOLAN_33);
                     $no_error = FALSE;
                 }
                 // Save pack info in the database
                 //	$tmp = addslashes(serialize($confArray));
                 $tmp = e107::getArrayStorage()->WriteArray($confArray);
                 $File_type = EMOLAN_23 . ":";
             }
             if ($confFile['type'] == "php") {
                 include_once e_IMAGE . "emotes/" . $value . "/" . $confFile['file'];
                 $File_type = EMOLAN_24 . ":";
                 $tmp = $_emoteconf;
                 // Use consistent name
             }
             if ($no_error) {
                 if ($do_one) {
                     // Assume existing pack
                     $sql->db_Update("core", "`e107_value`='{$tmp}' WHERE `e107_name`='emote_" . $value . "'");
                 } else {
                     // Assume new pack
                     $sql->db_Insert("core", "'emote_" . $value . "', '{$tmp}' ");
                 }
                 $mes->addInfo("<strong>{$File_type}</strong> '{$value}'");
             } else {
                 // Error occurred
                 $mes->addError(EMOLAN_27 . ": '{$value}'");
             }
         }
     }
     if (count($pack_local)) {
         foreach ($pack_local as $p => $d) {
             $mes->addInfo(EMOLAN_34 . ":" . $p . EMOLAN_35);
             $sql->db_Delete("core", "`e107_name` = 'emote_{$p}'");
         }
     }
     return TRUE;
 }
Example #6
0
function update_706_to_800($type = '')
{
    global $pref, $e107info;
    global $sysprefs, $eArrayStorage;
    //$mes = new messageLog;		// Combined logging and message displaying handler
    //$mes = e107::getMessage();
    $log = e107::getAdminLog();
    // Used for combined logging and message displaying
    $sql = e107::getDb();
    $sql2 = e107::getDb('sql2');
    $tp = e107::getParser();
    $ns = e107::getRender();
    e107::getCache()->clearAll('db');
    e107::getCache()->clearAll('system');
    // List of unwanted $pref values which can go
    $obs_prefs = array('frontpage_type', 'rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle', 'utf-compatmode', 'frontpage_method', 'standards_mode', 'image_owner', 'im_quality', 'signup_option_timezone', 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news', 'upload_storagetype');
    // List of DB tables not required (includes a few from 0.6xx)
    $obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last', 'session', 'preset', 'tinymce');
    // List of DB tables newly required  (defined in core_sql.php) (The existing dblog table gets renamed)
    // No Longer required. - automatically checked against core_sql.php.
    //	$new_tables = array('audit_log', 'dblog', 'news_rewrite', 'core_media', 'core_media_cat','cron', 'mail_recipients', 'mail_content');
    // List of core prefs that need to be converted from serialized to e107ArrayStorage.
    $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'", "'pm_prefs'");
    $create_dir = array(e_MEDIA, e_SYSTEM, e_CACHE, e_CACHE_CONTENT, e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT);
    foreach ($create_dir as $dr) {
        if (!is_dir($dr)) {
            mkdir($dr, 0755);
        }
    }
    // List of changed DB tables (defined in core_sql.php)
    // No Longer required. - automatically checked against core_sql.php.
    // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
    // $changed_tables = array('user', 'dblog', 'admin_log', 'userclass_classes', 'banlist', 'menus',
    // 'plugin', 'news', 'news_category', 'online', 'page', 'links', 'comments');
    // List of changed DB tables from core plugins (defined in pluginname_sql.php file)
    // key = plugin directory name. Data = comma-separated list of tables to check
    // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
    // No Longer required. - automatically checked by db-verify
    /* $pluginChangedTables = array('linkwords' => 'linkwords',
    								'featurebox' => 'featurebox',
    								'links_page' => 'links_page',
    								'poll' => 'polls',
    								'content' => 'pcontent'
    								);
    	 
    	 */
    /*
    	$setCorePrefs = array( //modified prefs during upgrade.
    		'adminstyle' 		=> 'infopanel',
    		'admintheme' 		=> 'bootstrap',
    		'admincss'			=> 'admin_style.css',
    		'resize_dimensions' => array(
    			'news-image' 	=> array('w' => 250, 'h' => 250),
    			'news-bbcode' 	=> array('w' => 250, 'h' => 250),
    			'page-bbcode' 	=> array('w' => 250, 'h' => 250)
    		)
    	);
    */
    $do_save = TRUE;
    // List of changed menu locations.
    $changeMenuPaths = array(array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'latestnews_menu'), array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'usertheme_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'userlanguage_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news2_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'poll_menu', 'newpath' => 'poll', 'menu' => 'poll_menu'), array('oldpath' => 'banner_menu', 'newpath' => 'banner', 'menu' => 'banner_menu'), array('oldpath' => 'online_menu', 'newpath' => 'online', 'menu' => 'online_menu'));
    // List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
    $ip_upgrade = array('download_requests' => 'download_request_ip', 'submitnews' => 'submitnews_ip', 'tmp' => 'tmp_ip', 'chatbox' => 'cb_ip');
    $db_parser = new db_table_admin();
    // Class to read table defs and process them
    $do_save = FALSE;
    // Set TRUE to update prefs when update complete
    $updateMessages = array();
    // Used to log actions for the admin log - TODO: will go once all converted to new class
    $just_check = $type == 'do' ? FALSE : TRUE;
    // TRUE if we're just seeing whether an update is needed
    //	if (!$just_check)
    //	{
    //	foreach(vartrue($setCorePrefs) as $k=>$v)
    //	{
    //		$pref[$k] = $v;
    //	}
    //	}
    if (!$just_check) {
        $log->logMessage(LAN_UPDATE_14 . $e107info['e107_version'], E_MESSAGE_NODISPLAY);
    }
    $statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
    if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle'])) {
        if ($just_check) {
            return update_needed('pref: forum_user_customtitle needs to be renamed');
        }
        $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
        unset($pref['forum_user_customtitle']);
        $log->logMessage(LAN_UPDATE_20 . 'customtitle', E_MESSAGE_SUCCESS);
        $do_save = TRUE;
    }
    // convert all serialized core prefs to e107 ArrayStorage;
    $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' ";
    $serialz_qry .= "AND e107_name IN (" . implode(",", $serialized_prefs) . ") ";
    if (e107::getDb()->select("core", "*", $serialz_qry)) {
        if ($just_check) {
            return update_needed('Convert serialized core prefs');
        }
        while ($row = e107::getDb()->fetch(MYSQL_ASSOC)) {
            $status = e107::getDb('sql2')->update('core', "e107_value=\"" . convert_serialized($row['e107_value']) . "\" WHERE e107_name='" . $row['e107_name'] . "'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
            $log->addDebug(LAN_UPDATE_22 . $row['e107_name'] . ": " . $status);
        }
    }
    if (e107::getDb()->select("core", "*", "e107_name='pm_prefs' LIMIT 1")) {
        if ($just_check) {
            return update_needed('Rename the pm prefs');
        }
        e107::getDb()->update("core", "e107_name='plugin_pm' WHERE e107_name = 'pm_prefs'");
    }
    //@TODO de-serialize the user_prefs also.
    // Banlist
    if (!$sql->field('banlist', 'banlist_id')) {
        if ($just_check) {
            return update_needed('Banlist table requires updating.');
        }
        $sql->gen("ALTER TABLE #banlist DROP PRIMARY KEY");
        $sql->gen("ALTER TABLE `#banlist` ADD `banlist_id` INT( 11 ) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
    }
    // Move the maximum online counts from menu prefs to a separate pref - 'history'
    e107::getCache()->clearAll('system');
    $menuConfig = e107::getConfig('menu', true, true);
    if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp')) {
        $status = E_MESSAGE_DEBUG;
        if ($just_check) {
            return update_needed('Move online counts from menupref');
        }
        $newPrefs = e107::getConfig('history');
        foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v) {
            if (FALSE === $newPrefs->get($v, FALSE)) {
                if (FALSE !== $menuConfig->get($v, FALSE)) {
                    $newPrefs->set($v, $menuConfig->get($v));
                } else {
                    $newPrefs->set($v, 0);
                }
            }
            $menuConfig->remove($v);
        }
        $result = $newPrefs->save(false, true, false);
        if ($result === TRUE) {
            $resultMessage = 'Historic member counts updated';
            $result = $menuConfig->save(false, true, false);
            // Only re-save if successul.
        } elseif ($result === FALSE) {
            $resultMessage = 'moving historic member counts';
            $status = E_MESSAGE_ERROR;
        } else {
            // No change
            $resultMessage = 'Historic member counts already updated';
            $status = E_MESSAGE_INFO;
        }
        // $result = $menuConfig->save(false, true, false);	// Save updated menuprefs - without the counts - don't delete them if it fails.
        //$updateMessages[] = $statusTexts[$status].': '.$resultMessage;		// Admin log message
        $log->logMessage($resultMessage, $status);
        // User message
    }
    // ++++++++ Modify Menu Paths +++++++.
    if (varset($changeMenuPaths)) {
        foreach ($changeMenuPaths as $val) {
            $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) LIMIT 1";
            if ($sql->gen($qry)) {
                if ($just_check) {
                    return update_needed('Menu path changed required:  ' . $val['menu'] . ' ');
                }
                $updqry = "menu_path='" . $val['newpath'] . "/' WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) ";
                $status = $sql->update('menus', $updqry) ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
                $log->logMessage(LAN_UPDATE_23 . '<b>' . $val['menu'] . '</b> : ' . $val['oldpath'] . ' => ' . $val['newpath'], $status);
                // LAN_UPDATE_25;
                // catch_error($sql);
            }
        }
    }
    // Leave this one here.. just in case..
    //delete record for online_extended_menu (now only using one online menu)
    if ($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'")) {
        if ($just_check) {
            return update_needed("The Menu table needs to have some paths corrected in its data.");
        }
        $row = $sql->db_Fetch();
        //if online_extended is activated, we need to activate the new 'online' menu, and delete this record
        if ($row['menu_location'] != 0) {
            $status = $sql->update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
            $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status);
        } else {
            //else if the menu is not active
            //we need to delete the online_extended menu row, and change the online_menu to online
            $sql->delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' ");
            $log->logMessage(LAN_UPDATE_31, E_MESSAGE_DEBUG);
        }
        catch_error($sql);
    }
    //change menu_path for online_menu (if it still exists)
    if ($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'")) {
        if ($just_check) {
            return update_needed('change menu_path for online menu');
        }
        $status = $sql->update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
        $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status);
        catch_error($sql);
    }
    if (!$just_check) {
        // Alert Admin to delete deprecated menu folders.
        $chgPath = array();
        foreach ($changeMenuPaths as $cgpArray) {
            if (is_dir(e_PLUGIN . $cgpArray['oldpath'])) {
                if (!in_array($cgpArray['oldpath'], $chgPath)) {
                    $chgPath[] = $cgpArray['oldpath'];
                }
            }
        }
        if (count($chgPath)) {
            $log->addWarning(LAN_UPDATE_57 . ' ');
            array_unique($chgPath);
            asort($chgPath);
            foreach ($chgPath as $cgp) {
                $log->addWarning(e_PLUGIN_ABS . "<b>" . $cgp . "</b>");
            }
        }
    }
    //---------------------------------------------------------
    //			Comments - split user field
    //---------------------------------------------------------
    if ($sql->db_Field('comments', 'comment_author')) {
        if ($just_check) {
            return update_needed('Comment table author field update');
        }
        if (!$sql->db_Field('comments', 'comment_author_id') && !$sql->gen("ALTER TABLE `#comments`\r\n\t\t\t\tADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`,\r\n\t\t\t\tADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`")) {
            // Flag error
            // $commentMessage = LAN_UPDAXXTE_34;
            $log->logMessage(LAN_UPDATE_21 . "comments", E_MESSAGE_ERROR);
        } else {
            if (FALSE === $sql->update('comments', "comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1),  comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) {
                // Flag error
                $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_ERROR);
            } else {
                // Delete superceded field - comment_author
                if (!$sql->gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) {
                    // Flag error
                    $log->logMessage(LAN_UPDATE_24 . 'comments - comment_author', E_MESSAGE_ERROR);
                }
            }
        }
        $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_DEBUG);
    }
    //	Add index to download history
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Extra index to tmp table
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Extra index to rss table (if used)
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Front page prefs (logic has changed)
    if (!isset($pref['frontpage_force'])) {
        if ($just_check) {
            return update_needed('Change front page prefs');
        }
        $pref['frontpage_force'] = array(e_UC_PUBLIC => '');
        $fpdef = vartrue($pref['frontpage']['all']) == 'index.php' ? 'index.php' : 'news.php';
        $pref['frontpage'] = array(e_UC_PUBLIC => $fpdef);
        // $_pdateMessages[] = LAN_UPDATE_38; //FIXME
        $log->logMessage(LAN_UPDATE_20 . "frontpage", E_MESSAGE_DEBUG);
        $do_save = TRUE;
    }
    // Check need for user timezone before we delete the field
    if (vartrue($pref['signup_option_timezone'])) {
        if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended', 'user_timezone', '', TRUE)) {
            if ($just_check) {
                return update_needed('Move user timezone info');
            }
            if (!copy_user_timezone()) {
                // Error doing the transfer
                //$updateMessages[] = LAN_UPDATE_42;
                $log->logMessage(LAN_UPDATE_42, E_MESSAGE_ERROR);
                return FALSE;
            }
            //$updateMessages[] = LAN_UPDATE_41;
            $log->logMessage(LAN_UPDATE_41, E_MESSAGE_DEBUG);
        }
    }
    // Tables defined in core_sql.php to be RENAMED.
    // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release
    if ($sql->isTable('rl_history') && !$sql->isTable('dblog')) {
        if ($just_check) {
            return update_needed('Rename rl_history to dblog');
        }
        $sql->gen('ALTER TABLE `' . MPREFIX . 'rl_history` RENAME `' . MPREFIX . 'dblog`');
        //$updateMessages[] = LAN_UPDATE_44;
        $log->logMessage(LAN_UPDATE_44, E_MESSAGE_DEBUG);
        catch_error($sql);
    }
    //---------------------------------
    if ($sql->isTable('dblog') && !$sql->isTable('admin_log')) {
        if ($just_check) {
            return update_needed('Rename dblog to admin_log');
        }
        $sql->gen('ALTER TABLE `' . MPREFIX . 'dblog` RENAME `' . MPREFIX . 'admin_log`');
        catch_error($sql);
        //$updateMessages[] = LAN_UPDATE_43;
        $log->logMessage(LAN_UPDATE_43, E_MESSAGE_DEBUG);
    }
    // New tables required (list at top. Definitions in core_sql.php)
    // ALL DEPRECATED by db_verify class.. see below.
    /*
    	foreach ($new_tables as $nt)
    	{
    		if (!$sql->isTable($nt))
    		{
    			if ($just_check) return update_needed('Add table: '.$nt);
    			// Get the definition
    			$defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php');
    			if (count($defs)) // **** Add in table here
    			{	
    				$status = $sql->gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
    			//	$updateMessages[] = LAN_UPDATE_45.$defs[0][1];		
    				$log->logMessage(LAN_UPDATE_27.$defs[0][1], $status);
    				// catch_error($sql);
    			}
    			else
    			{  // error parsing defs file
    				$log->logMessage(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR);
    			}
    			unset($defs);
    		}
    	}
    	
    	
    	// Tables whose definition needs changing significantly
         $debugLevel = E107_DBG_SQLDETAILS;
    	foreach ($changed_tables as $ct)
    	{
    	  $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php");
    	  $req_fields = $db_parser->parse_field_defs($req_defs[0][2]);					// Required definitions
    	  if ($debugLevel)
    	  {
    	  	$log->logMessage("Required table structure: <br />".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG);			
    	  } 
    	  if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs))			// Adds current default prefix
    	  {
    			$log->logMessage("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG);		
    	  }
    	  else
    	  {
    //		echo $db_parser->make_table_list($actual_defs);
    		$actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
    		if ($debugLevel)
    		{
    			$log->logMessage("Actual table structure: <br />".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG);		
    		} 
    		$diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
    		if (count($diffs[0]))
    		{  // Changes needed
    		  	if ($just_check) return update_needed("Field changes rqd; table: ".$ct);
    		
    			// Do the changes here
    		  	if ($debugLevel)
    		  	{
    		  		$log->logMessage("List of changes found:<br />".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG);		
    		  	} 
    		  
    			$qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
    		  
    			if ($debugLevel)
    			{
    				$log->logMessage("Update Query used: ".$qry, E_MESSAGE_DEBUG);	
    			} 
    		  
    			$status = $sql->gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; 
    			$log->logMessage(LAN_UPDATE_21.$ct, $status);
    		  	catch_error($sql);
    		}
    	  }
    	}
    	// Plugin tables whose definition needs changing significantly
    	foreach ($pluginChangedTables as $plugName => $plugList)
    	{
    		if (e107::isInstalled($plugName))
    		{
    			$ttc = explode(',',$plugList);
    			foreach ($ttc as $ct)
    			{
    				$sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php';		// Filename containing definitions
    //				echo "Looking at file: {$sqlDefs}, table {$ct}<br />";
    				$req_defs = $db_parser->get_table_def($ct,$sqlDefs);
    				if (!is_array($req_defs))
    				{
    					echo "Couldn't get definitions from file {$sqlDefs}<br />";
    					continue;
    				}
    				$req_fields = $db_parser->parse_field_defs($req_defs[0][2]);					// Required definitions
    				if (E107_DBG_SQLDETAILS)
    				{
    				  $message = "Required plugin table structure: <br />".$db_parser->make_field_list($req_fields);
    				  
    				  $log->logMessage($message, E_MESSAGE_DEBUG);
    				  	
    				} 
    				if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs))			// Adds current default prefix
    				{
    //	    			echo "Couldn't get table structure: {$ct}<br />";
    				}
    				else
    				{
    //					echo $db_parser->make_table_list($actual_defs);
    					$actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
    					if (E107_DBG_SQLDETAILS)
    					{					
    						$message= "Actual table structure: <br />".$db_parser->make_field_list($actual_fields);
    						$log->logMessage($message, E_MESSAGE_DEBUG);
    					} 
    					$diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
    					if (count($diffs[0]))
    					{  // Changes needed
    						if (E107_DBG_SQLDETAILS)
    						{
    							$message = "List of changes found:<br />".$db_parser->make_changes_list($diffs);
    							$log->logMessage($message, E_MESSAGE_DEBUG);	
    						} 
    						if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct);
    						// Do the changes here
    						$qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
    						if (E107_DBG_SQLDETAILS)
    						{
    							 $message = "Update Query used: ".$qry."<br />";
    							 $log->logMessage($message, E_MESSAGE_DEBUG);	
    						}
    						$sql->gen($qry);
    						$updateMessages[] = LAN_UPDATE_51.$ct;  
    						$log->logMessage(LAN_UPDATE_51.$ct, E_MESSAGE_SUCCESS);
    						catch_error($sql);
    					}
    				}
    			}
    		}
    	}
    */
    // Obsolete tables (list at top)
    $sql->mySQLtableList = false;
    // clear the cached table list.
    foreach ($obs_tables as $ot) {
        if ($sql->isTable($ot)) {
            if ($just_check) {
                return update_needed("Delete table: " . $ot);
            }
            $status = $sql->gen('DROP TABLE `' . MPREFIX . $ot . '`') ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
            $log->logMessage(LAN_UPDATE_25 . $ot, $status);
        }
    }
    // Tables where IP address field needs updating to accommodate IPV6
    // Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
    foreach ($ip_upgrade as $t => $f) {
        if ($sql->isTable($t)) {
            // Check for table - might add some core plugin tables in here
            if ($field_info = $sql->db_Field($t, $f, '', TRUE)) {
                if (strtolower($field_info['Type']) != 'varchar(45)') {
                    if ($just_check) {
                        return update_needed('Update IP address field ' . $f . ' in table ' . $t);
                    }
                    $status = $sql->gen("ALTER TABLE `" . MPREFIX . $t . "` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
                    $log->logMessage(LAN_UPDATE_26 . $t . ' - ' . $f, $status);
                    // catch_error($sql);
                }
            } else {
                // Got a strange error here
            }
        }
    }
    // Obsolete prefs (list at top)
    // Intentionally do this last - we may check some of them during the update
    $accum = array();
    foreach ($obs_prefs as $p) {
        if (isset($pref[$p])) {
            if ($just_check) {
                return update_needed('Remove obsolete prefs');
            }
            unset($pref[$p]);
            $do_save = TRUE;
            $log->addDebug('Removed obsolete pref: ' . $p);
            //	$accum[] = $p;
        }
    }
    /* -------------- Upgrade Entire Table Structure - Multi-Language Supported ----------------- */
    // ONLY ever add fields, never deletes.
    require_once e_HANDLER . "db_verify_class.php";
    $dbv = new db_verify();
    if ($plugUpgradeReq = e107::getPlugin()->updateRequired()) {
        $exclude = array_keys($plugUpgradeReq);
        // search xxxxx_setup.php and check for 'upgrade_required()' == true.
        asort($exclude);
    } else {
        $exclude = false;
    }
    $dbv->compareAll($exclude);
    // core & plugins, but not plugins calling for an update with xxxxx_setup.php
    if (count($dbv->errors)) {
        if ($just_check) {
            $mes = e107::getMessage();
            $log->addDebug(print_a($dbv->errors, true));
            return update_needed("Database Tables require updating.");
        }
        $dbv->compileResults();
        $dbv->runFix();
        // Fix entire core database structure and plugins too.
    }
    // print_a($dbv->results);
    // print_a($dbv->fixList);
    //TODO - send notification messages to Log.
    if ($sql->field('page', 'page_theme') && $sql->gen("SELECT * FROM `#page` WHERE page_theme != '' AND menu_title = '' LIMIT 1")) {
        if ($just_check) {
            return update_needed("Pages/Menus Table requires updating.");
        }
        if ($sql->update('page', "menu_name = page_theme, menu_title = page_title, menu_text = page_text, menu_template='default', page_title = '', page_text = '' WHERE page_theme !='' AND menu_title = '' AND menu_text = '' ")) {
            $sql->gen("ALTER TABLE `#page` DROP page_theme ");
            $mes = e107::getMessage();
            $log->addDebug("Successfully updated pages/menus table to new format. ");
        }
    }
    if ($sql->field('plugin', 'plugin_releaseUrl')) {
        if ($just_check) {
            return update_needed('plugin_releaseUrl is deprecated and needs to be removed. ');
        }
        if ($sql->gen("ALTER TABLE `#plugin` DROP `plugin_releaseUrl`")) {
            $log->addDebug("Successfully removed plugin_releaseUrl. ");
        }
    }
    // --- Notify Prefs
    //	$notify_prefs = $sysprefs -> get('notify_prefs');
    //	$notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
    e107::getCache()->clearAll('system');
    $notify_prefs = e107::getConfig('notify', true, true)->getPref();
    $nt_changed = 0;
    if (vartrue($notify_prefs['event'])) {
        foreach ($notify_prefs['event'] as $e => $d) {
            if (isset($d['type'])) {
                if ($just_check) {
                    return update_needed('Notify pref: ' . $e . ' outdated');
                }
                switch ($d['type']) {
                    case 'main':
                        $notify_prefs['event'][$e]['class'] = e_UC_MAINADMIN;
                        break;
                    case 'class':
                        // Should already have class defined
                        break;
                    case 'email':
                        $notify_prefs['event'][$e]['class'] = 'email';
                        break;
                    case 'off':
                        // Need to disable
                    // Need to disable
                    default:
                        $notify_prefs['event'][$e]['class'] = e_UC_NOBODY;
                        // Just disable if we don't know what else to do
                }
                $nt_changed++;
                $notify_prefs['event'][$e]['legacy'] = 1;
                unset($notify_prefs['event'][$e]['type']);
            }
        }
    }
    if ($nt_changed) {
        $s_prefs = $tp->toDB($notify_prefs);
        $s_prefs = $eArrayStorage->WriteArray($s_prefs);
        // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems  ????
        $status = $sql->update("core", "e107_value='" . $s_prefs . "' WHERE e107_name='notify_prefs'") !== FALSE ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
        $message = str_replace('--COUNT--', $nt_changed, LAN_UPDATE_20);
        $log->logMessage($message, $status);
    }
    // ---------------  Saved emails - copy across
    if (!$just_check && $sql->db_Select('generic', '*', "gen_type='massmail'")) {
        if ($just_check) {
            return update_needed('Copy across saved emails');
        }
        require_once e_HANDLER . 'mail_manager_class.php';
        $mailHandler = new e107MailManager();
        $i = 0;
        while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
            $mailRecord = array('mail_create_date' => $row['gen_datestamp'], 'mail_creator' => $row['gen_user_id'], 'mail_title' => $row['gen_ip'], 'mail_subject' => $row['gen_ip'], 'mail_body' => $row['gen_chardata'], 'mail_content_status' => MAIL_STATUS_SAVED);
            $mailHandler->mailtoDb($mailRecord, TRUE);
            $mailHandler->saveEmail($mailRecord, TRUE);
            $sql2->delete('generic', 'gen_id=' . intval($row['gen_id']));
            // Delete as we go in case operation fails part way through
            $i++;
        }
        unset($mailHandler);
        $log->logMessage(str_replace('--COUNT--', $i, LAN_UPDATE_28));
    }
    // -------------------  Populate Plugin Table With Changes ------------------
    if (!isset($pref['shortcode_legacy_list'])) {
        if ($just_check) {
            return update_needed('Legacy shortcode conversion');
        }
        // Reset, legacy and new shortcode list will be generated in plugin update routine
        $pref['shortcode_legacy_list'] = array();
        $pref['shortcode_list'] = array();
        save_prefs();
        $ep = e107::getPlugin();
        $ep->update_plugins_table($mode);
        // scan for e_xxx changes and save to plugin table.
        $ep->save_addon_prefs($mode);
        // generate global e_xxx_list prefs from plugin table.
    }
    // This has to be done after the table is upgraded
    if ($sql->select('plugin', 'plugin_category', "plugin_category = ''")) {
        if ($just_check) {
            return update_needed('Update plugin table');
        }
        require_once e_HANDLER . 'plugin_class.php';
        $ep = new e107plugin();
        $ep->update_plugins_table('update');
        //	$_pdateMessages[] = LAN_UPDATE_XX24;
        //	catch_error($sql);
    }
    //-- Media-manger import --------------------------------------------------
    // Autogenerate filetypes.xml if not found.
    if (!is_readable(e_SYSTEM . "filetypes.xml")) {
        $data = '<?xml version="1.0" encoding="utf-8"?>
<e107Filetypes>
	<class name="253" type="zip,gz,jpg,jpeg,png,gif,xml" maxupload="2M" />
</e107Filetypes>';
        file_put_contents(e_SYSTEM . "filetypes.xml", $data);
    }
    $root_media = str_replace(basename(e_MEDIA) . "/", "", e_MEDIA);
    $user_media_dirs = array("images", "avatars", "avatars/default", "avatars/upload", "files", "temp", "videos", "icons");
    // check for old paths and rename.
    if (is_dir($root_media . "images") || is_dir($root_media . "temp")) {
        foreach ($user_media_dirs as $md) {
            @rename($root_media . $md, e_MEDIA . $md);
        }
    }
    // create sub-directories if they do not exist.
    if (!is_dir(e_MEDIA . "images") || !is_dir(e_MEDIA . "temp") || !is_dir(e_AVATAR_UPLOAD) || !is_dir(e_AVATAR_DEFAULT)) {
        foreach ($user_media_dirs as $md) {
            if (!is_dir(e_MEDIA . $md)) {
                mkdir(e_MEDIA . $md);
            }
        }
    }
    // Move Avatars to new location
    $av1 = e107::getFile()->get_files(e_FILE . 'public/avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG');
    $av2 = e107::getFile()->get_files(e_IMAGE . 'avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG');
    $avatar_images = array_merge($av1, $av2);
    if (count($avatar_images)) {
        if ($just_check) {
            return update_needed('Avatar paths require updating.');
        }
        foreach ($avatar_images as $av) {
            $apath = strstr($av['path'], 'public/') ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT;
            @rename($av['path'] . $av['fname'], $apath . $av['fname']);
        }
    }
    // -------------------------------
    if (!e107::isInstalled('download') && $sql->gen("SELECT * FROM #links WHERE link_url LIKE 'download.php%' AND link_class != '" . e_UC_NOBODY . "' LIMIT 1")) {
        if ($just_check) {
            return update_needed('Download Plugin needs to be installed.');
        }
        //	e107::getSingleton('e107plugin')->install('download',array('nolinks'=>true));
        e107::getSingleton('e107plugin')->refresh('download');
    }
    if (!e107::isInstalled('banner') && $sql->isTable('banner')) {
        if ($just_check) {
            return update_needed('Banner Table found, but plugin not installed. Needs to be refreshed.');
        }
        e107::getSingleton('e107plugin')->refresh('banner');
    }
    // ---------------------------------
    $med = e107::getMedia();
    // Media Category Update
    if ($sql->db_Field("core_media_cat", "media_cat_nick")) {
        $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick = '_common'  ");
        if ($count == 1) {
            if ($just_check) {
                return update_needed('Media-Manager Categories needs to be updated.');
            }
            $sql->update('core_media_cat', "media_cat_owner = media_cat_nick, media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_common|news|page|_icon_16|_icon_32|_icon_48|_icon_64' ");
            $sql->update('core_media_cat', "media_cat_owner = '_icon', media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ");
            $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_image' WHERE media_cat_nick = 'download' ");
            $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_thumb' WHERE media_cat_nick = 'downloadthumb' ");
            $sql->update('core_media_cat', "media_cat_owner = 'news', media_cat_category='news_thumb' WHERE media_cat_nick = 'newsthumb' ");
            $log->addDebug("core-media-cat Categories and Ownership updated");
            if ($sql->gen("ALTER TABLE `" . MPREFIX . "core_media_cat` DROP `media_cat_nick`")) {
                $log->addDebug("core-media-cat `media_cat_nick` field removed.");
            }
            //		$query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES
            //		(0, 'gallery', 'gallery_1', 'Gallery 1', 'Visible to the public at /gallery.php', 0, '', 0);
            ///		";
            //
            //		if(mysql_query($query))
            //		{
            //			$log->addDebug("Added core-media-cat Gallery.");
            //		}
        }
    }
    // Media Update
    $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = 'newsthumb' OR media_category = 'downloadthumb'  LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Data needs to be updated.');
        }
        $sql->update('core_media', "media_category='download_image' WHERE media_category = 'download' ");
        $sql->update('core_media', "media_category='download_thumb' WHERE media_category = 'downloadthumb' ");
        $sql->update('core_media', "media_category='news_thumb' WHERE media_category = 'newsthumb' ");
        $log->addDebug("core-media Category names updated");
    }
    // Media Update - core media and core-file.
    $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = '_common' LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Category Data needs to be updated.');
        }
        $sql->update('core_media', "media_category='_common_image' WHERE media_category = '_common' ");
        $log->addDebug("core-media _common Category updated");
    }
    // Media Update - core media and core-file. CATEGORY
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_category = '_common' LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Category Data needs to be updated.');
        }
        $sql->update('core_media_cat', "media_cat_category='_common_image' WHERE media_cat_category = '_common' ");
        $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, '_common', '_common_file', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0);");
        $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, 'download', 'download_file', 'Download Files', '', 253, '', 0);");
        $log->addDebug("core-media-cat _common Category updated");
    }
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_owner` = '_common' LIMIT 1 ");
    if ($count != 1) {
        if ($just_check) {
            return update_needed('Add Media-Manager Categories and Import existing images.');
        }
        $e107_core_media_cat = array(array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_image', 'media_cat_title' => '(Common Images)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_file', 'media_cat_title' => '(Common Files)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news', 'media_cat_title' => 'News', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the news area.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1'), array('media_cat_id' => 0, 'media_cat_owner' => 'page', 'media_cat_category' => 'page', 'media_cat_title' => 'Custom Pages', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the custom pages area of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_image', 'media_cat_title' => 'Download Images', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_thumb', 'media_cat_title' => 'Download Thumbnails', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_file', 'media_cat_title' => 'Download Files', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news_thumb', 'media_cat_title' => 'News Thumbnails (Legacy)', 'media_cat_sef' => '', 'media_cat_diz' => 'Legacy news thumbnails.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1'));
        foreach ($e107_core_media_cat as $insert) {
            $sql->insert('core_media_cat', $insert);
        }
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_image', '(Common Images)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 1);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_file', '(Common Files)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 2);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news', 'News', '', 'Will be available in the news area. ', 253, '', 3);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'page', 'page', 'Custom Pages', '', 'Will be available in the custom pages area of admin. ', 253, '', 4);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_image','', 'Download Images', '', 253, '', 5);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_thumb', '', 'Download Thumbnails', '', 253, '', 6);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_file', '', 'Download Files', '', 253, '', 7);");
        //	mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news_thumb', 'News Thumbnails (Legacy)', '', 'Legacy news thumbnails. ', 253, '', 8);");
        $med->import('news_thumb', e_IMAGE . 'newspost_images', "^thumb_");
        $med->import('news', e_IMAGE . 'newspost_images');
        $med->import('page', e_IMAGE . 'custom');
    } else {
        //		$log->addDebug("Media COUNT was ".$count. " LINE: ".__LINE__);
    }
    // Check for Legacy Download Images.
    $fl = e107::getFile();
    $dl_images = $fl->get_files(e_FILE . 'downloadimages');
    if (count($dl_images) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_image' ")) {
        if ($just_check) {
            return update_needed('Import Download Images into Media Manager');
        }
        $med->import('download_image', e_FILE . 'downloadimages');
        $med->import('download_thumb', e_FILE . 'downloadthumbs');
    }
    $dl_files = $fl->get_files(e_FILE . 'downloads', "", "standard", 5);
    // don't use e_DOWNLOAD or a loop may occur.
    $publicFilter = array('_FT', '^thumbs\\.db$', '^Thumbs\\.db$', '.*\\._$', '^\\.htaccess$', '^\\.cvsignore$', '^\\.ftpquota$', '^index\\.html$', '^null\\.txt$', '\\.bak$', '^.tmp');
    // Default file filter (regex format)
    //	$publicFilter = array(1);
    $public_files = $fl->get_files(e_FILE . 'public', '', $publicFilter);
    if ((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' ")) {
        if ($just_check) {
            return update_needed('Import ' . count($dl_files) . ' Download File(s) and ' . count($public_files) . ' Public File(s) into Media Manager');
        }
        if ($sql->gen("SELECT download_url FROM `#download` ")) {
            $allowed_types = array();
            while ($row = $sql->fetch()) {
                $ext = strrchr($row['download_url'], ".");
                $suffix = ltrim($ext, ".");
                if (!isset($allowed_types[$suffix])) {
                    $allowed_types[$suffix] = $suffix;
                }
            }
            $allowed_types = array_unique($allowed_types);
        } else {
            $allowed_types = array('zip', 'gz', 'pdf');
        }
        $fmask = '[a-zA-z0-9_-]+\\.(' . implode('|', $allowed_types) . ')$';
        $med->import('download_file', e_DOWNLOAD, $fmask);
        $med->import('_common_file', e_FILE . 'public', $fmask);
    }
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon'  ");
    if (!$count) {
        if ($just_check) {
            return update_needed('Add icons to media-manager');
        }
        $query = "INSERT INTO `" . MPREFIX . "core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES\r\n\t\t(0, '_icon', '_icon_16', 'Icons 16px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_32', 'Icons 32px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_48', 'Icons 48px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_64', 'Icons 64px', 'Available where icons are used in admin. ', 253, '', 0);\r\n\t\t";
        if (!$sql->gen($query)) {
            // echo "mysyql error";
            // error or already exists.
        }
        $med->importIcons(e_PLUGIN);
        $med->importIcons(e_IMAGE . "icons/");
        $med->importIcons(e_THEME . $pref['sitetheme'] . "/images/");
        $log->addDebug("Icon category added");
    }
    // Search Clean up ----------------------------------
    $searchPref = e107::getConfig('search');
    if ($searchPref->getPref('core_handlers/news')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/news')->save(false, true, false);
    }
    if ($searchPref->getPref('core_handlers/downloads')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/downloads')->save(false, true, false);
    }
    if ($searchPref->getPref('core_handlers/pages')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/pages')->save(false, true, false);
        e107::getSingleton('e107plugin')->refresh('page');
    }
    // Clean up news keywords. - remove spaces between commas.
    if ($sql->select('news', 'news_id', "news_meta_keywords LIKE '%, %' LIMIT 1")) {
        if ($just_check) {
            return update_needed('News keywords contain spaces between commas and needs to be updated. ');
        }
        $sql->update('news', "news_meta_keywords = REPLACE(news_meta_keywords, ', ', ',')");
    }
    // Any other images should be imported manually via Media Manager batch-import.
    // ------------------------------------------------------------------
    // Check that custompages have been imported from current theme.php file
    if (!$just_check) {
        if (!is_array($pref['sitetheme_layouts']) || !vartrue($pref['sitetheme_deflayout'])) {
            $th = e107::getSingleton('themeHandler');
            $tmp = $th->getThemeInfo($pref['sitetheme']);
            if ($th->setTheme($pref['sitetheme'], false)) {
                $log->addDebug("Updated SiteTheme prefs");
            } else {
                $log->addDebug("Couldn't update SiteTheme prefs");
            }
        }
        $log->toFile('upgrade_v1_to_v2');
        if ($do_save) {
            save_prefs();
            $log->logMessage(LAN_UPDATE_50);
            //	$log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
            //$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); 	// Note for admin log
        }
        $log->flushMessages('UPDATE_01');
        // Write admin log entry, update message handler
    } else {
        $log->toFile('upgrade_v1_to_v2_check');
    }
    //FIXME grab message-stack from $log for the log.
    //if ($just_check) return TRUE;
    //e107::getLog()->add('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,'');	// Log result of actual update
    return $just_check;
}
Example #7
0
 function getAddons($plugin_path, $debug = FALSE)
 {
     $fl = e107::getFile();
     $mes = e107::getMessage();
     $p_addons = array();
     foreach ($this->plugin_addons as $addon) {
         //	if(preg_match("#^(e_.*)\.php$#", $f['fname'], $matches))
         $addonPHP = $addon . ".php";
         if (is_readable(e_PLUGIN . $plugin_path . "/" . $addonPHP)) {
             if ($debug === 'check') {
                 $passfail = '';
                 $file_text = file_get_contents(e_PLUGIN . $plugin_path . "/" . $addonPHP);
                 if (substr($file_text, 0, 5) != '<' . '?php' || substr($file_text, -2, 2) != '?' . '>' && strrpos($file_text, '?' . '>') !== FALSE) {
                     $passfail = '<b>fail</b>';
                 } else {
                     $passfail = 'pass';
                 }
                 echo $plugin_path . "/" . $addon . ".php - " . $passfail . "<br />";
             }
             // $mes->add('Detected addon: <b>'.$addon.'</b>', E_MESSAGE_DEBUG);
             $p_addons[] = $addon;
         }
     }
     // Grab List of Shortcodes & BBcodes
     $shortcodeLegacyList = $fl->get_files(e_PLUGIN . $plugin_path, '\\.sc$', "standard", 1);
     $shortcodeList = $fl->get_files(e_PLUGIN . $plugin_path . '/shortcodes/single', '\\.php$', "standard", 1);
     $bbcodeList = $fl->get_files(e_PLUGIN . $plugin_path, '\\.bb$', "standard", 1);
     $bbcodeClassList = $fl->get_files(e_PLUGIN . $plugin_path, '^bb_(.*)\\.php$', "standard", 1);
     $bbcodeList = array_merge($bbcodeList, $bbcodeClassList);
     $sqlList = $fl->get_files(e_PLUGIN . $plugin_path, '_sql\\.php$', "standard", 1);
     // Search Shortcodes
     foreach ($shortcodeLegacyList as $sc) {
         if (is_readable(e_PLUGIN . $plugin_path . "/" . $sc['fname'])) {
             $p_addons[] = $sc['fname'];
         }
     }
     foreach ($shortcodeList as $sc) {
         if (is_readable(e_PLUGIN . $plugin_path . "/shortcodes/single/" . $sc['fname'])) {
             $p_addons[] = 'sc_' . $sc['fname'];
         }
     }
     // Search Bbcodes.
     foreach ($bbcodeList as $bb) {
         if (is_readable(e_PLUGIN . $plugin_path . "/" . $bb['fname'])) {
             $p_addons[] = $bb['fname'];
         }
     }
     // Search _sql files.
     foreach ($sqlList as $esql) {
         if (is_readable(e_PLUGIN . $plugin_path . "/" . $esql['fname'])) {
             $fname = str_replace(".php", "", $esql['fname']);
             if (!in_array($fname, $p_addons)) {
                 $p_addons[] = $fname;
             }
             // Probably already found - avoid duplication
         }
     }
     if ($debug == true) {
         echo $plugin_path . " = " . implode(",", $p_addons) . "<br />";
     }
     return implode(",", $p_addons);
 }
Example #8
0
 /**
  * Clear Full Cache
  * @param string $type: content | system| browser | db | image
  * @example clearAll('db');
  */
 function clearAll($type, $mask = null)
 {
     $path = null;
     if ($type == 'content') {
         $this->clear();
         return;
     }
     if ($type == 'system') {
         $this->clear_sys();
         return;
     }
     if ($type == 'browser') {
         e107::getConfig()->set('e_jslib_browser_cache', time())->save(false);
         return;
     }
     if ($type == 'db') {
         $path = e_CACHE_DB;
         $mask = $mask == null ? '.*\\.php' : $mask;
     }
     if ($type == 'image') {
         $path = e_CACHE_IMAGE;
         $mask = $mask == null ? '.*\\.cache\\.bin' : $mask;
     }
     if (null == $path || null == $mask) {
         return;
     }
     $fl = e107::getFile(false);
     $fl->mode = 'fname';
     $files = $fl->get_files($path, $mask);
     if ($files) {
         foreach ($files as $file) {
             unlink($path . $file);
         }
     }
 }
Example #9
0
 function xmlInput($name, $info, $default = '')
 {
     $frm = e107::getForm();
     list($cat, $type) = explode("-", $info);
     $size = 30;
     $help = '';
     switch ($info) {
         case 'main-name':
             $help = "The name of your theme. (Must be written in English)";
             $required = true;
             $pattern = "[A-Za-z ]*";
             break;
         case 'main-lang':
             $help = "If you have a language file, enter the LAN_XXX value for the theme's name";
             $required = false;
             $placeholder = " ";
             $pattern = "[A-Z0-9_]*";
             break;
         case 'main-date':
             $help = "Creation date of your theme";
             $required = true;
             break;
         case 'main-version':
             $default = '1.0';
             $required = true;
             $help = "The version of your theme. Format: x.x";
             $pattern = "^[\\d]{1,2}\\.[\\d]{1,2}\$";
             break;
         case 'main-compatibility':
             $default = '2.0';
             $required = true;
             $help = "Compatible with this version of e107";
             $pattern = "^[\\d]{1,2}\\.[\\d]{1,2}\$";
             break;
         case 'author-name':
             $default = vartrue($default) ? $default : USERNAME;
             $required = true;
             $help = "Author Name";
             $pattern = "[A-Za-z \\.0-9]*";
             break;
         case 'author-url':
             $required = true;
             $help = "Author Website Url";
             //	$pattern	= "https?://.+";
             break;
             //case 'main-installRequired':
             //	return "Installation required: ".$frm->radio_switch($name,'',LAN_YES, LAN_NO);
             //break;
         //case 'main-installRequired':
         //	return "Installation required: ".$frm->radio_switch($name,'',LAN_YES, LAN_NO);
         //break;
         case 'summary-summary':
             $help = "A short one-line description of the plugin. (!@#\$%^&* characters not permitted) <br />(Must be written in English)";
             $required = true;
             $size = 100;
             $placeholder = " ";
             $pattern = "[A-Za-z,() \\.0-9]*";
             break;
         case 'keywords-one':
         case 'keywords-two':
             $help = "Keyword/Tag for this theme<br />(Must be written in English)";
             $required = true;
             $size = 20;
             $placeholder = " ";
             $pattern = '^[a-z]*$';
             break;
         case 'description-description':
             $help = "A full description of the theme<br />(Must be written in English)";
             $required = true;
             $size = 100;
             $placeholder = " ";
             $pattern = "[A-Za-z \\.0-9]*";
             break;
         case 'category-category':
             $help = "What category of theme is this?";
             $required = true;
             $size = 20;
             break;
         default:
             break;
     }
     $req = $required == true ? "&required=1" : "";
     $placeholder = varset($placeholder) ? $placeholder : $type;
     $pat = $pattern ? "&pattern=" . $pattern : "";
     switch ($type) {
         case 'stylesheets':
             $fl = e107::getFile();
             $fl->setMode('full');
             $stylesheets = $fl->get_files(e_THEME . $this->themeName . "/", "\\.css", $reject, 1);
             foreach ($stylesheets as $key => $path) {
                 $file = str_replace(e_THEME . $this->themeName . "/", '', $path);
                 $text .= "<div class='row-fluid'>";
                 $text .= "<div class='controls'>";
                 $text .= "<div class='span3'>" . $frm->checkbox($name . '[' . $key . '][file]', $file, false, array('label' => $file)) . "\n\t\t\t\t\t\t<div class='field-help'>Enable this stylesheet as a selectable option in the Theme Manager.</div></div>";
                 $text .= "<div class='span3'>" . $frm->text($name . '[' . $key . '][name]', $default, $size, 'placeholder=' . $file . $req . $pat) . "\n\t\t\t\t\t\t<div class='field-help'>Give this stylesheet a name</div></div>";
                 //	$text .= "<div class='span2'>".$frm->checkbox('css['.$key.'][file]',$file, false, array('label'=>$file))."</div>";
                 //	$text .= "<div class='span2'>".$frm->text('css['.$key.'][name]', $default, $size, 'placeholder='.$placeholder . $req. $pat)."</div>";
                 $text .= "</div>";
                 $text .= "</div>";
             }
             return $text;
             break;
         case 'date':
             $text = $frm->datepicker($name, time(), 'format=yyyy-mm-dd' . $req);
             break;
         case 'description':
             $text = $frm->textarea($name, $default, 3, 100, $req);
             // pattern not supported.
             break;
         case 'category':
             $allowedCategories = array('generic', 'adult', 'blog', 'clan', 'children', 'corporate', 'forum', 'gaming', 'gallery', 'news', 'social', 'video', 'multimedia');
             sort($allowedCategories);
             $text = $frm->select($name, $allowedCategories, '', 'useValues=1&required=1', true);
             break;
         default:
             $text = $frm->text($name, $default, $size, 'placeholder=' . $placeholder . $req . $pat);
             break;
     }
     $text .= $help ? "<span class='field-help'>" . $help . "</span>" : "";
     return $text;
 }
Example #10
0
 /**
  * Get Remote XML file contents
  * use setOptArrayTags above if you require a consistent array result by in 1 item or many. 
  * @param string $address
  * @param integer $timeout [optional] seconds
  * @return string
  */
 function getRemoteFile($address, $timeout = 10, $postData = null)
 {
     $_file = e107::getFile();
     $this->xmlFileContents = $_file->getRemoteContent($address, array('timeout' => $timeout, 'post' => $postData));
     $this->error = $_file->error;
     return $this->xmlFileContents;
     // ------ MOVED TO FILE HANDLER ------ //
     // Could do something like: if ($timeout <= 0) $timeout = $pref['get_remote_timeout'];  here
     $timeout = min($timeout, 120);
     $timeout = max($timeout, 3);
     $this->xmlFileContents = '';
     $mes = e107::getMessage();
     if ($this->_feedUrl) {
         $mes->addDebug("getting Remote File: " . $this->_feedUrl);
     } else {
         $address = str_replace(array("\r", "\n", "\t"), '', $address);
         // May be paranoia, but streaky thought it might be a good idea
         // ... and there shouldn't be unprintable characters in the URL anyway
     }
     if ($this->urlPrefix !== false) {
         $address = $this->urlPrefix . $address;
     }
     // ... and there shouldn't be unprintable characters in the URL anyway
     // Keep this in first position.
     if (function_exists("curl_init")) {
         $cu = curl_init();
         curl_setopt($cu, CURLOPT_URL, $address);
         curl_setopt($cu, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($cu, CURLOPT_HEADER, 0);
         curl_setopt($cu, CURLOPT_TIMEOUT, $timeout);
         curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($cu, CURLOPT_REFERER, e_REQUEST_HTTP);
         curl_setopt($cu, CURLOPT_FOLLOWLOCATION, 0);
         curl_setopt($cu, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
         curl_setopt($cu, CURLOPT_COOKIEFILE, e_SYSTEM . 'cookies.txt');
         curl_setopt($cu, CURLOPT_COOKIEJAR, e_SYSTEM . 'cookies.txt');
         if (!file_exists(e_SYSTEM . 'cookies.txt')) {
             file_put_contents(e_SYSTEM . 'cookies.txt', '');
         }
         $this->xmlFileContents = curl_exec($cu);
         if (curl_error($cu)) {
             $this->error = "Curl error: " . curl_errno($cu) . ", " . curl_error($cu);
             return FALSE;
         }
         curl_close($cu);
         return $this->xmlFileContents;
     }
     if (function_exists('file_get_contents') && ini_get('allow_url_fopen')) {
         $old_timeout = e107_ini_set('default_socket_timeout', $timeout);
         $address = $this->_feedUrl ? $this->_feedUrl : urldecode($address);
         $data = file_get_contents($address);
         //		  $data = file_get_contents(htmlspecialchars($address));	// buggy - sometimes fails.
         if ($old_timeout !== FALSE) {
             e107_ini_set('default_socket_timeout', $old_timeout);
         }
         if ($data !== FALSE) {
             $this->xmlFileContents = $data;
             return $data;
         }
         $this->error = "File_get_contents(XML) error";
         // Fill in more info later
         return FALSE;
     }
     if (ini_get("allow_url_fopen")) {
         $old_timeout = e107_ini_set('default_socket_timeout', $timeout);
         $remote = @fopen($address, "r");
         if (!$remote) {
             $this->error = "fopen: Unable to open remote XML file: " . $address;
             return FALSE;
         }
     } else {
         $old_timeout = $timeout;
         $tmp = parse_url($address);
         if (!($remote = fsockopen($tmp['host'], 80, $errno, $errstr, $timeout))) {
             $this->error = "Sockets: Unable to open remote XML file: " . $address;
             return FALSE;
         } else {
             socket_set_timeout($remote, $timeout);
             fputs($remote, "GET " . urlencode($address) . " HTTP/1.0\r\n\r\n");
         }
     }
     $this->xmlFileContents = "";
     while (!feof($remote)) {
         $this->xmlFileContents .= fgets($remote, 4096);
     }
     fclose($remote);
     if ($old_timeout != $timeout) {
         if ($old_timeout !== FALSE) {
             e107_ini_set('default_socket_timeout', $old_timeout);
         }
     }
     return $this->xmlFileContents;
 }
Example #11
0
 function get_comp_lan_phrases($comp_dir, $lang, $depth = 0)
 {
     $fl = e107::getFile();
     $ret = array();
     if ($lang_array = $fl->get_files($comp_dir, '\\.php', 'standard', $depth)) {
         sort($lang_array);
     }
     $regexp = strpos($comp_dir, e_LANGUAGEDIR) !== FALSE ? "#.php#" : "#" . $lang . "#";
     foreach ($lang_array as $f) {
         if (preg_match($regexp, $f['path'] . $f['fname'])) {
             $data = file($f['path'] . $f['fname']);
             $relpath = str_replace($comp_dir, "", $f['path']);
             if (substr($data[0], 0, 5) != "<?php") {
                 $key = str_replace(".php", "", $relpath . $f['fname']);
                 $ret['bom'][$key] = $f['fname'];
             }
             if ($f['path'] . $f['fname'] == e_LANGUAGEDIR . $lang . "/" . $lang . ".php") {
                 $f['fname'] = "English.php";
                 // change the key for the main language file.
             }
             if ($f['path'] . $f['fname'] == e_LANGUAGEDIR . $lang . "/" . $lang . "_custom.php") {
                 $f['fname'] = "English_custom.php";
                 // change the key for the main language file.
             }
             $ret = $ret + $this->fill_phrases_array($data, $relpath . $f['fname']);
         }
     }
     return $ret;
 }
Example #12
0
 /**
  * Detect available config locations (readable check), based on available url_modules {@link eDispatcher::adminReadModules()} core preference arrays 
  * Used to rebuild url_locations core preference value
  * @see eDispatcher::adminBuildConfig()
  * @see eDispatcher::adminReadModules()
  * @param array $available {@link eDispatcher::adminReadModules()} stored as url_modules core preference
  * @return array available config locations, stored as url_locations core preference
  */
 public static function adminBuildLocations($available = null)
 {
     $ret = array();
     if (null === $available) {
         $available = self::adminReadModules();
     }
     $fl = e107::getFile();
     // Core
     foreach ($available['core'] as $module) {
         // Default module
         $ret[$module] = array('core');
         // read sub-locations
         $path = eDispatcher::getConfigLocationPath($module, 'core');
         //$sub = $fl->get_dirs($path);
         $sub = eRouter::adminReadConfigs($path);
         if ($sub) {
             foreach ($sub as $moduleSub) {
                 // auto-override: override available (controller or url config), check for config
                 if (in_array($module, $available['override']) && is_readable(eDispatcher::getConfigPath($module, 'override/' . $moduleSub))) {
                     $ret[$module][] = 'override/' . $moduleSub;
                 } elseif (is_readable(eDispatcher::getConfigPath($module, 'core/' . $moduleSub))) {
                     $ret[$module][] = 'core/' . $moduleSub;
                 }
             }
         }
     }
     // Plugins
     foreach ($available['plugin'] as $module) {
         // Default module
         $ret[$module] = array('plugin');
         // read sub-locations
         $path = eDispatcher::getConfigLocationPath($module, 'plugin');
         //$sub = $fl->get_dirs($path);
         $sub = eRouter::adminReadConfigs($path);
         if ($sub) {
             foreach ($sub as $moduleSub) {
                 // auto-override: override available (controller or url config), check for config
                 if (in_array($module, $available['override']) && is_readable(eDispatcher::getConfigPath($module, 'override/' . $moduleSub))) {
                     $ret[$module][] = 'override/' . $moduleSub;
                 } elseif (is_readable(eDispatcher::getConfigPath($module, 'plugin/' . $moduleSub))) {
                     $ret[$module][] = 'plugin/' . $moduleSub;
                 }
             }
         }
     }
     // Go through all overrides, register those who don't belong to core & plugins as standalone core modules
     foreach ($available['override'] as $module) {
         // either it is a core/plugin module or e_url.php is not readable - continue
         if (in_array($module, $available['core']) || in_array($module, $available['plugin'])) {
             continue;
         }
         // Default module
         $ret[$module] = array('override');
         // read sub-locations
         $path = eDispatcher::getConfigLocationPath($module, 'override');
         //$sub = $fl->get_dirs($path);
         $sub = eRouter::adminReadConfigs($path);
         if ($sub) {
             foreach ($sub as $moduleSub) {
                 if (is_readable(eDispatcher::getConfigPath($module, 'override/' . $moduleSub))) {
                     $ret[$module][] = 'override/' . $moduleSub;
                 }
             }
         }
     }
     return $ret;
 }
Example #13
0
function PreFile_Select($formid = 'prefile_selector')
{
    require_once e_HANDLER . "userclass_class.php";
    global $IMAGES_DIRECTORY, $fl;
    $sql = e107::getDb();
    $fl = e107::getFile();
    $filelist = array();
    $downloadList = array();
    /*$sql->db_Select('download', '*', 'download_class != '.e_UC_NOBODY);
    	while ($row = $sql->db_Fetch()) {
    		extract($row);
    		if($download_url)
    		{
    			$filelist[] = array('id' => $download_id, 'name' => $download_name, 'url' => $download_url, 'class' => $download_class);
    			$downloadList[] = $download_url;
    		}
    	}*/
    $tmp = $fl->get_files(e_FILE . 'downloads/');
    foreach ($tmp as $value) {
        if (!in_array($value['fname'], $downloadList)) {
            $filelist[] = array('id' => 0, 'name' => $value['fname'], 'url' => $value['fname']);
        }
    }
    $text = "<!-- Start of PreFile selector -->\n\t<div style='margin-left:0px;margin-right:0px; position:relative;z-index:1000;float:right;display:none' id='{$formid}'>";
    $text .= "<div style='position:absolute; bottom:30px; right:75px'>";
    $text .= "<table class='fborder' style='background-color: #fff'>\n\t<tr><td class='forumheader3' style='white-space: nowrap'>";
    if (!count($filelist)) {
        $text .= LANHELP_40;
    } else {
        $text .= "<select class='tbox' name='prefileselect' onchange=\"addtext(this.value); expandit('{$formid}')\">\n\t\t\t\t<option value=''>" . LANHELP_43 . "</option>";
        foreach ($filelist as $file) {
            if (isset($file['class'])) {
                $ucinfo = "^" . $file['class'];
                $ucname = r_userclass_name($file['class']);
            } else {
                $ucinfo = "";
                $ucname = r_userclass_name(0);
            }
            if ($file['id']) {
                $text .= "<option value=\"[file={e_BASE}request.php?" . $file['id'] . "{$ucinfo}]" . htmlspecialchars($file['name']) . "[/file]\">" . htmlspecialchars($file['name']) . " - {$ucname}</option>\n";
            } else {
                $text .= "<option value=\"[file={e_BASE}request.php?" . htmlspecialchars($file['url']) . "{$ucinfo}]" . htmlspecialchars($file['name']) . "[/file]\">" . htmlspecialchars($file['name']) . " - {$ucname}</option>\n";
            }
        }
        $text .= "</select>";
    }
    $text .= "</td></tr>\t\n </table></div>\n\t</div>\n<!-- End of PreFile selector -->\n";
    return $text;
}
Example #14
0
/**
 *	Parse a file size string (e.g. 16M) and compute the simple numeric value.
 *	Proxy to e_file::file_size_decode().
 *
 *	@see e_file::file_size_decode()
 *	@param string $source - input string which may include 'multiplier' characters such as 'M' or 'G'. Converted to 'decoded value'
 *	@param int $compare - a 'compare' value
 *	@param string $action - values (gt|lt)
 *
 *	@return int file size value.
 *		If the decoded value evaluates to zero, returns the value of $compare
 *		If $action == 'gt', return the larger of the decoded value and $compare
 *		If $action == 'lt', return the smaller of the decoded value and $compare
 */
function file_size_decode($source, $compare = 0, $action = '')
{
    return e107::getFile(true)->file_size_decode($source, $compare, $action);
}
Example #15
0
 public function init()
 {
     $tmp = e107::getFile()->get_files(e_IMAGE . 'ranks', '.*?\\.(png|gif|jpg)');
     $mode = $this->getMode();
     $action = $this->getAction();
     $existing = e107::getDb()->gen("SELECT gen_id FROM #generic WHERE gen_type='user_rank_data' LIMIT 1 ");
     if ($mode == 'ranks' && $action == 'list' && !$existing) {
         $this->createDefaultRecords();
     }
     //	$this->addTitle(LAN_USER_RANKS);
     foreach ($tmp as $k => $v) {
         $id = $v['fname'];
         $this->fields['gen_chardata']['writeParms']['optArray'][$id] = $v['fname'];
     }
     unset($tmp);
     natsort($imageList);
 }
Example #16
0
    /**
     * Display a Video file. 
     * @param string $file - format: id.type eg. x123dkax.youtube 
     * @param boolean $thumbnail  - set to 'tag' to return an image thumbnail and 'src' to return the src url or 'video' for a small video thumbnail. 
     */
    function toVideo($file, $parm = array())
    {
        list($id, $type) = explode(".", $file, 2);
        $thumb = vartrue($parm['thumb']);
        $pref = e107::getPref();
        $ytpref = array();
        foreach ($pref as $k => $v) {
            if (substr($k, 0, 8) == 'youtube_') {
                $key = substr($k, 8);
                $ytpref[$key] = $v;
            }
        }
        $ytqry = http_build_query($ytpref);
        if ($type == 'youtube') {
            //	$thumbSrc = "https://i1.ytimg.com/vi/".$id."/0.jpg";
            $thumbSrc = "http://i1.ytimg.com/vi/" . $id . "/mqdefault.jpg";
            $video = '<iframe width="560" height="315" src="//www.youtube.com/embed/' . $id . '?' . $ytqry . '" style="background-size: 100%;background-image: url(' . $thumbSrc . ');border:0px" allowfullscreen></iframe>';
            if ($thumb == 'tag') {
                return "<img class='img-responsive' src='" . $thumbSrc . "' alt='Youtube Video' style='width:" . vartrue($parm['w'], '80') . "px'/>";
            }
            if ($thumb == 'email') {
                $thumbSrc = "http://i1.ytimg.com/vi/" . $id . "/maxresdefault.jpg";
                // 640 x 480
                $filename = 'temp/yt-thumb-' . md5($id) . ".jpg";
                $filepath = e_MEDIA . $filename;
                $url = 'http://youtu.be/' . $id;
                if (!file_exists($filepath)) {
                    e107::getFile()->getRemoteFile($thumbSrc, $filename, 'media');
                }
                return "<a href='" . $url . "'><img class='video-responsive video-thumbnail' src='{e_MEDIA}" . $filename . "' alt='Youtube Video' title='Click to view on Youtube' />\n\t\t\t\t<div class='video-thumbnail-caption'><small>Click to watch video</small></div></a>";
            }
            if ($thumb == 'src') {
                return $thumbSrc;
            }
            if ($thumb == 'video') {
                return '<div class="video-responsive video-thumbnail thumbnail">' . $video . '</div>';
            }
            return '<div class="video-responsive ' . vartrue($parm['class']) . '">' . $video . '</div>';
        }
        if ($type == 'youtubepl') {
            if ($thumb == 'tag') {
                $thumbSrc = e107::getMedia()->getThumb($id);
                return "<img class='img-responsive' src='" . $thumbSrc . "' alt='Youtube Video Playlist' style='width:" . vartrue($parm['w'], '80') . "px'/>";
            }
            if ($thumb == 'src') {
                return e107::getMedia()->getThumb($id);
            }
            $video = '<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=' . $id . '" style="border:0" allowfullscreen></iframe>';
            return '<div class="video-responsive ' . vartrue($parm['class']) . '">' . $video . '</div>';
        }
        if ($type == 'mp4') {
            return '
			<div class="video-responsive">
			<video width="320" height="240" controls>
			  <source src="' . $file . '" type="video/mp4">
		
			  Your browser does not support the video tag.
			</video>
			</div>';
        }
        return false;
    }
Example #17
0
+ ----------------------------------------------------------------------------+
|     e107 website system
|
|     Copyright (C) 2008-2013 e107 Inc 
|     http://e107.org
|
|     Released under the terms and conditions of the
|     GNU General Public License (http://gnu.org).
|		
|	  Generic File Request Script. 
|
+----------------------------------------------------------------------------+
*/
require_once "class2.php";
if (!e_QUERY || isset($_POST['userlogin'])) {
    header("location: " . SITEURL);
    // $e107->base_path
    exit;
}
// Media-Manager direct file download.
if (vartrue($_GET['file']) && is_numeric($_GET['file'])) {
    $sql = e107::getDb();
    if ($sql->select('core_media', 'media_url', "media_id= " . intval($_GET['file']) . " AND media_userclass IN (" . USERCLASS_LIST . ") LIMIT 1 ")) {
        $row = $sql->fetch();
        // $file = $tp->replaceConstants($row['media_url'],'rel');
        e107::getFile()->send($row['media_url']);
    }
} else {
    e107::getRedirect()->redirect(e_PLUGIN . "download/request.php?" . e_QUERY);
}
exit;
Example #18
0
 function show_existing_mirrors()
 {
     $sql = e107::getDb();
     $tp = e107::getParser();
     $mes = e107::getMessage();
     $fl = e107::getFile();
     $action = $this->action;
     $subAction = $this->subAction;
     $id = $this->id;
     global $delete, $del_id, $admin_log;
     require_once e_HANDLER . "form_handler.php";
     $frm = new e_form();
     if ($delete == "mirror") {
         $mes->addAuto($sql->db_Delete("download_mirror", "mirror_id=" . $del_id), delete, DOWLAN_135);
         e107::getLog()->add('DOWNL_14', 'ID: ' . $del_id, E_LOG_INFORMATIVE, '');
     }
     if (!$sql->select("download_mirror")) {
         $mes->addInfo(DOWLAN_144);
         // $text = "<div style='text-align:center;'>".DOWLAN_144."</div>"; // No mirrors defined yet
     } else {
         $text = "<div>\n\t         <form method='post' action='" . e_SELF . "?" . e_QUERY . "'>\n\t         <table style='" . ADMIN_WIDTH . "' class='adminlist'>\n\t         <tr>\n\t         <td style='width: 10%; text-align: center;' class='forumheader'>ID</td>\n\t         <td style='width: 30%;' class='forumheader'>" . DOWLAN_12 . "</td>\n\t         <td style='width: 30%;' class='forumheader'>" . DOWLAN_136 . "</td>\n\t         <td style='width: 30%; text-align: center;' class='forumheader'>" . LAN_OPTIONS . "</td>\n\t         </tr>\n\t         ";
         $mirrorList = $sql->db_getList();
         foreach ($mirrorList as $mirror) {
             extract($mirror);
             $text .= "\n\t\n\t            <tr>\n\t            <td style='width: 10%; text-align: center;'>{$mirror_id}</td>\n\t            <td style='width: 30%;'>" . $tp->toHTML($mirror_name) . "</td>\n\t            <td style='width: 30%;'>" . ($mirror_image ? "<img src='" . e_FILE . "downloadimages/" . $mirror_image . "' alt=''/>" : DOWLAN_28) . "</td>\n\t            <td style='width: 30%; text-align: center;'>\n\t            <a href='" . e_SELF . "?mirror.edit.{$mirror_id}'>" . ADMIN_EDIT_ICON . "</a>\n\t            <input type='image' title='" . LAN_DELETE . "' name='delete[mirror_{$mirror_id}]' src='" . ADMIN_DELETE_ICON_PATH . "' onclick=\"return jsconfirm('" . DOWLAN_137 . " [ID: {$mirror_id} ]')\"/>\n\t            </td>\n\t            </tr>\n\t            ";
         }
         $text .= "</table></form></div>";
     }
     // $ns -> tablerender(DOWLAN_138, $text);
     echo $text;
     $imagelist = $fl->get_files(e_FILE . 'downloadimages/');
     if ($subAction == "edit" && !defined("SUBMITTED")) {
         $sql->select("download_mirror", "*", "mirror_id='" . intval($id) . "' ");
         $mirror = $sql->fetch();
         extract($mirror);
         $edit = TRUE;
     } else {
         unset($mirror_name, $mirror_url, $mirror_image, $mirror_location, $mirror_description);
         $edit = FALSE;
     }
     $text = "<div>\n\t      <form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='dataform'>\n\n\t      <table class='table adminform'>\n\t\n\t      <tr>\n\t      <td style='width: 30%;'>" . DOWLAN_12 . "</td>\n\t      <td style='width: 70%;'>\n\t      <input class='tbox' type='text' name='mirror_name' size='60' value='{$mirror_name}' maxlength='200'/>\n\t      </td>\n\t      </tr>\n\t\n\t      <tr>\n\t      <td style='width: 30%;'>" . DOWLAN_139 . "</td>\n\t      <td style='width: 70%;'>\n\t      <input class='tbox' type='text' name='mirror_url' size='70' value='{$mirror_url}' maxlength='255'/>\n\t      </td>\n\t      </tr>\n\t\n\t      <tr>\n\t      <td style='width: 30%;'>" . DOWLAN_136 . "</td>\n\t      <td style='width: 70%;'>\n\t      <input class='tbox' type='text' id='mirror_image' name='mirror_image' size='60' value='{$mirror_image}' maxlength='200'/>\n\t\n\t\n\t      <br /><input class='btn btn-default button' type ='button' style='cursor:pointer' size='30' value='" . DOWLAN_42 . "' onclick='expandit(this)'/>\n\t      <div id='imagefile' style='display:none;{head}'>";
     $text .= DOWLAN_140 . "<br/>";
     foreach ($imagelist as $file) {
         $text .= "<a href=\"javascript:insertext('" . $file['fname'] . "','mirror_image','imagefile')\"><img src='" . e_FILE . "downloadimages/" . $file['fname'] . "' alt=''/></a> ";
     }
     $text .= "</div>\n\t      </td>\n\t      </tr>\n\t\n\t      <tr>\n\t      <td style='width: 30%;'>" . DOWLAN_141 . "</td>\n\t      <td style='width: 70%;'>\n\t      <input class='tbox' type='text' name='mirror_location' size='60' value='{$mirror_location}' maxlength='200'/>\n\t      </td>\n\t      </tr>\n\t\n\t      <tr>\n\t      <td style='width: 30%;'>" . DOWLAN_18 . "</td>\n\t      <td style='width: 70%;'>";
     $text .= $frm->bbarea('mirror_description', $mirror_description);
     $text .= "</td>\n\t      </tr>\n\t\n\t      <tr>\n\t      <td colspan='2' class='forumheader' style='text-align:center;'>\n\t      " . ($edit ? "<input class='btn btn-default button' type='submit' name='submit_mirror' value='" . DOWLAN_142 . "'/><input type='hidden' name='id' value='{$mirror_id}'/>" : "<input class='btn button' type='submit' name='submit_mirror' value='" . DOWLAN_143 . "'/>") . "\n\t      </td>\n\t      </tr>\n\t\n\t      </table>\n\t      </form>\n\t      </div>";
     $caption = $edit ? DOWLAN_142 : DOWLAN_143;
     echo $text;
     // $ns -> tablerender($caption, $text);
 }
Example #19
0
 function processUpload()
 {
     $ns = e107::getRender();
     $sql = e107::getDb();
     $mes = e107::getMessage();
     $tp = e107::getParser();
     $error = false;
     $postemail = '';
     if (($_POST['file_email'] || USER == TRUE) && $_POST['file_name'] && $_POST['file_description'] && $_POST['download_category']) {
         //	$uploaded = file_upload(e_FILE."public/", "unique");
         $fl = e107::getFile();
         $uploaded = $fl->getUploaded(e_UPLOAD, "unique", array('max_file_count' => 2, 'extra_file_types' => TRUE));
         //      $uploaded = process_uploaded_files(e_UPLOAD, "unique", array('max_file_count' => 2, 'extra_file_types' => TRUE));
         // First, see what errors the upload handler picked up
         if ($uploaded === FALSE) {
             $error = true;
             $mes->addError(LAN_UL_021);
         }
         // Now see if we have a code file
         if (count($uploaded) > 0) {
             if ($uploaded[0]['error'] == 0) {
                 $file = $uploaded[0]['name'];
                 $filesize = $uploaded[0]['size'];
             } else {
                 $error = true;
                 $mes->addError($uploaded[0]['message']);
             }
         }
         // Now see if we have an image file
         if (count($uploaded) > 1) {
             if ($uploaded[1]['error'] == 0) {
                 $image = $uploaded[1]['name'];
             } else {
                 $error = true;
                 $mes->addError($uploaded[1]['message']);
             }
         }
         // The upload handler checks max file size
         $downloadCategory = intval($_POST['download_category']);
         if (!$downloadCategory) {
             $error = true;
             $mes->addError(LAN_UL_037);
         }
         // an error - delete the files to keep things tidy
         if ($error) {
             @unlink($file);
             @unlink($image);
         } else {
             if (USER) {
                 $poster = USERID;
                 $row = e107::getUser()->toArray();
                 if ($row['user_hideemail']) {
                     $postemail = '-witheld-';
                 } else {
                     $postemail = USEREMAIL;
                 }
             } else {
                 $poster = "0";
                 //.$tp -> toDB($_POST['file_poster']);
                 $postemail = $tp->toDB($_POST['file_email']);
             }
             if ($postemail != '-witheld-' && !check_email($postemail)) {
                 $error = true;
                 $mes->addError(LAN_UL_001);
             } else {
                 if ($postemail == '-witheld-') {
                     $postemail = '';
                 }
                 $_POST['file_description'] = $tp->toDB($_POST['file_description']);
                 $file_time = time();
                 $sql->insert("upload", "0, '" . $poster . "', '" . $postemail . "', '" . $tp->toDB($_POST['file_website']) . "', '" . $file_time . "', '" . $tp->toDB($_POST['file_name']) . "', '" . $tp->toDB($_POST['file_version']) . "', '" . $file . "', '" . $image . "', '" . $tp->toDB($_POST['file_description']) . "', '" . $tp->toDB($_POST['file_demo']) . "', '" . $filesize . "', 0, '" . $downloadCategory . "'");
                 $edata_fu = array("upload_user" => $poster, "upload_email" => $postemail, "upload_name" => $tp->toDB($_POST['file_name']), "upload_file" => $file, "upload_version" => $_POST['file_version'], "upload_description" => $tp->toDB($_POST['file_description']), "upload_size" => $filesize, "upload_category" => $downloadCategory, "upload_website" => $tp->toDB($_POST['file_website']), "upload_image" => $image, "upload_demo" => $tp->toDB($_POST['file_demo']), "upload_time" => $file_time);
                 e107::getEvent()->trigger("fileupload", $edata_fu);
                 // BC
                 e107::getEvent()->trigger("user_file_upload", $edata_fu);
                 $mes->addSuccess(LAN_404);
             }
         }
     } else {
         // Error - missing data
         $mes->addError(LAN_ERROR_29);
     }
     echo e107::getMessage()->render();
 }
Example #20
0
 /**
  * Auto-render Form Element
  * @param string $key
  * @param mixed $value
  * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
  * #param array (under construction) $required_data required array as defined in e_model/validator
  * @return string
  */
 function renderElement($key, $value, $attributes, $required_data = array(), $id = 0)
 {
     //	return print_a($value,true);
     $parms = vartrue($attributes['writeParms'], array());
     $tp = e107::getParser();
     if (is_string($parms)) {
         parse_str($parms, $parms);
     }
     if (!empty($attributes['multilan'])) {
         $value = is_array($value) ? varset($value[e_LANGUAGE], '') : $value;
         $parms['post'] = "<small class='e-tip admin-multilanguage-field input-group-addon' style='cursor:help; padding-left:10px' title='Multi-language field'>" . $tp->toGlyph('fa-language') . "</small>";
     }
     if (empty($value) && !empty($parms['default'])) {
         $value = $parms['default'];
     }
     // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless.
     if (vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly']) === 2)) {
         if (vartrue($attributes['writeParms'])) {
             $attributes['readParms'] = $attributes['writeParms'];
         }
         return $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
         //
     }
     // FIXME standard - writeParams['__options'] is introduced for list elements, bundle adding to writeParms is non reliable way
     $writeParamsOptionable = array('dropdown', 'comma', 'radio', 'lanlist', 'language', 'user');
     $writeParamsDisabled = array('layouts', 'templates', 'userclass', 'userclasses');
     // FIXME it breaks all list like elements - dropdowns, radio, etc
     if (vartrue($required_data[0]) || vartrue($attributes['required'])) {
         // FIXME - another approach, raise standards, remove checks
         if (in_array($attributes['type'], $writeParamsOptionable)) {
             $parms['__options']['required'] = 1;
         } elseif (!in_array($attributes['type'], $writeParamsDisabled)) {
             $parms['required'] = 1;
         }
     }
     // FIXME it breaks all list like elements - dropdowns, radio, etc
     if (vartrue($required_data[3]) || vartrue($attributes['pattern'])) {
         // FIXME - another approach, raise standards, remove checks
         if (in_array($attributes['type'], $writeParamsOptionable)) {
             $parms['__options']['pattern'] = vartrue($attributes['pattern'], $required_data[3]);
         } elseif (!in_array($attributes['type'], $writeParamsDisabled)) {
             $parms['pattern'] = vartrue($attributes['pattern'], $required_data[3]);
         }
     }
     // XXX Fixes For the above.  - use optArray variable. eg. $field['key']['writeParms']['optArray'] = array('one','two','three');
     if (($attributes['type'] == 'dropdown' || $attributes['type'] == 'radio' || $attributes['type'] == 'checkboxes') && !empty($parms['optArray'])) {
         $fopts = $parms;
         $parms = $fopts['optArray'];
         unset($fopts['optArray']);
         $parms['__options'] = $fopts;
     }
     $this->renderElementTrigger($key, $value, $parms, $required_data, $id);
     switch ($attributes['type']) {
         case 'number':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             if (!vartrue($parms['size'])) {
                 $parms['size'] = 'mini';
             }
             if (!vartrue($parms['class'])) {
                 $parms['class'] = 'tbox number e-spinner';
             }
             if (!$value) {
                 $value = '0';
             }
             $ret = vartrue($parms['pre']) . $this->number($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             break;
         case 'ip':
             $ret = vartrue($parms['pre']) . $this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms) . vartrue($parms['post']);
             break;
         case 'email':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->email($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'url':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->url($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
             //	case 'email':
         //	case 'email':
         case 'password':
             // encrypts to md5 when saved.
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'text':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             if (!empty($parms['password'])) {
                 $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             } else {
                 $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, $parms) . vartrue($parms['post']);
                 // vartrue($parms['__options']) is limited. See 'required'=>true
             }
             if (!empty($attributes['multilan'])) {
                 $ret = "<span class='input-group input-xxlarge'>" . $ret . "</span>";
             }
             break;
         case 'tags':
             $maxlength = vartrue($parms['maxlength'], 255);
             $ret = vartrue($parms['pre']) . $this->tags($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'textarea':
             $text = "";
             if (vartrue($parms['append']) && vartrue($value)) {
                 $attributes['readParms'] = 'bb=1';
                 $text = $this->renderValue($key, $value, $attributes);
                 $text .= '<br />';
                 $value = "";
                 // Appending needs is  performed and customized using function: beforeUpdate($new_data, $old_data, $id)
             }
             $text .= vartrue($parms['pre']) . $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'], $parms), varset($parms['counter'], false)) . vartrue($parms['post']);
             $ret = $text;
             break;
         case 'bbarea':
             $options = array('counter' => varset($parms['counter'], false));
             // Media = media-category owner used by media-manager.
             $ret = vartrue($parms['pre']) . $this->bbarea($key, $value, vartrue($parms['template']), vartrue($parms['media']), vartrue($parms['size'], 'medium'), $options) . vartrue($parms['post']);
             break;
         case 'image':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->imagepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'images':
             //	return print_a($value, true);
             $ret = "";
             $label = varset($parms['label'], 'LAN_EDIT');
             for ($i = 0; $i < 5; $i++) {
                 $k = $key . '[' . $i . '][path]';
                 $ival = $value[$i]['path'];
                 $ret .= $this->imagepicker($k, $ival, defset($label, $label), $parms);
             }
             break;
         case 'files':
             if ($attributes['data'] == 'array') {
                 $parms['data'] = 'array';
             }
             $ret = '<ol>';
             for ($i = 0; $i < 5; $i++) {
                 //	$k 		= $key.'['.$i.'][path]';
                 //	$ival 	= $value[$i]['path'];
                 $k = $key . '[' . $i . ']';
                 $ival = $value[$i];
                 $ret .= '<li>' . $this->filepicker($k, $ival, defset($label, $label), $parms) . '</li>';
             }
             $ret .= '</ol>';
             break;
         case 'file':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->filepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'icon':
             $label = varset($parms['label'], 'LAN_EDIT');
             $ajax = varset($parms['ajax'], true) ? true : false;
             unset($parms['label'], $parms['ajax']);
             $ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax);
             break;
         case 'date':
             // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         case 'datestamp':
             // If hidden, value is updated regardless. eg. a 'last updated' field.
             // If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
             // otherwise it is added. eg. during the creation of a new record.
             if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) {
                 $value = time();
             }
             if (vartrue($parms['readonly'])) {
                 $ret = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
             } elseif (vartrue($parms['hidden'])) {
                 $ret = $this->hidden($key, $value);
             } else {
                 $ret = $this->datepicker($key, $value, $parms);
             }
             break;
         case 'layouts':
             //to do - exclude param (exact match)
             $location = varset($parms['plugin']);
             // empty - core
             $ilocation = vartrue($parms['id'], $location);
             // omit if same as plugin name
             $where = vartrue($parms['area'], 'front');
             //default is 'front'
             $filter = varset($parms['filter']);
             $merge = vartrue($parms['merge']) ? true : false;
             $layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true);
             if (varset($parms['default']) && !isset($layouts[0]['default'])) {
                 $layouts[0] = array('default' => $parms['default']) + $layouts[0];
             }
             $info = array();
             if ($layouts[1]) {
                 foreach ($layouts[1] as $k => $info_array) {
                     if (isset($info_array['description'])) {
                         $info[$k] = defset($info_array['description'], $info_array['description']);
                     }
                 }
             }
             //$this->selectbox($key, $layouts, $value)
             $ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, array('sep' => "<br />"), $info);
             break;
         case 'templates':
             //to do - exclude param (exact match)
             $templates = array();
             if (varset($parms['default'])) {
                 $templates['default'] = defset($parms['default'], $parms['default']);
             }
             $location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME;
             $ilocation = vartrue($parms['location']);
             $tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             // override
             $where = vartrue($parms['area'], 'front');
             $location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : '';
             $tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             $ret = vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value);
             break;
         case 'checkboxes':
             if (is_array($parms)) {
                 $eloptions = vartrue($parms['__options'], array());
                 if (is_string($eloptions)) {
                     parse_str($eloptions, $eloptions);
                 }
                 if ($attributes['type'] === 'comma') {
                     $eloptions['multiple'] = true;
                 }
                 unset($parms['__options']);
                 if (!is_array($value) && !empty($value)) {
                     $value = explode(",", $value);
                 }
                 $ret = vartrue($eloptions['pre']) . $this->checkboxes($key, $parms, $value, $eloptions) . vartrue($eloptions['post']);
             }
             return $ret;
             break;
         case 'dropdown':
         case 'comma':
             $eloptions = vartrue($parms['__options'], array());
             if (is_string($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             if ($attributes['type'] === 'comma') {
                 $eloptions['multiple'] = true;
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $parms, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         case 'radio':
             // TODO - more options (multi-line, help)
             $eloptions = vartrue($parms['__options'], array());
             if (is_string($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             $ret = vartrue($eloptions['pre']) . $this->radio_multi($key, $parms, $value, $eloptions, false) . vartrue($eloptions['post']);
             break;
         case 'userclass':
         case 'userclasses':
             $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes');
             // defaults to 'public,guest,nobody,member,classes' (userclass handler)
             unset($parms['classlist']);
             //	$method = ($attributes['type'] == 'userclass') ? 'uc_select' : 'uc_select';
             if (vartrue($attributes['type']) == 'userclasses') {
                 $parms['multiple'] = true;
             }
             $ret = vartrue($parms['pre']) . $this->uc_select($key, $value, $uc_options, vartrue($parms, array())) . vartrue($parms['post']);
             break;
             /*case 'user_name':
             		case 'user_loginname':
             		case 'user_login':
             		case 'user_customtitle':
             		case 'user_email':*/
         /*case 'user_name':
         		case 'user_loginname':
         		case 'user_login':
         		case 'user_customtitle':
         		case 'user_email':*/
         case 'user':
             //user_id expected
             // Just temporary solution, could be changed soon
             if (!isset($parms['__options'])) {
                 $parms['__options'] = array();
             }
             if (!is_array($parms['__options'])) {
                 parse_str($parms['__options'], $parms['__options']);
             }
             if (empty($value) && varset($parms['currentInit'], USERID) !== 0 || vartrue($parms['current'])) {
                 $value = USERID;
                 if (vartrue($parms['current'])) {
                     $parms['__options']['readonly'] = true;
                 }
             }
             if (!is_array($value)) {
                 $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();
                 // e107::user($value);
             }
             $colname = vartrue($parms['nameType'], 'user_name');
             $parms['__options']['name'] = $colname;
             if (!$value) {
                 $value = array();
             }
             $uname = varset($value[$colname]);
             $value = varset($value['user_id'], 0);
             $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options']));
             break;
         case 'bool':
         case 'boolean':
             if (varset($parms['label']) === 'yesno') {
                 $lenabled = 'LAN_YES';
                 $ldisabled = 'LAN_NO';
             } else {
                 $lenabled = vartrue($parms['enabled'], 'LAN_ENABLED');
                 $ldisabled = vartrue($parms['disabled'], 'LAN_DISABLED');
             }
             unset($parms['enabled'], $parms['disabled'], $parms['label']);
             $ret = vartrue($parms['pre']) . $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled), $parms) . vartrue($parms['post']);
             break;
         case "checkbox":
             $value = isset($parms['value']) ? $parms['value'] : $value;
             $ret = vartrue($parms['pre']) . $this->checkbox($key, 1, $value, $parms) . vartrue($parms['post']);
             break;
         case 'method':
             // Custom Function
             $meth = !empty($attributes['method']) ? $attributes['method'] : $key;
             $parms['field'] = $key;
             $ret = call_user_func_array(array($this, $meth), array($value, 'write', $parms));
             break;
         case 'upload':
             //TODO - from method
             // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms)
             $disbut = varset($parms['disable_button'], '0');
             $ret = $tp->parseTemplate("{UPLOADFILE=" . (vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD) . "|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}");
             break;
         case 'hidden':
             $value = isset($parms['value']) ? $parms['value'] : $value;
             $ret = vartrue($parms['show']) ? $value ? $value : varset($parms['empty'], $value) : '';
             $ret = $ret . $this->hidden($key, $value);
             break;
         case 'lanlist':
             // installed languages
         // installed languages
         case 'language':
             // all languages
             $options = $attributes['type'] === 'language' ? e107::getLanguage()->getList() : e107::getLanguage()->getLanSelectArray();
             $eloptions = vartrue($parms['__options'], array());
             if (!is_array($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $options, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         case null:
             //	Possibly used in db but should not be submitted in form. @see news_extended.
             break;
         default:
             // No LAN necessary, debug only.
             $ret = ADMIN ? "<span class='alert alert-error alert-danger'>" . LAN_ERROR . " Unknown 'type' : " . $attributes['type'] . "</span>" : $value;
             break;
     }
     if (vartrue($parms['expand'])) {
         $k = "exp-" . $this->name2id($key);
         $text = "<a class='e-expandit e-tip' href='#{$k}'>" . $parms['expand'] . "</a>";
         $text .= vartrue($parms['help']) ? '<div class="field-help">' . $parms['help'] . '</div>' : '';
         $text .= "<div id='{$k}' class='e-hideme'>" . $ret . "</div>";
         return $text;
     } else {
         $ret .= vartrue($parms['help']) ? '<div class="field-help">' . $tp->toHtml($parms['help'], false, 'defs') . '</div>' : '';
     }
     return $ret;
 }
Example #21
0
 /**
  * Save a Media-Manager thumbnail from remote location.
  * @param string $imageUrl
  * @param string $id
  * @return bool|string
  */
 function saveThumb($imageUrl = '', $id = '')
 {
     if (empty($id) || empty($imageUrl)) {
         return false;
     }
     $filename = 'temp/thumb-' . md5($id) . ".jpg";
     $filepath = e_MEDIA . $filename;
     if (!file_exists($filepath)) {
         e107::getFile()->getRemoteFile($imageUrl, $filename, 'media');
     }
     return $filepath;
 }
Example #22
0
 function batchImport()
 {
     $fl = e107::getFile();
     $mes = e107::getMessage();
     $sql = e107::getDb();
     $tp = e107::getParser();
     if (!count($_POST['batch_selected'])) {
         $mes->addError(IMALAN_126);
         return;
     }
     list($img_import_w, $img_import_h) = explode("x", e107::getPref('img_import_resize'));
     if (vartrue($_POST['batch_import_watermark'])) {
         $WM = TRUE;
         $watermarkPath = e_THEME . e107::getPref('sitetheme') . "/images/watermark.png";
         $watermark = PhpThumbFactory::create($watermarkPath);
     } else {
         $WM = FALSE;
     }
     // Disable resize-on-import and watermark for now.
     $img_import_w = 2816;
     $img_import_h = 2112;
     foreach ($_POST['batch_selected'] as $key => $file) {
         //	$oldpath = e_MEDIA."temp/".$file;
         $oldpath = e_IMPORT . $file;
         // Resize on Import Routine ------------------------
         if (vartrue($img_import_w) && vartrue($img_import_h)) {
             // $this->resizeImage($file,$img_import_w,$img_import_h);
         }
         // End Resize routine. ---------------------
         $f = $fl->get_file_info($oldpath);
         if (!$f['mime']) {
             $mes->add(IMALAN_127 . " " . $oldpath, E_MESSAGE_WARNING);
             // $mes->add(print_a($f,true), E_MESSAGE_ERROR);
             $f['mime'] = "other/file";
         }
         $newpath = $this->checkDupe($oldpath, $this->getPath($f['mime']) . '/' . $file);
         $newname = $tp->toDB($_POST['batch_import_name'][$key]);
         $newdiz = $tp->toDB($_POST['batch_import_diz'][$key]);
         $f['fname'] = $file;
         /*
         	
         			if(file_exists($newpath) || $sql->db_Select("core_media","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
         			{
         				$mes->addWarning($newpath." already exists and was renamed during import.");	
         				$file = $f['pathinfo']['filename']."_.".$f['pathinfo']['extension'];
         				$newpath = $this->getPath($f['mime']).'/'.$file;						
         			}
         */
         if (rename($oldpath, $newpath)) {
             $insert = array('media_caption' => $newdiz, 'media_description' => '', 'media_category' => $_POST['batch_category'], 'media_datestamp' => $f['modified'], 'media_url' => $tp->createConstants($newpath, 'rel'), 'media_userclass' => '0', 'media_name' => $newname, 'media_author' => USERID, 'media_size' => $f['fsize'], 'media_dimensions' => $f['img-width'] . " x " . $f['img-height'], 'media_usedby' => '', 'media_tags' => '', 'media_type' => $f['mime']);
             if ($sql->db_Insert("core_media", $insert)) {
                 $mes->add(IMALAN_128 . " " . $f['fname'], E_MESSAGE_SUCCESS);
                 $this->deleteFileXml($f['fname']);
             } else {
                 rename($newpath, $oldpath);
                 //move it back.
             }
         }
     }
 }
Example #23
0
 function get_comp_lan_phrases($comp_dir, $lang, $depth = 0)
 {
     if (!is_dir($comp_dir)) {
         return array();
     }
     $fl = e107::getFile();
     $ret = array();
     if ($lang_array = $fl->get_files($comp_dir, ".php\$", "standard", $depth)) {
         sort($lang_array);
     }
     if (strpos($comp_dir, e_LANGUAGEDIR) !== false) {
         $regexp = "#.php#";
         $mode = 'core';
     } else {
         $regexp = "#" . $lang . "#";
         $mode = 'plugins';
     }
     //	$regexp = (strpos($comp_dir,e_LANGUAGEDIR) !== FALSE) ? "#.php#" : "#".$lang."#";
     foreach ($lang_array as $f) {
         if ($mode == 'plugins') {
             $tmpDir = str_replace($comp_dir, '', $f['path']);
             //	echo "<br />".$tmpDir;
             list($pluginDirectory, $other) = explode("/", $tmpDir, 2);
             if ($mode == 'plugins' && $this->thirdPartyPlugins !== true && !in_array($pluginDirectory, $this->core_plugins)) {
                 continue;
             }
         }
         if (preg_match($regexp, $f['path'] . $f['fname']) && is_file($f['path'] . $f['fname'])) {
             $allData = file_get_contents($f['path'] . $f['fname']);
             $data = explode("\n", $allData);
             // $data = file($f['path'].$f['fname']);
             $relpath = str_replace($comp_dir, "", $f['path']);
             $key = str_replace(".php", "", $relpath . $f['fname']);
             if (substr($data[0], 0, 5) != "<?php") {
                 $ret['bom'][$key] = $f['fname'];
             }
             $end_of_file = 0;
             foreach ($data as $line) {
                 if ($end_of_file == 1) {
                     $ret['bom'][$key] = $f['fname'];
                 }
                 $line = trim($line);
                 if ($line == "?>") {
                     $end_of_file = 1;
                 }
             }
             if ($f['path'] . $f['fname'] == e_LANGUAGEDIR . $lang . "/" . $lang . ".php") {
                 $f['fname'] = "English.php";
                 // change the key for the main language file.
             }
             if ($f['path'] . $f['fname'] == e_LANGUAGEDIR . $lang . "/" . $lang . "_custom.php") {
                 $f['fname'] = "English_custom.php";
                 // change the key for the main language file.
             }
             $ret = $ret + $this->fill_phrases_array($allData, $relpath . $f['fname']);
         }
     }
     return $ret;
 }
Example #24
0
File: db.php Project: notzen/e107
 /**
  * Correct Folder and File permissions. 
  */
 function correct_perms()
 {
     $mes = e107::getMessage();
     $fl = e107::getFile();
     ob_start();
     $fl->chmod(e_BASE);
     $fl->chmod(e_BASE . "cron.php", 0755);
     $errors = ob_get_clean();
     if ($errors != '') {
         $mes->addError($errors);
     } else {
         $mes->addSuccess("Folder and File permissions have been updated");
     }
     e107::getRender()->tablerender("Correcting File and Directory Permissions", $mes->render());
 }
Example #25
0
 function step1()
 {
     $fl = e107::getFile();
     $frm = e107::getForm();
     $ns = e107::getRender();
     $mes = e107::getMessage();
     $plugFolders = $fl->get_dirs(e_PLUGIN);
     foreach ($plugFolders as $dir) {
         $lanDir[$dir] = $dir;
         if (E107_DEBUG_LEVEL == 0 && file_exists(e_PLUGIN . $dir . "/admin_config.php")) {
             continue;
         }
         $newDir[$dir] = $dir;
     }
     $info = EPL_ADLAN_102;
     $info .= "<ul>";
     $info .= "<li>" . str_replace('[x]', e_PLUGIN, EPL_ADLAN_103) . "</li>";
     $info .= "<li>" . EPL_ADLAN_104 . "</li>";
     $info .= "<li>" . EPL_ADLAN_105 . "</li>";
     $info .= "<li>" . EPL_ADLAN_106 . "</li>";
     $info .= "</ul>";
     $mes->addInfo($info);
     $text = $frm->open('createPlugin', 'get');
     $text .= "<table class='table adminform'>\n\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t\t</colgroup>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . EPL_ADLAN_107 . "</td>\n\t\t\t\t\t<td><div class='input-append form-inline'>" . $frm->open('createPlugin', 'get', e_SELF . "?mode=create") . $frm->select("newplugin", $newDir) . $frm->admin_button('step', 2, 'other', 'Go') . "</div> " . $frm->checkbox('createFiles', 1, 1, 'Create Files') . $frm->close() . "</td>\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . EPL_ADLAN_108 . "</td>\n\t\t\t\t\t<td><div class='input-append form-inline'>" . $frm->open('checkPluginLangs', 'get', e_SELF . "?mode=lans") . $frm->select("newplugin", $lanDir) . $frm->admin_button('step', 2, 'other', 'Go') . "</div> " . $frm->close() . "</td>\n\t\t\t\t</tr>";
     /* NOT a good idea - requires the use of $_POST which would prevent browser 'go Back' navigation. 
     			if(e_DOMAIN == FALSE) // localhost. 
     			{
     				$text .= "<tr>
     					<td>Pasted MySql Dump Here</td>
     					<td>".$frm->textarea('mysql','', 10,80)."
     					<span class='field-help'>eg. </span></td>
     					</tr>";			
     			}
     			*/
     $text .= "\t\t\t\t\n\t\t\t\t</table>\n\t\t\t\t<div class='buttons-bar center'>\n\t\t\t\t\n\t\t\t\t</div>";
     $text .= $frm->close();
     $ns->tablerender(ADLAN_98 . SEP . EPL_ADLAN_114, $mes->render() . $text);
     //	$var['lans']['text'] = EPL_ADLAN_226;
     //		$var['lans']['link'] = e_SELF."?mode=lans";
 }
Example #26
0
    /**
     * Display a Video file. 
     * @param string $file - format: id.type eg. x123dkax.youtube 
     * @param boolean $thumbnail  - set to 'tag' to return an image thumbnail and 'src' to return the src url or 'video' for a small video thumbnail. 
     */
    function toVideo($file, $parm = array())
    {
        if (empty($file)) {
            return false;
        }
        list($id, $type) = explode(".", $file, 2);
        $thumb = vartrue($parm['thumb']);
        $pref = e107::getPref();
        $ytpref = array();
        foreach ($pref as $k => $v) {
            if (substr($k, 0, 8) == 'youtube_') {
                $key = substr($k, 8);
                $ytpref[$key] = $v;
            }
        }
        unset($ytpref['bbcode_responsive']);
        // do not include in embed code.
        if (!empty($ytpref['cc_load_policy'])) {
            $ytpref['cc_lang_pref'] = e_LAN;
            // switch captions with chosen user language.
        }
        $ytqry = http_build_query($ytpref);
        $defClass = deftrue('BOOTSTRAP') ? "embed-responsive embed-responsive-16by9" : "video-responsive";
        // levacy backup.
        if ($type == 'youtube') {
            //	$thumbSrc = "https://i1.ytimg.com/vi/".$id."/0.jpg";
            $thumbSrc = "http://i1.ytimg.com/vi/" . $id . "/mqdefault.jpg";
            $video = '<iframe class="embed-responsive-item" width="560" height="315" src="//www.youtube.com/embed/' . $id . '?' . $ytqry . '" style="background-size: 100%;background-image: url(' . $thumbSrc . ');border:0px" allowfullscreen></iframe>';
            if ($thumb == 'tag') {
                return "<img class='img-responsive' src='" . $thumbSrc . "' alt='Youtube Video' style='width:" . vartrue($parm['w'], '80') . "px'/>";
            }
            if ($thumb == 'email') {
                $thumbSrc = "http://i1.ytimg.com/vi/" . $id . "/maxresdefault.jpg";
                // 640 x 480
                $filename = 'temp/yt-thumb-' . md5($id) . ".jpg";
                $filepath = e_MEDIA . $filename;
                $url = 'http://youtu.be/' . $id;
                if (!file_exists($filepath)) {
                    e107::getFile()->getRemoteFile($thumbSrc, $filename, 'media');
                }
                return "<a href='" . $url . "'><img class='video-responsive video-thumbnail' src='{e_MEDIA}" . $filename . "' alt='Youtube Video' title='Click to view on Youtube' />\n\t\t\t\t<div class='video-thumbnail-caption'><small>Click to watch video</small></div></a>";
            }
            if ($thumb == 'src') {
                return $thumbSrc;
            }
            if ($thumb == 'video') {
                return '<div class="' . $defClass . ' video-thumbnail thumbnail">' . $video . '</div>';
            }
            return '<div class="' . $defClass . ' ' . vartrue($parm['class']) . '">' . $video . '</div>';
        }
        if ($type == 'youtubepl') {
            if ($thumb == 'tag') {
                $thumbSrc = e107::getMedia()->getThumb($id);
                if (empty($thumbSrc)) {
                    $thumbSrc = e_IMAGE_ABS . "generic/playlist_120.png";
                }
                return "<img class='img-responsive' src='" . $thumbSrc . "' alt='Youtube Video Playlist' style='width:" . vartrue($parm['w'], '80') . "px'/>";
            }
            if ($thumb == 'src') {
                $thumb = e107::getMedia()->getThumb($id);
                if (!empty($thumb)) {
                    return $thumb;
                } else {
                    // return "https://cdn0.iconfinder.com/data/icons/internet-2-2/64/youtube_playlist_videos_vid_web_online_internet-256.png";
                    return e_IMAGE_ABS . "generic/playlist_120.png";
                }
            }
            $video = '<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=' . $id . '" style="border:0" allowfullscreen></iframe>';
            return '<div class="' . $defClass . ' ' . vartrue($parm['class']) . '">' . $video . '</div>';
        }
        if ($type == 'mp4') {
            return '
			<div class="video-responsive">
			<video width="320" height="240" controls>
			  <source src="' . $file . '" type="video/mp4">
		
			  Your browser does not support the video tag.
			</video>
			</div>';
        }
        return false;
    }
Example #27
0
 static function form()
 {
     $frm = e107::getForm();
     $mes = e107::getMessage();
     $text = "";
     $text .= "\n\t\t<form id='ziplang' method='post' action='" . e_SELF . "?tools'>\n\t\t\t<fieldset id='core-language-package'>\n\t\t\t\t<legend class='e-hideme'>" . LANG_LAN_23 . "</legend>\n\t\t\t\t<table class='table adminform'>\n\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t</colgroup>\n\t\t\t\t\t<tbody>";
     $fl = e107::getFile();
     $fl->mode = 'full';
     // $_SESSION['languageTools_lanFileList'] = null;
     if (!$_SESSION['languageTools_lanFileList']) {
         $_SESSION['languageTools_lanFileList'] = $fl->get_files(e_LANGUAGEDIR . "English", '.*?(English|lan_).*?\\.php$', 'standard', 3);
     }
     //	print_a($_SESSION['languageTools_lanFileList']);
     $text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Search for Deprecated Lans</td>\n\t\t\t\t\t\t\t<td class='form-inline'>\n\t\t\t\t\t\t\t\t<select name='deprecatedLans'>\n\t\t\t\t\t\t\t\t\t<option value=''>Select Script...</option>";
     $omit = array('languages', '\\.png', '\\.gif', 'handlers');
     $lans = $fl->get_files(e_ADMIN, '.php', 'standard', 0);
     $fl->setFileFilter(array("^e_"));
     $root = $fl->get_files(e_BASE, '.*?/?.*?\\.php', $omit, 0);
     $exclude = array('lan_admin.php');
     $srch = array(e_ADMIN, e_PLUGIN, e_BASE);
     $text .= "<optgroup label='Root'>";
     foreach ($root as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = $lan == varset($_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace($srch, "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $text .= "<optgroup label='Admin Area'>";
     foreach ($lans as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = $lan == varset($_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace($srch, "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $depOptions = array(1 => "Script > Lan File", 0 => "Script < Lan File");
     $text .= "\n\t\t\t\t\t\t\t\t</select> " . $frm->select('deprecatedLansReverse', $depOptions, $_POST['deprecatedLansReverse'], 'class=select') . " ";
     $search = array(e_PLUGIN, e_ADMIN, e_LANGUAGEDIR . "English/", e_THEME);
     $replace = array("Plugins ", "Admin ", "Core ", "Themes ");
     $prev = 'Core';
     $text .= "<select name='deprecatedLanFile'>\n\n\t\t\t\t\t\t\t\t";
     $text .= "<option value=''>Auto-Detect</option><optgroup label='Specific LAN file:'>\n";
     foreach ($_SESSION['languageTools_lanFileList'] as $val) {
         if (strstr($val, e_SYSTEM)) {
             continue;
         }
         $selected = $val === $_POST['deprecatedLanFile'] ? "selected='selected'" : "";
         $diz = str_replace($search, $replace, $val);
         list($type, $label) = explode(" ", $diz);
         if ($type !== $prev) {
             $text .= "</optgroup><optgroup label='" . $type . "'>\n";
         }
         $text .= "<option value='" . $val . "' " . $selected . ">" . $label . "</option>\n";
         $prev = $type;
     }
     $text .= "</optgroup>";
     $text .= "</select>";
     // $frm->select('deprecatedLanFile',$_SESSION['languageTools_lanFileList'], $_POST['deprecatedLanFile'],'class=select&useValues=1','Select Language File (optional)').
     $text .= $frm->admin_button('searchDeprecated', "Check", 'other');
     //		$text .= "<span class='field-help'>".(count($lans) + count($plugs))." files found</span>";
     $text .= "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
     $text .= "\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</fieldset>\n\t\t</form>\n\t";
     e107::getRender()->tablerender(ADLAN_132 . SEP . "Core Language-Pack Developer", $mes->render() . $text);
 }
Example #28
0
 static function form()
 {
     $frm = e107::getForm();
     $mes = e107::getMessage();
     $text = "";
     $text .= "\n\t\t<form id='lanDev' method='post' action='" . e_REQUEST_URI . "'>\n\t\t\t<fieldset id='core-language-package'>\n\n\t\t\t\t<table class='table adminform'>\n\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t</colgroup>\n\t\t\t\t\t<tbody>";
     $fl = e107::getFile();
     $fl->mode = 'full';
     // $_SESSION['languageTools_lanFileList'] = null;
     if (!$_SESSION['languageTools_lanFileList']) {
         $_SESSION['languageTools_lanFileList'] = $fl->get_files(e_LANGUAGEDIR . "English", '.*?(English|lan_).*?\\.php$', 'standard', 3);
     }
     //	print_a($_SESSION['languageTools_lanFileList']);
     $text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><div class='alert-info alert alert-block'>Hold down CTRL key to select multiple.<br />eg. To check <b>lan_signup.php</b> you'll want to also select <b>signup_shortcodes.php</b> and <b>signup_template.php</b>.</div></td>\n\t\t\t\t\t\t\t<td class='form-inline'>\n\t\t\t\t\t\t\t\t<select name='deprecatedLans[]' multiple style='height:200px'>\n\t\t\t\t\t\t\t\t\t<option value=''>Select Script...</option>";
     $omit = array('languages', '\\.png', '\\.gif', 'handlers');
     $lans = $fl->get_files(e_ADMIN, '.php', 'standard', 0);
     $fl->setFileFilter(array("^e_"));
     $root = $fl->get_files(e_BASE, '.*?/?.*?\\.php', $omit, 0);
     $templates = $fl->get_files(e_CORE . "templates", '.*?/?.*?\\.php', $omit, 0);
     $shortcodes = $fl->get_files(e_CORE . "shortcodes", '.*?/?.*?\\.php', $omit, 1);
     $exclude = array('lan_admin.php');
     $srch = array(e_ADMIN, e_PLUGIN, e_CORE, e_BASE);
     $text .= "<optgroup label='Admin Area'>";
     foreach ($lans as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = !empty($_POST['deprecatedLans']) && in_array($lan, $_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace('../e107_', "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $text .= "<optgroup label='Root'>";
     foreach ($root as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = !empty($_POST['deprecatedLans']) && in_array($lan, $_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace($srch, "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $text .= "<optgroup label='Templates'>";
     foreach ($templates as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = !empty($_POST['deprecatedLans']) && in_array($lan, $_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace($srch, "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $text .= "<optgroup label='Shortcodes'>";
     foreach ($shortcodes as $script => $lan) {
         if (in_array(basename($lan), $exclude)) {
             continue;
         }
         $selected = !empty($_POST['deprecatedLans']) && in_array($lan, $_POST['deprecatedLans']) ? "selected='selected'" : "";
         $text .= "<option value='" . $lan . "' {$selected}>" . str_replace($srch, "", $lan) . "</option>\n";
     }
     $text .= "</optgroup>";
     $depOptions = array(1 => "Script > Lan File", 0 => "Script < Lan File");
     $text .= "\n\t\t\t\t\t\t\t\t</select> " . $frm->select('deprecatedLansReverse', $depOptions, $_POST['deprecatedLansReverse'], 'class=select') . " ";
     $search = array(e_PLUGIN, e_ADMIN, e_LANGUAGEDIR . "English/", e_THEME);
     $replace = array("Plugins ", "Admin ", "Core ", "Themes ");
     $prev = 'Core';
     $text .= "<select name='deprecatedLanFile[]' multiple style='height:200px'>\n\n\t\t\t\t\t\t\t\t";
     $selected = $_POST['deprecatedLanFile'][0] == 'auto' ? "selected='selected'" : "";
     $text .= "<option value='auto' {$selected}>Auto-Detect</option><optgroup label='Specific LAN file:'>\n";
     foreach ($_SESSION['languageTools_lanFileList'] as $val) {
         if (strstr($val, e_SYSTEM)) {
             continue;
         }
         $selected = !empty($_POST['deprecatedLanFile']) && in_array($val, $_POST['deprecatedLanFile']) ? "selected='selected'" : "";
         $diz = str_replace($search, $replace, $val);
         list($type, $label) = explode(" ", $diz);
         if ($type !== $prev) {
             $text .= "</optgroup><optgroup label='" . $type . "'>\n";
         }
         $text .= "<option value='" . $val . "' " . $selected . ">" . $label . "</option>\n";
         $prev = $type;
     }
     $text .= "</optgroup>";
     $text .= "</select>";
     // $frm->select('deprecatedLanFile',$_SESSION['languageTools_lanFileList'], $_POST['deprecatedLanFile'],'class=select&useValues=1','Select Language File (optional)').
     $text .= $frm->admin_button('searchDeprecated', "Check", 'other');
     //		$text .= "<span class='field-help'>".(count($lans) + count($plugs))." files found</span>";
     $text .= "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
     $text .= "\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</fieldset>\n\t\t</form>\n\t";
     return $mes->render() . $text;
 }
Example #29
0
 function getConfig($config = false)
 {
     $tp = e107::getParser();
     $fl = e107::getFile();
     if (getperms('0')) {
         $template = "mainadmin.xml";
     } elseif (ADMIN) {
         $template = "admin.xml";
     } elseif (USER) {
         $template = "member.xml";
     } else {
         $template = "public.xml";
     }
     $configPath = is_readable(THEME . "templates/tinymce/" . $template) ? THEME . "templates/tinymce/" . $template : e_PLUGIN . "tinymce4/templates/" . $template;
     $config = e107::getXml()->loadXMLfile($configPath, true);
     //TODO Cache!
     $this->configName = $config['@attributes']['name'];
     unset($config['@attributes']);
     $ret = array('selector' => '.e-wysiwyg', 'theme' => 'modern', 'plugins' => $this->filter_plugins($config['tinymce_plugins']), 'language' => $this->tinymce_lang());
     // Loop thru XML parms.
     foreach ($config as $k => $xml) {
         $ret[$k] = $xml;
     }
     $tPref = e107::pref('tinymce4');
     if (!empty($tPref['paste_as_text'])) {
         $ret['paste_as_text'] = true;
     }
     if (!empty($tPref['browser_spellcheck'])) {
         $ret['browser_spellcheck'] = true;
     }
     $formats = array('hilitecolor' => array('inline' => 'span', 'classes' => 'hilitecolor', 'styles' => array('backgroundColor' => '%value')));
     //@see http://www.tinymce.com/wiki.php/Configuration:formats
     $formats = "[\n                {title: 'Headers', items: [\n                    {title: 'Heading 1', block: 'h1'},\n                    {title: 'Heading 2', block: 'h2'},\n                    {title: 'Heading 3', block: 'h3'},\n                    {title: 'Heading 4', block: 'h4'},\n                    {title: 'Heading 5', block: 'h5'},\n                    {title: 'Heading 6', block: 'h6'}\n                ]},\n\n                {title: 'Inline', items: [\n                    {title: 'Bold', inline: 'b', icon: 'bold'},\n                    {title: 'Italic', inline: 'em', icon: 'italic'},\n                    {title: 'Underline', inline: 'span', styles : {textDecoration : 'underline'}, icon: 'underline'},\n                    {title: 'Strikethrough', inline: 'span', styles : {textDecoration : 'line-through'}, icon: 'strikethrough'},\n                    {title: 'Superscript', inline: 'sup', icon: 'superscript'},\n                    {title: 'Subscript', inline: 'sub', icon: 'subscript'},\n                    {title: 'Code', inline: 'code', icon: 'code'},\n                    {title: 'Small', inline: 'small', icon: ''},\n                ]},\n\n                {title: 'Blocks', items: [\n                    {title: 'Paragraph', block: 'p'},\n                    {title: 'Blockquote', block: 'blockquote'},\n                    {title: 'Div', block: 'div'},\n                    {title: 'Pre', block: 'pre'},\n                    {title: 'Code Highlighted', block: 'pre', classes: 'prettyprint linenums' }\n                ]},\n\n                {title: 'Alignment', items: [\n                    {title: 'Left', block: 'div', classes: 'text-left',  icon: 'alignleft'},\n                    {title: 'Center', block: 'div',classes: 'text-center', icon: 'aligncenter'},\n                    {title: 'Right', block: 'div', classes: 'text-right',  icon: 'alignright'},\n                    {title: 'Justify', block: 'div', classes: 'text-justify', icon: 'alignjustify'},\n                    {title: 'No-Wrap', block: 'div', classes: 'text-nowrap', icon: ''},\n                    {title: 'Image Left', selector: 'img', classes: 'pull-left', styles: {'margin': '0 10px 5px 0'  },  icon: 'alignleft'},\n                    {title: 'Image Right', selector: 'img', classes: 'pull-right', styles: { 'margin': '0 0 5px 10px'}, icon: 'alignright'}\n\n                ]},\n\n                {title: 'Bootstrap Inline', items: [\n\t\t\t\t {title: 'Label (Default)', inline: 'span', classes: 'label label-default'},\n\t\t\t\t {title: 'Label (Primary)', inline: 'span', classes: 'label label-primary'},\n                 {title: 'Label (Success)', inline: 'span', classes: 'label label-success'},\n                 {title: 'Label (Info)', inline: 'span', classes: 'label label-info'},\n                 {title: 'Label (Warning)', inline: 'span', classes: 'label label-warning'},\n                 {title: 'Label (Danger)', inline: 'span', classes: 'label label-danger'},\n                 {title: 'Muted', inline: 'span', classes: 'text-muted'},\n                ]},\n\n                 {title: 'Bootstrap Blocks', items: [\n                 {title: 'Alert (Success)', block: 'div', classes: 'alert alert-success'},\n                 {title: 'Alert (Info)', block: 'div', classes: 'alert alert-info'},\n                 {title: 'Alert (Warning)', block: 'div', classes: 'alert alert-warning'},\n                 {title: 'Alert (Danger)', block: 'div', classes: 'alert alert-block alert-danger'},\n                 {title: 'Float Clear', block: 'div', classes: 'clearfix'},\n                 {title: 'Lead', block: 'p', classes: 'lead'},\n                 {title: 'Well', block: 'div', classes: 'well'},\n                 {title: '1/4 Width Block', block: 'div', classes: 'col-md-3 col-sm-12'},\n                 {title: '3/4 Width Block', block: 'div', classes: 'col-md-9 col-sm-12'},\n                 {title: '1/3 Width Block', block: 'div', classes: 'col-md-4 col-sm-12'},\n                 {title: '2/3 Width Block', block: 'div', classes: 'col-md-8 col-sm-12'},\n                 {title: '1/2 Width Block', block: 'div', classes: 'col-md-6 col-sm-12'},\n                ]},\n\n                 {title: 'Bootstrap Buttons', items: [\n                 {title: 'Button (Default)', selector: 'a', classes: 'btn btn-default'},\n\t\t\t\t {title: 'Button (Primary)', selector: 'a', classes: 'btn btn-primary'},\n                 {title: 'Button (Success)', selector: 'a', classes: 'btn btn-success'},\n                 {title: 'Button (Info)', selector: 'a', classes: 'btn btn-info'},\n                 {title: 'Button (Warning)', selector: 'a', classes: 'btn-warning'},\n                 {title: 'Button (Danger)', selector: 'a', classes: 'btn-danger'},\n                ]},\n\n\t\t\t\t {title: 'Bootstrap Images', items: [\n\t\t\t\t {title: 'Responsive (recommended)',  selector: 'img', classes: 'img-responsive'},\n\t\t\t\t {title: 'Rounded',  selector: 'img', classes: 'img-rounded'},\n\t\t\t\t {title: 'Circle', selector: 'img', classes: 'img-circle'},\n                 {title: 'Thumbnail', selector: 'img', classes: 'img-thumbnail'},\n                ]},\n\n\t\t\t\t {title: 'Bootstrap Tables', items: [\n\t\t\t\t {title: 'Bordered',  selector: 'table', classes: 'table-bordered'},\n\t\t\t\t {title: 'Condensed', selector: 'table', classes: 'table-condensed'},\n\t\t\t\t {title: 'Hover', selector: 'table', classes: 'table-hover'},\n                 {title: 'Striped', selector: 'table', classes: 'table-striped'},\n                ]},\n\n\n            ]";
     //	$ret['style_formats_merge'] = true;
     //	$ret['visualblocks_default_state'] = true; //pref
     $ret['style_formats'] = $formats;
     // json_encode($formats);
     $ret['link_class_list'] = "[\n        {title: 'None', value: ''},\n        {title: 'Link', value: 'btn btn-link'},\n        {title: 'Alert Link', value: 'alert-link'},\n        {title: 'Button (Default)', value: 'btn btn-default'},\n        {title: 'Button (Primary)', value: 'btn btn-primary'},\n        {title: 'Button (Success)', value: 'btn btn-success'},\n        {title: 'Button (Info)', value: 'btn btn-info'},\n        {title: 'Button (Warning)', value: 'btn btn-warning'},\n        {title: 'Button (Danger)', value: 'btn btn-danger'}\n    ]";
     // https://github.com/valtlfelipe/TinyMCE-LocalAutoSave
     /*
     		$ret['setup'] = "function(ed) {
           ed.addMenuItem('test', {
              text: 'Clear Floats',
              context: 'insert',
              icon: false,
              onclick: function() {
                 ed.insertContent('<br class=\"clearfix\" />');
              }
           });
           }";
     */
     // e107 Bbcodes.
     /*
     
     		$ret['setup'] = "function(ed) {
     			ed.addButton('e107-bbcode', {
     				text: 'bbcode',
     				icon: 'emoticons',
     				onclick: function() {
     		// Open window
     
     			ed.windowManager.open({
     						title: 'Example plugin',
     						body: [
     							{type: 'listbox', name: 'code', label: 'BbCode', values: [
     								{text: 'Left', value: 'left'},
     						        {text: 'Right', value: 'right'},
     						        {text: 'Center', value: 'center'}
     						    ]},
                                 {type: 'textbox', name: 'parm', label: 'Parameters'}
     						],
     						onsubmit: function(e) {
     
     							var selected = ed.selection.getContent({format : 'text'});
     
     						//	alert(selected);
     							// Insert content when the window form is submitted
     							ed.insertContent('[' + e.data.code + ']' + selected + '[/' + e.data.code + ']');
     						}
     					});
     				}
     			});
     	}";
     */
     // Emoticon Support @see //https://github.com/nhammadi/Smileys
     if (e107::pref('core', 'smiley_activate', false)) {
         $emo = e107::getConfig("emote")->getPref();
         $pack = e107::pref('core', 'emotepack');
         $emotes = array();
         $i = 0;
         $c = 0;
         foreach ($emo as $path => $co) {
             $codes = explode(" ", $co);
             $url = SITEURLBASE . e_IMAGE_ABS . "emotes/" . $pack . "/" . str_replace("!", ".", $path);
             $emotes[$i][] = array('shortcut' => $codes, 'url' => $url, 'title' => ucfirst($path));
             if ($c == 6) {
                 $i++;
                 $c = 0;
             } else {
                 $c++;
             }
         }
         //	print_r($emotes);
         $ret['extended_smileys'] = json_encode($emotes);
     }
     //	$ret['skin']                    = 'e107admin';
     //	$ret['skin_url']                = SITEURLBASE.e_PLUGIN_ABS.'tinymce4/skins/e107admin';
     $ret['convert_fonts_to_spans'] = false;
     $ret['content_css'] = e_PLUGIN_ABS . 'tinymce4/editor.css,https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css,http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css';
     $ret['relative_urls'] = false;
     //Media Manager prefers it like this.
     $ret['preformatted'] = true;
     $ret['document_base_url'] = SITEURL;
     //	$ret['table_default_attributes'] = json_encode(array('class'=>'table table-striped' ));
     if (!empty($ret['templates'])) {
         $ret['templates'] = $tp->replaceConstants($ret['templates'], 'abs');
         // $this->getTemplates();
     }
     //	$this->config['verify_css_classes']	= 'false';
     $text = array();
     foreach ($ret as $k => $v) {
         if ($k == 'external_plugins') {
             $text[] = 'external_plugins: ' . $this->getExternalPlugins($v);
             continue;
         }
         $text[] = $k . ': ' . $this->convertBoolean($v);
     }
     $this->config = implode(",\n", $text);
     return;
     // -------------------------------------------------------------------------------------
     $cssFiles = $fl->get_files(THEME, "\\.css", '', 2);
     foreach ($cssFiles as $val) {
         $css[] = str_replace(THEME, THEME_ABS, $val['path'] . $val['fname']);
     }
     $css[] = "{e_WEB_ABS}js/bootstrap/css/bootstrap.min.css";
     $content_css = vartrue($config['content_css'], implode(",", $css));
     $content_styles = array('Bootstrap Button' => 'btn btn-primary', 'Bootstrap Table' => 'table');
     $this->config += array('dialog_type' => "modal", 'theme_advanced_resizing' => 'true', 'remove_linebreaks' => 'false', 'extended_valid_elements' => vartrue($config['extended_valid_elements']), 'apply_source_formatting' => 'true', 'invalid_elements' => 'font,align,script,applet', 'auto_cleanup_word' => 'true', 'cleanup' => 'true', 'convert_fonts_to_spans' => 'true', 'popup_css' => 'false', 'trim_span_elements' => 'true', 'inline_styles' => 'true', 'auto_resize' => 'false', 'debug' => 'true', 'force_br_newlines' => 'true', 'media_strict' => 'false', 'width' => vartrue($config['width'], '100%'), 'forced_root_block' => 'false', 'convert_newlines_to_brs' => 'true', 'entity_encoding' => 'raw', 'convert_fonts_to_styles' => 'true', 'remove_script_host' => 'true', 'relative_urls' => 'false', 'preformatted' => 'true', 'document_base_url' => SITEURL, 'verify_css_classes' => 'false');
     //		$this->config['cleanup_callback'] = 'tinymce_e107Paths';
     $paste_plugin = false;
     // (strpos($config['tinymce_plugins'],'paste')!==FALSE) ? TRUE : FALSE;
     if ($paste_plugin) {
         $this->config += array('paste_text_sticky' => 'true', 'paste_text_sticky_default' => 'true', 'paste_text_linebreaktype' => 'br', 'remove_linebreaks' => 'false', 'paste_create_paragraphs' => 'false', 'paste_create_linebreaks' => 'true', 'paste_use_dialog' => 'true', 'paste_auto_cleanup_on_paste' => 'true', 'paste_convert_middot_lists' => 'false', 'paste_unindented_list_class' => 'unindentedList', 'paste_convert_headers_to_strong' => 'true', 'paste_insert_word_content_callback' => 'convertWord', 'auto_cleanup_word' => 'true');
     }
     if (ADMIN) {
         //		$this->config['external_link_list_url'] = e_PLUGIN_ABS."tiny_mce/filelist.php";
     }
 }
Example #30
0
 * Plugin administration area
 *
 */
require_once "../class2.php";
if (!getperms("Z")) {
    header("location:" . e_BASE . "index.php");
    exit;
}
// Only tested Locally so far.
if (e_AJAX_REQUEST && isset($_GET['src'])) {
    $string = base64_decode($_GET['src']);
    parse_str($string, $p);
    $remotefile = $p['plugin_url'];
    $localfile = md5($remotefile . time()) . ".zip";
    $status = "Downloading...";
    e107::getFile()->getRemoteFile($remotefile, $localfile);
    if (!file_exists(e_TEMP . $localfile)) {
        echo 'There was a problem retrieving the file';
        exit;
    }
    //	chmod(e_PLUGIN,0777);
    chmod(e_TEMP . $localfile, 0755);
    require_once e_HANDLER . "pclzip.lib.php";
    $archive = new PclZip(e_TEMP . $localfile);
    $unarc = $fileList = $archive->extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0755);
    //	chmod(e_PLUGIN,0755);
    $dir = basename($unarc[0]['filename']);
    //		chmod(e_UPLOAD.$localfile,0666);
    /* Cannot use this yet until 'folder' is included in feed. 
    	if($dir != $p['plugin_folder'])
    	{