X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Ffunctions.php;h=9125df3bd8a367cd65cca22d4be2596d67cc77b1;hb=50052fb78a3a9d1bb3fa488e7fd7b23125c38124;hp=3cd21969d27f90f3b86d509832b1c8bfb7d2f6fc;hpb=65e98f40867862eb345676e23b633b9f52109d30;p=tt-rss.git diff --git a/include/functions.php b/include/functions.php index 3cd21969..9125df3b 100755 --- a/include/functions.php +++ b/include/functions.php @@ -13,7 +13,6 @@ $fetch_last_error_content = false; // curl only for the time being $fetch_effective_url = false; $fetch_curl_used = false; - $suppress_debugging = false; libxml_disable_entity_loader(true); @@ -156,67 +155,11 @@ $schema_version = false; - function _debug_suppress($suppress) { - global $suppress_debugging; - - $suppress_debugging = $suppress; + // TODO: compat wrapper, remove at some point + function _debug($msg) { + Debug::log($msg); } - /** - * Print a timestamped debug message. - * - * @param string $msg The debug message. - * @return void - */ - function _debug($msg, $show = true) { - global $suppress_debugging; - - //echo "[$suppress_debugging] $msg $show\n"; - - if ($suppress_debugging) return false; - - $ts = strftime("%H:%M:%S", time()); - if (function_exists('posix_getpid')) { - $ts = "$ts/" . posix_getpid(); - } - - if ($show && !(defined('QUIET') && QUIET)) { - print "[$ts] $msg\n"; - } - - if (defined('LOGFILE')) { - $fp = fopen(LOGFILE, 'a+'); - - if ($fp) { - $locked = false; - - if (function_exists("flock")) { - $tries = 0; - - // try to lock logfile for writing - while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { - sleep(1); - ++$tries; - } - - if (!$locked) { - fclose($fp); - return; - } - } - - fputs($fp, "[$ts] $msg\n"); - - if (function_exists("flock")) { - flock($fp, LOCK_UN); - } - - fclose($fp); - } - } - - } // function _debug - /** * Purge a feed old posts. * @@ -227,7 +170,7 @@ * @access public * @return void */ - function purge_feed($feed_id, $purge_interval, $debug = false) { + function purge_feed($feed_id, $purge_interval) { if (!$purge_interval) $purge_interval = feed_purge_interval($feed_id); @@ -292,9 +235,7 @@ CCache::update($feed_id, $owner_uid); - if ($debug) { - _debug("Purged feed $feed_id ($purge_interval): deleted $rows articles"); - } + Debug::log("Purged feed $feed_id ($purge_interval): deleted $rows articles"); return $rows; } // function purge_feed @@ -421,7 +362,7 @@ // holy shit closures in php // download & upload are *expected* sizes respectively, could be zero curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { - //_debug("[curl progressfunction] $downloaded $max_size"); + Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it }); @@ -700,29 +641,26 @@ if (!SINGLE_USER_MODE) { $user_id = false; + $auth_module = false; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_AUTH_USER) as $plugin) { $user_id = (int) $plugin->authenticate($login, $password); if ($user_id) { - $_SESSION["auth_module"] = strtolower(get_class($plugin)); + $auth_module = strtolower(get_class($plugin)); break; } } if ($user_id && !$check_only) { - if (session_status() != PHP_SESSION_NONE) { - session_destroy(); - session_commit(); - } - session_start(); session_regenerate_id(true); $_SESSION["uid"] = $user_id; $_SESSION["version"] = VERSION_STATIC; + $_SESSION["auth_module"] = $auth_module; $pdo = DB::pdo(); $sth = $pdo->prepare("SELECT login,access_level,pwd_hash FROM ttrss_users @@ -1226,8 +1164,7 @@ "feed_debug_viewfeed" => __("Debug viewfeed()"), "catchup_all" => __("Mark all feeds as read"), "cat_toggle_collapse" => __("Un/collapse current category"), - "toggle_combined_mode" => __("Toggle combined mode"), - "toggle_cdm_expanded" => __("Toggle auto expand in combined mode")), + "toggle_combined_mode" => __("Toggle combined mode")), __("Go to") => array( "goto_all" => __("All articles"), "goto_fresh" => __("Fresh"), @@ -1295,7 +1232,6 @@ "f *d" => "feed_debug_update", "f *g" => "feed_debug_viewfeed", "f *c" => "toggle_combined_mode", - "f c" => "toggle_cdm_expanded", "*q" => "catchup_all", "x" => "cat_toggle_collapse", // "goto" => array( @@ -1372,7 +1308,6 @@ $data["num_feeds"] = (int) $num_feeds; $data['last_article_id'] = Article::getLastArticleId(); - $data['cdm_expanded'] = get_pref('CDM_EXPANDED'); $data['dep_ts'] = calculate_dep_timestamp(); $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE'); @@ -1826,6 +1761,10 @@ array_push($attrs_to_remove, $attr); } + if (strpos($attr->nodeName, "data-") === 0) { + array_push($attrs_to_remove, $attr); + } + if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) { array_push($attrs_to_remove, $attr); } @@ -2155,7 +2094,7 @@ $sth = $pdo->prepare("SELECT access_key FROM ttrss_access_keys WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?"); - $sth->execute([$feed_id, (int)$is_cat, $owner_uid]); + $sth->execute([$feed_id, $is_cat, $owner_uid]); if ($row = $sth->fetch()) { return $row["access_key"]; @@ -2166,7 +2105,7 @@ (access_key, feed_id, is_cat, owner_uid) VALUES (?, ?, ?, ?)"); - $sth->execute([$key, $feed_id, (int)$is_cat, $owner_uid]); + $sth->execute([$key, $feed_id, $is_cat, $owner_uid]); return $key; }