Exemplo n.º 1
0
 public function update()
 {
     $c = '';
     if (empty($_GET['lid'])) {
         $id = 0;
     } else {
         $id = (int) $_GET['lid'];
     }
     if (!empty($id)) {
         $q = $this->db->query('SELECT * FROM ' . $this->table . 'cache WHERE id=' . $id);
         $oldlink = $this->db->fetch($q);
         if ($oldlink) {
             $params = \Bednarik\Cooluri\Core\Functions::cache2params($oldlink['params']);
             $this->lt->params2cool($params, '', true, false, true);
             // multidomain option - it's a Typo3 hack, but what the heck
             // it may be used even without Typo3
             $md = explode('@', $oldlink['url']);
             if (count($md) > 1) {
                 // now it's required to add the prefix back
                 // domain change won't be supported
                 $q = $this->db->query('UPDATE ' . $this->table . 'cache set url=CONCAT(\'' . $md[0] . '\',\'@\',url) WHERE id=' . $id);
             }
             $q = $this->db->query('SELECT * FROM ' . $this->table . 'cache WHERE id=' . $id);
             $newlink = $this->db->fetch($q);
             if ($newlink['url'] == $oldlink['url']) {
                 $c .= '<div class="error"><p>The link hasn\'t been changed.</p></div>';
             } else {
                 $c .= '<div class="succes"><p>The link has been updated from ' . $oldlink['url'] . ' to ' . $newlink['url'] . '.</p></div>';
             }
         } else {
             $c .= '<div class="error"><p>Link with this ID is not in the cache.</p></div>';
         }
     }
     $c .= $this->getBackLink();
     return $c;
 }