Skip to content

Instantly share code, notes, and snippets.

@0x46616c6b
Created May 9, 2011 20:38
Show Gist options
  • Save 0x46616c6b/963341 to your computer and use it in GitHub Desktop.
Save 0x46616c6b/963341 to your computer and use it in GitHub Desktop.
<?php
require_once( dirname(__FILE__) . '/www/wp-load.php' );
$mysql_host = "localhost";
$mysql_user = "stickeraward";
$mysql_password = "**********";
$mysql_db = "stickeraward";
if ( mysql_connect($mysql_host, $mysql_user, $mysql_password) ) {
if ( (!mysql_select_db($mysql_db)) ) {
die('Fehler: ' . mysql_error());
}
} else {
die('Fehler: ' . mysql_error());
}
$query = "SELECT userPicture,userName,userSpot FROM usersfotos ORDER BY userPicture DESC";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$filename = $row["userPicture"];
$spot = $row["userSpot"];
$user_name = $row["userName"];
$user_id = username_exists( $user_name );
$pid = $wpdb->get_var("SELECT pid FROM $wpdb->nggpictures WHERE filename = '$filename'");
if ( substr($filename, 0, 4) == "2010" ) {
$gal_id = 6;
} else if ( substr($filename, 0, 4) == "2009" ) {
$gal_id = 8;
} else if ( substr($filename, 0, 4) == "2008" ) {
$gal_id = 10;
} else if ( substr($filename, 0, 4) == "2007" ) {
$gal_id = 12;
} else if ( substr($filename, 0, 4) == "2006" ) {
$gal_id = 14;
} else if ( substr($filename, 0, 4) == "2005" ) {
$gal_id = 16;
}
if ( $pid > 0 ) {
$post = array();
$post["nggcf_fields"][$pid][1] = $user_name;
$post["nggcf_fields"][$pid][5] = $spot;
$post["nggcf_fields"][$pid][7] = $user_id;
if (function_exists(nggcf_save_pics)) {
nggcf_save_pics($gal_id, $post);
echo $filename . " from " . $user_name . " (" . $user_id . ") with spot: " . $spot . "\n";
usleep(200000);
}
} else {
die("ERROR: Unable to fetch the picture id!\n");
}
}
mysql_free_result($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment