示例#1
0
文件: update.php 项目: kojoty/okapi
 private static function ver43()
 {
     $emails = self::get_consumers_of(array('services/replicate/changelog', 'services/replicate/fulldump'), 14);
     ob_start();
     print "Hi!\n\n";
     print "We send this email to all developers who used 'replicate' module\n";
     print "in last 14 days. Thank you for testing our BETA-status module.\n\n";
     print "As you probably know, BETA status implies that we may decide to\n";
     print "modify something in a backward-incompatible way. One of such\n";
     print "modifications just happened and it may concern you.\n\n";
     print "We removed 'attrnames' from the list of synchronized fields of\n";
     print "'geocache'-type objects. Watch our blog for updates!\n\n";
     print "-- \n";
     print "OKAPI Team";
     Okapi::mail_from_okapi($emails, "A change in the 'replicate' module.", ob_get_clean());
 }
示例#2
0
文件: core.php 项目: Slini11/okapi
 /**
  * Register new OKAPI Consumer, send him an email with his key-pair, etc.
  * This method does not verify parameter values, check if they are in
  * a correct format prior the execution.
  */
 public static function register_new_consumer($appname, $appurl, $email)
 {
     require_once $GLOBALS['rootpath'] . "okapi/service_runner.php";
     $consumer = new OkapiConsumer(Okapi::generate_key(20), Okapi::generate_key(40), $appname, $appurl, $email);
     $sample_cache = OkapiServiceRunner::call("services/caches/search/all", new OkapiInternalRequest($consumer, null, array('limit', 1)));
     if (count($sample_cache['results']) > 0) {
         $sample_cache_code = $sample_cache['results'][0];
     } else {
         $sample_cache_code = "CACHECODE";
     }
     # Message for the Consumer.
     ob_start();
     print "This is the key-pair we have created for your application:\n\n";
     print "Consumer Key: {$consumer->key}\n";
     print "Consumer Secret: {$consumer->secret}\n\n";
     print "Note: Consumer Secret is needed only when you intend to use OAuth.\n";
     print "You don't need Consumer Secret for Level 1 Authentication.\n\n";
     print "Now you can easily access Level 1 OKAPI methods. E.g.:\n";
     print Settings::get('SITE_URL') . "okapi/services/caches/geocache?cache_code={$sample_cache_code}&consumer_key={$consumer->key}\n\n";
     print "If you plan on using OKAPI for a longer time, then you may want to\n";
     print "subscribe to the OKAPI News blog to stay up-to-date:\n";
     print "http://opencaching-api.blogspot.com/\n\n";
     print "Have fun!\n\n";
     print "-- \n";
     print "OKAPI Team\n";
     Okapi::mail_from_okapi($email, "Your OKAPI Consumer Key", ob_get_clean());
     # Message for the Admins.
     ob_start();
     print "Name: {$consumer->name}\n";
     print "Developer: {$consumer->email}\n";
     print $consumer->url ? "URL: {$consumer->url}\n" : "";
     print "Consumer Key: {$consumer->key}\n";
     Okapi::mail_admins("New OKAPI app registered!", ob_get_clean());
     Db::execute("\n            insert into okapi_consumers (`key`, name, secret, url, email, date_created)\n            values (\n                '" . mysql_real_escape_string($consumer->key) . "',\n                '" . mysql_real_escape_string($consumer->name) . "',\n                '" . mysql_real_escape_string($consumer->secret) . "',\n                '" . mysql_real_escape_string($consumer->url) . "',\n                '" . mysql_real_escape_string($consumer->email) . "',\n                now()\n            );\n        ");
 }
示例#3
0
 /**
  * Scan the database and compare the current values of old entries to
  * the cached values of the same entries. If differences found, update
  * okapi_syncbase accordingly, and email the OKAPI developers.
  *
  * Currently, only caches are checked (log entries are not).
  */
 public static function verify_clog_consistency($force_all = false, $geocache_ignored_fields = null)
 {
     set_time_limit(0);
     ignore_user_abort(true);
     # We will SKIP the entries which have been modified SINCE one day ago.
     # Such entries might have not been seen by the update_clog_table() yet
     # (e.g. other long-running cronjob is preventing update_clog_table from
     # running).
     #
     # If $force_all is true, then all caches will be verified. This is
     # quite important when used in conjunction with ignored_fields.
     $cache_codes = Db::select_column("\n            select wp_oc\n            from caches\n            " . ($force_all ? "" : "where okapi_syncbase < date_add(now(), interval -1 day)") . "\n        ");
     $cache_code_groups = Okapi::make_groups($cache_codes, 50);
     unset($cache_codes);
     # For each group, get the changelog entries, but don't store them
     # (the "fulldump" mode). Instead, just update the okapi_syncbase column.
     $sum = 0;
     $two_examples = array();
     foreach ($cache_code_groups as $cache_codes) {
         $entries = self::generate_changelog_entries('services/caches/geocaches', 'geocache', 'cache_codes', 'code', $cache_codes, self::$logged_cache_fields, true, true, null);
         foreach ($entries as $entry) {
             if ($entry['object_type'] != 'geocache') {
                 continue;
             }
             $cache_code = $entry['object_key']['code'];
             if ($entry['change_type'] == 'replace' && $geocache_ignored_fields != null) {
                 # We were called with a non-null ignored fields. Probably
                 # this call originated from the database update script
                 # and new fields have been added to the replicate module.
                 # We will ignore such new fields - this way no unnecessary
                 # clog entries will be created.
                 foreach ($geocache_ignored_fields as $field) {
                     unset($entry['data'][$field]);
                 }
                 if (count($entry['data']) == 0) {
                     # Skip this geocache. Nothing was changed here, only
                     # new fields have been added.
                     continue;
                 }
             }
             # We will story the first and the last entry in the $two_examples
             # vars which is to be emailed to OKAPI developers.
             if (count($two_examples) == 0) {
                 $two_examples[0] = $entry;
             }
             /* The first entry */
             $two_examples[1] = $entry;
             /* The last entry */
             Db::execute("\n                    update caches\n                    set okapi_syncbase = now()\n                    where wp_oc = '" . mysql_real_escape_string($cache_code) . "'\n                ");
             $sum += 1;
         }
     }
     if ($sum > 0) {
         $message = "Number of invalid entries scheduled to be fixed: {$sum}\n" . "Approx revision of the first one: " . Okapi::get_var('clog_revision') . "\n\n" . "Two examples:\n\n" . print_r($two_examples, true);
         Okapi::mail_from_okapi("*****@*****.**", "verify_clog_consistency - " . Okapi::get_normalized_site_name(), $message, true);
     }
 }