txp_tag_convert(); } function txp_tag_convert() { parent::Controller(); } function index() { $this->load->database('txp'); $f = '@(]+))*\s*/?'.chr(62).')@s'; $t = '@:(\w+)(.*?)/?.$@s'; $sql = "select ID, Body_html as Body from textpattern"; $qry = $this->db->query($sql); $baseURL = '/txp/images/'; foreach ( $qry->result() as $row ) { $replaces = array(); $txpTags = array(); $parsed = preg_split( $f, $row->Body, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ( $parsed as &$val ) { if ( strncmp('db->query($sql1); if ( $qry1->num_rows() > 0 ) { $row1 = $qry1->first_row(); // display the image tag if ( empty($row1->alt) ) { $theTag = "id}{$row1->ext}\" width=\"$row1->w\" height=\"$row1->h\" />"; } else { $alt = htmlspecialchars($row1->alt); $theTag = "id}{$row1->ext}\" alt=\"$alt\" width=\"$row1->w\" height=\"$row1->h\" />"; } $replaces[] = $theTag; $txpTags[] = $val; } } } break; case 'thumbnail': for ($i = 2; $i < count($matches); $i++) { if ( preg_match('/id="(\w+)"/', $matches[$i], $param) ) { $sql1 = "select * from txp_image where id = {$param[1]}"; $qry1 = $this->db->query($sql1); if ( $qry1->num_rows() > 0 ) { $row1 = $qry1->first_row(); // display the image tag if ( empty($row1->alt) ) { $theTag = "id}t{$row1->ext}\" width=\"$row1->thumb_w\" height=\"$row1->thumb_h\" />"; } else { $alt = htmlspecialchars($row1->alt); $theTag = "id}t{$row1->ext}\" alt=\"\" width=\"$row1->thumb_w\" height=\"$row1->thumb_h\" />"; } // update the text $replaces[] = $theTag; $txpTags[] = $val; } } } break; } } } } // replace $msg = str_replace($txpTags, $replaces, $row->Body); $this->db->update('textpattern', array('Body' => $msg), "id = $row->ID"); } } function url_generation() { $txpDB = $this->load->database('txp', true); $wpDB = $this->load->database('wordpress', true); $data = array('match_type' => 'url', 'action_type' => 'url', 'status' => 'enabled', 'action_code' => 301, 'group_id' => 2, ); $sql = "select ID, url_title, Section, year(Posted) y, month(Posted) m from textpattern where status = 4"; $qry = $txpDB->query($sql); foreach ( $qry->result() as $row ) { // get post name $pName = $wpDB->query("select post_name from wp_posts where ID = $row->ID")->first_row()->post_name; $data['url'] = '/'.$row->Section.'/'.$row->ID.'/'.$row->url_title; $data['action_data'] = '/'.$row->y.'/'.$row->m.'/'.$pName; $wpDB->insert('wp_redirection_items', $data); //var_dump($data); } } } ?>