You are here

function smiley_import_add_pak in Smiley 6

1 call to smiley_import_add_pak()
smiley_import_add in ./smiley_import.module
Menu callback; Add a Smiley pack.

File

./smiley_import.module, line 214

Code

function smiley_import_add_pak($pack) {
  $delimeter = '=+:';
  smiley_import_delete($pack, 1);
  if (!($packd = smiley_import_packs($pack))) {
    drupal_set_message(t('Cannot find smiley package %pack.', array(
      '%pack' => $pack,
    )));
    drupal_goto('admin/settings/smiley/import');
  }
  $fcontents = @file(dirname($packd->filename) . '/' . $pack . '.pak');
  for ($i = 0; $i < count($fcontents); $i++) {
    $smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
    for ($j = 2; $j < count($smile_data); $j++) {
      $smile_data[$j] = str_replace("<", "&lt;", $smile_data[$j]);
      $smile_data[$j] = str_replace(">", "&gt;", $smile_data[$j]);
      db_query("INSERT INTO {smiley} (acronyms, image, description, standalone, promote_to_box, package) VALUES ('%s', '%s', '%s', %d, 0, '%s')", str_replace("\\'", "''", $smile_data[$j]), dirname($packd->filename) . '/' . str_replace("\\'", "''", $smile_data[0]), str_replace("\\'", "''", $smile_data[1]), 1, $pack);
    }
  }
}