| 156 | | |
|---|
| 157 | | function links2wp($links='') |
|---|
| | 138 | function get_txp_links() |
|---|
| | 139 | { |
|---|
| | 140 | //General Housekeeping |
|---|
| | 141 | $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); |
|---|
| | 142 | set_magic_quotes_runtime(0); |
|---|
| | 143 | $prefix = get_option('tpre'); |
|---|
| | 144 | |
|---|
| | 145 | return $txpdb->get_results('SELECT |
|---|
| | 146 | id, |
|---|
| | 147 | date, |
|---|
| | 148 | category, |
|---|
| | 149 | url, |
|---|
| | 150 | linkname, |
|---|
| | 151 | description |
|---|
| | 152 | FROM '.$prefix.'txp_link', |
|---|
| | 153 | ARRAY_A); |
|---|
| | 154 | } |
|---|
| | 155 | |
|---|
| | 156 | function cat2wp($categories='') |
|---|
| 170 | | extract($link); |
|---|
| 171 | | |
|---|
| 172 | | // Make nice vars |
|---|
| 173 | | $category = $wpdb->escape($category); |
|---|
| 174 | | $linkname = $wpdb->escape($linkname); |
|---|
| 175 | | $description = $wpdb->escape($description); |
|---|
| 176 | | |
|---|
| 177 | | if($linfo = link_exists($linkname)) |
|---|
| 178 | | { |
|---|
| 179 | | $ret_id = wp_insert_link(array( |
|---|
| 180 | | 'link_id' => $linfo, |
|---|
| 181 | | 'link_url' => $url, |
|---|
| 182 | | 'link_name' => $linkname, |
|---|
| 183 | | 'link_category' => $category, |
|---|
| 184 | | 'link_description' => $description, |
|---|
| 185 | | 'link_updated' => $date) |
|---|
| 186 | | ); |
|---|
| 187 | | } |
|---|
| 188 | | else |
|---|
| 189 | | { |
|---|
| 190 | | $ret_id = wp_insert_link(array( |
|---|
| 191 | | 'link_url' => $url, |
|---|
| 192 | | 'link_name' => $linkname, |
|---|
| 193 | | 'link_category' => $category, |
|---|
| 194 | | 'link_description' => $description, |
|---|
| 195 | | 'link_updated' => $date) |
|---|
| 196 | | ); |
|---|
| 197 | | } |
|---|
| 198 | | $txplinks2wplinks[$link_id] = $ret_id; |
|---|
| 199 | | } |
|---|
| 200 | | add_option('txplinks2wplinks',$txplinks2wplinks); |
|---|
| 201 | | echo __('<p>Done! <strong>'.$count.'</strong> Links imported.<br /><br /></p>'); |
|---|
| | 169 | extract($category); |
|---|
| | 170 | |
|---|
| | 171 | |
|---|
| | 172 | // Make Nice Variables |
|---|
| | 173 | $name = $wpdb->escape($name); |
|---|
| | 174 | $title = $wpdb->escape($title); |
|---|
| | 175 | |
|---|
| | 176 | if($cinfo = category_exists($name)) |
|---|
| | 177 | { |
|---|
| | 178 | $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title)); |
|---|
| | 179 | } |
|---|
| | 180 | else |
|---|
| | 181 | { |
|---|
| | 182 | $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title)); |
|---|
| | 183 | } |
|---|
| | 184 | $txpcat2wpcat[$id] = $ret_id; |
|---|
| | 185 | } |
|---|
| | 186 | |
|---|
| | 187 | // Store category translation for future use |
|---|
| | 188 | add_option('txpcat2wpcat',$txpcat2wpcat); |
|---|
| | 189 | echo __('<p>Done! <strong>'.$count.'</strong> categories imported.<br /><br /></p>'); |
|---|
| 281 | | |
|---|
| 282 | | function cat2wp($categories='') |
|---|
| 283 | | { |
|---|
| 284 | | // General Housekeeping |
|---|
| 285 | | global $wpdb; |
|---|
| 286 | | $count = 0; |
|---|
| 287 | | $txpcat2wpcat = array(); |
|---|
| 288 | | // Do the Magic |
|---|
| 289 | | if(is_array($categories)) |
|---|
| 290 | | { |
|---|
| 291 | | echo __('<p>Importing Categories...<br /><br /></p>'); |
|---|
| 292 | | foreach ($categories as $category) |
|---|
| 293 | | { |
|---|
| 294 | | $count++; |
|---|
| 295 | | extract($category); |
|---|
| 296 | | |
|---|
| 297 | | |
|---|
| 298 | | // Make Nice Variables |
|---|
| 299 | | $name = $wpdb->escape($name); |
|---|
| 300 | | $title = $wpdb->escape($title); |
|---|
| 301 | | |
|---|
| 302 | | if($cinfo = category_exists($name)) |
|---|
| 303 | | { |
|---|
| 304 | | $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title)); |
|---|
| 305 | | } |
|---|
| 306 | | else |
|---|
| 307 | | { |
|---|
| 308 | | $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title)); |
|---|
| 309 | | } |
|---|
| 310 | | $txpcat2wpcat[$id] = $ret_id; |
|---|
| 311 | | } |
|---|
| 312 | | |
|---|
| 313 | | // Store category translation for future use |
|---|
| 314 | | add_option('txpcat2wpcat',$txpcat2wpcat); |
|---|
| 315 | | echo __('<p>Done! <strong>'.$count.'</strong> categories imported.<br /><br /></p>'); |
|---|
| 316 | | return true; |
|---|
| 317 | | } |
|---|
| 318 | | echo __('No Categories to Import!'); |
|---|
| 319 | | return false; |
|---|
| 320 | | |
|---|
| 321 | | } |
|---|
| | 418 | return false; |
|---|
| | 419 | } |
|---|
| | 420 | |
|---|
| | 421 | function links2wp($links='') |
|---|
| | 422 | { |
|---|
| | 423 | // General Housekeeping |
|---|
| | 424 | global $wpdb; |
|---|
| | 425 | $count = 0; |
|---|
| | 426 | |
|---|
| | 427 | // Deal with the links |
|---|
| | 428 | if(is_array($links)) |
|---|
| | 429 | { |
|---|
| | 430 | echo __('<p>Importing Links...<br /><br /></p>'); |
|---|
| | 431 | foreach($links as $link) |
|---|
| | 432 | { |
|---|
| | 433 | $count++; |
|---|
| | 434 | extract($link); |
|---|
| | 435 | |
|---|
| | 436 | // Make nice vars |
|---|
| | 437 | $category = $wpdb->escape($category); |
|---|
| | 438 | $linkname = $wpdb->escape($linkname); |
|---|
| | 439 | $description = $wpdb->escape($description); |
|---|
| | 440 | |
|---|
| | 441 | if($linfo = link_exists($linkname)) |
|---|
| | 442 | { |
|---|
| | 443 | $ret_id = wp_insert_link(array( |
|---|
| | 444 | 'link_id' => $linfo, |
|---|
| | 445 | 'link_url' => $url, |
|---|
| | 446 | 'link_name' => $linkname, |
|---|
| | 447 | 'link_category' => $category, |
|---|
| | 448 | 'link_description' => $description, |
|---|
| | 449 | 'link_updated' => $date) |
|---|
| | 450 | ); |
|---|
| | 451 | } |
|---|
| | 452 | else |
|---|
| | 453 | { |
|---|
| | 454 | $ret_id = wp_insert_link(array( |
|---|
| | 455 | 'link_url' => $url, |
|---|
| | 456 | 'link_name' => $linkname, |
|---|
| | 457 | 'link_category' => $category, |
|---|
| | 458 | 'link_description' => $description, |
|---|
| | 459 | 'link_updated' => $date) |
|---|
| | 460 | ); |
|---|
| | 461 | } |
|---|
| | 462 | $txplinks2wplinks[$link_id] = $ret_id; |
|---|
| | 463 | } |
|---|
| | 464 | add_option('txplinks2wplinks',$txplinks2wplinks); |
|---|
| | 465 | echo __('<p>Done! <strong>'.$count.'</strong> Links imported.<br /><br /></p>'); |
|---|
| | 466 | return true; |
|---|
| | 467 | } |
|---|
| | 468 | echo __('No Links to Import!'); |
|---|
| 589 | | if(false !== get_option('txpuser')) {add_option('txpuser',$_POST['dbuser']); } |
|---|
| 590 | | if(false !== get_option('txppass')) {add_option('txppass',$_POST['dbpass']); } |
|---|
| 591 | | if(false !== get_option('txpname')) {add_option('txpname',$_POST['dbname']); } |
|---|
| 592 | | if(false !== get_option('txphost')) {add_option('txphost',$_POST['dbhost']); } |
|---|
| 593 | | if(false !== get_option('tpre')) { add_option('tpre', $tpre); } |
|---|
| | 589 | if($_POST['dbuser']) |
|---|
| | 590 | { |
|---|
| | 591 | if(get_option('txpuser')) |
|---|
| | 592 | delete_option('txpuser'); |
|---|
| | 593 | add_option('txpuser',$_POST['dbuser']); |
|---|
| | 594 | } |
|---|
| | 595 | if($_POST['dbpass']) |
|---|
| | 596 | { |
|---|
| | 597 | if(get_option('txppass')) |
|---|
| | 598 | delete_option('txppass'); |
|---|
| | 599 | add_option('txppass',$_POST['dbpass']); |
|---|
| | 600 | } |
|---|
| | 601 | |
|---|
| | 602 | if($_POST['dbname']) |
|---|
| | 603 | { |
|---|
| | 604 | if(get_option('txpname')) |
|---|
| | 605 | delete_option('txpname'); |
|---|
| | 606 | add_option('txpname',$_POST['dbname']); |
|---|
| | 607 | } |
|---|
| | 608 | if($_POST['dbhost']) |
|---|
| | 609 | { |
|---|
| | 610 | if(get_option('txphost')) |
|---|
| | 611 | delete_option('txphost'); |
|---|
| | 612 | add_option('txphost',$_POST['dbhost']); |
|---|
| | 613 | } |
|---|
| | 614 | if($_POST['dbprefix']) |
|---|
| | 615 | { |
|---|
| | 616 | if(get_option('tpre')) |
|---|
| | 617 | delete_option('tpre'); |
|---|
| | 618 | add_option('tpre',$_POST['dbprefix']); |
|---|
| | 619 | } |
|---|
| | 620 | |
|---|