예제 #1
0
/**
 * Validate the user session based on user name and password hash.
 *
 * @param string $user_name -- The user name to create a session for
 * @param string $password -- The MD5 sum of the user's password
 * @return true -- If the session is created
 * @return false -- If the session is not created
 */
function validate_user($user_name, $password)
{
    global $server, $current_user, $sugar_config;
    $user = BeanFactory::getBean('Users');
    $user->user_name = $user_name;
    $authController = AuthenticationController::getInstance();
    // Check to see if the user name and password are consistent.
    if ($user->authenticate_user($password)) {
        // we also need to set the current_user.
        $user->retrieve($user->id);
        $current_user = $user;
        login_success();
        return true;
    } else {
        if (function_exists('mcrypt_cbc')) {
            $password = decrypt_string($password);
            if ($authController->login($user_name, $password) && isset($_SESSION['authenticated_user_id'])) {
                $user->retrieve($_SESSION['authenticated_user_id']);
                $current_user = $user;
                login_success();
                return true;
            }
        } else {
            $GLOBALS['log']->fatal("SECURITY: failed attempted login for {$user_name} using SOAP api");
            $server->setError("Invalid username and/or password");
            return false;
        }
    }
}
예제 #2
0
/** Get password from session
* @return string
*/
function get_password()
{
    $return = get_session("pwds");
    if (is_array($return)) {
        $return = $_COOKIE["adminer_key"] ? decrypt_string($return[0], $_COOKIE["adminer_key"]) : false;
    }
    return $return;
}
예제 #3
0
 public function update_elements_champs($array, $id_element)
 {
     global $thisSite;
     $PDO = new myPDO();
     $temp = array();
     $this->get_champs();
     foreach ($array as $k => $row) {
         if (is_numeric($k)) {
             if (in_array($k, $this->list_champ_crypte)) {
                 $temp[$k] = crypt_string('KEY', $row);
             } else {
                 $temp[$k] = $row;
             }
         }
     }
     // UPDATE les valeurs saisie par l'utilisateur elements_champs
     foreach ($temp as $key => $data) {
         $result = $PDO->free_requete("UPDATE " . $thisSite->PREFIXE_TBL_CLI . "elements_champs \n                                SET valeur = '{$data}'\n                                WHERE " . $thisSite->PREFIXE_TBL_CLI . "elements_champs.id_element = {$id_element}\n                                AND " . $thisSite->PREFIXE_TBL_CLI . "elements_champs.id = {$key}");
     }
     /* decrypter le valeurs pour le rendre à la vue */
     foreach ($temp as $kk => $vv) {
         if (in_array($kk, $this->list_champ_crypte)) {
             $temp[$kk] = decrypt_string('KEY', $vv);
         }
     }
     $this->valeurs = $temp;
 }
예제 #4
0
/**
 * Log the user into the application
 *
 * @param UserAuth array $user_auth -- Set user_name and password (password needs to be
 *      in the right encoding for the type of authentication the user is setup for.  For Base
 *      sugar validation, password is the MD5 sum of the plain text password.
 * @param String $application -- The name of the application you are logging in from.  (Currently unused).
 * @return Array(session_id, error) -- session_id is the id of the session that was
 *      created.  Error is set if there was any error during creation.
 */
