function print_r_html($arr, $style = "display: none; margin-left: 10px;") { static $i = 0; $i++; echo "\n<div id=\"array_tree_{$i}\" class=\"array_tree\">\n"; foreach ($arr as $key => $val) { switch (gettype($val)) { case "array": echo "<a onclick=\"document.getElementById('"; echo "array_tree_element_" . $i . "').style.display = "; echo "document.getElementById('array_tree_element_{$i}"; echo "').style.display == 'block' ?"; echo "'none' : 'block';\"\n"; echo "name=\"array_tree_link_{$i}\" href=\"#array_tree_link_{$i}\">" . htmlspecialchars($key) . "</a><br />\n"; echo "<div class=\"array_tree_element_\" id=\"array_tree_element_{$i}\" style=\"{$style}\">"; echo print_r_html($val); echo "</div>"; break; case "integer": echo "<b>" . htmlspecialchars($key) . "</b> => <i>" . htmlspecialchars($val) . "</i><br />"; break; case "double": echo "<b>" . htmlspecialchars($key) . "</b> => <i>" . htmlspecialchars($val) . "</i><br />"; break; case "boolean": echo "<b>" . htmlspecialchars($key) . "</b> => "; if ($val) { echo "true"; } else { echo "false"; } echo "<br />\n"; break; case "string": echo "<b>" . htmlspecialchars($key) . "</b> => <code>" . htmlspecialchars($val) . "</code><br />"; break; default: echo "<b>" . htmlspecialchars($key) . "</b> => " . gettype($val) . "<br />"; break; } echo "\n"; } echo "</div>\n"; }
/** * Sets up the object * * @constructor sotf_AudioCheck * @param object $list FileList object contains list of files to be checked * @use $config['videoFormats'], $config['bitrateTolerance'] */ function sotf_VideoCheck($list) { global $config; $display_arr = false; $this->list =& $list; for ($i = 0; $i < count($config['videoFormats']); $i++) { $found = false; // indicates whether the current audio format has been found for ($j = 0; $j < count($this->list->list); $j++) { // $this->list->list[$j] means the current AudioFile object if ($this->list->list[$j]->type != "video") { continue; // This is not an video, get another one } if ($config['videoFormats'][$i]['format'] != $this->list->list[$j]->format) { if ($display_arr) { print "{$i}{$j} wrong format: " . $this->list->list[$j]->format . ", should be " . $config['videoFormats'][$i]['format'] . "<br>" . print_r_html($this->list->list[$j]) . "<br> <br>"; } continue; // This is not the one we need, get another one } $found = $j; // That's what we need, store its position break; // don't need to search for another, leave the loop } if ($found !== false) { $this->reqs[] = array(true, $found); // store the position of the matched file continue; // get the next requested format } $this->reqs[] = array(false, false); // There was nothing we could have use } }
function update_pr_tools() { global $prtools_debug; global $prtools_version; $prtools_settings = get_option('pagerank_tools_settings'); // unset($prtools_settings['running_number']); if ($prtools_debug) { print_r_html($prtools_settings); } // Reorganizing tables // 08. December 2010 // Version 0.2 to 0.2.1 // Adding entries for requests urls without pr from google, // adding first creation log, // get difference between last PR and new PR in table // and getting num of entries in table if ($prtools_settings['running_number'] == "") { cleanup_db_from_02(); } if ($prtools_settings['running_number'] < 3) { alter_table_from_02(); update_url_table(true, true); $prtools_settings['fetch_titles_num'] = 2; } // Saving which updates have been made $prtools_settings['version'] = $prtools_version; $prtools_settings['running_number'] = 3; // if($prtools_debug)unset($prtools_settings['running_number']); update_option('pagerank_tools_settings', $prtools_settings); }
function show_urls() { print_r_html(wp_get_urls()); }
$this->SetTextColor(0); $this->SetFont(''); //Data $fill = false; for ($i = 0; $i < count($data); $i++) { $this->Cell($w[0], 5, utf8_decode($data[$i][0]), 'LR', 0, 'L', $fill); $this->Cell($w[1], 5, utf8_decode($data[$i][1]), 'LR', 0, 'L', $fill); $this->Cell($w[2], 5, utf8_decode($data[$i][2]), 'LR', 0, 'L', $fill); $this->Cell($w[3], 5, utf8_decode($data[$i][8]), 'LR', 0, 'L', $fill); $this->Cell($w[4], 5, utf8_decode($data[$i][9]), 'LR', 0, 'L', $fill); $this->Ln(); $fill = !$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request $input = file_get_contents("php://input"); $json = json_decode($input); $data = $json->aaData; $pdf = new PDF(); //Column titles $header = array('ID', 'Name', 'Vorname', 'Geburtstag', 'Alter'); //Data loading $pdf->SetFont('Arial', '', 10); $pdf->AddPage(); $pdf->FancyTable($header, $data); $pdf->Output(); print_r_html($test); }
function rss_import_showpage() { global $main_smarty, $the_template, $db; include_once 'config.php'; include_once mnminclude . 'html1.php'; include_once mnminclude . 'link.php'; include_once mnminclude . 'tags.php'; include_once mnminclude . 'smartyvariables.php'; require_once 'class.rssimport.php'; require_once 'modules/rss_import/magpierss/rss_fetch.inc'; define('MAGPIE_CACHE_DIR', 'cache/templates_c/'); define('rss_import_export_version', '0.4'); $smarty = $main_smarty; include_once mnminclude . 'qeip_0_3.php'; force_authentication(); $amIgod = 0; $amIgod = $amIgod + checklevel('god'); // pagename define('modulename', 'rss_import'); $main_smarty->assign('modulename', modulename); // breadcrumbs and page title $navwhere['text1'] = $smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'); $navwhere['link1'] = getmyurl('admin', ''); $navwhere['text2'] = $smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel_RSSImport'); $smarty->assign('navbar_where', $navwhere); $smarty->assign('posttitle', ' / ' . $smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel_RSSImport')); // sidebar $main_smarty = do_sidebar($main_smarty); if ($amIgod == 1) { $tableexists = checkfortable(table_prefix . 'feeds'); if (!$tableexists) { echo "Creating Tables<hr />"; include_once 'create_feed_tables.php'; die("<hr />If there are no errors then refresh this page to continue"); } $filename = 'create_feed_tables.php'; if (file_exists($filename)) { // die("Please delete or rename the file create_feed_tables.php, then refresh this page"); } $smarty->register_function('feedsListFeeds', 'smarty_function_feedsListFeeds'); $smarty->register_function('feedsListFeedLinks', 'smarty_function_feedsListFeedLinks'); $smarty->register_function('feedsListFeedFields', 'smarty_function_feedsListFeedFields'); $smarty->register_function('feedsListPliggLinkFields', 'smarty_function_feedsListPliggLinkFields'); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_name', 'key' => 'feed_id'); // a unique identifier for the row $smarty->assign('qeip_FeedName', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_url', 'key' => 'feed_id'); // a unique identifier for the row $smarty->assign('qeip_FeedURL', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_category', 'key' => 'feed_id'); // a unique identifier for the row $smarty->assign('qeip_FeedCategory', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_freq_hours', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedFreqHours', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_votes', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedVotes', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_item_limit', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedItemLimit', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_url_dupe', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedURLDupe', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_title_dupe', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedTitleDupe', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_submitter', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedSubmitter', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feed_link', 'field_name' => 'feed_field', 'key' => 'feed_link_id', 'eip_type' => 'select'); // the type of EIP field to show $smarty->assign('qeip_FeedLink_FeedField', $QEIPA); $QEIPA = array('table_name' => table_prefix . 'feed_link', 'field_name' => 'pligg_field', 'key' => 'feed_link_id', 'eip_type' => 'select'); // the type of EIP field to show $smarty->assign('qeip_FeedLink_PliggField', $QEIPA); // feed oldest first $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_last_item_first', 'key' => 'feed_id'); // a unique identifier for the row $smarty->assign('qeip_FeedLastItemFirst', $QEIPA); // feed random vote $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_enable', 'key' => 'feed_id'); // a unique identifier for the row $smarty->assign('qeip_FeedRandomVoteEnable', $QEIPA); // feed random vote min $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_min', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedRandomVotesMin', $QEIPA); // feed random vote max $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_max', 'key' => 'feed_id', 'field_type' => 'number'); // the type of database field we are reading from / writing to $smarty->assign('qeip_FeedRandomVotesMax', $QEIPA); $QEIP = new QuickEIP(); if (!isset($_REQUEST['action'])) { $smarty->assign('tpl_center', rss_import_tpl_path . 'admin_rss_center'); $main_smarty->display($template_dir . '/admin/admin.tpl'); echo $QEIP->ShowOnloadJS(); } else { if ($_REQUEST['action'] == "addnewfieldlink") { $RSSImport = new RSSImport(); $RSSImport->FeedLinkId = $_REQUEST['FeedLinkId']; $RSSImport->new_field_link(); redirect('module.php?module=rss_import&action=editfeed&feed_id=' . $_REQUEST['FeedLinkId']); } if ($_REQUEST['action'] == "dropfieldlink") { $RSSImport = new RSSImport(); $RSSImport->FeedLinkId = $_REQUEST['FeedLinkId']; $RSSImport->drop_field_link(); redirect('module.php?module=rss_import'); } if ($_REQUEST['action'] == "addnewfeed") { $RSSImport = new RSSImport(); $RSSImport->FeedName = "New Feed"; $RSSImport->new_feed(); redirect('module.php?module=rss_import'); } if ($_REQUEST['action'] == "dropfeed") { $RSSImport = new RSSImport(); $RSSImport->FeedId = $_REQUEST['feed_id']; $RSSImport->drop_feed(); redirect('module.php?module=rss_import'); } if ($_REQUEST['action'] == "save") { echo $QEIP->save_field($smarty); } if ($_REQUEST['action'] == "examinefeed") { $RSSImport = new RSSImport(); $RSSImport->FeedId = $_REQUEST['feed_id']; $RSSImport->read_feed(); $rss = fetch_rss($RSSImport->FeedURL); $z = $rss->items[0]; if ($z) { echo 'First item in the feed.<hr />'; print_r_html($z); echo '<hr />Feed dump.<hr />'; print_r_html($rss); } else { echo '<hr />There are no items in this feed<hr />'; } } if ($_REQUEST['action'] == "editfeed") { $RSSImport = new RSSImport(); $RSSImport->FeedId = $_REQUEST['feed_id']; $smarty->assign('tpl_center', rss_import_tpl_path . 'admin_rss_center2'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($_REQUEST['action'] == "exportfeed") { echo 'copy all the text in the box<br />'; echo '<textarea rows=10 cols=70>' . serialize_feed($_REQUEST['feed_id']) . '</textarea>'; echo '<br /><br /><a href = "module.php?module=rss_import">return to the rss importer</a>'; } if ($_REQUEST['action'] == "importprebuiltfeed_go") { $feed = stripslashes($_REQUEST['prebuiltfeed']); if (strpos($feed, '://') < 10) { $r = new HTTPRequest($feed); $feed = $r->DownloadToString(); } if (import_prebuilt($feed)) { redirect(my_pligg_base . '/module.php?module=rss_import'); } else { // what do we do if error? } } } //echo $QEIP->ShowOnloadJS(); } }
</td> <td><?php printf("%d (%d%%)", round($Medical[13][0]), $Medical[13][0] / 2160 * 100); ?> </td> <td><?php printf("%d (%d%%)", round($Medical[13][1]), $Medical[13][1] / 1440 * 100); ?> </td> </tr> <!-- <tr><td colspan="5"> <br><?php print_r_html($Medical); ?> </td></tr> --> <!-- <tr><td colspan="5"> <br><?php print_r_html($currentState); ?> </td></tr> --> <tr><td colspan="6"> </td></tr> </table> <?php if ($notindeadtable) { ?> <table id="playeractions"> <tr> <th class="custom-th"> Options </th> <?php if ($map == 'chernarus') { ?>
function test_sApi_createAccount() { printResultStart(__FUNCTION__); $messages = array(); //Test try { $sfdcRes = sApi::createSfdcAccount('NEW-ECOMMERCE-TEST-ACCOUNT'); print_r_html($sfdcRes); } catch (Exception $e) { array_push($messages, $e->getMessage()); } printResultEnd($messages); }
function rs_get_title($url) { if ($html = @file_get_contents($url, false, $context)) { // If libxml is installed if (class_exists('DOMDocument')) { $doc = new DOMDocument(); if (@$doc->loadHTML($html) == false) { return false; } $titles = $doc->getElementsByTagName('title'); foreach ($doc->getElementsByTagName('title') as $nodes) { $pageTitle[] = $nodes->nodeValue; } return $pageTitle[0]; // Otherwise use preg_match } else { $opts = array('http' => array('timeout' => 5)); $context = stream_context_create($opts); preg_match('/<title>(\\r\\n)(.*)<\\/title>/U', $html, $pageTitle); print_r_html($pageTitle); return $pageTitle[1]; } } else { return "404 Page not found"; } /* $r = new HTTPRequest($url); $html = $r->DownloadToString(); preg_match('/<title>(.*)<\/title>/U', $html, $pageTitle); return $pageTitle[1]; // $url="www.fachwissen-daten.de/berichte/die-neue-generation-an-gartenmobel/48"; echo "allow_url_fopen: ".ini_get('allow_url_fopen') . '<br>'; $fp = fsockopen($url, 80, $errno, $errstr, 5); if (!$fp) { echo "Nein!<br />"; echo "$errstr ($errno)<br />\n"; } else { print_r_html($fp); /* $out = "GET / HTTP/1.1\r\n"; $out .= "Host: www.example.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } $file = @fopen ($url,"r"); if (trim($file) == "") { echo "Service out of order"; return false; } else { $i=0; while (!feof($file)) { // Wenn das File entsprechend groß ist, kann es unter Umständen // notwendig sein, die Zahl 2000 entsprechend zu erhöhen. Im Falle // eines Buffer-Overflows gibt PHP eine entsprechende Fehlermeldung aus. $zeile[$i] = fgets($file,2000); $i++; } $html=implode($zeile); preg_match('/<title>(.*)<\/title>/U', $html, $pageTitle); return $pageTitle[1]; } fclose($file); $html=file_get_contents($url); // cURL URL Aufruf $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Daten aus der URL auslesen $inhalt = curl_exec($ch); $daten = unserialize($inhalt); echo $daten[0][0]; // cURL wird geschlossen curl_close($ch); preg_match('/<title>(.*)<\/title>/U', $inhalt, $pageTitle); return $pageTitle[1]; $opts = array('http' => array( 'timeout' => 5 ) ); $context = stream_context_create($opts); if($html=file_get_contents($url, false, $context)){ // echo $html; preg_match('/<title>(\r\n)(.*)<\/title>/U', $html, $pageTitle); print_r_html($pageTitle); return $pageTitle[1]; }else{ return "404 Page not found"; } */ }
function tk_show_bp_vars() { global $bp, $forum_template; global $wp_post_types; // print_r_html( $bp ); print_r_html($wp_post_types); // print_r_html( $forum_template ); }
function fetch_pr() { global $wpdb; global $prtools_debug; global $prtools_url_table; global $prtools_pr_table; $sql = "SELECT ID FROM " . $wpdb->posts . " WHERE post_status='publish'"; $published_posts = $wpdb->get_results($sql); $prtools_settings = get_option('pagerank_tools_settings'); $lastcheck = time() - $prtools_settings['fetch_interval'] * 60; $lastcheck_url = time() - $prtools_settings['fetch_url_interval'] * 24 * 60 * 60; $lastcheck_url_new = time() - $prtools_settings['fetch_url_interval_new'] * 24 * 60 * 60; $sql = "SELECT * FROM " . $prtools_url_table . " ORDER BY lastcheck DESC LIMIT 0,1"; $prtools_last = $wpdb->get_row($sql); $sql = "SELECT * FROM " . $prtools_url_table . " WHERE queue=1 LIMIT 0,1"; $queued_urls = $wpdb->get_results($sql); /* echo "LU: ".$prtools_last->lastupdate."<br>"; $s=time()-$prtools_last->lastupdate; echo "S: ".$s."<br>"; echo "T: ".time()."<br>"; */ /* * Checking time of last pr request ***************************************/ if ($prtools_last->lastcheck < $lastcheck || $queued_urls > 0) { // Getting sites which are updatable by settings $sql = "SELECT * FROM " . $prtools_url_table . " WHERE (lastcheck<" . $lastcheck_url . " OR (lastcheck<" . $lastcheck_url_new . " AND pr=-1) OR (lastcheck<" . $lastcheck_url_new . " AND pr=-2)) OR queue=1 ORDER BY pr DESC LIMIT 0," . $prtools_settings['fetch_num']; // $sql="SELECT * FROM ".$prtools_url_table." WHERE lastcheck<=".$lastcheck_url." ORDER BY pr DESC LIMIT 0,".$prtools_settings['fetch_num']; $url_rows = $wpdb->get_results($sql); if ($prtools_debug) { echo $sql . "<br />\n"; } if ($prtools_debug) { echo "Lastcheck to be maximum at: " . date("d.m.Y - H:i", $lastcheck) . "<br />"; } if ($prtools_debug) { echo "Lastcheck URL have to be maximum at: " . date("d.m.Y - H:i", $lastcheck_url) . "<br />"; } if ($prtools_debug) { echo "Lastcheck of new URL have to be maximum at: " . date("d.m.Y - H:i", $lastcheck_url) . "<br />"; } if ($prtools_debug) { print_r_html($prtools_settings); } if ($prtools_debug) { print_r_html($url_rows); } // Get all published urls $published_blog_urls = get_blog_urls(); /* * Checking pageranks ***************************************/ foreach ($url_rows as $url_row) { // If post is an actual published url if (in_array($url_row->url, $published_blog_urls)) { if ($prtools_debug) { $time_start = time(); } if ($prtools_debug) { echo $lastcheck . " > " . $prtools_settings['last_google_request'] . "<br />"; } if ($lastcheck > $prtools_settings['last_google_request']) { $pr = getpagerank($url_row->url); if ($url_row->queue == 1) { if ($prtools_debug) { echo "GETTING PR FOR QUEUE<br>URL: " . $url_row->url . "<br />\n"; } } else { if ($prtools_debug) { echo "GETTING PR<br>URL: " . $url_row->url . "<br />\n"; } } if ($prtools_debug) { $time_end = time(); echo "Request time: " . ($time_end - $time_start) . "<br />\n"; } if ($pr == "") { $pr = -1; } // If PR is a new rank update and insert $actual_pr = (int) $pr; $last_pr = (int) $url_row->pr; if ($prtools_debug) { echo "URL: " . $url_row->url . "<br />"; } if ($prtools_debug) { echo "New PR: " . $actual_pr . " <br />Old PR: " . $last_pr . "<br />"; } if ($actual_pr != $last_pr) { if ($prtools_debug) { echo "<b>updating</b><br /><br />"; } $diff_last_pr = $actual_pr - $last_pr; $url_row->pr_entries++; $wpdb->update($prtools_url_table, array('lastcheck' => time(), 'lastupdate' => time(), 'pr' => $actual_pr, 'diff_last_pr' => $diff_last_pr, 'pr_entries' => $url_row->pr_entries, 'queue' => 0), array('url' => $url_row->url)); $wpdb->insert($prtools_pr_table, array('entrydate' => time(), 'url' => $url_row->url, 'pr' => $actual_pr)); do_action('prtools_update_pr', $url_row, $actual_pr, $last_pr); } else { if ($prtools_debug) { echo "<b>not updating</b><br /><br />"; } $wpdb->update($prtools_url_table, array('lastcheck' => time(), 'queue' => 0), array('url' => $url_row->url)); } } } } $prtools_settings['last_google_request'] = time(); update_option('pagerank_tools_settings', $prtools_settings); } }
/** * Updating database from Version 0.2 or less */ function cleanup_db_from_02() { global $prtools_debug; global $wpdb; global $prtools_url_table; global $prtools_pr_table; // Updating table $sql = "ALTER TABLE " . $prtools_url_table . " ADD diff_last_pr INT( 1 ) NOT NULL AFTER pr"; $wpdb->query($sql); if ($prtools_debug) { echo $sql . "<br />"; } $sql = "ALTER TABLE " . $prtools_url_table . " ADD pr_entries INT( 11 ) NOT NULL AFTER diff_last_pr"; $wpdb->query($sql); if ($prtools_debug) { echo $sql . "<br />"; } $sql = "ALTER TABLE " . $prtools_url_table . " ADD lastcheck INT( 11 ) NOT NULL AFTER lastupdate"; $wpdb->query($sql); if ($prtools_debug) { echo $sql . "<br />"; } $sql = "ALTER TABLE " . $prtools_url_table . " ADD title TEXT NOT NULL AFTER url"; $wpdb->query($sql); if ($prtools_debug) { echo $sql . "<br />"; } // Creating missing pagerank entries in pagerank table $sql = "SELECT * FROM " . $prtools_url_table; $url_rows = $wpdb->get_results($sql); if ($prtools_debug) { echo $sql . "<br />"; } if ($prtools_debug) { echo "<hr />"; } $updated = false; foreach ($url_rows as $url_row) { // Counting all entries of one url $sql = "SELECT * FROM " . $prtools_pr_table . " WHERE url='" . $url_row->url . "' ORDER BY entrydate DESC"; $pr_rows = $wpdb->get_results($sql); $entries = count($pr_rows); if ($prtools_debug) { echo "<b>URL: " . $url_row->url . "</b><br />"; } if ($prtools_debug) { echo "URL Table<br /"; } if ($prtools_debug) { print_r_html($url_row); } if ($prtools_debug) { echo "PR Table<br /"; } if ($prtools_debug) { print_r_html($pr_rows); } // No entry exists if ($entries == 0) { $diff_last_pr = $url_row->pr - -2; if ($prtools_debug) { echo "No entry found<br />Adding first google request log entry with PR (" . $url_row->pr . ")<br />"; } $wpdb->insert($prtools_pr_table, array('entrydate' => $url_row->lastupdate, 'url' => $url_row->url, 'pr' => $url_row->pr)); // Adding first creation log entry if ($prtools_debug) { echo "Adding first creation log entry with timestamp (" . $url_row->entrydate . ")<br />"; } $wpdb->insert($prtools_pr_table, array('entrydate' => $url_row->entrydate, 'url' => $url_row->url, 'pr' => -2)); if ($prtools_debug) { echo "Updating Number of entries (2) and setting diff to (" . $diff_last_pr . ")<br />"; } $wpdb->update($prtools_url_table, array('diff_last_pr' => $diff_last_pr, 'pr_entries' => 2), array('url' => $url_row->url)); // Entry / entries existing } else { // If more than one entry is in pr table -> set data for difference to last pr and num of entries if ($entries > 1) { if ($prtools_debug) { echo $entries . " entries found<br />"; } // Checking rows for double entries - Only changes on pagerank have to be logged if ($prtools_debug) { echo "Checking for double entries<br />"; } $sql = "SELECT * FROM " . $prtools_pr_table . " WHERE url='" . $url_row->url . "' ORDER BY entrydate DESC"; $pr_rows = $wpdb->get_results($sql); for ($i = 0; $i < count($pr_rows); $i++) { if ($pr_rows[$i]->pr == $pr_rows[$i + 1]->pr && $pr_rows[$i + 1]->ID != "") { // Deleting double entry $sql = "DELETE FROM " . $prtools_pr_table . " WHERE ID=" . $pr_rows[$i + 1]->ID; $wpdb->query($sql); if ($prtools_debug) { echo "Deleting double entry: " . $pr_rows[$i]->url . " : " . $pr_rows[$i]->ID . "<br />"; } } elseif ($pr_rows[$i + 1]->ID != "") { if ($prtools_debug) { echo "Found a change of PR.<br />"; } } } // Getting new resultlist $sql = "SELECT * FROM " . $prtools_pr_table . " WHERE url='" . $url_row->url . "' ORDER BY entrydate desc"; $pr_rows = $wpdb->get_results($sql); $entries = count($pr_rows); if ($entries > 1) { if ($prtools_debug) { echo "More than one entries left<br />"; } $diff_last_pr = $pr_rows[count($entries) - 1]->pr - $pr_rows[count($entries)]->pr; if ($prtools_debug) { print_r_html($pr_rows); } if ($prtools_debug) { echo $pr_rows[count($entries) - 1]->pr . " - " . $pr_rows[count($entries)]->pr . " = " . $diff_last_pr . "<br />"; } $pr_arr = array(); foreach ($pr_rows as $pr_row) { array_push($pr_arr, $pr_row->pr); } $start_entry = 0; if (!in_array(-2, $pr_arr)) { // Adding first creation log entry if ($prtools_debug) { echo "Adding first creation log entry with timestamp (" . $url_row->entrydate . ")<br />"; } $wpdb->insert($prtools_pr_table, array('entrydate' => $url_row->entrydate, 'url' => $url_row->url, 'pr' => -2)); $start_entry++; } if ($prtools_debug) { echo "Updating Number of entries (" . ($entries + $start_entry) . "), setting diff to (" . $diff_last_pr . ") and PR (" . $pr_rows[count($entries) - 1]->pr . ")<br />"; } $wpdb->update($prtools_url_table, array('diff_last_pr' => $diff_last_pr, 'pr_entries' => $entries + $start_entry, 'pr' => $pr_rows[count($entries) - 1]->pr), array('url' => $url_row->url)); } else { $diff_last_pr = $pr_rows[0]->pr - -2; if ($prtools_debug) { echo "Only one entry left with PR (" . $pr_rows[0]->pr . ")<br />"; } // Adding first creation log entry if ($prtools_debug) { echo "Adding first creation log entry with timestamp (" . $url_row->entrydate . ")<br />"; } $wpdb->insert($prtools_pr_table, array('entrydate' => $url_row->entrydate, 'url' => $url_row->url, 'pr' => -2)); if ($prtools_debug) { echo "Updating Number of entries (2), setting diff (" . $diff_last_pr . ") and PR (" . $pr_rows[count($entries) - 1]->pr . ")<br />"; } $wpdb->update($prtools_url_table, array('diff_last_pr' => $diff_last_pr, 'pr_entries' => 2, 'pr' => $pr_rows[count($entries) - 1]->pr), array('url' => $url_row->url)); } } else { $diff_last_pr = $pr_rows[0]->pr - -2; if ($prtools_debug) { echo "Only one entry found PR (" . $pr_rows[0]->pr . ")<br />"; } // Adding first creation log entry if ($prtools_debug) { echo "Adding first creation log entry with timestamp (" . $url_row->entrydate . ")<br />"; } $wpdb->insert($prtools_pr_table, array('entrydate' => $url_row->entrydate, 'url' => $url_row->url, 'pr' => -2)); if ($prtools_debug) { echo "Updating Number of entries (2), setting diff (" . $diff_last_pr . ") and PR (" . $pr_rows[count($entries) - 1]->pr . ")<br />"; } $wpdb->update($prtools_url_table, array('diff_last_pr' => $diff_last_pr, 'pr_entries' => 2, 'pr' => $pr_rows[count($entries) - 1]->pr), array('url' => $url_row->url)); } } if ($prtools_debug) { echo "<hr />"; } } }