function db_correction()
{
    $db_connect = mysqli_connect('localhost', 'root', '', 'ddn');
    $query = "SELECT news_id, news_content FROM news";
    if ($res = mysqli_query($db_connect, $query)) {
        while ($row = mysqli_fetch_assoc($res)) {
            $arr[] = $row;
        }
        foreach ($arr as $row) {
            $text1 = $row['news_content'];
            $id = $row['news_id'];
            $text2 = add_tags($text1);
            if ($text2['change']) {
                $text = $text2['text'];
                $query = "UPDATE news " . "SET news_content={$text} " . "WHERE news_id={$id}";
                mysqli_query($db_connect, $query);
            }
        }
    }
}
 echo "<td width='80%' class='tbl'><textarea name='page_content' cols='100' rows='25' class='textbox' style='width:98%'>" . $page_content . "</textarea></td>\n";
 echo "</tr>\n<tr>\n";
 if (!isset($_COOKIE['custompages_wysiwyg_editor']) || !$_COOKIE['custompages_wysiwyg_editor'] || !$settings['wysiwyg_enabled']) {
     echo "<td class='tbl'></td><td class='tbl'>\n";
     echo "<input type='button' value='&lt;?php?&gt;' class='button' style='width:60px;' onclick=\"addText('page_content', '&lt;?php\\n', '\\n?&gt;');\" />\n";
     echo "<input type='button' value='&lt;p&gt;' class='button' style='width:35px;' onclick=\"addText('page_content', '&lt;p&gt;', '&lt;/p&gt;');\" />\n";
     echo "<input type='button' value='&lt;br /&gt;' class='button' style='width:40px;' onclick=\"insertText('page_content', '&lt;br /&gt;');\" />\n";
     echo display_html("inputform", "page_content", true) . "</td>\n";
     echo "</tr>\n";
 }
 if ($settings['enable_tags']) {
     if ($request_edit && $request_page_id) {
         echo edit_tags($request_page_id, "C");
         // Pimped: tag
     } else {
         echo add_tags("C");
         // Pimped: tag
     }
 }
 echo "<tr>\n";
 echo "<td width='100' class='tbl'>" . $locale['431'] . "</td>\n";
 // meta
 echo "<td class='tbl'><input type='text' name='page_keywords' value='" . $page_keywords . "' class='textbox' style='width:250px;' /></td>\n";
 echo "</tr>\n<tr>\n";
 if (!check_admin_pass(isset($_POST['admin_password']) ? stripinput($_POST['admin_password']) : "")) {
     echo "<td class='tbl'>" . $locale['425'] . "</td>\n";
     echo "<td class='tbl'><input type='password' name='admin_password' value='" . (isset($_POST['admin_password']) ? stripinput($_POST['admin_password']) : "") . "' class='textbox' style='width:150px;' /></td>\n";
     echo "</tr>\n<tr>\n";
 }
 echo "<td class='tbl'></td><td class='tbl'>\n";
 if (!$request_page_id) {
Beispiel #3
0
<?php

/* Adds a post to the database */
if (!(isset($_POST) && @$_POST['title'] != '')) {
    _die("tpl/post_form.html");
}
include "lib/post.php";
include "lib/tags.php";
$post_data =& $_POST;
foreach (array('title', 'contents', 'tags', 'time', 'slug') as $key) {
    $post_data[$key] = pg_escape_string(@$post_data[$key]);
}
$post_data['tags'] = clean_tags($post_data['tags']);
if (trim($post_data['slug']) == '') {
    $post_data['slug'] = make_slug($post_data['title']);
}
if (!($time = strtotime(@$post_data['time']))) {
    $time = date("Y-m-d H:i:s O", time());
} else {
    $time = date("Y-m-d H:i:s O", $time);
}
if (db('INSERT INTO "public"."notes" ("title", "contents", "slug", "tags", "time") VALUES (' . "\n\t'{$post_data['title']}','{$post_data['contents']}','{$post_data['slug']}','{$post_data['tags']}','{$time}' )")) {
    add_tags($post_data['tags']);
    header('Location: ' . _l("/archive/{$_POST['slug']}"));
} else {
    _die("Some error occoured. Try again.");
}
$res = null;
// decode and unpack data
if (@$_REQUEST['data']) {
    $data = json_decode(urldecode(@$_REQUEST['data']), true);
    switch (@$_REQUEST['action']) {
        case 'delete_bookmark':
            $res = delete_bookmarks($data);
            break;
        case 'add_wgTags_by_id':
            $res = add_wgTags_by_id($data);
            break;
        case 'remove_wgTags_by_id':
            $res = remove_wgTags_by_id($data);
            break;
        case 'add_tags':
            $res = add_tags($data);
            break;
        case 'remove_tags':
            $res = remove_tags($data);
            break;
        case 'bookmark_reference':
            $res = bookmark_references($data);
            break;
        case 'bookmark_and_tag':
        case 'bookmark_and_tags':
            //save collection of ids with some tag
            $res = bookmark_and_tag_record_ids($data);
            break;
        case 'set_ratings':
            $res = set_ratings($data);
            break;
 $datas = array();
 $errors = array();
 $warnings = array();
 $infos = array();
 foreach ($images as $image) {
     // Fech reverse location from API
     $condition = $forecast->getHistoricalConditions($image['latitude'], $image['longitude'], $image['date']);
     if (!isset($condition) or $condition === 'false') {
         $errors[] = "Error fetching weather condition data for " . $image['name'];
     }
     //print_r($condition);
     // If reponse include icon
     if (isset($condition) and isset($condition->icon) and !empty($condition->icon)) {
         if (!$sync_options['simulate']) {
             $id = tag_id_from_tag_name($sync_options['fc_tag_group'] . ":" . $condition->icon);
             add_tags([$id], [$image['id']]);
         }
         $infos[] = "Set tag '" . $condition->icon . "' for " . $image['name'];
         $datas[] = $image['id'];
     } else {
         $warnings[] = "No valid tags for " . $image['name'];
     }
     //die("Done one image");
 }
 // Images loop
 // Send sync result to template
 $template->assign('sync_errors', $errors);
 $template->assign('sync_warnings', $warnings);
 $template->assign('sync_infos', $infos);
 // Send result to templates
 $template->assign('metadata_result', array('NB_ELEMENTS_DONE' => count($datas), 'NB_ELEMENTS_CANDIDATES' => count($images), 'NB_ERRORS' => count($errors), 'NB_WARNINGS' => count($warnings)));
Beispiel #6
0
$dt = gmdate('Y-m-d H:i:s');
$hash = md5($dt . $to_email . $message);
$hash = md5($dt . $email . $message);
$db->query($db->prepare("INSERT INTO {$db->threads} ( hash, dt, email, subject ) VALUES ( %s, %s, %s, %s )", $hash, $dt, $to_email, $subject));
$thread_id = $db->insert_id;
$db->query($db->prepare("INSERT INTO {$db->messages} ( hash, thread_id, dt, email, content ) VALUES ( %s, %s, %s, %s, %s )", $hash, $thread_id, $dt, "support+{$current_user->user_login}@{$email_domain}", $message));
// Status stuff
$status = 'open';
if (isset($_POST['sendtickle'])) {
    $status = 'tickle';
}
if (isset($_POST['sendclose'])) {
    $status = 'closed';
}
if ($tags) {
    add_tags($thread_id, $tags);
}
$count = $db->get_var("SELECT COUNT(*) FROM {$db->messages} WHERE thread_id = {$thread_id}");
$db->query("UPDATE {$db->threads} SET messages = {$count}, state = '{$status}' WHERE thread_id = {$thread_id}");
$name = "{$current_user->first_name} {$current_user->last_name}";
$reply = str_replace(array("\r\n", "\r"), "\n", $reply);
// cross-platform newlines
$reply = preg_replace("/\n\n+/", "\n\n", $reply);
// take care of duplicates
$reply .= "\n\n-- \n{$name}";
wp_mail($to_email, $subject, $message, "From: {$name} <{$support_email}>\nReply-to: {$name} <{$support_email}>\nMessage-Id: <{$hash}@{$email_domain}>");
if ('closed' == $status) {
    header('Location: ' . $site_url);
} else {
    header('Location: thread.php?t=' . $thread_id);
}
Beispiel #7
0
    <p>We have a great selection of musical instruments including
        guitars, basses, and drums. And we're constantly adding more to give
        you the best selection possible!
    </p>
    <table>
    <?php 
foreach ($products as $product) {
    // Get product data
    $list_price = $product['listPrice'];
    $discount_percent = $product['discountPercent'];
    $description = $product['description'];
    // Calculate unit price
    $discount_amount = round($list_price * ($discount_percent / 100.0), 2);
    $unit_price = $list_price - $discount_amount;
    // Get first paragraph of description
    $description_with_tags = add_tags($description);
    $i = strpos($description_with_tags, "</p>");
    $first_paragraph = substr($description_with_tags, 3, $i - 3);
    ?>
        <tr>
            <td class="product_image_column" >
                <img src="images/<?php 
    echo htmlspecialchars($product['productCode']);
    ?>
_s.png"
                     alt="&nbsp;">
            </td>
            <td>
                <p>
                    <a href="catalog?product_id=<?php 
    echo $product['productID'];
Beispiel #8
0
    }
    if ($game['leaderboard_enabled'] == true) {
        $highscores = 1;
    } else {
        $highscores = 0;
    }
    $date = date("Y-m-d H:i:s");
    $default_ad = $feed_setting['default_ad'];
    $seo_url = create_seoname($name, 0, 'game');
    mysql_query("INSERT INTO ava_games (name, description, url, category_id, published, filetype, width, height, image, instructions , mochi, date_added, advert_id, highscores, mochi_id, seo_url)\nVALUES ('{$name}', '{$description}', '{$url}', '{$category}', 1, 'swf', '{$game['width']}', '{$game['height']}', '{$thumb_url}', '{$instructions}', 1, '{$date}', {$default_ad}, {$highscores}, '{$game['game_tag']}', '{$seo_url}')") or die(mysql_error());
    $new_id = mysql_insert_id();
    mysql_query("UPDATE ava_mochi SET visible='2' WHERE gametag='{$game['game_tag']}'");
    $tag_list = '';
    $ti = 0;
    print_r($game['tags']);
    foreach ($game['tags'] as $game_tags) {
        if ($ti == 1) {
            $tag_list = $tag_list . ',' . $game_tags;
        } else {
            $tag_list = $tag_list . $game_tags;
            $ti = 1;
        }
    }
    // Add game tags
    if ($feed_setting['get_tags'] == 1) {
        $tags = str_replace(" ", "", $tag_list);
        $tag_array = explode(",", $tags);
        add_tags($tag_array, $new_id);
        include 'tagcloud_gen.php';
    }
}
 echo "<td valign='top' width='145' class='tbl2'>" . $locale['463'] . "</td>\n";
 echo "<td class='tbl1'>\n";
 if (iMOD || iSUPERADMIN) {
     echo "<label><input type='checkbox' name='sticky_thread' value='1'" . $sticky_thread_check . " /> " . $locale['480'] . "</label><br />\n";
     echo "<label><input type='checkbox' name='lock_thread' value='1'" . $lock_thread_check . " /> " . $locale['481'] . "</label><br />\n";
 }
 echo "<label><input type='checkbox' name='disable_smileys' value='1'" . $disable_smileys_check . " /> " . $locale['482'] . "</label>";
 if (array_key_exists("user_sig", $userdata) && $userdata['user_sig']) {
     echo "<br />\n<label><input type='checkbox' name='show_sig' value='1'" . $sig_checked . " /> " . $locale['483'] . "</label>";
 }
 if ($settings['thread_notify']) {
     echo "<br />\n<label><input type='checkbox' name='notify_me' value='1'" . $notify_checked . " /> " . $locale['486'] . "</label>";
 }
 echo "</td>\n</tr>\n";
 if ($settings['enable_tags']) {
     echo add_tags("F", "tbl2");
     // Pimped: tag
 }
 if ($fdata['forum_attach'] && checkgroup($fdata['forum_attach'])) {
     add_to_head("<script src='" . INCLUDES_JS . "multiupload.js' type='text/javascript'></script>");
     // Pimped: Multi-Upload
     echo "<tr>\n<td width='145' class='tbl2'>" . $locale['464'] . "</td>\n";
     $attachtypes = explode(",", $settings['attachtypes']);
     $insert_type = '';
     $x = true;
     foreach ($attachtypes as $type) {
         if (substr($type, 0, 1) == '.') {
             $type = substr($type, 1);
         }
         $insert_type .= ($x == false ? '|' : '') . $type;
         $x = false;
Beispiel #10
0
function clean_text_with_tags($string, $wrap=0, $replace_nl=true, $maxlength=0) {
	$string = add_tags(clean_text($string, $wrap, $replace_nl, $maxlength));
	$string = preg_replace_callback('/(?:&lt;|<)(\/{0,1})(\w{1,6})(?:&gt;|>)/', 'enable_tags_callback', $string);
	$string = close_tags($string);
	$string = preg_replace('/<\/(\w{1,6})>( *)<(\1)>/', "$2", $string); // Deletes useless close+open tags
	//$string = preg_replace('/<(\/{0,1}\w{1,6})>( *)<(\1)>/', "<$1>$2", $string); // Deletes repeated tags
	return $string;
}
             array_push($tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'] . ":" . $response['address']['country']));
             array_push($tag_names, $response['address']['country']);
         }
         if (isset($response['address']['postcode']) and $sync_options['osm_tag_address_postcode']) {
             array_push($tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'] . ":" . $response['address']['postcode']));
             array_push($tag_names, $response['address']['postcode']);
         }
         if (isset($response['address']['country_code']) and $sync_options['osm_tag_address_country_code']) {
             array_push($tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'] . ":" . $response['address']['country_code']));
             array_push($tag_names, $response['address']['country_code']);
         }
         //print_r($tag_ids);
         //print_r($tag_names);
         if (!empty($tag_ids) and !empty($tag_names)) {
             if (!$sync_options['simulate']) {
                 add_tags($tag_ids, [$image['id']]);
             }
             $datas[] = $image['id'];
             $infos[] = "Set tags '" . osm_pprint_r($tag_names) . "' for " . $image['name'];
         } else {
             $warnings = "No valid tags for " . $image['name'] . " available tag: " . osm_pprint_r(array_keys($response['address']));
         }
     }
     //die("Done one image");
 }
 // Images loop
 // Send sync result to template
 $template->assign('sync_errors', $errors);
 $template->assign('sync_warnings', $warnings);
 $template->assign('sync_infos', $infos);
 // Send result to templates
        <div class="banner"><h2>Workgroup Tags</h2></div>
        <?php 
}
?>

        <div id="page-inner">
            Unlike personal tags, which can be freely added by individual users while editing data and apply only to that user,
            workgroup tags are a controlled list of shared tags established by a workgroup administrator.
            <br>The list below only shows workgroups of which you are an administrator. <br>

            <?php 
if (array_key_exists('deleting', $_REQUEST) && $_REQUEST['deleting']) {
    delete_tag();
} else {
    if (array_key_exists('adding', $_REQUEST) && $_REQUEST['adding']) {
        add_tags();
    }
}
?>

            <form method="post">
                <br>Note: Deleting a tag deletes all references to that tag.
                <p>To add new tags, type a tag into the blank field at the end of a workgroup and hit [enter] or click this button:

                <input type="submit" value="Add workgroup tag(s)">
                <?php 
if (@$_REQUEST['popup'] == "yes") {
    ?>
                <input type="button" value="Close Form" onclick="{window.close('bla');}">
                <?php 
}
 echo "<tr>\n<td valign='top' width='100' class='tbl'>" . $locale['425'] . "</td>\n";
 echo "<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox' style='width:98%'>" . $body2 . "</textarea></td>\n";
 echo "</tr>\n";
 if (!isset($_COOKIE['articles_wysiwyg_editor']) || !$_COOKIE['articles_wysiwyg_editor'] || !$settings['wysiwyg_enabled']) {
     echo "<tr>\n<td class='tbl'></td><td class='tbl'>\n";
     echo "<input type='button' value='" . $locale['432'] . "' class='button' style='width:80px;' onclick=\"insertText('body2', '<--PAGEBREAK-->');\" />\n";
     echo display_html("inputform", "body2", true, true, true, IMAGES_A);
     echo "</td>\n</tr>\n";
 }
 if ($settings['enable_tags']) {
     if (isset($_GET['action']) && $_GET['action'] == "edit" && (isset($_POST['article_id']) && isnum($_POST['article_id']) || isset($_GET['article_id']) && isnum($_GET['article_id']))) {
         $id = isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'];
         echo edit_tags($id, "A");
         // Pimped: tag
     } else {
         echo add_tags("A");
         // Pimped: tag
     }
 }
 echo "<tr>\n";
 echo "<td width='100' class='tbl'>" . $locale['435'] . "</td>\n";
 // meta
 echo "<td class='tbl'><input type='text' name='article_keywords' value='" . $article_keywords . "' class='textbox' style='width:250px;' /></td>\n";
 echo "</tr>\n<tr>\n";
 echo "<td class='tbl'></td><td class='tbl'>\n";
 echo "<label><input type='checkbox' name='article_draft' value='yes'" . $draft . " /> " . $locale['426'] . "</label><br />\n";
 if (!isset($_COOKIE['articles_wysiwyg_editor']) || !$_COOKIE['articles_wysiwyg_editor'] || !$settings['wysiwyg_enabled']) {
     echo "<label><input type='checkbox' name='line_breaks' value='yes'" . $breaks . " /> " . $locale['427'] . "</label><br />\n";
 }
 echo "<label><input type='checkbox' name='article_comments' value='yes'" . $comments . " /> " . $locale['428'] . "</label><br />\n";
 echo "<label><input type='checkbox' name='article_ratings' value='yes'" . $ratings . " /> " . $locale['429'] . "</label></td>\n";
Beispiel #14
0
<?php

require_once '_init.php';
/*foreach($_POST as $key=>$value) {
    echo $key." = ".$value;    
}*/
$id = $_POST['id'];
$tags = isset($_POST['tags' . '_' . $id]);
$from = $_POST['from'];
$tipo = $_POST['mediatype'];
$arrayCampos = array('titulo' . '_' . $id, 'texto' . '_' . $id, 'fuente' . '_' . $id, 'preview' . '_' . $id);
if (makeUpdateQuery($arrayCampos, $id, true, 'files', true)) {
    $out[] = array('mode' => 'update media info', 'success' => 'true', 'arrayCampos' => $arrayCampos);
} else {
    $out[] = array('mode' => 'update media info', 'success' => 'false', 'arrayCampos' => $arrayCampos);
}
if ($tags && add_tags($tags, $id, $from, 'files', $tipo)) {
    $out[] = array('mode' => 'add tags to media', 'success' => 'true', 'tags' => $tags);
}
echo json_encode($out);
Beispiel #15
0
 echo "</select> : <select name='news_end[minutes]' class='textbox'>\n";
 for ($i = 0; $i <= 60; $i++) {
     echo "<option" . (isset($news_end['minutes']) && $news_end['minutes'] == $i ? " selected='selected'" : "") . ">{$i}</option>\n";
 }
 echo "</select> : 00 " . $locale['429'] . "</td>\n";
 echo "</tr>\n<tr>\n";
 echo "<td class='tbl'>" . $locale['430'] . "</td>\n";
 echo "<td class='tbl'><select name='news_visibility' class='textbox'>\n" . $visibility_opts . "</select></td>\n";
 echo "</tr>\n";
 if ($settings['enable_tags']) {
     if (isset($_GET['action']) && $_GET['action'] == "edit" && (isset($_POST['news_id']) && isnum($_POST['news_id']) || isset($_GET['news_id']) && isnum($_GET['news_id']))) {
         $id = isset($_POST['news_id']) ? $_POST['news_id'] : $_GET['news_id'];
         echo edit_tags($id, "N");
         // Pimped: tag
     } else {
         echo add_tags("N");
         // Pimped: tag
     }
 }
 echo "<tr>\n";
 echo "<td width='100' class='tbl'>" . $locale['441'] . "</td>\n";
 // meta
 echo "<td class='tbl'><input type='text' name='news_keywords' value='" . $news_keywords . "' class='textbox' style='width:250px;' /></td>\n";
 echo "</tr>\n<tr>\n";
 echo "<td class='tbl'></td><td class='tbl'>\n";
 echo "<label><input type='checkbox' name='news_draft' value='yes'" . $news_draft . " /> " . $locale['431'] . "</label><br />\n";
 echo "<label><input type='checkbox' name='news_sticky' value='yes'" . $news_sticky . " /> " . $locale['432'] . "</label><br />\n";
 if (!isset($_COOKIE['news_wysiwyg_editor']) || !$_COOKIE['news_wysiwyg_editor'] || !$settings['wysiwyg_enabled']) {
     echo "<label><input type='checkbox' name='line_breaks' value='yes'" . $news_breaks . " /> " . $locale['433'] . "</label><br />\n";
 }
 echo "<label><input type='checkbox' name='news_comments' value='yes' onclick='SetRatings();'" . $news_comments . " /> " . $locale['434'] . "</label><br />\n";
 function format_list($list, $toplevel = false)
 {
     global $auth;
     global $itemId;
     global $parent;
     global $parent_id_global;
     echo "\n<ul>\n";
     foreach ($list as $item) {
         $parent_id = $item['parent'];
         //a check to see if this item is parent to the item being added
         $is_parent_of_add = $parent == $item['itemId'] && $itemId == -1;
         if ($item['itemId'] == $itemId && $auth == 1) {
             echo '<li><a name="li_' . $itemId . '" style="text-decoration:none;">
         <form method="post">
         <input type="hidden" name="edit_itemId" value="' . $itemId . '">
         <input type="text" name="label" value="' . $item['label'] . '"> :
         <input type="text" name="value" value="' . $item['value'] . '">
         <input type="submit" name="edit_item" value="Save">
         <input type="submit" name="cancel" value="Cancel">
         </form>
         </a></li>';
         } else {
             $text = strpos($item['value'], 'http://') === 0 ? '<a href="' . $item['value'] . '">' . $item['value'] . '</a>' : $item['value'];
             $label = empty($item['label']) ? $text : $item['label'] . ': ' . $text;
             if ($toplevel) {
                 $label = "<b>{$label}</b>";
             }
             echo add_tags($item['itemId'], $parent_id, $label);
         }
         if (!empty($item['children']) || $is_parent_of_add) {
             format_list($item['children']);
         } else {
             if ($auth == 1) {
                 echo '<ul class="ghost_link">
           <li><span class="editable" onclick="add_list_item(' . $item['itemId'] . ')">Click to add a sublist here</span></li>
         </ul>';
             }
         }
         echo '</li>';
     }
     //add the add child part here
     if ($auth == 1 && $itemId == -1 && (!isset($parent_id) || $parent_id == $parent)) {
         echo '<li>
       <form method="post">
       <input type="hidden" name="parent_id" value="' . $parent . '">
       <input onfocus="clear_default_message(this);" type="text" style="width:280px"
              name="label" value="Leave this box blank to not display the colon ->"> :
       <input type="text" name="value">
       <input type="submit" name="add_child" value="Add">
       <input type="submit" name="cancel" value="Cancel">
       </form>
       </li>';
     } else {
         if ($auth == 1 && !$toplevel) {
             echo '<li class="ghost_link"><span class="editable" onclick="add_list_item(' . $parent_id . ')">Click to add another item here</span></li>';
         }
     }
     echo "</ul>\n";
 }
Beispiel #17
0
/**
 * API method
 * Sets details of an image
 * @param mixed[] $params
 *    @option int image_id
 *    @option string file (optional)
 *    @option string name (optional)
 *    @option string author (optional)
 *    @option string date_creation (optional)
 *    @option string comment (optional)
 *    @option string categories (optional) - "cat_id[,rank];cat_id[,rank]"
 *    @option string tags_ids (optional) - "tag_id,tag_id"
 *    @option int level (optional)
 *    @option string single_value_mode
 *    @option string multiple_value_mode
 */
function ws_images_setInfo($params, $service)
{
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    $query = '
SELECT *
  FROM ' . IMAGES_TABLE . '
  WHERE id = ' . $params['image_id'] . '
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result) == 0) {
        return new PwgError(404, 'image_id not found');
    }
    $image_row = pwg_db_fetch_assoc($result);
    // database registration
    $update = array();
    $info_columns = array('name', 'author', 'comment', 'level', 'date_creation');
    foreach ($info_columns as $key) {
        if (isset($params[$key])) {
            if ('fill_if_empty' == $params['single_value_mode']) {
                if (empty($image_row[$key])) {
                    $update[$key] = $params[$key];
                }
            } elseif ('replace' == $params['single_value_mode']) {
                $update[$key] = $params[$key];
            } else {
                return new PwgError(500, '[ws_images_setInfo]' . ' invalid parameter single_value_mode "' . $params['single_value_mode'] . '"' . ', possible values are {fill_if_empty, replace}.');
            }
        }
    }
    if (isset($params['file'])) {
        if (!empty($image_row['storage_category_id'])) {
            return new PwgError(500, '[ws_images_setInfo] updating "file" is forbidden on photos added by synchronization');
        }
        $update['file'] = $params['file'];
    }
    if (count(array_keys($update)) > 0) {
        $update['id'] = $params['image_id'];
        single_update(IMAGES_TABLE, $update, array('id' => $update['id']));
    }
    if (isset($params['categories'])) {
        ws_add_image_category_relations($params['image_id'], $params['categories'], 'replace' == $params['multiple_value_mode'] ? true : false);
    }
    // and now, let's create tag associations
    if (isset($params['tag_ids'])) {
        $tag_ids = array();
        foreach (explode(',', $params['tag_ids']) as $candidate) {
            $candidate = trim($candidate);
            if (preg_match(PATTERN_ID, $candidate)) {
                $tag_ids[] = $candidate;
            }
        }
        if ('replace' == $params['multiple_value_mode']) {
            set_tags($tag_ids, $params['image_id']);
        } elseif ('append' == $params['multiple_value_mode']) {
            add_tags($tag_ids, array($params['image_id']));
        } else {
            return new PwgError(500, '[ws_images_setInfo]' . ' invalid parameter multiple_value_mode "' . $params['multiple_value_mode'] . '"' . ', possible values are {replace, append}.');
        }
    }
    invalidate_user_cache();
}
 public function getForm()
 {
     // VALUES FOR CREATE
     if (!$this->id) {
         if (isset($this->moduleCfg['lists']['categories'])) {
             $this->catId = $_GET['cat_id'];
             $this->values[$this->moduleCfg['lists']['items']['query']['campoCat']] = $this->catId;
         }
         if (isset($this->moduleCfg['lists']['subCategories'])) {
             $this->subcatId = $_GET['subcat_id'];
             $this->values[$this->moduleCfg['lists']['items']['query']['campoSubCat']] = $this->subcatId;
         }
         $this->mode = 'insert';
     }
     // VALUES FOR UPDATE
     if ($this->id) {
         $this->values = a("SELECT * " . $this->moduleCfg['lists']['items']['query']['selectItem'] . " FROM " . $this->moduleCfg['general']['table'] . " WHERE id=" . $this->id);
         if (isset($this->moduleCfg['lists']['categories'])) {
             $this->catId = $this->values[$this->moduleCfg['lists']['items']['query']['campoCat']];
         }
         if (isset($this->moduleCfg['lists']['subCategories'])) {
             $this->subcatId = $this->values[$this->moduleCfg['lists']['items']['query']['campoSubCat']];
         }
         $this->mode = 'update';
     }
     // IF FORM VALID AND POST SUBMITED PROCESS
     if ($this->formIsValid($this->moduleCfg['form']['fields']) && isset($_POST['submitted']) && $_POST['submitted'] == 1) {
         // SQL INSERT (NUEVO)
         if ($this->mode == 'insert') {
             if ($this->moduleCfg['general']['createTable'] && $this->config['createModuleTables']) {
                 $createTable = makeCreateTableQuery($this->moduleCfg['form']['fields'], $this->moduleCfg['general']['executeQuerys'], $this->moduleCfg['general']['table']);
             }
             $creado = makeInsertQuery($this->moduleCfg['form']['fields'], $this->moduleCfg['general']['executeQuerys'], $this->moduleCfg['general']['table']);
             $this->id = mysql_insert_id();
             if (isset($_POST['tags'])) {
                 add_tags($_POST['tags'], $this->id, $this->moduleCfg['general']['table'], $this->moduleCfg['general']['table'], $this->moduleCfg['general']['table']);
             }
         }
         // SQL UPDATE (EDIT)
         if ($this->mode == 'update') {
             $editado = makeUpdateQuery($this->moduleCfg['form']['fields'], $this->id, $this->moduleCfg['general']['executeQuerys'], $this->moduleCfg['general']['table']);
             if (isset($_POST['tags'])) {
                 add_tags($_POST['tags'], $this->id, $this->moduleCfg['general']['table'], $this->moduleCfg['general']['table'], $this->moduleCfg['general']['table']);
             }
         }
         // UPLOAD
         if (isset($this->moduleCfg['form']['uploads'])) {
             foreach ($this->moduleCfg['form']['uploads'] as $k => $v) {
                 if (is_array($v) && !empty($v)) {
                     $upload = new Upload();
                     $upload->campo = $k;
                     $upload->id = $this->id;
                     $upload->tabla = $this->moduleCfg['general']['table'];
                     $upload->cat_id = $this->catId;
                     $upload->subcat_id = $this->subcatId;
                     $upload->titulo = $_POST[$this->moduleCfg['form']['uploads']['defaultUploadTitleField']];
                     foreach ($v as $paramK => $paramV) {
                         $upload->{$paramK} = $paramV;
                     }
                     if (isset($this->moduleCfg['form']['uploads']['removeFilesBeforeUpload'])) {
                         $upload->removeFilesBeforeUpload = $this->moduleCfg['form']['uploads']['removeFilesBeforeUpload'];
                     }
                     $upload->doUpload();
                 }
             }
         }
         // REDIRECT TO LIST
         if ($this->moduleCfg['form']['general']['redirectToList']) {
             $cat = 0;
             $subcat = 0;
             if (isset($this->moduleCfg['lists']['categories']['whereCountItems'])) {
                 if (isset($_POST[$this->moduleCfg['lists']['categories']['whereCountItems']])) {
                     $cat = $_POST[$this->moduleCfg['lists']['categories']['whereCountItems']];
                 }
             }
             if (isset($this->moduleCfg['lists']['subCategories']['whereCountItems'])) {
                 if (isset($_POST[$this->moduleCfg['lists']['subCategories']['whereCountItems']])) {
                     $subcat = $_POST[$this->moduleCfg['lists']['subCategories']['whereCountItems']];
                 }
             }
             if ($this->mode == 'insert' || $this->mode == 'update') {
                 header('Location: ?m=' . $_GET['m'] . '&action=list&cat_id=' . $cat . '&subcat_id=' . $subcat);
             }
         } else {
             // REDIRECCION NUEVO
             if ($this->mode == 'insert') {
                 header('Location: ?m=' . $_GET['m'] . '&action=edit&id=' . $this->id . '&created=' . $creado);
             }
             // REDIRECCION EDIT
             if ($this->mode == 'update') {
                 header('Location: ?m=' . $_GET['m'] . '&action=edit&id=' . $this->id . '&edited=' . $editado);
             }
         }
     }
     $out[] = $this->mainBlocks->getHead();
     $out[] = $this->mainBlocks->getMenu();
     // RIGHT
     $wCls = isset($this->moduleCfg['form']['uploads']) ? '' : '';
     // forceWidthTo40
     $out[] = '
     <div id="right" class="right_' . $this->moduleCfg['general']['table'] . ' ' . $wCls . '">
     ';
     // rightPadding
     $out[] = '
         <div class="rightPadding">
         ';
     // BREAD
     $bread = new Bread();
     $bread->catId = $this->catId;
     if (isset($this->moduleCfg['lists']['categories'])) {
         $bread->categories = $this->moduleCfg['lists']['categories'];
     }
     $bread->subcatId = $this->subcatId;
     if (isset($this->moduleCfg['lists']['subcategories'])) {
         $bread->subcategories = $this->moduleCfg['lists']['subcategories'];
     }
     $bread->showAll = $this->showAll;
     $out[] = $bread->getBread();
     // ERRORS TBAR IF SUBMIT AND ERRORS FOUND
     $out[] = $this->getErrorsTbar();
     // IF CREADO O EDITADO
     $out[] = $this->getStatusTbar();
     // CREAR FORM
     if ($_GET['action'] == 'create') {
         $out[] = '<form action="?m=' . $_GET['m'] . '&amp;action=create&amp;cat_id=' . $this->catId . '&amp;subcat_id=' . $this->subcatId . '" method="post" enctype="multipart/form-data" name="formulario" id="formulario">';
     }
     // EDITAR FORM
     if ($_GET['action'] == 'edit') {
         $out[] = '<form action="?m=' . $_GET['m'] . '&amp;action=edit&amp;id=' . $this->id . '" method="post" enctype="multipart/form-data" name="formulario" id="formulario">';
     }
     // COL-1 || MAIN
     if (isset($this->moduleCfg['form']['uploads'])) {
         $out[] = '<div id="col-1">';
     } else {
         $out[] = '<div id="main">';
     }
     $out[] = '<div class="boxContainer">';
     // HIDDEN SUBMIT FIELD
     $out[] = '<input type="hidden" name="submitted" value="1" />';
     // INSTANCIA FORM INPUTS SEGUN CONFIG DEL MODULO
     foreach ($this->moduleCfg['form']['fields'] as $campo) {
         $formInput = new formInputs();
         $formInput->tabla = $this->moduleCfg['general']['table'];
         if ($this->id) {
             $formInput->item_id = $this->id;
             if ($this->values[$campo['name']]) {
                 $formInput->value = $this->values[$campo['name']];
             }
         }
         foreach ($campo as $k => $v) {
             if (isset($this->values[$campo['name']])) {
                 $formInput->value = $this->values[$campo['name']];
             }
             if ($v || $v === false) {
                 $formInput->{$k} = $v;
             }
         }
         $out[] = $formInput->getFormInput();
     }
     // SUBMIT BTN
     if ($this->moduleCfg['form']['general']['canSave']) {
         $f = new formInputs();
         $f->fieldLabel = 'Guardar';
         $f->inputType = 'submit';
         $f->name = 'submit';
         $f->submitFormId = 'formulario';
         $out[] = $f->getFormInput();
     }
     $out[] = '</div>';
     $out[] = '</div>';
     // COL-2
     if (isset($this->moduleCfg['form']['uploads'])) {
         $out[] = '<div id="col-2">';
         foreach ($this->moduleCfg['form']['uploads'] as $k => $v) {
             if (is_array($v['showMedia']) && !empty($v['showMedia'])) {
                 $out[] = '<div class="boxContainer">';
                 if ($this->id) {
                     $ShowMedia = new ShowMedia();
                     $ShowMedia->itemId = $this->id;
                     $ShowMedia->type = $k;
                     $ShowMedia->table = $this->moduleCfg['general']['table'];
                     foreach ($v['showMedia'] as $paramK => $paramV) {
                         $ShowMedia->{$paramK} = $paramV;
                     }
                 }
                 $formInput = new formInputs();
                 $formInput->fieldLabel = $v['uploadLabel'] ? $v['uploadLabel'] : lang('adjuntar ' . $k);
                 $formInput->name = $k;
                 $formInput->inputType = 'file';
                 $formInput->maxFiles = $v['maxFiles'] ? $v['maxFiles'] : 0;
                 $formInput->acceptedExtencions = isset($v['acceptedExtencions']) ? $v['acceptedExtencions'] : array('jpg', 'gif', 'png');
                 if ($this->id) {
                     $formInput->afterFieldHtml = $ShowMedia->getMediaOut();
                     $formInput->disabled = $ShowMedia->getCant() == $v['maxFiles'] ? true : false;
                 }
                 if ($v['showMedia']['fileFieldCfg']) {
                     foreach ($v['showMedia']['fileFieldCfg'] as $paramY => $paramZ) {
                         $formInput->{$paramY} = $paramZ;
                     }
                 }
                 $formInput->tabla = $this->moduleCfg['general']['table'];
                 $out[] = $formInput->getFormInput();
                 $out[] = '</div>';
             }
         }
         $out[] = '</div>';
     }
     $out[] = '</form>';
     // EO rightPadding
     $out[] = '
         </div>
         ';
     // EO RIGHT
     $out[] = '
     </div>
     ';
     $out[] = $this->mainBlocks->getFooter();
     return join("\n", $out);
 }
Beispiel #19
0
<?php

// Parse data
$category_id = $product['categoryID'];
$product_code = $product['productCode'];
$product_name = $product['productName'];
$description = $product['description'];
$list_price = $product['listPrice'];
$discount_percent = $product['discountPercent'];
// Add HMTL tags to the description
$description_tags = add_tags($description);
// Calculate discounts
$discount_amount = round($list_price * ($discount_percent / 100), 2);
$unit_price = $list_price - $discount_amount;
// Format discounts
$discount_percent_f = number_format($discount_percent, 0);
$discount_amount_f = number_format($discount_amount, 2);
$unit_price_f = number_format($unit_price, 2);
// Get image URL and alternate text
$image_filename = $product_code . '_m.png';
$image_path = $app_path . 'images/' . $image_filename;
$image_alt = 'Image filename: ' . $image_filename;
?>

<h1><?php 
echo $product_name;
?>
</h1>
<div id="left_column">
    <p><img src="<?php 
echo $image_path;
if (@$_REQUEST['data']) {
    //$data = json_decode(urldecode($_REQUEST['data']), true);
    $str = $_REQUEST['data'];
    $data = json_decode($str, true);
    switch (@$_REQUEST['action']) {
        case 'delete_bookmark':
            $result = delete_bookmarks($data);
            break;
        case 'add_wgTags_by_id':
            $result = add_wgTags_by_id($data);
            break;
        case 'remove_wgTags_by_id':
            $result = remove_wgTags_by_id($data);
            break;
        case 'add_tags':
            $result = add_tags($data);
            break;
        case 'remove_tags':
            $result = remove_tags($data);
            break;
        case 'bookmark_reference':
            $result = bookmark_references($data);
            break;
        case 'bookmark_and_tag':
        case 'bookmark_and_tags':
            //save collection of ids with some tag
            $result = bookmark_and_tag_record_ids($data);
            break;
        case 'add_detail':
            $result = add_detail($data);
            break;
        $query = '
DELETE
  FROM ' . CADDIE_TABLE . '
  WHERE element_id IN (' . implode(',', $collection) . ')
    AND user_id = ' . $user['id'] . '
;';
        pwg_query($query);
        // remove from caddie action available only in caddie so reload content
        $redirect = true;
    } else {
        if ('add_tags' == $action) {
            if (empty($_POST['add_tags'])) {
                $page['errors'][] = l10n('Select at least one tag');
            } else {
                $tag_ids = get_tag_ids($_POST['add_tags']);
                add_tags($tag_ids, $collection);
                if ('no_tag' == $page['prefilter']) {
                    $redirect = true;
                }
            }
        } else {
            if ('del_tags' == $action) {
                if (isset($_POST['del_tags']) and count($_POST['del_tags']) > 0) {
                    $query = '
DELETE
  FROM ' . IMAGE_TAG_TABLE . '
  WHERE image_id IN (' . implode(',', $collection) . ')
    AND tag_id IN (' . implode(',', $_POST['del_tags']) . ')
;';
                    pwg_query($query);
                    if (isset($_SESSION['bulk_manager_filter']['tags']) && count(array_intersect($_SESSION['bulk_manager_filter']['tags'], $_POST['del_tags']))) {
Beispiel #22
0
    </p>

    <!-- display product -->
    <h1>Featured products</h1>
    <table>
    <?php 
foreach ($products as $product) {
    // Get product data
    $list_price = $product['listPrice'];
    $discount_percent = $product['discountPercent'];
    $description = $product['description'];
    // Calculate unit price
    $discount_amount = round($list_price * ($discount_percent / 100.0), 2);
    $unit_price = $list_price - $discount_amount;
    // Get first paragraph of description
    $description = add_tags($description);
    $i = strpos($description, "</p>");
    $description = substr($description, 3, $i - 3);
    ?>
        <tr>
            <td id="product_image_column">
                <img src="images/<?php 
    echo $product['productCode'];
    ?>
_s.png"
                     alt="&nbsp;">
            </td>
            <td>
                <p>
                    <a href="catalog?action=view_product&amp;product_id=<?php 
    echo $product['productID'];
Beispiel #23
0
function get_media_events($htmlOptions, $extra)
{
    $a = array('onabort', 'oncanplay', 'oncanplaythrough', 'ondurationchange', 'onemptied', 'onended', 'onloadeddata', 'onloadedmetadata', 'onloadstart', 'onpause', 'onplay', 'onplaying', 'onprogress', 'onratechange', 'onreadystatechange', 'onseeked', 'onstalled', 'onsuspend', 'ontimeupdate', 'onvolumechange', 'onwaiting');
    $ret = '';
    foreach ($a as $option) {
        if (isset($htmlOptions[$option])) {
            $ret .= combine_tags($option, $htmlOptions[$option], $extra);
        } else {
            $e = add_tags($option, $extra);
            if ($e !== false) {
                $ret .= $e;
            }
        }
    }
    return $ret;
}