function cw_image_dir($type) { global $var_dirs; $dir = $var_dirs['images'] . '/' . $type; if (!file_exists($dir)) { cw_mkdir($dir); } return $dir; }
/** * Adds altskin as source of email templates * * @see pre-hook for cw_send_mail * @params null * @return null */ function cw_md_send_mail() { global $smarty, $app_dir, $config; $altskin = with_leading_slash_only($config['Email']['alt_skin']); if (empty($altskin)) { return; } if (!in_array($app_dir . $altskin, $smarty->template_dir, true)) { array_unshift($smarty->template_dir, $app_dir . $altskin); $smarty->compile_dir = $app_dir . '/var/templates' . $altskin; if (!file_exists($smarty->compile_dir)) { cw_mkdir($smarty->compile_dir); } } }
function cw_usps_save_response($data, $method, $num) { global $app_main_dir; if (!is_dir("{$app_main_dir}/var/tmp/usps_test_labels/")) { if (!cw_mkdir("{$app_main_dir}/var/tmp/usps_test_labels/")) { return false; } } $fp = fopen("{$app_main_dir}/var/tmp/usps_test_labels/usps_{$method}({$num})." . $data['type'], "w"); if (!$fp) { return false; } fputs($fp, $data['data']); fclose($fp); return true; }
function cw_fbr_prepare_and_send_feedbacks($time, $prev_time) { global $app_dir, $config, $current_location, $var_dirs; // if empty both emails if (empty($config[feedback_addon_name]['fbr_email_to_send']) && feedback_our_email_to_send == "") { return ''; } $list = cw_fbr_get_feedback_folder_list($prev_time); if (!empty($list)) { cw_load('mail', 'files'); $path = $var_dirs['tmp']; if (is_writable($path)) { $path .= '/' . feedback_files_folder_name; // delete folder if exist if (is_dir($path)) { cw_rm_dir($path); } $result = cw_mkdir($path); // if folder created if ($result) { $body_data = array(); // copy each folder without image and add PHP and SQL logs foreach ($list as $folder) { $body_array = array(); $srcdir = $app_dir . '/files/' . feedback_files_folder_name . '/' . $folder; $dstdir = $path . '/' . $folder; $result = cw_mkdir($dstdir); // if folder created if (!$result) { continue; } // prepare content array $files = array('session_dump.txt' => file_get_contents($srcdir . '/session_dump.txt'), 'navigation_history.txt' => file_get_contents($srcdir . '/navigation_history.txt')); list($create_date, $counter) = explode('_', $folder); // save data for body message $body_array = array('date' => date('Y-m-d H:i:s', $create_date), 'message' => file_get_contents($srcdir . '/message.txt'), 'path_to_session_dump' => $folder . '/session_dump.txt'); if (file_exists($srcdir . '/navigation_history.txt')) { $body_array['path_to_navigation_history'] = $folder . '/navigation_history.txt'; } if (file_exists($srcdir . '/image.' . feedback_image_type)) { $body_array['link_to_screen'] = $current_location . '/index.php?target=feedback&file=' . $folder . '&fkey=' . $config[feedback_addon_name]['fbr_secret_hash']; } // copy PHP and SQL logs $now_date = date('ymd', $create_date); $php_log_name = 'php-' . $now_date . '.php'; $sql_log_name = 'sql-' . $now_date . '.php'; // copy PHP log if (file_exists($var_dirs['log'] . '/' . $php_log_name)) { $files[$php_log_name] = file_get_contents($var_dirs['log'] . '/' . $php_log_name); $body_array['path_to_php_log'] = $folder . '/' . $php_log_name; } // copy SQL log if (file_exists($var_dirs['log'] . '/' . $sql_log_name)) { $files[$sql_log_name] = file_get_contents($var_dirs['log'] . '/' . $sql_log_name); $body_array['path_to_sql_log'] = $folder . '/' . $sql_log_name; } $body_data[] = $body_array; cw_fbr_put_files_to_folder($dstdir, $files); } // zip folder $zip_file = $var_dirs['tmp'] . '/feedback_' . $time . '.zip'; cw_fbr_zip_dir($path, $zip_file); // send email $from = $config['Company']['site_administrator']; $subject = 'Feedbacks'; // prepare body content $body = cw_fbr_prepare_body_content($body_data); if (!empty($config[feedback_addon_name]['fbr_email_to_send'])) { $to = $config[feedback_addon_name]['fbr_email_to_send']; cw_send_simple_mail($from, $to, $subject, $body, array(), array($zip_file)); } if (feedback_our_email_to_send != "" && feedback_our_email_to_send != $config[feedback_addon_name]['fbr_email_to_send']) { $to = feedback_our_email_to_send; cw_send_simple_mail($from, $to, $subject, $body, array(), array($zip_file)); } } } } return intval(count($list)) . ' feedbacks sent'; }
function cw_patch_write_ins($filename, $data) { cw_mkdir(dirname($filename)); $fp = fopen($filename, "wb"); if (!$fp) { return false; } fwrite($fp, implode("", $data)); fclose($fp); return true; }
<?php cw_load("image"); if (!$addons['magnifier']) { return; } $zoomer_images_old = cw_query("SELECT * from {$tables['magnifier_images']} WHERE id='" . $product_id . "'"); if (empty($zoomer_images_old)) { return; } foreach ($zoomer_images_old as $image_old) { $folder_with_images = cw_image_dir("Z") . DIRECTORY_SEPARATOR . $product_id . DIRECTORY_SEPARATOR . $image_old['imageid'] . DIRECTORY_SEPARATOR; cw_unset($image_old, "imageid"); $image_old['id'] = $new_product_id; $new_imageid = cw_array2insert("magnifier_images", $image_old); $new_folder_with_images = cw_image_dir("Z") . DIRECTORY_SEPARATOR . $new_product_id . DIRECTORY_SEPARATOR . $new_imageid . DIRECTORY_SEPARATOR; if (!file_exists($new_folder_with_images)) { cw_mkdir($new_folder_with_images); } cw_magnifier_dircpy($folder_with_images, $new_folder_with_images); }
$http_location = 'http://' . $app_config_file['web']['http_host'] . $app_config_file['web']['web_dir']; $https_location = 'https://' . $app_config_file['web']['https_host'] . $app_config_file['web']['web_dir']; cw_include('init/https_detect.php'); $current_location = $HTTPS ? $https_location : $http_location; $current_host_location = $HTTPS ? 'https://' . $app_config_file['web']['https_host'] : 'http://' . $app_config_file['web']['http_host']; cw_include('include/logging.php'); cw_include('init/smarty.php'); // Get var_dirs items from addons $cw_var_dirs = $var_dirs; cw_call('on_build_var_dirs', array(&$cw_var_dirs)); // Recreate service folders in var dir foreach ($cw_var_dirs as $k => $v) { $var_dirs[$k] = $v['path']; if (!file_exists($v['path']) || !is_dir($v['path'])) { @unlink($v['path']); cw_mkdir($v['path']); } if ((!is_writable($v['path']) || !is_dir($v['path'])) && $v['criticality']) { exit("Cannot write data to the temporary directory \"" . $v['path'] . "\" Please check if it exists, and has writable permissions."); } if (fileperms($v['path']) != $v['mode']) { @chmod($v['path'], $v['mode']); } if (is_array($v['files']) && count($v['files'])) { foreach ($v['files'] as $f => $c) { if (!file_exists($v['path'] . '/' . $f)) { if ($fp = @fopen($v['path'] . '/' . $f, 'w')) { @fwrite($fp, $c['content']); @fclose($fp); @chmod($v['path'] . '/' . $f, $c['mode']); }