function login($user_auth, $application)
{
    global $sugar_config, $system_config;
    $error = new SoapError();
    $user = new User();
    $success = false;
    //rrs
    $system_config = new Administration();
    $system_config->retrieveSettings('system');
    $authController = new AuthenticationController(!empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate');
    //rrs
    $isLoginSuccess = $authController->login($user_auth['user_name'], $user_auth['password'], array('passwordEncrypted' => true));
    $usr_id = $user->retrieve_user_id($user_auth['user_name']);
    if ($usr_id) {
        $user->retrieve($usr_id);
    }
    if ($isLoginSuccess) {
        if ($_SESSION['hasExpiredPassword'] == '1') {
            $error->set_error('password_expired');
            $GLOBALS['log']->fatal('password expired for user ' . $user_auth['user_name']);
            LogicHook::initialize();
            $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
            return array('id' => -1, 'error' => $error);
        }
        // if
        if (!empty($user) && !empty($user->id) && !$user->is_group) {
            $success = true;
            global $current_user;
            $current_user = $user;
        }
        // if
    } else {
        if ($usr_id && isset($user->user_name) && $user->getPreference('lockout') == '1') {
            $error->set_error('lockout_reached');
            $GLOBALS['log']->fatal('Lockout reached for user ' . $user_auth['user_name']);
            LogicHook::initialize();
            $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
            return array('id' => -1, 'error' => $error);
        } else {
            if (function_exists('mcrypt_cbc')) {
                $password = decrypt_string($user_auth['password']);
                $authController = new AuthenticationController(!empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate');
                if ($authController->login($user_auth['user_name'], $password) && isset($_SESSION['authenticated_user_id'])) {
                    $success = true;
                }
                // if
            }
        }
    }
    // else if
    if ($success) {
        session_start();
        global $current_user;
        //$current_user = $user;
        login_success();
        $current_user->loadPreferences();
        $_SESSION['is_valid_session'] = true;
        $_SESSION['ip_address'] = query_client_ip();
        $_SESSION['user_id'] = $current_user->id;
        $_SESSION['type'] = 'user';
        $_SESSION['avail_modules'] = get_user_module_list($current_user);
        $_SESSION['authenticated_user_id'] = $current_user->id;
        $_SESSION['unique_key'] = $sugar_config['unique_key'];
        $current_user->call_custom_logic('after_login');
        return array('id' => session_id(), 'error' => $error);
    }
    $error->set_error('invalid_login');
    $GLOBALS['log']->fatal('SECURITY: User authentication for ' . $user_auth['user_name'] . ' failed');
    LogicHook::initialize();
    $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
    return array('id' => -1, 'error' => $error);
}
예제 #5
0
        }
        $key = base64_encode(DRIVER) . "-" . base64_encode(SERVER) . "-" . base64_encode($_GET["username"]);
        if ($permanent[$key]) {
            unset($permanent[$key]);
            cookie("adminer_permanent", implode(" ", $permanent));
        }
        redirect(substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.'));
    }
} elseif ($permanent && !$_SESSION["pwds"]) {
    session_regenerate_id();
    $private = $adminer->permanentLogin();
    // try to decode even if not set
    foreach ($permanent as $key => $val) {
        list(, $cipher) = explode(":", $val);
        list($driver, $server, $username) = array_map('base64_decode', explode("-", $key));
        $_SESSION["pwds"][$driver][$server][$username] = decrypt_string(base64_decode($cipher), $private);
    }
}
function auth_error($exception = null)
{
    global $connection, $adminer, $token;
    $session_name = session_name();
    $error = "";
    if (!$_COOKIE[$session_name] && $_GET[$session_name] && ini_bool("session.use_only_cookies")) {
        $error = lang('Session support must be enabled.');
    } elseif (isset($_GET["username"])) {
        if (($_COOKIE[$session_name] || $_GET[$session_name]) && !$token) {
            $error = lang('Session expired, please login again.');
        } else {
            $password =& get_session("pwds");
            if (isset($password)) {
/**
 * Log the user into the application
 *
 * @param UserAuth array $user_auth -- Set user_name and password (password needs to be
 *      in the right encoding for the type of authentication the user is setup for.  For Base
 *      sugar validation, password is the MD5 sum of the plain text password.
 * @param String $application -- The name of the application you are logging in from.  (Currently unused).
 * @return Array(session_id, error) -- session_id is the id of the session that was
 *      created.  Error is set if there was any error during creation.
 */
function login($user_auth, $application)
{
    global $sugar_config, $system_config;
    $error = new SoapError();
    $user = new User();
    $success = false;
    //rrs
    $system_config = new Administration();
    $system_config->retrieveSettings('system');
    $authController = new AuthenticationController(!empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate');
    //rrs
    $user = $user->retrieve_by_string_fields(array('user_name' => $user_auth['user_name'], 'user_hash' => $user_auth['password'], 'deleted' => 0, 'status' => 'Active', 'portal_only' => 0));
    if (!empty($user) && !empty($user->id) && !$user->is_group) {
        $success = true;
        global $current_user;
        $current_user = $user;
    } else {
        if (function_exists('mcrypt_cbc')) {
            $password = decrypt_string($user_auth['password']);
            if ($authController->login($user_auth['user_name'], $password) && isset($_SESSION['authenticated_user_id'])) {
                $success = true;
            }
        }
    }
    if ($success) {
        session_start();
        global $current_user;
        //$current_user = $user;
        login_success();
        $current_user->loadPreferences();
        $_SESSION['is_valid_session'] = true;
        $_SESSION['ip_address'] = query_client_ip();
        $_SESSION['user_id'] = $current_user->id;
        $_SESSION['type'] = 'user';
        $_SESSION['avail_modules'] = get_user_module_list($current_user);
        $_SESSION['authenticated_user_id'] = $current_user->id;
        $_SESSION['unique_key'] = $sugar_config['unique_key'];
        $current_user->call_custom_logic('after_login');
        return array('id' => session_id(), 'error' => $error);
    }
    $error->set_error('invalid_login');
    $GLOBALS['log']->fatal('SECURITY: User authentication for ' . $user_auth['user_name'] . ' failed');
    LogicHook::initialize();
    $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
    return array('id' => -1, 'error' => $error);
}
예제 #7
0
    $mySelect->tables = $thisSite->PREFIXE_TBL_CLI . "elements_champs";
    $mySelect->fields = "id,valeur";
    $mySelect->where = "id_element=:id_element";
    $mySelect->whereValue["id_element"] = $vlistE['id'];
    $listValeur[] = $mySelect->query();
}
$listFiltre = array();
foreach ($listChamp as $KLC => $ChampFiltre) {
    foreach ($listChamp[$KLC] as $KeyLC => $VLC) {
        $listFiltre[$KLC] = $VLC['filtre'];
    }
}
// Injecter dans listChamps le tableaux des valeurs
$list_Champ_Valeur = array();
foreach ($listChamp as $Klistchamp => $Vlistchamp) {
    $list_Champ_Valeur[$Klistchamp]['Champ'] = $Vlistchamp;
    $list_Champ_Valeur[$Klistchamp]['Valeur'] = $listValeur[$Klistchamp];
}
// Décrypter les valeurs crypter
$newChampValeurs = array();
foreach ($list_Champ_Valeur as $kLCV => $value) {
    foreach ($value['Champ'] as $kChamp => $vChamp) {
        if (!empty($vChamp['filtre'])) {
            $list_Champ_Valeur[$kLCV]['Valeur'][$kChamp]['valeur'] = decrypt_string("KEY", $value['Valeur'][$kChamp]['valeur']);
        }
    }
}
// Htmlspechialchars
foreach ($list_Champ_Valeur[0]['Valeur'] as $key => $data) {
    $list_Champ_Valeur[0]['Valeur'][$key]['valeur'] = htmlspecialchars($data['valeur'], ENT_QUOTES);
}
function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false)
{
    $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
    _debug("start", $debug_enabled);
    $result = db_query("SELECT id,update_interval,auth_login,\n\t\t\tfeed_url,auth_pass,cache_images,last_updated,\n\t\t\tmark_unread_on_update, owner_uid,\n\t\t\tpubsub_state, auth_pass_encrypted,\n\t\t\t(SELECT max(date_entered) FROM\n\t\t\t\tttrss_entries, ttrss_user_entries where ref_id = id AND feed_id = '{$feed}') AS last_article_timestamp\n\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
    if (db_num_rows($result) == 0) {
        _debug("feed {$feed} NOT FOUND/SKIPPED", $debug_enabled);
        return false;
    }
    $last_updated = db_fetch_result($result, 0, "last_updated");
    $last_article_timestamp = @strtotime(db_fetch_result($result, 0, "last_article_timestamp"));
    if (defined('_DISABLE_HTTP_304')) {
        $last_article_timestamp = 0;
    }
    $owner_uid = db_fetch_result($result, 0, "owner_uid");
    $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
    $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
    $auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result, 0, "auth_pass_encrypted"));
    db_query("UPDATE ttrss_feeds SET last_update_started = NOW()\n\t\t\tWHERE id = '{$feed}'");
    $auth_login = db_fetch_result($result, 0, "auth_login");
    $auth_pass = db_fetch_result($result, 0, "auth_pass");
    if ($auth_pass_encrypted) {
        require_once "crypt.php";
        $auth_pass = decrypt_string($auth_pass);
    }
    $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
    $fetch_url = db_fetch_result($result, 0, "feed_url");
    $feed = db_escape_string($feed);
    $date_feed_processed = date('Y-m-d H:i');
    $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
    $pluginhost = new PluginHost();
    $pluginhost->set_debug($debug_enabled);
    $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
    $pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
    $pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
    $pluginhost->load_data();
    $rss = false;
    $rss_hash = false;
    $force_refetch = isset($_REQUEST["force_refetch"]);
    if (file_exists($cache_filename) && is_readable($cache_filename) && !$auth_login && !$auth_pass && filemtime($cache_filename) > time() - 30) {
        _debug("using local cache.", $debug_enabled);
        @($feed_data = file_get_contents($cache_filename));
        if ($feed_data) {
            $rss_hash = sha1($feed_data);
        }
    } else {
        _debug("local cache will not be used for this feed", $debug_enabled);
    }
    if (!$rss) {
        foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
            $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed);
        }
        if (!$feed_data) {
            _debug("fetching [{$fetch_url}]...", $debug_enabled);
            _debug("If-Modified-Since: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $last_article_timestamp), $debug_enabled);
            $feed_data = fetch_file_contents($fetch_url, false, $auth_login, $auth_pass, false, $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT, $force_refetch ? 0 : $last_article_timestamp);
            global $fetch_curl_used;
            if (!$fetch_curl_used) {
                $tmp = @gzdecode($feed_data);
                if ($tmp) {
                    $feed_data = $tmp;
                }
            }
            $feed_data = trim($feed_data);
            _debug("fetch done.", $debug_enabled);
            /* if ($feed_data) {
            					$error = verify_feed_xml($feed_data);
            
            					if ($error) {
            						_debug("error verifying XML, code: " . $error->code, $debug_enabled);
            
            						if ($error->code == 26) {
            							_debug("got error 26, trying to decode entities...", $debug_enabled);
            
            							$feed_data = html_entity_decode($feed_data, ENT_COMPAT, 'UTF-8');
            
            							$error = verify_feed_xml($feed_data);
            
            							if ($error) $feed_data = '';
            						}
            					}
            				} */
        }
        if (!$feed_data) {
            global $fetch_last_error;
            global $fetch_last_error_code;
            _debug("unable to fetch: {$fetch_last_error} [{$fetch_last_error_code}]", $debug_enabled);
            $error_escaped = '';
            // If-Modified-Since
            if ($fetch_last_error_code != 304) {
                $error_escaped = db_escape_string($fetch_last_error);
            } else {
                _debug("source claims data not modified, nothing to do.", $debug_enabled);
            }
            db_query("UPDATE ttrss_feeds SET last_error = '{$error_escaped}',\n\t\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
            return;
        }
    }
    foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
        $feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed);
    }
    // set last update to now so if anything *simplepie* crashes later we won't be
    // continuously failing on the same feed
    //db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'");
    if (!$rss) {
        $rss = new FeedParser($feed_data);
        $rss->init();
    }
    //		print_r($rss);
    $feed = db_escape_string($feed);
    if (!$rss->error()) {
        // cache data for later
        if (!$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
            $new_rss_hash = sha1($rss_data);
            if ($new_rss_hash != $rss_hash && count($rss->get_items()) > 0) {
                _debug("saving {$cache_filename}", $debug_enabled);
                @file_put_contents($cache_filename, $feed_data);
            }
        }
        // We use local pluginhost here because we need to load different per-user feed plugins
        $pluginhost->run_hooks(PluginHost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
        _debug("processing feed data...", $debug_enabled);
        //			db_query("BEGIN");
        if (DB_TYPE == "pgsql") {
            $favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'";
        } else {
            $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)";
        }
        $result = db_query("SELECT title,site_url,owner_uid,favicon_avg_color,\n\t\t\t\t(favicon_last_checked IS NULL OR {$favicon_interval_qpart}) AS\n\t\t\t\t\t\tfavicon_needs_check\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
        $registered_title = db_fetch_result($result, 0, "title");
        $orig_site_url = db_fetch_result($result, 0, "site_url");
        $favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0, "favicon_needs_check"));
        $favicon_avg_color = db_fetch_result($result, 0, "favicon_avg_color");
        $owner_uid = db_fetch_result($result, 0, "owner_uid");
        $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245));
        _debug("site_url: {$site_url}", $debug_enabled);
        _debug("feed_title: " . $rss->get_title(), $debug_enabled);
        if ($favicon_needs_check || $force_refetch) {
            /* terrible hack: if we crash on floicon shit here, we won't check
             * the icon avgcolor again (unless the icon got updated) */
            $favicon_file = ICONS_DIR . "/{$feed}.ico";
            $favicon_modified = @filemtime($favicon_file);
            _debug("checking favicon...", $debug_enabled);
            check_feed_favicon($site_url, $feed);
            $favicon_modified_new = @filemtime($favicon_file);
            if ($favicon_modified_new > $favicon_modified) {
                $favicon_avg_color = '';
            }
            if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color == '') {
                require_once "colors.php";
                db_query("UPDATE ttrss_feeds SET favicon_avg_color = 'fail' WHERE\n\t\t\t\t\t\t\tid = '{$feed}'");
                $favicon_color = db_escape_string(calculate_avg_color($favicon_file));
                $favicon_colorstring = ",favicon_avg_color = '" . $favicon_color . "'";
            } else {
                if ($favicon_avg_color == 'fail') {
                    _debug("floicon failed on this file, not trying to recalculate avg color", $debug_enabled);
                }
            }
            db_query("UPDATE ttrss_feeds SET favicon_last_checked = NOW()\n\t\t\t\t\t{$favicon_colorstring}\n\t\t\t\t\tWHERE id = '{$feed}'");
        }
        if (!$registered_title || $registered_title == "[Unknown]") {
            $feed_title = db_escape_string($rss->get_title());
            if ($feed_title) {
                _debug("registering title: {$feed_title}", $debug_enabled);
                db_query("UPDATE ttrss_feeds SET\n\t\t\t\t\t\ttitle = '{$feed_title}' WHERE id = '{$feed}'");
            }
        }
        if ($site_url && $orig_site_url != $site_url) {
            db_query("UPDATE ttrss_feeds SET\n\t\t\t\t\tsite_url = '{$site_url}' WHERE id = '{$feed}'");
        }
        _debug("loading filters & labels...", $debug_enabled);
        $filters = load_filters($feed, $owner_uid);
        $labels = get_all_labels($owner_uid);
        _debug("" . count($filters) . " filters loaded.", $debug_enabled);
        $items = $rss->get_items();
        if (!is_array($items)) {
            _debug("no articles found.", $debug_enabled);
            db_query("UPDATE ttrss_feeds\n\t\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
            return;
            // no articles
        }
        if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) {
            _debug("checking for PUSH hub...", $debug_enabled);
            $feed_hub_url = false;
            $links = $rss->get_links('hub');
            if ($links && is_array($links)) {
                foreach ($links as $l) {
                    $feed_hub_url = $l;
                    break;
                }
            }
            _debug("feed hub url: {$feed_hub_url}", $debug_enabled);
            if ($feed_hub_url && function_exists('curl_init') && !ini_get("open_basedir")) {
                require_once 'lib/pubsubhubbub/subscriber.php';
                $callback_url = get_self_url_prefix() . "/public.php?op=pubsub&id={$feed}";
                $s = new Subscriber($feed_hub_url, $callback_url);
                $rc = $s->subscribe($fetch_url);
                _debug("feed hub url found, subscribe request sent.", $debug_enabled);
                db_query("UPDATE ttrss_feeds SET pubsub_state = 1\n\t\t\t\t\t\tWHERE id = '{$feed}'");
            }
        }
        _debug("processing articles...", $debug_enabled);
        foreach ($items as $item) {
            if ($_REQUEST['xdebug'] == 3) {
                print_r($item);
            }
            $entry_guid = $item->get_id();
            if (!$entry_guid) {
                $entry_guid = $item->get_link();
            }
            if (!$entry_guid) {
                $entry_guid = make_guid_from_title($item->get_title());
            }
            _debug("f_guid {$entry_guid}", $debug_enabled);
            if (!$entry_guid) {
                continue;
            }
            $entry_guid = "{$owner_uid},{$entry_guid}";
            $entry_guid_hashed = db_escape_string('SHA1:' . sha1($entry_guid));
            _debug("guid {$entry_guid} / {$entry_guid_hashed}", $debug_enabled);
            $entry_timestamp = "";
            $entry_timestamp = $item->get_date();
            _debug("orig date: " . $item->get_date(), $debug_enabled);
            if ($entry_timestamp == -1 || !$entry_timestamp || $entry_timestamp > time()) {
                $entry_timestamp = time();
                $no_orig_date = 'true';
            } else {
                $no_orig_date = 'false';
            }
            $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
            _debug("date {$entry_timestamp} [{$entry_timestamp_fmt}]", $debug_enabled);
            //				$entry_title = html_entity_decode($item->get_title(), ENT_COMPAT, 'UTF-8');
            //				$entry_title = decode_numeric_entities($entry_title);
            $entry_title = $item->get_title();
            $entry_link = rewrite_relative_url($site_url, $item->get_link());
            _debug("title {$entry_title}", $debug_enabled);
            _debug("link {$entry_link}", $debug_enabled);
            if (!$entry_title) {
                $entry_title = date("Y-m-d H:i:s", $entry_timestamp);
            }
            $entry_content = $item->get_content();
            if (!$entry_content) {
                $entry_content = $item->get_description();
            }
            if ($_REQUEST["xdebug"] == 2) {
                print "content: ";
                print $entry_content;
                print "\n";
            }
            $entry_comments = $item->get_comments_url();
            $entry_author = $item->get_author();
            $entry_guid = db_escape_string(mb_substr($entry_guid, 0, 245));
            $entry_comments = db_escape_string(mb_substr(trim($entry_comments), 0, 245));
            $entry_author = db_escape_string(mb_substr(trim($entry_author), 0, 245));
            $num_comments = (int) $item->get_comments_count();
            _debug("author {$entry_author}", $debug_enabled);
            _debug("num_comments: {$num_comments}", $debug_enabled);
            _debug("looking for tags...", $debug_enabled);
            // parse <category> entries into tags
            $additional_tags = array();
            $additional_tags_src = $item->get_categories();
            if (is_array($additional_tags_src)) {
                foreach ($additional_tags_src as $tobj) {
                    array_push($additional_tags, $tobj);
                }
            }
            $entry_tags = array_unique($additional_tags);
            for ($i = 0; $i < count($entry_tags); $i++) {
                $entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
            }
            _debug("tags found: " . join(",", $entry_tags), $debug_enabled);
            _debug("done collecting data.", $debug_enabled);
            // TODO: less memory-hungry implementation
            _debug("applying plugin filters..", $debug_enabled);
            // FIXME not sure if owner_uid is a good idea here, we may have a base entry without user entry (?)
            $result = db_query("SELECT plugin_data,title,content,link,tag_cache,author FROM ttrss_entries, ttrss_user_entries\n\t\t\t\t\tWHERE ref_id = id AND (guid = '" . db_escape_string($entry_guid) . "' OR guid = '{$entry_guid_hashed}') AND owner_uid = {$owner_uid}");
            if (db_num_rows($result) != 0) {
                $entry_plugin_data = db_fetch_result($result, 0, "plugin_data");
                $stored_article = array("title" => db_fetch_result($result, 0, "title"), "content" => db_fetch_result($result, 0, "content"), "link" => db_fetch_result($result, 0, "link"), "tags" => explode(",", db_fetch_result($result, 0, "tag_cache")), "author" => db_fetch_result($result, 0, "author"));
            } else {
                $entry_plugin_data = "";
                $stored_article = array();
            }
            $article = array("owner_uid" => $owner_uid, "guid" => $entry_guid, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "tags" => $entry_tags, "plugin_data" => $entry_plugin_data, "author" => $entry_author, "stored" => $stored_article);
            foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
                $article = $plugin->hook_article_filter($article);
            }
            $entry_tags = $article["tags"];
            $entry_guid = db_escape_string($entry_guid);
            $entry_title = db_escape_string($article["title"]);
            $entry_author = db_escape_string($article["author"]);
            $entry_link = db_escape_string($article["link"]);
            $entry_plugin_data = db_escape_string($article["plugin_data"]);
            $entry_content = $article["content"];
            // escaped below
            _debug("plugin data: {$entry_plugin_data}", $debug_enabled);
            if ($cache_images && is_writable(CACHE_DIR . '/images')) {
                cache_images($entry_content, $site_url, $debug_enabled);
            }
            $entry_content = db_escape_string($entry_content, false);
            $content_hash = "SHA1:" . sha1($entry_content);
            db_query("BEGIN");
            $result = db_query("SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE (guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}')");
            if (db_num_rows($result) == 0) {
                _debug("base guid [{$entry_guid}] not found", $debug_enabled);
                // base post entry does not exist, create it
                $result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid_hashed}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$date_feed_processed}',\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_author}')");
                $article_labels = array();
            } else {
                // we keep encountering the entry in feeds, so we need to
                // update date_updated column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
                $article_labels = get_article_labels($base_entry_id, $owner_uid);
            }
            // now it should exist, if not - bad luck then
            $result = db_query("SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,guid,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                _debug("base guid found, checking for user record", $debug_enabled);
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
                $orig_plugin_data = db_fetch_result($result, 0, "plugin_data");
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                /* $stored_guid = db_fetch_result($result, 0, "guid");
                					if ($stored_guid != $entry_guid_hashed) {
                						if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled);
                
                						db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
                							id = '$ref_id'");
                					} */
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("article filters: ", $debug_enabled);
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query("COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters);
                _debug("initial score: {$score}", $debug_enabled);
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    _debug("user record not found, creating...", $debug_enabled);
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
                    } else {
                        $marked = 'false';
                    }
                    if (find_article_filter($article_filters, 'publish')) {
                        $published = 'true';
                    } else {
                        $published = 'false';
                    }
                    // N-grams
                    if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
                        $result = db_query("SELECT COUNT(*) AS similar FROM\n\t\t\t\t\t\t\t\t\tttrss_entries,ttrss_user_entries\n\t\t\t\t\t\t\t\tWHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'\n\t\t\t\t\t\t\t\t\tAND similarity(title, '{$entry_title}') >= " . _NGRAM_TITLE_DUPLICATE_THRESHOLD . "\n\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                        $ngram_similar = db_fetch_result($result, 0, "similar");
                        _debug("N-gram similar results: {$ngram_similar}", $debug_enabled);
                        if ($ngram_similar > 0) {
                            $unread = 'false';
                        }
                    }
                    $last_marked = $marked == 'true' ? 'NOW()' : 'NULL';
                    $last_published = $published == 'true' ? 'NOW()' : 'NULL';
                    $result = db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, last_read, marked,\n\t\t\t\t\t\t\t\tpublished, score, tag_cache, label_cache, uuid,\n\t\t\t\t\t\t\t\tlast_marked, last_published)\n\t\t\t\t\t\t\tVALUES ('{$ref_id}', '{$owner_uid}', '{$feed}', {$unread},\n\t\t\t\t\t\t\t\t{$last_read_qpart}, {$marked}, {$published}, '{$score}', '', '',\n\t\t\t\t\t\t\t\t'', {$last_marked}, {$last_published})");
                    if (PUBSUBHUBBUB_HUB && $published == 'true') {
                        $rss_link = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key(-2, false, $owner_uid);
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
                        $pubsub_result = $p->publish_update($rss_link);
                    }
                    $result = db_query("SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t\t\t\tfeed_id = '{$feed}' LIMIT 1");
                    if (db_num_rows($result) == 1) {
                        $entry_int_id = db_fetch_result($result, 0, "int_id");
                    }
                } else {
                    _debug("user record FOUND", $debug_enabled);
                    $entry_ref_id = db_fetch_result($result, 0, "ref_id");
                    $entry_int_id = db_fetch_result($result, 0, "int_id");
                }
                _debug("RID: {$entry_ref_id}, IID: {$entry_int_id}", $debug_enabled);
                $post_needs_update = false;
                $update_insignificant = false;
                if ($orig_num_comments != $num_comments) {
                    $post_needs_update = true;
                    $update_insignificant = true;
                }
                if ($entry_plugin_data != $orig_plugin_data) {
                    $post_needs_update = true;
                    $update_insignificant = true;
                }
                if ($content_hash != $orig_content_hash) {
                    $post_needs_update = true;
                    $update_insignificant = false;
                }
                if (db_escape_string($orig_title) != $entry_title) {
                    $post_needs_update = true;
                    $update_insignificant = false;
                }
                // if post needs update, update it and mark all user entries
                // linking to this post as updated
                if ($post_needs_update) {
                    if (defined('DAEMON_EXTENDED_DEBUG')) {
                        _debug("post {$entry_guid_hashed} needs update...", $debug_enabled);
                    }
                    //						print "<!-- post $orig_title needs update : $post_needs_update -->";
                    db_query("UPDATE ttrss_entries\n\t\t\t\t\t\t\tSET title = '{$entry_title}', content = '{$entry_content}',\n\t\t\t\t\t\t\t\tcontent_hash = '{$content_hash}',\n\t\t\t\t\t\t\t\tupdated = '{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t\tnum_comments = '{$num_comments}',\n\t\t\t\t\t\t\t\tplugin_data = '{$entry_plugin_data}'\n\t\t\t\t\t\t\tWHERE id = '{$ref_id}'");
                    if (!$update_insignificant) {
                        if ($mark_unread_on_update) {
                            db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\t\t\tSET last_read = null, unread = true WHERE ref_id = '{$ref_id}'");
                        }
                    }
                }
            }
            db_query("COMMIT");
            _debug("assigning labels...", $debug_enabled);
            assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels);
            _debug("looking for enclosures...", $debug_enabled);
            // enclosures
            $enclosures = array();
            $encs = $item->get_enclosures();
            if (is_array($encs)) {
                foreach ($encs as $e) {
                    $e_item = array($e->link, $e->type, $e->length);
                    array_push($enclosures, $e_item);
                }
            }
            if ($debug_enabled) {
                _debug("article enclosures:", $debug_enabled);
                print_r($enclosures);
            }
            db_query("BEGIN");
            foreach ($enclosures as $enc) {
                $enc_url = db_escape_string($enc[0]);
                $enc_type = db_escape_string($enc[1]);
                $enc_dur = db_escape_string($enc[2]);
                $result = db_query("SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
                if (db_num_rows($result) == 0) {
                    db_query("INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
                }
            }
            db_query("COMMIT");
            // check for manual tags (we have to do it here since they're loaded from filters)
            foreach ($article_filters as $f) {
                if ($f["type"] == "tag") {
                    $manual_tags = trim_array(explode(",", $f["param"]));
                    foreach ($manual_tags as $tag) {
                        if (tag_is_valid($tag)) {
                            array_push($entry_tags, $tag);
                        }
                    }
                }
            }
            // Skip boring tags
            $boring_tags = trim_array(explode(",", mb_strtolower(get_pref('BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
            $filtered_tags = array();
            $tags_to_cache = array();
            if ($entry_tags && is_array($entry_tags)) {
                foreach ($entry_tags as $tag) {
                    if (array_search($tag, $boring_tags) === false) {
                        array_push($filtered_tags, $tag);
                    }
                }
            }
            $filtered_tags = array_unique($filtered_tags);
            if ($debug_enabled) {
                _debug("filtered article tags:", $debug_enabled);
                print_r($filtered_tags);
            }
            // Save article tags in the database
            if (count($filtered_tags) > 0) {
                db_query("BEGIN");
                foreach ($filtered_tags as $tag) {
                    $tag = sanitize_tag($tag);
                    $tag = db_escape_string($tag);
                    if (!tag_is_valid($tag)) {
                        continue;
                    }
                    $result = db_query("SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
                    if ($result && db_num_rows($result) == 0) {
                        db_query("INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
                    }
                    array_push($tags_to_cache, $tag);
                }
                /* update the cache */
                $tags_to_cache = array_unique($tags_to_cache);
                $tags_str = db_escape_string(join(",", $tags_to_cache));
                db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                db_query("COMMIT");
            }
            if (get_pref("AUTO_ASSIGN_LABELS", $owner_uid, false)) {
                _debug("auto-assigning labels...", $debug_enabled);
                foreach ($labels as $label) {
                    $caption = preg_quote($label["caption"]);
                    if ($caption && preg_match("/\\b{$caption}\\b/i", "{$tags_str} " . strip_tags($entry_content) . " {$entry_title}")) {
                        if (!labels_contains_caption($article_labels, $caption)) {
                            label_add_article($entry_ref_id, $caption, $owner_uid);
                        }
                    }
                }
            }
            _debug("article processed", $debug_enabled);
        }
        _debug("purging feed...", $debug_enabled);
        purge_feed($feed, 0, $debug_enabled);
        db_query("UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
        //			db_query("COMMIT");
    } else {
        $error_msg = db_escape_string(mb_substr($rss->error(), 0, 245));
        _debug("error fetching feed: {$error_msg}", $debug_enabled);
        db_query("UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
    }
    unset($rss);
    _debug("done", $debug_enabled);
}
예제 #9
0
if ($F__utilisateur != "" && $F__utilisateur != 'noneItem') {
    $formList->where .= " AND id_utilisateur='" . $F__utilisateur . "'";
}
$formList->clause_where();
$count_datas = $formList->get_datas();
if (count($formList->datasList) > 0) {
    include DOS_INCPAGES_ADMIN . "list-beforeLoop.php";
    $listRow = array();
    foreach ($formList->datasList as $keyId => $datas) {
        $valeurs = array();
        include DOS_INCPAGES_ADMIN . "list-inLoop.php";
        // chargement d'autres données ///////////////////////////////////////
        // Décrypter les mots de passe
        if (isset($list_champ_crypte[$valeurs["id_champ"]])) {
            $valeurs["valeur_avant"] = decrypt_string("KEY", $valeurs["valeur_avant"]);
            $valeurs["valeur_apres"] = decrypt_string("KEY", $valeurs["valeur_apres"]);
        }
        $valeurs["id_champ"] = $tabChamp[$valeurs["id_champ"]];
        $valeurs["id_element"] = $tabElement[$valeurs["id_element"]];
        // Convetir la date au bon format
        $dt = new DateTime();
        $valeurs["datetime"] = $dt->format('d-m-Y à H:i:s');
        // Récupérer le prefix de id_utilisateur "admin-"
        $prefix_utilisateur = substr($valeurs["id_utilisateur"], 0, 6);
        if ($prefix_utilisateur == "admin-") {
            // garder les valeurs apres "admin-"
            $nom_utilisateur = substr($valeurs["id_utilisateur"], 6);
            $valeurs["id_utilisateur"] = ucfirst($nom_utilisateur);
        }
        // fin chargement données manuellement
        $listRow[$keyId] = $valeurs;
예제 #10
0
require_once "settings.php";
require_once "tools/compat.php";
require_once "functions-ftp.php";
require_once "access_list.php";
require_once "gettext.php";
$cookie_array = array("", "", "");
$cookie_present = FALSE;
if ($ftp_disable_mcrypt) {
    $ftp_remember_me = FALSE;
} elseif (extension_loaded($mcrypt_mod)) {
    if (isset($nocookie)) {
        setcookie("WeebleFM_cookie", "", time(), "/", $HTTP_SERVER_VARS["SERVER_NAME"], 0);
        setcookie("WeebleFM_SID", "", time(), "/", $HTTP_SERVER_VARS["SERVER_NAME"], 0);
        setcookie("WeebleFM_Server", "", time(), "/", $HTTP_SERVER_VARS["SERVER_NAME"], 0);
    } elseif (isset($WeebleFM_cookie) && isset($WeebleFM_SID)) {
        $cookie_string = decrypt_string($WeebleFM_cookie, $key, $WeebleFM_SID, $pref_ciphers);
        $cookie_array = explode("::", $cookie_string, 2);
        if (isset($WeebleFM_Server)) {
            $cookie_array[2] = $WeebleFM_Server;
        }
        $cookie_present = TRUE;
    }
} else {
    if (!isset($ERROR)) {
        $ERROR = 20;
    }
    $ftp_remember_me = FALSE;
}
// If register_globals = off display an error.
if (!ini_get("register_globals") && !isset($ERROR)) {
    $ERROR = 21;
예제 #11
0
     echo $msg;
     exit;
 }
 //echo $response = $xml->response;
 //echo print_r($xml);
 //exit;
 if ($xml->response == "success") {
     /* foreach($xml->line as $row)
              {     
               $row1 = decrypt_string($row); 
        //echo $row1.'<br><br>';
                             mysql_query($row1) or die("Could not perform query - " . mysql_error()); 
        } */
     for ($i = 0; $i <= 61; $i++) {
         $row1 = $xml->line[$i];
         $row1 = decrypt_string($row1);
         mysql_query($row1);
         //echo $row1.'<br><br>';
         if (mysql_error()) {
             echo "There was a unknow problem occured, While installing your application. Try to follow the instructions and install again!";
             echo "<br />1. Before reinstalling DROP the existing tables in your dadabase.";
             echo "<br />2. Delete the files dboprations.php and docroot.php in /system/includes folder, If it exists.";
             exit;
         }
     }
     //exit;
 } else {
     echo $xml->response;
     exit;
 }
 /* $str='<?php 
예제 #12
0
$mySelect->whereValue["id"] = $__GET['idc'];
$result = $mySelect->query();
$row = current($result);
$list_champ_categorie = explode(",", $row["list_champ"]);
foreach ($list_champ_categorie as $idChamp) {
    $mySelect = new mySelect(__FILE__);
    $mySelect->tables = $thisSite->PREFIXE_TBL_CLI . "elements_champs";
    $mySelect->fields = "valeur";
    $mySelect->where = "id_element=:id_element AND id=:id";
    $mySelect->whereValue["id_element"] = $__GET['ide'];
    $mySelect->whereValue["id"] = $idChamp;
    $resultValeur = $mySelect->query();
    $rowValeur = current($resultValeur);
    if ($rowValeur["valeur"] != "") {
        if (in_array($idChamp, $list_champ_crypte)) {
            $rowValeur["valeur"] = decrypt_string("KEY", $rowValeur["valeur"]);
        }
    }
    ?>

<section>
    <div class="row">
        <label class='label col col-2'><?php 
    echo $list_champ[$idChamp];
    ?>
</label>
        <div class='col col-8 '>
            <label class='input lang'>
            <input  class='ctrlg_ ' name='champ<?php 
    echo $idChamp;
    ?>
예제 #13
0
// Load the session data.
session_register("sess_Data");
session_register("theme");
session_register("personal");
// Redirect to the login page if the remote IP address doesn't match that
// specified in the session data.
if ($REMOTE_ADDR != $sess_Data["IP"]) {
    header("Location: login.php\n\n");
    exit;
}
// Checks the status of mcrypt and decrypts the password if necessary.  Redirect
// to the login page if mcrypt is unavailable but not disabled.
if ($ftp_disable_mcrypt) {
    $ftp_Pass = $sess_Data["pass"];
} elseif (extension_loaded($mcrypt_mod)) {
    $ftp_Pass = decrypt_string($sess_Data["pass"], $key . $REMOTE_ADDR . $HTTP_USER_AGENT, $SID, $pref_ciphers);
} else {
    header("Location: login.php\n\n");
    exit;
}
// Log into the user's FTP account.
$fp = ftp_connect($sess_Data["server"], $sess_Data["port"]);
//ftp_login ( $fp, $sess_Data["user"], $ftp_Pass );
// Attempt to log into your account with the username and password
$result = @ftp_login($fp, $sess_Data["user"], $ftp_Pass);
if ($result == 0) {
    header("Location: login.php?ERROR=3\n\n");
    exit;
}
// Set passive mode if needed.
if ($ftp_Passive_Mode) {
예제 #14
0
파일: smtp.php 프로젝트: JSpier/smacamp
function smtp_phpmailer_init($phpmailer)
{
    $smtp_options = get_option('smtp_options');
    $admin_info = get_userdata(1);
    // Set Mailer value
    $phpmailer->Mailer = 'smtp';
    // Set From value
    $phpmailer->From = $admin_info->user_email;
    // Set FromName value
    $phpmailer->FromName = $admin_info->display_name;
    // Set SMTPSecure value
    $phpmailer->SMTPSecure = $smtp_options['smtp_secure'];
    // Set Host value
    $phpmailer->Host = $smtp_options['host'];
    // Set Port value
    $phpmailer->Port = $smtp_options['port'];
    // If usrname option is not blank we have to use authentication
    if ($smtp_options['username'] != '') {
        $phpmailer->SMTPAuth = true;
        $phpmailer->Username = $smtp_options['username'];
        $phpmailer->Password = decrypt_string($smtp_options['password'], CRYPT_KEY);
    }
}
예제 #15
0
function decrypt_string_and_decode($salt, $string)
{
    return decrypt_string($salt, base64_decode($string));
}
예제 #16
0
/**
 * Validate the user session based on user name and password hash.
 *
 * @param string $user_name -- The user name to create a session for
 * @param string $password -- The MD5 sum of the user's password
 * @return true -- If the session is created
 * @return false -- If the session is not created
 */
function validate_user($user_name, $password)
{
    global $server, $current_user, $sugar_config, $system_config;
    $user = new User();
    $user->user_name = $user_name;
    $system_config = new Administration();
    $system_config->retrieveSettings('system');
    $authController = new AuthenticationController(!empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate');
    // Check to see if the user name and password are consistent.
    if ($user->authenticate_user($password)) {
        // we also need to set the current_user.
        $user->retrieve($user->id);
        $current_user = $user;
        login_success();
        return true;
    } else {
        if (function_exists('mcrypt_cbc')) {
            $password = decrypt_string($password);
            if ($authController->login($user_name, $password) && isset($_SESSION['authenticated_user_id'])) {
                $user->retrieve($_SESSION['authenticated_user_id']);
                $current_user = $user;
                login_success();
                return true;
            }
        } else {
            $GLOBALS['log']->fatal("SECURITY: failed attempted login for {$user_name} using SOAP api");
            $server->setError("Invalid username and/or password");
            return false;
        }
    }
}
예제 #17
0
Todo:  do we trigger \core\event\user_enrolment_created::create() ??
*/
function enrol_into_course($courseid, $userid, $roleid = 5)
{
    global $DB;
    $manualenrol = enrol_get_plugin('manual');
    // get the enrolment plugin
    $enrolinstance = $DB->get_record('enrol', array('courseid' => $courseid, 'status' => ENROL_INSTANCE_ENABLED, 'enrol' => 'manual'), '*', MUST_EXIST);
    // retrieve enrolment instance associated with your course
    return $manualenrol->enrol_user($enrolinstance, $userid, $roleid);
    // enrol the user
}
$rawdata = $_GET['data'];
if (!empty($_GET)) {
    // get the data that was passed in
    $userdata = decrypt_string($rawdata, $PASSTHROUGH_KEY);
    // time (in minutes) before incoming link is considered invalid
    $timeout = (int) get_config('auth/wp2moodle', 'timeout');
    if ($timeout == 0) {
        $timeout = 5;
    }
    // check the timestamp to make sure that the request is still within a few minutes of this servers time
    // if userdata didn't decrypt, then timestamp will = 0, so following code will be bypassed anyway (e.g. bad data)
    $timestamp = (int) get_key_value($userdata, "stamp");
    // remote site should have set this to new DateTime("now").getTimestamp(); which is a unix timestamp (utc)
    $theirs = new DateTime("@{$timestamp}");
    // @ format here: http://www.gnu.org/software/tar/manual/html_node/Seconds-since-the-Epoch.html#SEC127
    $diff = floatval(date_diff(date_create("now"), $theirs)->format("%i"));
    // http://www.php.net/manual/en/dateinterval.format.php
    if ($timestamp > 0 && $diff <= $timeout) {
        // less than N minutes passed since this link was created, so it's still ok
예제 #18
0
function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false, $rss = false)
{
    $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
    _debug_suppress(!$debug_enabled);
    _debug("start", $debug_enabled);
    $result = db_query("SELECT title FROM ttrss_feeds\n\t\t\tWHERE id = '{$feed}'");
    $title = db_fetch_result($result, 0, "title");
    // feed was batch-subscribed or something, we need to get basic info
    // this is not optimal currently as it fetches stuff separately TODO: optimize
    if ($title == "[Unknown]") {
        _debug("setting basic feed info for {$feed}...");
        set_basic_feed_info($feed);
    }
    $result = db_query("SELECT id,update_interval,auth_login,\n\t\t\tfeed_url,auth_pass,cache_images,\n\t\t\tmark_unread_on_update, owner_uid,\n\t\t\tpubsub_state, auth_pass_encrypted,\n\t\t\tfeed_language,\n\t\t\t(SELECT max(date_entered) FROM\n\t\t\t\tttrss_entries, ttrss_user_entries where ref_id = id AND feed_id = '{$feed}') AS last_article_timestamp\n\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
    if (db_num_rows($result) == 0) {
        _debug("feed {$feed} NOT FOUND/SKIPPED", $debug_enabled);
        return false;
    }
    $last_article_timestamp = @strtotime(db_fetch_result($result, 0, "last_article_timestamp"));
    if (defined('_DISABLE_HTTP_304')) {
        $last_article_timestamp = 0;
    }
    $owner_uid = db_fetch_result($result, 0, "owner_uid");
    $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
    $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
    $auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result, 0, "auth_pass_encrypted"));
    db_query("UPDATE ttrss_feeds SET last_update_started = NOW()\n\t\t\tWHERE id = '{$feed}'");
    $auth_login = db_fetch_result($result, 0, "auth_login");
    $auth_pass = db_fetch_result($result, 0, "auth_pass");
    if ($auth_pass_encrypted) {
        require_once "crypt.php";
        $auth_pass = decrypt_string($auth_pass);
    }
    $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
    $fetch_url = db_fetch_result($result, 0, "feed_url");
    $feed_language = db_escape_string(mb_strtolower(db_fetch_result($result, 0, "feed_language")));
    if (!$feed_language) {
        $feed_language = 'english';
    }
    $feed = db_escape_string($feed);
    $date_feed_processed = date('Y-m-d H:i');
    $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
    $pluginhost = new PluginHost();
    $pluginhost->set_debug($debug_enabled);
    $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
    $pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
    $pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
    $pluginhost->load_data();
    if ($rss && is_object($rss) && get_class($rss) == "FeedParser") {
        _debug("using previously initialized parser object");
    } else {
        $rss_hash = false;
        $force_refetch = isset($_REQUEST["force_refetch"]);
        foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
            $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass);
        }
        // try cache
        if (!$feed_data && file_exists($cache_filename) && is_readable($cache_filename) && !$auth_login && !$auth_pass && filemtime($cache_filename) > time() - 30) {
            _debug("using local cache [{$cache_filename}].", $debug_enabled);
            @($feed_data = file_get_contents($cache_filename));
            if ($feed_data) {
                $rss_hash = sha1($feed_data);
            }
        } else {
            _debug("local cache will not be used for this feed", $debug_enabled);
        }
        // fetch feed from source
        if (!$feed_data) {
            _debug("fetching [{$fetch_url}]...", $debug_enabled);
            _debug("If-Modified-Since: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $last_article_timestamp), $debug_enabled);
            $feed_data = fetch_file_contents($fetch_url, false, $auth_login, $auth_pass, false, $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT, $force_refetch ? 0 : $last_article_timestamp);
            global $fetch_curl_used;
            if (!$fetch_curl_used) {
                $tmp = @gzdecode($feed_data);
                if ($tmp) {
                    $feed_data = $tmp;
                }
            }
            $feed_data = trim($feed_data);
            _debug("fetch done.", $debug_enabled);
            // cache vanilla feed data for re-use
            if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
                $new_rss_hash = sha1($feed_data);
                if ($new_rss_hash != $rss_hash) {
                    _debug("saving {$cache_filename}", $debug_enabled);
                    @file_put_contents($cache_filename, $feed_data);
                }
            }
        }
        if (!$feed_data) {
            global $fetch_last_error;
            global $fetch_last_error_code;
            _debug("unable to fetch: {$fetch_last_error} [{$fetch_last_error_code}]", $debug_enabled);
            $error_escaped = '';
            // If-Modified-Since
            if ($fetch_last_error_code != 304) {
                $error_escaped = db_escape_string($fetch_last_error);
            } else {
                _debug("source claims data not modified, nothing to do.", $debug_enabled);
            }
            db_query("UPDATE ttrss_feeds SET last_error = '{$error_escaped}',\n\t\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
            return;
        }
    }
    foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
        $feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed);
    }
    // set last update to now so if anything *simplepie* crashes later we won't be
    // continuously failing on the same feed
    //db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'");
    if (!$rss) {
        $rss = new FeedParser($feed_data);
        $rss->init();
    }
    //		print_r($rss);
    $feed = db_escape_string($feed);
    if (!$rss->error()) {
        // We use local pluginhost here because we need to load different per-user feed plugins
        $pluginhost->run_hooks(PluginHost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
        _debug("language: {$feed_language}", $debug_enabled);
        _debug("processing feed data...", $debug_enabled);
        //			db_query("BEGIN");
        if (DB_TYPE == "pgsql") {
            $favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'";
        } else {
            $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)";
        }
        $result = db_query("SELECT owner_uid,favicon_avg_color,\n\t\t\t\t(favicon_last_checked IS NULL OR {$favicon_interval_qpart}) AS\n\t\t\t\t\t\tfavicon_needs_check\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
        $favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0, "favicon_needs_check"));
        $favicon_avg_color = db_fetch_result($result, 0, "favicon_avg_color");
        $owner_uid = db_fetch_result($result, 0, "owner_uid");
        $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245));
        _debug("site_url: {$site_url}", $debug_enabled);
        _debug("feed_title: " . $rss->get_title(), $debug_enabled);
        if ($favicon_needs_check || $force_refetch) {
            /* terrible hack: if we crash on floicon shit here, we won't check
             * the icon avgcolor again (unless the icon got updated) */
            $favicon_file = ICONS_DIR . "/{$feed}.ico";
            $favicon_modified = @filemtime($favicon_file);
            _debug("checking favicon...", $debug_enabled);
            check_feed_favicon($site_url, $feed);
            $favicon_modified_new = @filemtime($favicon_file);
            if ($favicon_modified_new > $favicon_modified) {
                $favicon_avg_color = '';
            }
            if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color == '') {
                require_once "colors.php";
                db_query("UPDATE ttrss_feeds SET favicon_avg_color = 'fail' WHERE\n\t\t\t\t\t\t\tid = '{$feed}'");
                $favicon_color = db_escape_string(calculate_avg_color($favicon_file));
                $favicon_colorstring = ",favicon_avg_color = '" . $favicon_color . "'";
            } else {
                if ($favicon_avg_color == 'fail') {
                    _debug("floicon failed on this file, not trying to recalculate avg color", $debug_enabled);
                }
            }
            db_query("UPDATE ttrss_feeds SET favicon_last_checked = NOW()\n\t\t\t\t\t{$favicon_colorstring}\n\t\t\t\t\tWHERE id = '{$feed}'");
        }
        _debug("loading filters & labels...", $debug_enabled);
        $filters = load_filters($feed, $owner_uid);
        _debug("" . count($filters) . " filters loaded.", $debug_enabled);
        $items = $rss->get_items();
        if (!is_array($items)) {
            _debug("no articles found.", $debug_enabled);
            db_query("UPDATE ttrss_feeds\n\t\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
            return;
            // no articles
        }
        if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) {
            _debug("checking for PUSH hub...", $debug_enabled);
            $feed_hub_url = false;
            $links = $rss->get_links('hub');
            if ($links && is_array($links)) {
                foreach ($links as $l) {
                    $feed_hub_url = $l;
                    break;
                }
            }
            _debug("feed hub url: {$feed_hub_url}", $debug_enabled);
            $feed_self_url = $fetch_url;
            $links = $rss->get_links('self');
            if ($links && is_array($links)) {
                foreach ($links as $l) {
                    $feed_self_url = $l;
                    break;
                }
            }
            _debug("feed self url = {$feed_self_url}");
            if ($feed_hub_url && $feed_self_url && function_exists('curl_init') && !ini_get("open_basedir")) {
                require_once 'lib/pubsubhubbub/subscriber.php';
                $callback_url = get_self_url_prefix() . "/public.php?op=pubsub&id={$feed}";
                $s = new Subscriber($feed_hub_url, $callback_url);
                $rc = $s->subscribe($feed_self_url);
                _debug("feed hub url found, subscribe request sent. [rc={$rc}]", $debug_enabled);
                db_query("UPDATE ttrss_feeds SET pubsub_state = 1\n\t\t\t\t\t\tWHERE id = '{$feed}'");
            }
        }
        _debug("processing articles...", $debug_enabled);
        $tstart = time();
        foreach ($items as $item) {
            if ($_REQUEST['xdebug'] == 3) {
                print_r($item);
            }
            if (ini_get("max_execution_time") > 0 && time() - $tstart >= ini_get("max_execution_time") * 0.7) {
                _debug("looks like there's too many articles to process at once, breaking out", $debug_enabled);
                break;
            }
            $entry_guid = $item->get_id();
            if (!$entry_guid) {
                $entry_guid = $item->get_link();
            }
            if (!$entry_guid) {
                $entry_guid = make_guid_from_title($item->get_title());
            }
            if (!$entry_guid) {
                continue;
            }
            $entry_guid = "{$owner_uid},{$entry_guid}";
            $entry_guid_hashed = db_escape_string('SHA1:' . sha1($entry_guid));
            _debug("guid {$entry_guid} / {$entry_guid_hashed}", $debug_enabled);
            $entry_timestamp = "";
            $entry_timestamp = $item->get_date();
            _debug("orig date: " . $item->get_date(), $debug_enabled);
            if ($entry_timestamp == -1 || !$entry_timestamp || $entry_timestamp > time()) {
                $entry_timestamp = time();
            }
            $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
            _debug("date {$entry_timestamp} [{$entry_timestamp_fmt}]", $debug_enabled);
            //				$entry_title = html_entity_decode($item->get_title(), ENT_COMPAT, 'UTF-8');
            //				$entry_title = decode_numeric_entities($entry_title);
            $entry_title = $item->get_title();
            $entry_link = rewrite_relative_url($site_url, $item->get_link());
            _debug("title {$entry_title}", $debug_enabled);
            _debug("link {$entry_link}", $debug_enabled);
            if (!$entry_title) {
                $entry_title = date("Y-m-d H:i:s", $entry_timestamp);
            }
            $entry_content = $item->get_content();
            if (!$entry_content) {
                $entry_content = $item->get_description();
            }
            if ($_REQUEST["xdebug"] == 2) {
                print "content: ";
                print $entry_content;
                print "\n";
            }
            $entry_comments = $item->get_comments_url();
            $entry_author = $item->get_author();
            $entry_guid = db_escape_string(mb_substr($entry_guid, 0, 245));
            $entry_comments = db_escape_string(mb_substr(trim($entry_comments), 0, 245));
            $entry_author = db_escape_string(mb_substr(trim($entry_author), 0, 245));
            $num_comments = (int) $item->get_comments_count();
            _debug("author {$entry_author}", $debug_enabled);
            _debug("num_comments: {$num_comments}", $debug_enabled);
            _debug("looking for tags...", $debug_enabled);
            // parse <category> entries into tags
            $additional_tags = array();
            $additional_tags_src = $item->get_categories();
            if (is_array($additional_tags_src)) {
                foreach ($additional_tags_src as $tobj) {
                    array_push($additional_tags, $tobj);
                }
            }
            $entry_tags = array_unique($additional_tags);
            for ($i = 0; $i < count($entry_tags); $i++) {
                $entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
            }
            _debug("tags found: " . join(",", $entry_tags), $debug_enabled);
            _debug("done collecting data.", $debug_enabled);
            $result = db_query("SELECT id, content_hash, lang FROM ttrss_entries\n\t\t\t\t\tWHERE guid = '" . db_escape_string($entry_guid) . "' OR guid = '{$entry_guid_hashed}'");
            if (db_num_rows($result) != 0) {
                $base_entry_id = db_fetch_result($result, 0, "id");
                $entry_stored_hash = db_fetch_result($result, 0, "content_hash");
                $article_labels = get_article_labels($base_entry_id, $owner_uid);
                $entry_language = db_fetch_result($result, 0, "lang");
            } else {
                $base_entry_id = false;
                $entry_stored_hash = "";
                $article_labels = array();
                $entry_language = "";
            }
            $article = array("owner_uid" => $owner_uid, "guid" => $entry_guid, "guid_hashed" => $entry_guid_hashed, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "labels" => $article_labels, "tags" => $entry_tags, "author" => $entry_author, "force_catchup" => false, "score_modifier" => 0, "language" => $entry_language, "feed" => array("id" => $feed, "fetch_url" => $fetch_url, "site_url" => $site_url));
            $entry_plugin_data = "";
            $entry_current_hash = calculate_article_hash($article, $pluginhost);
            _debug("article hash: {$entry_current_hash} [stored={$entry_stored_hash}]", $debug_enabled);
            if ($entry_current_hash == $entry_stored_hash && !isset($_REQUEST["force_rehash"])) {
                _debug("stored article seems up to date [IID: {$base_entry_id}], updating timestamp only", $debug_enabled);
                // we keep encountering the entry in feeds, so we need to
                // update date_updated column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
                // if we allow duplicate posts, we have to continue to
                // create the user entries for this feed
                if (!get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    continue;
                }
            }
            _debug("hash differs, applying plugin filters:", $debug_enabled);
            foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
                _debug("... " . get_class($plugin), $debug_enabled);
                $start = microtime(true);
                $article = $plugin->hook_article_filter($article);
                _debug("=== " . sprintf("%.4f (sec)", microtime(true) - $start), $debug_enabled);
                $entry_plugin_data .= mb_strtolower(get_class($plugin)) . ",";
            }
            $entry_plugin_data = db_escape_string($entry_plugin_data);
            _debug("plugin data: {$entry_plugin_data}", $debug_enabled);
            // Workaround: 4-byte unicode requires utf8mb4 in MySQL. See https://tt-rss.org/forum/viewtopic.php?f=1&t=3377&p=20077#p20077
            if (DB_TYPE == "mysql") {
                foreach ($article as $k => $v) {
                    // i guess we'll have to take the risk of 4byte unicode labels & tags here
                    if (!is_array($article[$k])) {
                        $article[$k] = preg_replace('/[\\x{10000}-\\x{10FFFF}]/u', "�", $v);
                    }
                }
            }
            $entry_tags = $article["tags"];
            $entry_guid = db_escape_string($entry_guid);
            $entry_title = db_escape_string($article["title"]);
            $entry_author = db_escape_string($article["author"]);
            $entry_link = db_escape_string($article["link"]);
            $entry_content = $article["content"];
            // escaped below
            $entry_force_catchup = $article["force_catchup"];
            $article_labels = $article["labels"];
            $entry_score_modifier = (int) $article["score_modifier"];
            $entry_language = db_escape_string($article["language"]);
            if ($debug_enabled) {
                _debug("article labels:", $debug_enabled);
                print_r($article_labels);
            }
            _debug("force catchup: {$entry_force_catchup}");
            if ($cache_images && is_writable(CACHE_DIR . '/images')) {
                cache_images($entry_content, $site_url, $debug_enabled);
            }
            $entry_content = db_escape_string($entry_content, false);
            db_query("BEGIN");
            $result = db_query("SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE (guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}')");
            if (db_num_rows($result) == 0) {
                _debug("base guid [{$entry_guid}] not found", $debug_enabled);
                // base post entry does not exist, create it
                $result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tlang,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid_hashed}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$entry_current_hash}',\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$date_feed_processed}',\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_language}',\n\t\t\t\t\t\t\t'{$entry_author}')");
            } else {
                $base_entry_id = db_fetch_result($result, 0, "id");
            }
            // now it should exist, if not - bad luck then
            $result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                _debug("base guid found, checking for user record", $debug_enabled);
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                /* $stored_guid = db_fetch_result($result, 0, "guid");
                					if ($stored_guid != $entry_guid_hashed) {
                						if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled);
                
                						db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
                							id = '$ref_id'");
                					} */
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("article filters: ", $debug_enabled);
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query("COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters) + $entry_score_modifier;
                _debug("initial score: {$score} [including plugin modifier: {$entry_score_modifier}]", $debug_enabled);
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    _debug("user record not found, creating...", $debug_enabled);
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
                    } else {
                        $marked = 'false';
                    }
                    if (find_article_filter($article_filters, 'publish')) {
                        $published = 'true';
                    } else {
                        $published = 'false';
                    }
                    // N-grams
                    /* if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
                    
                    							$result = db_query("SELECT COUNT(*) AS similar FROM
                    									ttrss_entries,ttrss_user_entries
                    								WHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'
                    									AND similarity(title, '$entry_title') >= "._NGRAM_TITLE_DUPLICATE_THRESHOLD."
                    									AND owner_uid = $owner_uid");
                    
                    							$ngram_similar = db_fetch_result($result, 0, "similar");
                    
                    							_debug("N-gram similar results: $ngram_similar", $debug_enabled);
                    
                    							if ($ngram_similar > 0) {
                    								$unread = 'false';
                    							}
                    						} */
                    $last_marked = $marked == 'true' ? 'NOW()' : 'NULL';
                    $last_published = $published == 'true' ? 'NOW()' : 'NULL';
                    $result = db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, last_read, marked,\n\t\t\t\t\t\t\t\tpublished, score, tag_cache, label_cache, uuid,\n\t\t\t\t\t\t\t\tlast_marked, last_published)\n\t\t\t\t\t\t\tVALUES ('{$ref_id}', '{$owner_uid}', '{$feed}', {$unread},\n\t\t\t\t\t\t\t\t{$last_read_qpart}, {$marked}, {$published}, '{$score}', '', '',\n\t\t\t\t\t\t\t\t'', {$last_marked}, {$last_published})");
                    if (PUBSUBHUBBUB_HUB && $published == 'true') {
                        $rss_link = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key(-2, false, $owner_uid);
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
                        /* $pubsub_result = */
                        $p->publish_update($rss_link);
                    }
                    $result = db_query("SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t\t\t\tfeed_id = '{$feed}' LIMIT 1");
                    if (db_num_rows($result) == 1) {
                        $entry_int_id = db_fetch_result($result, 0, "int_id");
                    }
                } else {
                    _debug("user record FOUND", $debug_enabled);
                    $entry_ref_id = db_fetch_result($result, 0, "ref_id");
                    $entry_int_id = db_fetch_result($result, 0, "int_id");
                }
                _debug("RID: {$entry_ref_id}, IID: {$entry_int_id}", $debug_enabled);
                if (DB_TYPE == "pgsql") {
                    $tsvector_combined = db_escape_string(mb_substr($entry_title . ' ' . strip_tags($entry_content), 0, 1000000));
                    $tsvector_qpart = "tsvector_combined = to_tsvector('{$feed_language}', '{$tsvector_combined}'),";
                } else {
                    $tsvector_qpart = "";
                }
                db_query("UPDATE ttrss_entries\n\t\t\t\t\t\tSET title = '{$entry_title}',\n\t\t\t\t\t\t\tcontent = '{$entry_content}',\n\t\t\t\t\t\t\tcontent_hash = '{$entry_current_hash}',\n\t\t\t\t\t\t\tupdated = '{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t{$tsvector_qpart}\n\t\t\t\t\t\t\tnum_comments = '{$num_comments}',\n\t\t\t\t\t\t\tplugin_data = '{$entry_plugin_data}',\n\t\t\t\t\t\t\tauthor = '{$entry_author}',\n\t\t\t\t\t\t\tlang = '{$entry_language}'\n\t\t\t\t\t\tWHERE id = '{$ref_id}'");
                // update aux data
                db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET score = '{$score}' WHERE ref_id = '{$ref_id}'");
                if ($mark_unread_on_update) {
                    db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET last_read = null, unread = true WHERE ref_id = '{$ref_id}'");
                }
            }
            db_query("COMMIT");
            _debug("assigning labels [other]...", $debug_enabled);
            foreach ($article_labels as $label) {
                label_add_article($entry_ref_id, $label[1], $owner_uid);
            }
            _debug("assigning labels [filters]...", $debug_enabled);
            assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels);
            _debug("looking for enclosures...", $debug_enabled);
            // enclosures
            $enclosures = array();
            $encs = $item->get_enclosures();
            if (is_array($encs)) {
                foreach ($encs as $e) {
                    $e_item = array($e->link, $e->type, $e->length, $e->title, $e->width, $e->height);
                    array_push($enclosures, $e_item);
                }
            }
            if ($debug_enabled) {
                _debug("article enclosures:", $debug_enabled);
                print_r($enclosures);
            }
            db_query("BEGIN");
            //				debugging
            //				db_query("DELETE FROM ttrss_enclosures WHERE post_id = '$entry_ref_id'");
            foreach ($enclosures as $enc) {
                $enc_url = db_escape_string($enc[0]);
                $enc_type = db_escape_string($enc[1]);
                $enc_dur = db_escape_string($enc[2]);
                $enc_title = db_escape_string($enc[3]);
                $enc_width = intval($enc[4]);
                $enc_height = intval($enc[5]);
                $result = db_query("SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
                if (db_num_rows($result) == 0) {
                    db_query("INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id, width, height) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '{$enc_title}', '{$enc_dur}', '{$entry_ref_id}', {$enc_width}, {$enc_height})");
                }
            }
            db_query("COMMIT");
            // check for manual tags (we have to do it here since they're loaded from filters)
            foreach ($article_filters as $f) {
                if ($f["type"] == "tag") {
                    $manual_tags = trim_array(explode(",", $f["param"]));
                    foreach ($manual_tags as $tag) {
                        if (tag_is_valid($tag)) {
                            array_push($entry_tags, $tag);
                        }
                    }
                }
            }
            // Skip boring tags
            $boring_tags = trim_array(explode(",", mb_strtolower(get_pref('BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
            $filtered_tags = array();
            $tags_to_cache = array();
            if ($entry_tags && is_array($entry_tags)) {
                foreach ($entry_tags as $tag) {
                    if (array_search($tag, $boring_tags) === false) {
                        array_push($filtered_tags, $tag);
                    }
                }
            }
            $filtered_tags = array_unique($filtered_tags);
            if ($debug_enabled) {
                _debug("filtered article tags:", $debug_enabled);
                print_r($filtered_tags);
            }
            // Save article tags in the database
            if (count($filtered_tags) > 0) {
                db_query("BEGIN");
                foreach ($filtered_tags as $tag) {
                    $tag = sanitize_tag($tag);
                    $tag = db_escape_string($tag);
                    if (!tag_is_valid($tag)) {
                        continue;
                    }
                    $result = db_query("SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
                    if ($result && db_num_rows($result) == 0) {
                        db_query("INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
                    }
                    array_push($tags_to_cache, $tag);
                }
                /* update the cache */
                $tags_to_cache = array_unique($tags_to_cache);
                $tags_str = db_escape_string(join(",", $tags_to_cache));
                db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                db_query("COMMIT");
            }
            _debug("article processed", $debug_enabled);
        }
        _debug("purging feed...", $debug_enabled);
        purge_feed($feed, 0, $debug_enabled);
        db_query("UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
        //			db_query("COMMIT");
    } else {
        $error_msg = db_escape_string(mb_substr($rss->error(), 0, 245));
        _debug("fetch error: {$error_msg}", $debug_enabled);
        if (count($rss->errors()) > 1) {
            foreach ($rss->errors() as $error) {
                _debug("+ {$error}");
            }
        }
        db_query("UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
        unset($rss);
    }
    _debug("done", $debug_enabled);
    return $rss;
}
예제 #19
0
파일: feeds.php 프로젝트: AHinMaine/ttrss
 function editfeed()
 {
     global $purge_intervals;
     global $update_intervals;
     print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
     		<div dojoType="dijit.layout.ContentPane" title="' . __('General') . '">';
     $feed_id = $this->dbh->escape_string($_REQUEST["id"]);
     $result = $this->dbh->query("SELECT * FROM ttrss_feeds WHERE id = '{$feed_id}' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"]);
     $auth_pass_encrypted = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "auth_pass_encrypted"));
     $title = htmlspecialchars($this->dbh->fetch_result($result, 0, "title"));
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$feed_id}\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
     print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
     print "<div class=\"dlgSecCont\">";
     /* Title */
     print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed Title") . "\"\n\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"title\" value=\"{$title}\">";
     /* Feed URL */
     $feed_url = $this->dbh->fetch_result($result, 0, "feed_url");
     $feed_url = htmlspecialchars($this->dbh->fetch_result($result, 0, "feed_url"));
     print "<hr/>";
     print __('URL:') . " ";
     print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed URL") . "\"\n\t\t\tregExp='^(http|https)://.*' style=\"width : 20em\"\n\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
     $last_error = $this->dbh->fetch_result($result, 0, "last_error");
     if ($last_error) {
         print "&nbsp;<img src=\"images/error.png\" alt=\"(error)\"\n\t\t\t\tstyle=\"vertical-align : middle\"\n\t\t\t\ttitle=\"" . htmlspecialchars($last_error) . "\">";
     }
     /* Category */
     if (get_pref('ENABLE_FEED_CATS')) {
         $cat_id = $this->dbh->fetch_result($result, 0, "cat_id");
         print "<hr/>";
         print __('Place in category:') . " ";
         print_feed_cat_select("cat_id", $cat_id, 'dojoType="dijit.form.Select"');
     }
     /* FTS Stemming Language */
     if (DB_TYPE == "pgsql") {
         $feed_language = $this->dbh->fetch_result($result, 0, "feed_language");
         print "<hr/>";
         print __('Language:') . " ";
         print_select("feed_language", $feed_language, $this::$feed_languages, 'dojoType="dijit.form.Select"');
     }
     print "</div>";
     print "<div class=\"dlgSec\">" . __("Update") . "</div>";
     print "<div class=\"dlgSecCont\">";
     /* Update Interval */
     $update_interval = $this->dbh->fetch_result($result, 0, "update_interval");
     print_select_hash("update_interval", $update_interval, $update_intervals, 'dojoType="dijit.form.Select"');
     /* Purge intl */
     $purge_interval = $this->dbh->fetch_result($result, 0, "purge_interval");
     print "<hr/>";
     print __('Article purging:') . " ";
     print_select_hash("purge_interval", $purge_interval, $purge_intervals, 'dojoType="dijit.form.Select" ' . (FORCE_ARTICLE_PURGE == 0 ? "" : 'disabled="1"'));
     print "</div>";
     print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
     print "<div class=\"dlgSecCont\">";
     $auth_login = htmlspecialchars($this->dbh->fetch_result($result, 0, "auth_login"));
     print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\"\n\t\t\tplaceHolder=\"" . __("Login") . "\"\n\t\t\tname=\"auth_login\" value=\"{$auth_login}\"><hr/>";
     $auth_pass = $this->dbh->fetch_result($result, 0, "auth_pass");
     if ($auth_pass_encrypted) {
         require_once "crypt.php";
         $auth_pass = decrypt_string($auth_pass);
     }
     $auth_pass = htmlspecialchars($auth_pass);
     print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"\n\t\t\tplaceHolder=\"" . __("Password") . "\"\n\t\t\tvalue=\"{$auth_pass}\">";
     print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\">\n\t\t\t" . __('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.') . "\n\t\t\t</div>";
     print "</div>";
     print '</div><div dojoType="dijit.layout.ContentPane" title="' . __('Options') . '">';
     //print "<div class=\"dlgSec\">".__("Options")."</div>";
     print "<div class=\"dlgSecSimple\">";
     $private = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "private"));
     if ($private) {
         $checked = "checked=\"1\"";
     } else {
         $checked = "";
     }
     print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"\n\t\t\t{$checked}>&nbsp;<label for=\"private\">" . __('Hide from Popular feeds') . "</label>";
     $include_in_digest = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "include_in_digest"));
     if ($include_in_digest) {
         $checked = "checked=\"1\"";
     } else {
         $checked = "";
     }
     print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"\n\t\t\tname=\"include_in_digest\"\n\t\t\t{$checked}>&nbsp;<label for=\"include_in_digest\">" . __('Include in e-mail digest') . "</label>";
     $always_display_enclosures = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "always_display_enclosures"));
     if ($always_display_enclosures) {
         $checked = "checked";
     } else {
         $checked = "";
     }
     print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"\n\t\t\tname=\"always_display_enclosures\"\n\t\t\t{$checked}>&nbsp;<label for=\"always_display_enclosures\">" . __('Always display image attachments') . "</label>";
     $hide_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "hide_images"));
     if ($hide_images) {
         $checked = "checked=\"1\"";
     } else {
         $checked = "";
     }
     print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"hide_images\"\n\t\tname=\"hide_images\"\n\t\t\t{$checked}>&nbsp;<label for=\"hide_images\">" . __('Do not embed images') . "</label>";
     $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
     if ($cache_images) {
         $checked = "checked=\"1\"";
     } else {
         $checked = "";
     }
     print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"\n\t\tname=\"cache_images\"\n\t\t\t{$checked}>&nbsp;<label for=\"cache_images\">" . __('Cache images locally') . "</label>";
     $mark_unread_on_update = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "mark_unread_on_update"));
     if ($mark_unread_on_update) {
         $checked = "checked";
     } else {
         $checked = "";
     }
     print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\"\n\t\t\tname=\"mark_unread_on_update\"\n\t\t\t{$checked}>&nbsp;<label for=\"mark_unread_on_update\">" . __('Mark updated articles as unread') . "</label>";
     print "</div>";
     print '</div><div dojoType="dijit.layout.ContentPane" title="' . __('Icon') . '">';
     /* Icon */
     print "<div class=\"dlgSecSimple\">";
     print "<iframe name=\"icon_upload_iframe\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
     print "<form style='display : block' target=\"icon_upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\">\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">\n\t\t\t<input type=\"hidden\" name=\"feed_id\" value=\"{$feed_id}\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"uploadicon\"><p>\n\t\t\t<button class=\"\" dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\"\n\t\t\t\ttype=\"submit\">" . __('Replace') . "</button>\n\t\t\t<button class=\"\" dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon({$feed_id});\"\n\t\t\t\ttype=\"submit\">" . __('Remove') . "</button>\n\t\t\t</form>";
     print "</div>";
     print '</div><div dojoType="dijit.layout.ContentPane" title="' . __('Plugins') . '">';
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED, "hook_prefs_edit_feed", $feed_id);
     print "</div></div>";
     $title = htmlspecialchars($title, ENT_QUOTES);
     print "<div class='dlgButtons'>\n\t\t\t<div style=\"float : left\">\n\t\t\t<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed({$feed_id}, \"{$title}\")'>" . __('Unsubscribe') . "</button>";
     if (PUBSUBHUBBUB_ENABLED) {
         $pubsub_state = $this->dbh->fetch_result($result, 0, "pubsub_state");
         $pubsub_btn_disabled = $pubsub_state == 2 ? "" : "disabled=\"1\"";
         print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" {$pubsub_btn_disabled}\n\t\t\t\t\tonclick='return resetPubSub({$feed_id}, \"{$title}\")'>" . __('Resubscribe to push updates') . "</button>";
     }
     print "</div>";
     print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">" . __('Resets PubSubHubbub subscription status for push-enabled feeds.') . "</div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">" . __('Save') . "</button>\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">" . __('Cancel') . "</button>\n\t\t</div>";
     return;
 }
예제 #20
0
파일: auth.inc.php 프로젝트: ly95/adminer
        page_footer("db");
        exit;
    } else {
        foreach (array("pwds", "db", "dbs", "queries") as $key) {
            set_session($key, null);
        }
        unset_permanent();
        redirect(substr(preg_replace('~\\b(username|db|ns)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.'));
    }
} elseif ($permanent && !$_SESSION["pwds"]) {
    session_regenerate_id();
    $private = $adminer->permanentLogin();
    foreach ($permanent as $key => $val) {
        list(, $cipher) = explode(":", $val);
        list($vendor, $server, $username, $db) = array_map('base64_decode', explode("-", $key));
        set_password($vendor, $server, $username, decrypt_string(base64_decode($cipher), $private));
        $_SESSION["db"][$vendor][$server][$username][$db] = true;
    }
}
function unset_permanent()
{
    global $permanent;
    foreach ($permanent as $key => $val) {
        list($vendor, $server, $username, $db) = array_map('base64_decode', explode("-", $key));
        if ($vendor == DRIVER && $server == SERVER && $username == $_GET["username"] && $db == DB) {
            unset($permanent[$key]);
        }
    }
    cookie("adminer_permanent", implode(" ", $permanent));
}
/** Renders an error message and a login form