[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 //19-11-2004 Fernando Batista -> Copy article, Copy strutures :http://fernandobatista.web.pt 24 //31-03-2005 Fernando Batista -> copy&cut Article Content :http://fernandobatista.web.pt 25 26 // session_name('hashID'); 27 session_start(); 28 $phpwcms = array(); 29 require_once ('../../config/phpwcms/conf.inc.php'); 30 require_once ('../inc_lib/default.inc.php'); 31 require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php'); 32 33 require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php'); 34 checkLogin(); 35 require_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php'); 36 37 if(empty($_SESSION['REFERER_URL'])) { 38 die('Goood bye.'); 39 } else { 40 $ref = $_SESSION['REFERER_URL']; 41 } 42 43 if($_SESSION["wcs_user_admin"] == 1) { //Wenn Benutzer Admin-Rechte hat 44 45 if(isset($_POST["acat_access"]) && is_array($_POST["acat_access"]) && count($_POST["acat_access"])) { 46 $acat_permit = implode(',', $_POST["acat_access"]); 47 } else { 48 $acat_permit = ''; 49 } 50 51 $acat_hidden = 0; 52 if(isset($_POST["acat_hidden"])) { 53 $acat_hidden = 1; 54 if(isset($_POST["acat_hiddenactive"])) { 55 $acat_hidden = 2; 56 } 57 } 58 59 $acat_cntpart = ''; 60 if(isset($_POST['acat_cp']) && is_array($_POST['acat_cp'])) { 61 62 $acat_cntpart = $_POST['acat_cp']; 63 $acat_cntpart = array_unique($acat_cntpart); 64 $acat_cntpart = implode(',', $acat_cntpart); 65 66 } 67 68 if(isset($_POST["acat_id"]) && $_POST["acat_id"] === 'index') { 69 // write index page config into flat file 70 $sql = "<?php\n"; 71 $sql .= "\$indexpage['acat_name'] = '". str_replace("''", "\\'", getpostvar($_POST["acat_name"]))."';\n"; 72 $sql .= "\$indexpage['acat_info'] = '". str_replace("''", "\\'", getpostvar($_POST["acat_info"], 32000))."';\n"; 73 $sql .= "\$indexpage['acat_alias'] = '". proof_alias($_POST["acat_id"], $_POST["acat_alias"])."';\n"; 74 $sql .= "\$indexpage['acat_aktiv'] = ". (isset($_POST["acat_aktiv"]) ? 1 : 0).";\n"; 75 $sql .= "\$indexpage['acat_public'] = ". (isset($_POST["acat_public"]) ? 1 : 0).";\n"; 76 $sql .= "\$indexpage['acat_template'] = ". intval($_POST["acat_template"]).";\n"; 77 78 $sql .= "\$indexpage['acat_hidden'] = ". $acat_hidden.";\n"; 79 $sql .= "\$indexpage['acat_ssl'] = ". (isset($_POST["acat_ssl"]) ? 1 : 0).";\n"; 80 $sql .= "\$indexpage['acat_regonly'] = ". (isset($_POST["acat_regonly"]) ? 1 : 0).";\n"; 81 $sql .= "\$indexpage['acat_topcount'] = ". intval($_POST["acat_topcount"]).";\n"; 82 $sql .= "\$indexpage['acat_maxlist'] = ". intval($_POST["acat_maxlist"]).";\n"; 83 $sql .= "\$indexpage['acat_redirect'] = '';\n"; 84 $cache_timeout = clean_slweg($_POST["acat_timeout"]); 85 if(isset($_POST['acat_cacheoff']) && intval($_POST['acat_cacheoff'])) $cache_timeout = 0; //check if cache = Off 86 $sql .= "\$indexpage['acat_timeout'] = '". $cache_timeout."';\n"; 87 $sql .= "\$indexpage['acat_nosearch'] = '". ((isset($_POST['acat_nosearch']) && intval($_POST['acat_nosearch'])) ? '1' : '')."';\n"; 88 $sql .= "\$indexpage['acat_nositemap'] = ". (isset($_POST["acat_nositemap"]) ? 1 : 0).";\n"; 89 $sql .= "\$indexpage['acat_order'] = ". set_correct_ordersort() .";\n"; 90 $sql .= "\$indexpage['acat_permit'] = '".$acat_permit."';\n"; 91 $sql .= "\$indexpage['acat_cntpart'] = '".$acat_cntpart."';\n"; 92 $sql .= "\$indexpage['acat_pagetitle'] = '". str_replace("''", "\\'", getpostvar($_POST["acat_pagetitle"]))."';\n"; 93 $sql .= "\$indexpage['acat_paginate'] = ". (isset($_POST["acat_paginate"]) ? 1 : 0).";\n"; 94 $sql .= "\$indexpage['acat_overwrite'] = '". str_replace("''", "\\'", getpostvar($_POST["acat_overwrite"]))."';\n"; 95 $sql .= "\$indexpage['acat_archive'] = ". (empty($_POST["acat_archive"]) ? 0 : 1) .";\n"; 96 $sql .= "?>"; 97 write_textfile(PHPWCMS_ROOT.'/config/phpwcms/conf.indexpage.inc.php', $sql); 98 } 99 100 $acat_sort_fallback = isset($_POST["acat_sort"]) ? intval(trim($_POST["acat_sort"])) : 0; 101 $acat_sort_temp = isset($_POST["acat_sort_temp"]) ? intval($_POST["acat_sort_temp"]) : 0; 102 103 if($acat_sort_fallback === 0 && $acat_sort_temp > 0) { 104 $acat_sort_fallback = $acat_sort_temp; 105 } 106 107 if(isset($_POST["acat_new"]) && intval($_POST["acat_new"]) == 1 && intval($_POST["acat_id"]) == 0 && $_POST["acat_id"] != 'index') { 108 if(trim($_POST["acat_name"])) { 109 110 $cache_timeout = clean_slweg($_POST["acat_timeout"]); 111 if(isset($_POST['acat_cacheoff']) && intval($_POST['acat_cacheoff'])) $cache_timeout = 0; //check if cache = Off 112 113 $sql = "INSERT INTO ".DB_PREPEND."phpwcms_articlecat (acat_name, acat_info, acat_aktiv, acat_ssl, acat_regonly, ". 114 "acat_public, acat_struct, acat_template, acat_sort, acat_uid, acat_alias, acat_hidden, acat_topcount, ". 115 "acat_redirect, acat_order, acat_cache, acat_nosearch, acat_nositemap, acat_permit, acat_maxlist, ". 116 "acat_cntpart, acat_pagetitle, acat_paginate, acat_overwrite, acat_archive) VALUES ('". 117 getpostvar($_POST["acat_name"])."','". 118 getpostvar($_POST["acat_info"], 32000)."',". 119 (isset($_POST["acat_aktiv"]) ? 1 : 0).",". 120 (isset($_POST["acat_ssl"]) ? 1 : 0).",". 121 (isset($_POST["acat_regonly"]) ? 1 : 0).",". 122 (isset($_POST["acat_public"]) ? 1 : 0).",". 123 intval($_POST["acat_struct"]).",". 124 intval($_POST["acat_template"]).",". 125 $acat_sort_fallback.",". 126 $_SESSION["wcs_user_id"].",'". 127 proof_alias($_POST["acat_id"], $_POST["acat_alias"])."',". 128 $acat_hidden.", ". 129 intval($_POST["acat_topcount"]).",'". 130 getpostvar($_POST["acat_redirect"])."', ". 131 set_correct_ordersort().",'". 132 $cache_timeout."', '".(isset($_POST['acat_nosearch']) ? 1 : '')."',". 133 (isset($_POST["acat_nositemap"]) ? 1 : 0).",". 134 "'".$acat_permit."', ".intval($_POST["acat_maxlist"]).", '".aporeplace($acat_cntpart)."','". 135 getpostvar($_POST["acat_pagetitle"])."', ".(isset($_POST["acat_paginate"]) ? 1 : 0).", '".getpostvar($_POST["acat_overwrite"])."',". 136 (empty($_POST["acat_archive"]) ? 0 : 1).")"; 137 if($result = mysql_query($sql, $db) or die("error")) { 138 $ref .= "&cat=".mysql_insert_id($db); 139 } 140 } 141 } 142 143 if(isset($_POST["acat_new"]) && isset($_POST["acat_id"]) && intval($_POST["acat_new"]) == 0 && intval($_POST["acat_id"])) { 144 if(trim($_POST["acat_name"])) { 145 146 $cache_timeout = clean_slweg($_POST["acat_timeout"]); 147 if(isset($_POST['acat_cacheoff']) && intval($_POST['acat_cacheoff'])) $cache_timeout = 0; //check if cache = Off 148 149 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecat SET ". 150 "acat_name='".getpostvar($_POST["acat_name"])."', ". 151 "acat_info='".getpostvar($_POST["acat_info"], 32000)."', ". 152 "acat_alias='".aporeplace(proof_alias($_POST["acat_id"], $_POST["acat_alias"]))."', ". 153 "acat_aktiv=".(isset($_POST["acat_aktiv"]) ? 1 : 0).", ". 154 "acat_public=".(isset($_POST["acat_public"]) ? 1 : 0).", ". 155 "acat_struct=".intval($_POST["acat_struct"]).", ". 156 "acat_template=".intval($_POST["acat_template"]).", ". 157 "acat_sort=".$acat_sort_fallback.", ". 158 "acat_uid=".$_SESSION["wcs_user_id"].", ". 159 "acat_hidden=".$acat_hidden.", ". 160 "acat_ssl=".(isset($_POST["acat_ssl"]) ? 1 : 0).", ". 161 "acat_regonly=".(isset($_POST["acat_regonly"]) ? 1 : 0).", ". 162 "acat_topcount=".intval($_POST["acat_topcount"]).", ". 163 "acat_redirect='".getpostvar($_POST["acat_redirect"])."',". 164 "acat_order=".set_correct_ordersort().", ". 165 "acat_cache='".aporeplace($cache_timeout)."', ". 166 "acat_nosearch='".(isset($_POST['acat_nosearch']) ? 1 : '')."', ". 167 "acat_nositemap=".(isset($_POST["acat_nositemap"]) ? 1 : 0).", ". 168 "acat_permit='".aporeplace($acat_permit)."', ". 169 "acat_maxlist=".intval($_POST["acat_maxlist"]).", ". 170 "acat_cntpart='".aporeplace($acat_cntpart)."', ". 171 "acat_pagetitle='".getpostvar($_POST["acat_pagetitle"])."', ". 172 "acat_paginate=".(isset($_POST["acat_paginate"]) ? 1 : 0).", ". 173 "acat_overwrite='".getpostvar($_POST["acat_overwrite"])."', ". 174 "acat_archive=".(empty($_POST["acat_archive"]) ? 0 : 1). 175 " WHERE acat_id=".intval($_POST["acat_id"]); 176 177 mysql_query($sql, $db) or die(_report_error('DB', $sql)); 178 } 179 } 180 181 //diverse Aktionen 182 $do = explode("|", isset($_GET["do"]) ? $_GET["do"] : ''); 183 184 185 switch(intval($do[0])) { 186 187 case 1: //Einfügen in 188 $do[1] = intval($do[1]); //cut ID 189 $do[2] = intval($do[2]); //paste ID 190 $do[3] = intval($do[3]); //sort Number 191 if($do[1]) { // && $do[2] = 0 für Root 192 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecat SET acat_struct=".$do[2].", acat_sort=".$do[3]." WHERE acat_id=".$do[1]; 193 mysql_query($sql, $db) or die("error while updating structure level"); 194 } 195 break; 196 197 case 2: //Sortierung ändern 198 $do[1] = intval($do[1]); //sort ID1 199 $do[2] = intval($do[2]); //sort NR1 200 $do[3] = intval($do[3]); //sort ID2 201 $do[4] = intval($do[4]); //sort NR2 202 if($do[1] && $do[2]>=10 && $do[3] && $do[4]>=10) { 203 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecat SET acat_sort=".$do[2]." WHERE acat_id=".$do[1]; 204 mysql_query($sql, $db) or die("error while updating sorting ID1"); 205 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecat SET acat_sort=".$do[4]." WHERE acat_id=".$do[3]; 206 mysql_query($sql, $db) or die("error while updating sorting ID1"); 207 } 208 break; 209 210 case 3: //Artikel einfügen in 211 $do[1] = intval($do[1]); //cut Article ID 212 $do[2] = intval($do[2]); //paste level ID 213 if($do[1]) { // && $do[2] = 0 für Root 214 $new_sort = getArticleSortValue($do[2]); 215 $sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_cid=".$do[2].", article_sort=".$new_sort." WHERE article_id=".$do[1]; 216 mysql_query($sql, $db) or die("error while updating article level"); 217 } 218 break; 219 220 case 4: //Sortierung Artikel ändern 221 $do[1] = intval($do[1]); //article sort ID1 222 $do[2] = intval($do[2]); //article sort NR1 223 $do[3] = intval($do[3]); //article sort ID2 224 $do[4] = intval($do[4]); //article sort NR2 225 if($do[1] && $do[2]>=10 && $do[3] && $do[4]>=10) { 226 $sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_sort=".$do[2].", article_tstamp=article_tstamp WHERE article_id=".$do[1]; 227 mysql_query($sql, $db) or die("error while updating sorting article ID1"); 228 $sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_sort=".$do[4].", article_tstamp=article_tstamp WHERE article_id=".$do[3]; 229 mysql_query($sql, $db) or die("error while updating sorting article ID1"); 230 } 231 break; 232 233 //19-11-2004 Fernando Batista start----------------------------------------------------------------------------------------------------------- 234 case 5: // COPY Article 235 $do[1] = intval($do[1]); //copy Article ID 236 $do[2] = intval($do[2]); //paste level ID 237 $do[3] = isset($do[3]) && $do[3] == 'open' ? 'open' : 0; // special link to copy an existing article and open the new 238 if($do[1]) { //also allowed for pasting in root structure 239 copy_article_to_level($do, $db); 240 } 241 break; 242 243 case 6: //COPY Structure 244 $do[1] = intval($do[1]); //copy level ID 245 $do[2] = intval($do[2]); //paste level ID 246 $do[3] = intval($do[3]); //sort Number 247 if($do[1]) { // && $do[2] = 0 für Root 248 copy_level_to_level($do, $db); 249 } 250 break; 251 //19-11-2004 Fernando Batista end------------------- 252 253 //31-03-2005 Fernando Batista start----------------------------------------------------------------------------------------------------------- 254 case 7: // 255 $do[1] = intval($do[1]); //cut Article Content ID 256 $do[2] = intval($do[2]); //paste Article ID 257 $do[3] = intval($do[3]); //sort Number 258 if($do[1]) { 259 260 $sql = "SELECT acontent_aid, acontent_sorting FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_id=".$do[1]; 261 $result = mysql_query($sql, $db) or die("error while updating Article Content"); 262 $row = mysql_fetch_assoc($result); 263 264 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_sorting=acontent_sorting-10 WHERE acontent_aid=".$row['acontent_aid']." AND acontent_sorting >= ".$row['acontent_sorting']."+10"; 265 mysql_query($sql, $db) or die("error while updating Article Content"); 266 267 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_sorting=acontent_sorting+10 WHERE acontent_aid=".$do[2]." AND acontent_sorting >= ".$do[3]."+10"; 268 mysql_query($sql, $db) or die("error while updating Article Content"); 269 270 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_aid=".$do[2].", acontent_sorting=".$do[3]."+10 WHERE acontent_id=".$do[1]; 271 mysql_query($sql, $db) or die("error while updating Article Content"); 272 273 } 274 break; 275 //------------- 276 case 8: // 277 $do[1] = intval($do[1]); //copy Article Content ID 278 $do[2] = intval($do[2]); //paste Article ID 279 $do[3] = intval($do[3]); //sort Number 280 if($do[1]) { 281 282 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_sorting=acontent_sorting+10 WHERE acontent_aid=".$do[2]." AND acontent_sorting >= ".$do[3]."+10"; 283 mysql_query($sql, $db) or die("error while updating Article Content"); 284 285 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_id=".$do[1]; 286 if($result = mysql_query($sql, $db) or die("error sql")) { 287 $row = mysql_fetch_assoc($result); 288 foreach($row as $key => $value) { 289 if($key == "acontent_created") { 290 $key1s .= ", ".$key; 291 $value1s .= ", NOW()"; 292 }elseif($key == "acontent_id" ){ 293 $key1s = $key; 294 $value1s = "''"; 295 }elseif($key == "acontent_aid" ){ 296 $key1s .= ", ".$key; 297 $value1s .= ", '".$do[2]."'"; 298 }elseif($key == "acontent_sorting" ){ 299 $key1s .= ", ".$key; 300 $do[3] = $do[3] + 10; 301 $value1s .= ", '".$do[3]."'"; 302 }else{ 303 $key1s .= ", ".$key; 304 $value1s .= ", '".aporeplace($value)."'"; 305 } 306 } 307 $sql2 = "INSERT INTO ".DB_PREPEND."phpwcms_articlecontent (".$key1s.") VALUES (".$value1s.")" ; 308 $result = mysql_query($sql2, $db) or die("error while copy article content <br>error while connecting to database: <br><pre>".$sql2."</pre>"); 309 310 } 311 312 313 } 314 break; 315 //31-03-2005 Fernando Batista end------------------- 316 317 318 case 9: //Löschen des Levels 319 $do[1] = intval($do[1]); //delete ID 320 if($do[1]) { 321 // extend deleting of structure levels also for deleting of all related child 322 // structure levels and articles on structure level 323 // this is necessary to be sure that such deleted articles/structures are 324 // not available anymore 325 326 // 1.) get all structure level IDs and put into an array 327 $struct_del = array(); 328 $article_del = array(); 329 330 $struct_del[] = $do[1]; //start 331 332 get_struct_del_id($do[1], $db); 333 334 // create SQL query to set articles deleted 335 if(count($article_del)) { 336 337 $a_del = ""; 338 foreach($article_del as $value) { 339 //delete cached articles 340 $sql = "DELETE FROM ".DB_PREPEND."phpwcms_cache WHERE cache_aid=".intval($value); 341 mysql_query($sql, $db) or die("error while deleting cached article ID:".$value); 342 343 $a_del .= ($a_del) ? " OR article_id=".$value : "article_id=".$value; 344 } 345 346 if($a_del) { 347 $sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_deleted=9, article_alias=CONCAT(article_alias,'_del-','".date('YmdHis')."') WHERE (".$a_del.")"; 348 mysql_query($sql, $db) or die("error while deleting articles while deleting structures"); 349 } 350 } 351 352 // create SQL query to set structure levels deleted 353 if(count($struct_del)) { 354 355 $s_del = ""; 356 foreach($struct_del as $value) { 357 //delete cached categories 358 $sql = "DELETE FROM ".DB_PREPEND."phpwcms_cache WHERE cache_cid=".intval($value); 359 mysql_query($sql, $db) or die("error while deleting cached category ID:".$value); 360 361 $s_del .= ($s_del) ? " OR acat_id=".$value : "acat_id=".$value; 362 } 363 364 if($s_del) { 365 $sql = "UPDATE ".DB_PREPEND."phpwcms_articlecat SET acat_trash=9, acat_alias=CONCAT(acat_alias,'_del-','".date('YmdHis')."') WHERE (".$s_del.")"; 366 mysql_query($sql, $db) or die("error while deleting structures"); 367 } 368 } 369 370 } 371 break; 372 373 } 374 375 } //Ende Abarbeiten Aktion 376 377 update_cache(); 378 379 if(isset($_POST['SubmitClose'])) { 380 headerRedirect(PHPWCMS_URL.'phpwcms.php?do=admin&p=6'); 381 } else { 382 headerRedirect($ref); 383 } 384 385 function get_struct_del_id($s_id=0, $dbcon) { 386 387 $s_id = intval($s_id); 388 389 //retrieve article ID list that should be deleted 390 $sql = "SELECT article_id FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND article_cid=".$s_id; 391 if($result = mysql_query($sql, $dbcon)) { 392 while($row = mysql_fetch_row($result)) { 393 $GLOBALS["article_del"][] = $row[0]; 394 } 395 mysql_free_result($result); 396 } 397 398 // retrieve structure ID list that should be deleted 399 $sql = "SELECT acat_id FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_trash=0 AND acat_struct=".$s_id; 400 if($result = mysql_query($sql, $dbcon)) { 401 while($row = mysql_fetch_row($result)) { 402 $GLOBALS["struct_del"][] = $row[0]; 403 get_struct_del_id($row[0], $dbcon); 404 } 405 mysql_free_result($result); 406 } 407 } 408 409 //19-11-2004 Fernando Batista start----------------------------------------------------------------------------------------------------------- 410 function copy_article_to_level($do, $dbcon) { 411 412 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND article_id=".$do[1]; 413 if($result = mysql_query($sql, $dbcon) or die("error while connecting to database: <br><pre>".$sql."</pre>")) { 414 415 if($row = mysql_fetch_assoc($result)) { 416 $row["article_cid"] = $do[2]; 417 $row["article_created"] = now(); 418 $row["article_tstamp"] = date('Y-m-d H:i:s', now() ); 419 $row["article_sort"] = getArticleSortValue($row["article_cid"]); 420 $row["article_alias"] = proof_alias(0, empty($row["article_alias"]) ? $row['article_title'] : $row["article_alias"], 'ARTICLE'); 421 422 foreach($row as $key => $value) { 423 if($key == "article_id" ){ 424 $keys = $key; 425 $values = "''"; 426 } else { 427 $keys .= ", ".$key; 428 $values .= ", '".aporeplace($value)."'"; 429 } 430 } 431 } 432 mysql_free_result($result); 433 434 $sql = "INSERT INTO ".DB_PREPEND."phpwcms_article (".$keys.") VALUES (".$values.")" ; 435 436 if($result = mysql_query($sql, $dbcon) or die("error while copy article <br>error while connecting to database: <br><pre>".$sql."</pre>")) { 437 438 $article_insert_id = mysql_insert_id($dbcon); 439 440 $sql1 = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_aid=".$do[1]; 441 if($result1 = mysql_query($sql1, $dbcon) or die("error sql")) { 442 while ($row1 = mysql_fetch_assoc($result1)) { 443 $row1["acontent_aid"] = $article_insert_id; 444 foreach($row1 as $key1 => $value1) { 445 if($key1 == "acontent_id" ){ 446 $key1s = $key1; 447 $value1s = "''"; 448 } else { 449 $key1s .= ", ".$key1; 450 $value1s .= ", '".aporeplace($value1)."'"; 451 } 452 } 453 $sql2 = "INSERT INTO ".DB_PREPEND."phpwcms_articlecontent (".$key1s.") VALUES (".$value1s.")" ; 454 $result = mysql_query($sql2, $dbcon) or die("error while copy article content <br>error while connecting to database: <br><pre>".$sql2."</pre>"); 455 } 456 mysql_free_result($result1); 457 } 458 459 if(isset($do[3]) && $do[3] == 'open' && $article_insert_id) { 460 461 headerRedirect(PHPWCMS_URL.'phpwcms.php?do=articles&p=2&s=1&id='.$article_insert_id); 462 463 } 464 465 } 466 467 } 468 } 469 470 function copy_level_to_level($do, $dbcon) { 471 // $do[1] -- copy level 472 // $do[2] -- paste level 473 // $do[3] -- sort Number 474 475 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_trash=0 AND acat_id=".$do[1]; 476 if($result = mysql_query($sql, $dbcon) or die("error while connecting to database: <br><pre>".$sql."</pre>")) { 477 if($row = mysql_fetch_assoc($result)) { 478 $row["acat_struct"] = $do[2]; 479 $row["acat_sort"] = $do[3]; 480 $row["acat_alias"] = proof_alias(0, empty($row["acat_alias"]) ? $row['acat_name'] : $row["acat_alias"], 'CATEGORY');; 481 482 foreach($row as $key => $value) { 483 if($key == "acat_id" ) { 484 $keys = $key; 485 $values = "''"; 486 } else { 487 $keys .= ", ".$key; 488 $values .= ", '".aporeplace($value)."'"; 489 } 490 } 491 } 492 mysql_free_result($result); 493 494 $sql = "INSERT INTO ".DB_PREPEND."phpwcms_articlecat (".$keys.") VALUES (".$values.")" ; 495 mysql_query($sql, $dbcon); 496 $acat_insert_id = mysql_insert_id($dbcon); 497 } 498 499 500 $sql = "SELECT article_id FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND article_cid=".$do[1]; 501 if($result = mysql_query($sql, $dbcon)) { 502 while($row = mysql_fetch_row($result)) { 503 $do_article[1] = $row[0]; 504 $do_article[2] = $acat_insert_id; 505 copy_article_to_level($do_article, $dbcon); 506 } 507 mysql_free_result($result); 508 } 509 510 511 $sql = "SELECT acat_id,acat_sort FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_trash=0 AND acat_struct=".$do[1]; 512 if($result = mysql_query($sql, $dbcon)) { 513 while($row = mysql_fetch_row($result)) { 514 $do_struct[1] = $row[0]; 515 $do_struct[2] = $acat_insert_id ; 516 $do_struct[3] = $row[1]; 517 copy_level_to_level($do_struct, $dbcon); 518 } 519 mysql_free_result($result); 520 } 521 } 522 //19-11-2004 Fernando Batista end------------------- 523 524 function set_correct_ordersort() { 525 // 0 = manual, 2 = creation date, 4 = start date -> + 0 = ASC, + 1 = DESC 526 $val = 0; 527 528 // but why not - should be possible too based on new sorting 529 $val = intval($_POST["acat_order"]) + intval($_POST["acat_ordersort"]); 530 531 return $val; 532 } 533 534 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |