]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions.php
force regenerate session id on successful login, remove previous blank SID check
[tt-rss.git] / include / functions.php
index 453f329b4bc3b3b2f47feb50dec95b8543d5cb1c..3cd21969d27f90f3b86d509832b1c8bfb7d2f6fc 100755 (executable)
                        }
 
                        if ($user_id && !$check_only) {
-                               @session_start();
+
+                               if (session_status() != PHP_SESSION_NONE) {
+                                       session_destroy();
+                                       session_commit();
+                               }
+
+                               session_start();
+                               session_regenerate_id(true);
 
                                $_SESSION["uid"] = $user_id;
                                $_SESSION["version"] = VERSION_STATIC;
        }
 
        function logout_user() {
-               session_destroy();
+               @session_destroy();
                if (isset($_COOKIE[session_name()])) {
                   setcookie(session_name(), '', time()-42000, '/');
                }
+               session_commit();
        }
 
        function validate_csrf($csrf_token) {
                                }
 
                                if (!$_SESSION["uid"]) {
-                                       @session_destroy();
-                                       setcookie(session_name(), '', time()-42000, '/');
+                                       logout_user();
 
                                        render_login_form();
                                        exit;
                                                }
                                        }
                                }
+                       }
+
+                       if ($entry->hasAttribute('src') &&
+                                       ($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || $_SESSION["bw_limit"]) {
+
+                               $p = $doc->createElement('p');
+
+                               $a = $doc->createElement('a');
+                               $a->setAttribute('href', $entry->getAttribute('src'));
+
+                               $a->appendChild(new DOMText($entry->getAttribute('src')));
+                               $a->setAttribute('target', '_blank');
+                               $a->setAttribute('rel', 'noopener noreferrer');
 
-                               if (($owner && get_pref("STRIP_IMAGES", $owner)) ||
-                                       $force_remove_images || $_SESSION["bw_limit"]) {
+                               $p->appendChild($a);
 
-                                       $p = $doc->createElement('p');
+                               if ($entry->nodeName == 'source') {
 
-                                       $a = $doc->createElement('a');
-                                       $a->setAttribute('href', $entry->getAttribute('src'));
+                                       if ($entry->parentNode && $entry->parentNode->parentNode)
+                                               $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
 
-                                       $a->appendChild(new DOMText($entry->getAttribute('src')));
-                                       $a->setAttribute('target', '_blank');
-                                       $a->setAttribute('rel', 'noopener noreferrer');
+                               } else if ($entry->nodeName == 'img') {
 
-                                       $p->appendChild($a);
+                                       if ($entry->parentNode)
+                                               $entry->parentNode->replaceChild($p, $entry);
 
-                                       $entry->parentNode->replaceChild($p, $entry);
                                }
                        }