Beispiel #1
0
 function copy()
 {
     global $set, $db, $apx;
     $_REQUEST['id'] = (int) $_REQUEST['id'];
     if (!$_REQUEST['id']) {
         die('missing ID!');
     }
     if ($_POST['send'] == 1) {
         if (!checkToken()) {
             printInvalidToken();
         } else {
             $res = $db->first("SELECT secid,catid,userid,send_username,send_email,newspic,title,subtitle,teaser,text,galid,links,top,sticky,allowcoms,allowrating,searchable,restricted FROM " . PRE . "_news WHERE ( id='" . $_REQUEST['id'] . "' " . iif(!$apx->user->has_spright('news.copy'), " AND userid='" . $apx->user->info['userid'] . "'") . " ) LIMIT 1");
             foreach ($res as $key => $val) {
                 $_POST[$key] = $val;
             }
             $_POST['title'] = $apx->lang->get('COPYOF') . $_POST['title'];
             $_POST['addtime'] = time();
             $db->dinsert(PRE . '_news', 'secid,catid,userid,send_username,send_email,newspic,title,subtitle,teaser,text,galid,links,addtime,top,sticky,allowcoms,allowrating,searchable,restricted');
             $nid = $db->insert_id();
             $oldId = $_REQUEST['id'];
             $newId = $nid;
             //Bilder kopieren
             $newPicture = str_replace($oldId, $newId, $res['newspic']);
             copy_with_thumbnail($res['newspic'], $newPicture);
             //Bilder update
             $db->query("UPDATE " . PRE . "_news SET newspic='" . addslashes($newPicture) . "' WHERE id='" . $newId . "' LIMIT 1");
             logit('NEWS_COPY', 'ID #' . $_REQUEST['id']);
             printJSRedirect(get_index('news.show'));
         }
     } else {
         list($title, $subtitle) = $db->first("SELECT title, subtitle FROM " . PRE . "_news WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
         $apx->tmpl->assign('MESSAGE', $apx->lang->get('MSG_TEXT', array('TITLE' => compatible_hsc($title . ($subtitle ? ' - ' . $subtitle : '')))));
         tmessageOverlay('copy', array('ID' => $_REQUEST['id']));
     }
 }
Beispiel #2
0
 function copy()
 {
     global $set, $db, $apx;
     $_REQUEST['id'] = (int) $_REQUEST['id'];
     if (!$_REQUEST['id']) {
         die('missing ID!');
     }
     if ($_POST['send'] == 1) {
         if (!checkToken()) {
             printInvalidToken();
         } else {
             $res = $db->first("SELECT type,secid,catid,userid,artpic,title,subtitle,teaser,galid,links,sticky,top,allowcoms,allowrating,searchable,restricted,pictures,pictures_nextid FROM " . PRE . "_articles WHERE ( id='" . $_REQUEST['id'] . "' " . iif(!$apx->user->has_spright('articles.copy'), " AND userid='" . $apx->user->info['userid'] . "'") . " ) LIMIT 1");
             foreach ($res as $key => $val) {
                 $_POST[$key] = $val;
             }
             $_POST['title'] = $apx->lang->get('COPYOF') . $_POST['title'];
             $_POST['addtime'] = time();
             //Insert
             $db->dinsert(PRE . '_articles', 'type,secid,catid,userid,title,subtitle,teaser,galid,links,addtime,sticky,top,allowcoms,allowrating,searchable,restricted,pictures,pictures_nextid');
             $nid = $db->insert_id();
             $oldId = $_REQUEST['id'];
             $newId = $nid;
             //Bilder kopieren
             $newPicture = str_replace($oldId, $newId, $res['artpic']);
             copy_with_thumbnail($res['artpic'], $newPicture);
             //Angefügte Bilder kopieren
             $newAttPics = array();
             $i = 0;
             $attPics = unserialize($res['pictures']);
             foreach ($attPics as $attPic) {
                 ++$i;
                 $newAttPic = str_replace('-' . $oldId . '-', '-' . $newId . '-', $attPic['thumbnail']);
                 copy_with_thumbnail($attPic['thumbnail'], $newAttPic);
                 $newAttPics[$i] = array('picture' => str_replace('-' . $oldId . '-', '-' . $newId . '-', $attPic['picture']), 'thumbnail' => str_replace('-' . $oldId . '-', '-' . $newId . '-', $attPic['thumbnail']));
             }
             //Update Artikel
             $db->query("UPDATE " . PRE . "_articles SET artpic='" . addslashes($newPicture) . "', pictures='" . addslashes(serialize($newAttPics)) . "' WHERE id='" . $newId . "' LIMIT 1");
             //Preview kopieren
             if ($res['type'] == 'preview') {
                 $res = array();
                 $_POST = array();
                 $res = $db->first("SELECT * FROM " . PRE . "_articles_previews WHERE artid='" . $_REQUEST['id'] . "' LIMIT 1");
                 foreach ($res as $key => $val) {
                     $_POST[$key] = $val;
                 }
                 $_POST['artid'] = $nid;
                 $db->dinsert(PRE . '_articles_previews', 'artid,custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10,impression,conclusion');
             } elseif ($res['type'] == 'review') {
                 $res = array();
                 $_POST = array();
                 $res = $db->first("SELECT * FROM " . PRE . "_articles_reviews WHERE artid='" . $_REQUEST['id'] . "' LIMIT 1");
                 foreach ($res as $key => $val) {
                     $_POST[$key] = $val;
                 }
                 $_POST['artid'] = $nid;
                 $db->dinsert(PRE . '_articles_reviews', 'artid,custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8,rate9,rate10,final_rate,positive,negative,conclusion,award');
             }
             //Pages
             $data = $db->fetch("SELECT title,text,addtime,ord FROM " . PRE . "_articles_pages WHERE artid='" . $_REQUEST['id'] . "'");
             if (count($data)) {
                 foreach ($data as $res) {
                     $db->query("INSERT INTO " . PRE . "_articles_pages VALUES ('','" . $nid . "','" . addslashes($res['title']) . "','" . addslashes($res['text']) . "','" . time() . "','" . $res['ord'] . "')");
                 }
             }
             logit('ARTICLES_COPY', 'ID #' . $_REQUEST['id']);
             printJSRedirect(get_index('articles.show'));
         }
     } else {
         list($title, $subtitle) = $db->first("SELECT title, subtitle FROM " . PRE . "_articles WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
         $apx->tmpl->assign('MESSAGE', $apx->lang->get('MSG_TEXT', array('TITLE' => compatible_hsc($title . ($subtitle ? ' - ' . $subtitle : '')))));
         tmessageOverlay('copy', array('ID' => $_REQUEST['id']));
     }
 }